e10da2
From eb826444f90c2563dadf148630b0cd6a9b41ba1e Mon Sep 17 00:00:00 2001
e10da2
From: Eric Blake <eblake@redhat.com>
e10da2
Date: Mon, 27 Sep 2010 10:10:06 -0600
e10da2
Subject: [PATCH 05/15] vcpu: implement the remote protocol
e10da2
e10da2
Done by editing the first three files, then running
e10da2
'make -C src rpcgen', then editing src/remote_protocol-structs
e10da2
to match.
e10da2
e10da2
* daemon/remote.c (remoteDispatchDomainSetVcpusFlags)
e10da2
(remoteDispatchDomainGetVcpusFlags): New functions.
e10da2
* src/remote/remote_driver.c (remoteDomainSetVcpusFlags)
e10da2
(remoteDomainGetVcpusFlags, remote_driver): Client side
e10da2
serialization.
e10da2
* src/remote/remote_protocol.x
e10da2
(remote_domain_set_vcpus_flags_args)
e10da2
(remote_domain_get_vcpus_flags_args)
e10da2
(remote_domain_get_vcpus_flags_ret)
e10da2
(REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS)
e10da2
(REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS): Define wire format.
e10da2
* daemon/remote_dispatch_args.h: Regenerate.
e10da2
* daemon/remote_dispatch_prototypes.h: Likewise.
e10da2
* daemon/remote_dispatch_table.h: Likewise.
e10da2
* src/remote/remote_protocol.c: Likewise.
e10da2
* src/remote/remote_protocol.h: Likewise.
e10da2
* src/remote_protocol-structs: Likewise.
e10da2
---
e10da2
 daemon/remote.c                     |   53 ++++++++++++++++++++++++++++++++
e10da2
 daemon/remote_dispatch_args.h       |    2 +
e10da2
 daemon/remote_dispatch_prototypes.h |   16 ++++++++++
e10da2
 daemon/remote_dispatch_ret.h        |    1 +
e10da2
 daemon/remote_dispatch_table.h      |   10 ++++++
e10da2
 src/remote/remote_driver.c          |   57 +++++++++++++++++++++++++++++++++-
e10da2
 src/remote/remote_protocol.c        |   33 ++++++++++++++++++++
e10da2
 src/remote/remote_protocol.h        |   26 ++++++++++++++++
e10da2
 src/remote/remote_protocol.x        |   19 +++++++++++-
e10da2
 src/remote_protocol-structs         |   12 +++++++
e10da2
 10 files changed, 226 insertions(+), 3 deletions(-)
e10da2
e10da2
diff --git a/daemon/remote.c b/daemon/remote.c
e10da2
index 7a96e29..323f00c 100644
e10da2
--- a/daemon/remote.c
e10da2
+++ b/daemon/remote.c
e10da2
@@ -1751,6 +1751,33 @@ oom:
e10da2
 }
e10da2
e10da2
 static int
e10da2
+remoteDispatchDomainGetVcpusFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
e10da2
+                                   struct qemud_client *client ATTRIBUTE_UNUSED,
e10da2
+                                   virConnectPtr conn,
e10da2
+                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
e10da2
+                                   remote_error *rerr,
e10da2
+                                   remote_domain_get_vcpus_flags_args *args,
e10da2
+                                   remote_domain_get_vcpus_flags_ret *ret)
e10da2
+{
e10da2
+    virDomainPtr dom;
e10da2
+
e10da2
+    dom = get_nonnull_domain (conn, args->dom);
e10da2
+    if (dom == NULL) {
e10da2
+        remoteDispatchConnError(rerr, conn);
e10da2
+        return -1;
e10da2
+    }
e10da2
+
e10da2
+    ret->num = virDomainGetVcpusFlags (dom, args->flags);
e10da2
+    if (ret->num == -1) {
e10da2
+        virDomainFree(dom);
e10da2
+        remoteDispatchConnError(rerr, conn);
e10da2
+        return -1;
e10da2
+    }
e10da2
+    virDomainFree(dom);
e10da2
+    return 0;
e10da2
+}
e10da2
+
e10da2
+static int
e10da2
 remoteDispatchDomainMigratePrepare (struct qemud_server *server ATTRIBUTE_UNUSED,
e10da2
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
e10da2
                                     virConnectPtr conn,
e10da2
@@ -2568,6 +2595,32 @@ remoteDispatchDomainSetVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
e10da2
 }
e10da2
e10da2
 static int
e10da2
+remoteDispatchDomainSetVcpusFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
e10da2
+                                   struct qemud_client *client ATTRIBUTE_UNUSED,
e10da2
+                                   virConnectPtr conn,
e10da2
+                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
e10da2
+                                   remote_error *rerr,
e10da2
+                                   remote_domain_set_vcpus_flags_args *args,
e10da2
+                                   void *ret ATTRIBUTE_UNUSED)
e10da2
+{
e10da2
+    virDomainPtr dom;
e10da2
+
e10da2
+    dom = get_nonnull_domain (conn, args->dom);
e10da2
+    if (dom == NULL) {
e10da2
+        remoteDispatchConnError(rerr, conn);
e10da2
+        return -1;
e10da2
+    }
e10da2
+
e10da2
+    if (virDomainSetVcpusFlags (dom, args->nvcpus, args->flags) == -1) {
e10da2
+        virDomainFree(dom);
e10da2
+        remoteDispatchConnError(rerr, conn);
e10da2
+        return -1;
e10da2
+    }
e10da2
+    virDomainFree(dom);
e10da2
+    return 0;
e10da2
+}
e10da2
+
e10da2
+static int
e10da2
 remoteDispatchDomainShutdown (struct qemud_server *server ATTRIBUTE_UNUSED,
e10da2
                               struct qemud_client *client ATTRIBUTE_UNUSED,
e10da2
                               virConnectPtr conn,
e10da2
diff --git a/daemon/remote_dispatch_args.h b/daemon/remote_dispatch_args.h
e10da2
index d8528b6..9583e9c 100644
e10da2
--- a/daemon/remote_dispatch_args.h
e10da2
+++ b/daemon/remote_dispatch_args.h
e10da2
@@ -167,3 +167,5 @@
e10da2
     remote_domain_create_with_flags_args val_remote_domain_create_with_flags_args;
e10da2
     remote_domain_set_memory_parameters_args val_remote_domain_set_memory_parameters_args;
e10da2
     remote_domain_get_memory_parameters_args val_remote_domain_get_memory_parameters_args;
e10da2
+    remote_domain_set_vcpus_flags_args val_remote_domain_set_vcpus_flags_args;
e10da2
+    remote_domain_get_vcpus_flags_args val_remote_domain_get_vcpus_flags_args;
e10da2
diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h
e10da2
index b674bb4..6b35851 100644
e10da2
--- a/daemon/remote_dispatch_prototypes.h
e10da2
+++ b/daemon/remote_dispatch_prototypes.h
e10da2
@@ -306,6 +306,14 @@ static int remoteDispatchDomainGetVcpus(
e10da2
     remote_error *err,
e10da2
     remote_domain_get_vcpus_args *args,
e10da2
     remote_domain_get_vcpus_ret *ret);
e10da2
+static int remoteDispatchDomainGetVcpusFlags(
e10da2
+    struct qemud_server *server,
e10da2
+    struct qemud_client *client,
e10da2
+    virConnectPtr conn,
e10da2
+    remote_message_header *hdr,
e10da2
+    remote_error *err,
e10da2
+    remote_domain_get_vcpus_flags_args *args,
e10da2
+    remote_domain_get_vcpus_flags_ret *ret);
e10da2
 static int remoteDispatchDomainHasCurrentSnapshot(
e10da2
     struct qemud_server *server,
e10da2
     struct qemud_client *client,
e10da2
@@ -554,6 +562,14 @@ static int remoteDispatchDomainSetVcpus(
e10da2
     remote_error *err,
e10da2
     remote_domain_set_vcpus_args *args,
e10da2
     void *ret);
e10da2
+static int remoteDispatchDomainSetVcpusFlags(
e10da2
+    struct qemud_server *server,
e10da2
+    struct qemud_client *client,
e10da2
+    virConnectPtr conn,
e10da2
+    remote_message_header *hdr,
e10da2
+    remote_error *err,
e10da2
+    remote_domain_set_vcpus_flags_args *args,
e10da2
+    void *ret);
e10da2
 static int remoteDispatchDomainShutdown(
e10da2
     struct qemud_server *server,
e10da2
     struct qemud_client *client,
e10da2
diff --git a/daemon/remote_dispatch_ret.h b/daemon/remote_dispatch_ret.h
e10da2
index 17c9bca..3723b00 100644
e10da2
--- a/daemon/remote_dispatch_ret.h
e10da2
+++ b/daemon/remote_dispatch_ret.h
e10da2
@@ -136,3 +136,4 @@
e10da2
     remote_domain_get_block_info_ret val_remote_domain_get_block_info_ret;
e10da2
     remote_domain_create_with_flags_ret val_remote_domain_create_with_flags_ret;
e10da2
     remote_domain_get_memory_parameters_ret val_remote_domain_get_memory_parameters_ret;
e10da2
+    remote_domain_get_vcpus_flags_ret val_remote_domain_get_vcpus_flags_ret;
e10da2
diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h
e10da2
index 47d95eb..dd2adc7 100644
e10da2
--- a/daemon/remote_dispatch_table.h
e10da2
+++ b/daemon/remote_dispatch_table.h
e10da2
@@ -997,3 +997,13 @@
e10da2
     .args_filter = (xdrproc_t) xdr_remote_domain_get_memory_parameters_args,
e10da2
     .ret_filter = (xdrproc_t) xdr_remote_domain_get_memory_parameters_ret,
e10da2
 },
e10da2
+{   /* DomainSetVcpusFlags => 199 */
e10da2
+    .fn = (dispatch_fn) remoteDispatchDomainSetVcpusFlags,
e10da2
+    .args_filter = (xdrproc_t) xdr_remote_domain_set_vcpus_flags_args,
e10da2
+    .ret_filter = (xdrproc_t) xdr_void,
e10da2
+},
e10da2
+{   /* DomainGetVcpusFlags => 200 */
e10da2
+    .fn = (dispatch_fn) remoteDispatchDomainGetVcpusFlags,
e10da2
+    .args_filter = (xdrproc_t) xdr_remote_domain_get_vcpus_flags_args,
e10da2
+    .ret_filter = (xdrproc_t) xdr_remote_domain_get_vcpus_flags_ret,
e10da2
+},
e10da2
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
e10da2
index 1a687ad..37c37ef 100644
e10da2
--- a/src/remote/remote_driver.c
e10da2
+++ b/src/remote/remote_driver.c
e10da2
@@ -2580,6 +2580,59 @@ done:
e10da2
 }
e10da2
e10da2
 static int
e10da2
+remoteDomainSetVcpusFlags (virDomainPtr domain, unsigned int nvcpus,
e10da2
+                           unsigned int flags)
e10da2
+{
e10da2
+    int rv = -1;
e10da2
+    remote_domain_set_vcpus_flags_args args;
e10da2
+    struct private_data *priv = domain->conn->privateData;
e10da2
+
e10da2
+    remoteDriverLock(priv);
e10da2
+
e10da2
+    make_nonnull_domain (&args.dom, domain);
e10da2
+    args.nvcpus = nvcpus;
e10da2
+    args.flags = flags;
e10da2
+
e10da2
+    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS,
e10da2
+              (xdrproc_t) xdr_remote_domain_set_vcpus_flags_args,
e10da2
+              (char *) &args,
e10da2
+              (xdrproc_t) xdr_void, (char *) NULL) == -1)
e10da2
+        goto done;
e10da2
+
e10da2
+    rv = 0;
e10da2
+
e10da2
+done:
e10da2
+    remoteDriverUnlock(priv);
e10da2
+    return rv;
e10da2
+}
e10da2
+
e10da2
+static int
e10da2
+remoteDomainGetVcpusFlags (virDomainPtr domain, unsigned int flags)
e10da2
+{
e10da2
+    int rv = -1;
e10da2
+    remote_domain_get_vcpus_flags_args args;
e10da2
+    remote_domain_get_vcpus_flags_ret ret;
e10da2
+    struct private_data *priv = domain->conn->privateData;
e10da2
+
e10da2
+    remoteDriverLock(priv);
e10da2
+
e10da2
+    make_nonnull_domain (&args.dom, domain);
e10da2
+    args.flags = flags;
e10da2
+
e10da2
+    memset (&ret, 0, sizeof ret);
e10da2
+    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS,
e10da2
+              (xdrproc_t) xdr_remote_domain_get_vcpus_flags_args, (char *) &args,
e10da2
+              (xdrproc_t) xdr_remote_domain_get_vcpus_flags_ret, (char *) &ret) == -1)
e10da2
+        goto done;
e10da2
+
e10da2
+    rv = ret.num;
e10da2
+
e10da2
+done:
e10da2
+    remoteDriverUnlock(priv);
e10da2
+    return rv;
e10da2
+}
e10da2
+
e10da2
+static int
e10da2
 remoteDomainPinVcpu (virDomainPtr domain,
e10da2
                      unsigned int vcpu,
e10da2
                      unsigned char *cpumap,
e10da2
@@ -10468,8 +10521,8 @@ static virDriver remote_driver = {
e10da2
     remoteDomainRestore, /* domainRestore */
e10da2
     remoteDomainCoreDump, /* domainCoreDump */
e10da2
     remoteDomainSetVcpus, /* domainSetVcpus */
e10da2
-    NULL, /* domainSetVcpusFlags */
e10da2
-    NULL, /* domainGetVcpusFlags */
e10da2
+    remoteDomainSetVcpusFlags, /* domainSetVcpusFlags */
e10da2
+    remoteDomainGetVcpusFlags, /* domainGetVcpusFlags */
e10da2
     remoteDomainPinVcpu, /* domainPinVcpu */
e10da2
     remoteDomainGetVcpus, /* domainGetVcpus */
e10da2
     remoteDomainGetMaxVcpus, /* domainGetMaxVcpus */
e10da2
diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
e10da2
index 5c55713..38ea050 100644
e10da2
--- a/src/remote/remote_protocol.c
e10da2
+++ b/src/remote/remote_protocol.c
e10da2
@@ -1355,6 +1355,39 @@ xdr_remote_domain_set_vcpus_args (XDR *xdrs, remote_domain_set_vcpus_args *objp)
e10da2
 }
e10da2
e10da2
 bool_t
e10da2
+xdr_remote_domain_set_vcpus_flags_args (XDR *xdrs, remote_domain_set_vcpus_flags_args *objp)
e10da2
+{
e10da2
+
e10da2
+         if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
e10da2
+                 return FALSE;
e10da2
+         if (!xdr_u_int (xdrs, &objp->nvcpus))
e10da2
+                 return FALSE;
e10da2
+         if (!xdr_u_int (xdrs, &objp->flags))
e10da2
+                 return FALSE;
e10da2
+        return TRUE;
e10da2
+}
e10da2
+
e10da2
+bool_t
e10da2
+xdr_remote_domain_get_vcpus_flags_args (XDR *xdrs, remote_domain_get_vcpus_flags_args *objp)
e10da2
+{
e10da2
+
e10da2
+         if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
e10da2
+                 return FALSE;
e10da2
+         if (!xdr_u_int (xdrs, &objp->flags))
e10da2
+                 return FALSE;
e10da2
+        return TRUE;
e10da2
+}
e10da2
+
e10da2
+bool_t
e10da2
+xdr_remote_domain_get_vcpus_flags_ret (XDR *xdrs, remote_domain_get_vcpus_flags_ret *objp)
e10da2
+{
e10da2
+
e10da2
+         if (!xdr_int (xdrs, &objp->num))
e10da2
+                 return FALSE;
e10da2
+        return TRUE;
e10da2
+}
e10da2
+
e10da2
+bool_t
e10da2
 xdr_remote_domain_pin_vcpu_args (XDR *xdrs, remote_domain_pin_vcpu_args *objp)
e10da2
 {
e10da2
         char **objp_cpp0 = (char **) (void *) &objp->cpumap.cpumap_val;
e10da2
diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
e10da2
index 756da11..d75e76c 100644
e10da2
--- a/src/remote/remote_protocol.h
e10da2
+++ b/src/remote/remote_protocol.h
e10da2
@@ -750,6 +750,24 @@ struct remote_domain_set_vcpus_args {
e10da2
 };
e10da2
 typedef struct remote_domain_set_vcpus_args remote_domain_set_vcpus_args;
e10da2
e10da2
+struct remote_domain_set_vcpus_flags_args {
e10da2
+        remote_nonnull_domain dom;
e10da2
+        u_int nvcpus;
e10da2
+        u_int flags;
e10da2
+};
e10da2
+typedef struct remote_domain_set_vcpus_flags_args remote_domain_set_vcpus_flags_args;
e10da2
+
e10da2
+struct remote_domain_get_vcpus_flags_args {
e10da2
+        remote_nonnull_domain dom;
e10da2
+        u_int flags;
e10da2
+};
e10da2
+typedef struct remote_domain_get_vcpus_flags_args remote_domain_get_vcpus_flags_args;
e10da2
+
e10da2
+struct remote_domain_get_vcpus_flags_ret {
e10da2
+        int num;
e10da2
+};
e10da2
+typedef struct remote_domain_get_vcpus_flags_ret remote_domain_get_vcpus_flags_ret;
e10da2
+
e10da2
 struct remote_domain_pin_vcpu_args {
e10da2
         remote_nonnull_domain dom;
e10da2
         int vcpu;
e10da2
@@ -2281,6 +2299,8 @@ enum remote_procedure {
e10da2
         REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS = 196,
e10da2
         REMOTE_PROC_DOMAIN_SET_MEMORY_PARAMETERS = 197,
e10da2
         REMOTE_PROC_DOMAIN_GET_MEMORY_PARAMETERS = 198,
e10da2
+        REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS = 199,
e10da2
+        REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS = 200,
e10da2
 };
e10da2
 typedef enum remote_procedure remote_procedure;
e10da2
e10da2
@@ -2422,6 +2442,9 @@ extern  bool_t xdr_remote_domain_define_xml_args (XDR *, remote_domain_define_xm
e10da2
 extern  bool_t xdr_remote_domain_define_xml_ret (XDR *, remote_domain_define_xml_ret*);
e10da2
 extern  bool_t xdr_remote_domain_undefine_args (XDR *, remote_domain_undefine_args*);
e10da2
 extern  bool_t xdr_remote_domain_set_vcpus_args (XDR *, remote_domain_set_vcpus_args*);
e10da2
+extern  bool_t xdr_remote_domain_set_vcpus_flags_args (XDR *, remote_domain_set_vcpus_flags_args*);
e10da2
+extern  bool_t xdr_remote_domain_get_vcpus_flags_args (XDR *, remote_domain_get_vcpus_flags_args*);
e10da2
+extern  bool_t xdr_remote_domain_get_vcpus_flags_ret (XDR *, remote_domain_get_vcpus_flags_ret*);
e10da2
 extern  bool_t xdr_remote_domain_pin_vcpu_args (XDR *, remote_domain_pin_vcpu_args*);
e10da2
 extern  bool_t xdr_remote_domain_get_vcpus_args (XDR *, remote_domain_get_vcpus_args*);
e10da2
 extern  bool_t xdr_remote_domain_get_vcpus_ret (XDR *, remote_domain_get_vcpus_ret*);
e10da2
@@ -2762,6 +2785,9 @@ extern bool_t xdr_remote_domain_define_xml_args ();
e10da2
 extern bool_t xdr_remote_domain_define_xml_ret ();
e10da2
 extern bool_t xdr_remote_domain_undefine_args ();
e10da2
 extern bool_t xdr_remote_domain_set_vcpus_args ();
e10da2
+extern bool_t xdr_remote_domain_set_vcpus_flags_args ();
e10da2
+extern bool_t xdr_remote_domain_get_vcpus_flags_args ();
e10da2
+extern bool_t xdr_remote_domain_get_vcpus_flags_ret ();
e10da2
 extern bool_t xdr_remote_domain_pin_vcpu_args ();
e10da2
 extern bool_t xdr_remote_domain_get_vcpus_args ();
e10da2
 extern bool_t xdr_remote_domain_get_vcpus_ret ();
e10da2
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
e10da2
index e80fb5f..d57e6d0 100644
e10da2
--- a/src/remote/remote_protocol.x
e10da2
+++ b/src/remote/remote_protocol.x
e10da2
@@ -768,6 +768,21 @@ struct remote_domain_set_vcpus_args {
e10da2
     int nvcpus;
e10da2
 };
e10da2
e10da2
+struct remote_domain_set_vcpus_flags_args {
e10da2
+    remote_nonnull_domain dom;
e10da2
+    unsigned int nvcpus;
e10da2
+    unsigned int flags;
e10da2
+};
e10da2
+
e10da2
+struct remote_domain_get_vcpus_flags_args {
e10da2
+    remote_nonnull_domain dom;
e10da2
+    unsigned int flags;
e10da2
+};
e10da2
+
e10da2
+struct remote_domain_get_vcpus_flags_ret {
e10da2
+    int num;
e10da2
+};
e10da2
+
e10da2
 struct remote_domain_pin_vcpu_args {
e10da2
     remote_nonnull_domain dom;
e10da2
     int vcpu;
e10da2
@@ -2062,7 +2077,9 @@ enum remote_procedure {
e10da2
     REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON = 195,
e10da2
     REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS = 196,
e10da2
     REMOTE_PROC_DOMAIN_SET_MEMORY_PARAMETERS = 197,
e10da2
-    REMOTE_PROC_DOMAIN_GET_MEMORY_PARAMETERS = 198
e10da2
+    REMOTE_PROC_DOMAIN_GET_MEMORY_PARAMETERS = 198,
e10da2
+    REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS = 199,
e10da2
+    REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS = 200
e10da2
e10da2
     /*
e10da2
      * Notice how the entries are grouped in sets of 10 ?
e10da2
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
e10da2
index 838423e..d505886 100644
e10da2
--- a/src/remote_protocol-structs
e10da2
+++ b/src/remote_protocol-structs
e10da2
@@ -461,6 +461,18 @@ struct remote_domain_set_vcpus_args {
e10da2
 	remote_nonnull_domain      dom;
e10da2
 	int                        nvcpus;
e10da2
 };
e10da2
+struct remote_domain_set_vcpus_flags_args {
e10da2
+	remote_nonnull_domain      dom;
e10da2
+	u_int                      nvcpus;
e10da2
+	u_int                      flags;
e10da2
+};
e10da2
+struct remote_domain_get_vcpus_flags_args {
e10da2
+	remote_nonnull_domain      dom;
e10da2
+	u_int                      flags;
e10da2
+};
e10da2
+struct remote_domain_get_vcpus_flags_ret {
e10da2
+	int                        num;
e10da2
+};
e10da2
 struct remote_domain_pin_vcpu_args {
e10da2
 	remote_nonnull_domain      dom;
e10da2
 	int                        vcpu;
e10da2
-- 
e10da2
1.7.2.3
e10da2