[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 06/12] vcpu: implement the remote protocol



* daemon/remote.c (remoteDispatchDomainSetVcpusFlags)
(remoteDispatchDomainGetVcpusFlags): New functions.
* src/remote/remote_driver.c (remoteDomainSetVcpusFlags)
(remoteDomainGetVcpusFlags, remote_driver): Client side
serialization.
* src/remote/remote_protocol.x
(remote_domain_set_vcpus_flags_args)
(remote_domain_get_vcpus_flags_args)
(remote_domain_get_vcpus_flags_ret)
(REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS)
(REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS): Define wire format.
* daemon/remote_dispatch_args.h: Regenerate.
* daemon/remote_dispatch_prototypes.h: Likewise.
* daemon/remote_dispatch_table.h: Likewise.
* src/remote/remote_protocol.c: Likewise.
* src/remote/remote_protocol.h: Likewise.
* src/remote_protocol-structs: Likewise.
---

Pretty mechanical.

 daemon/remote.c                     |   53 ++++++++++++++++++++++++++++++++
 daemon/remote_dispatch_args.h       |    2 +
 daemon/remote_dispatch_prototypes.h |   16 ++++++++++
 daemon/remote_dispatch_ret.h        |    1 +
 daemon/remote_dispatch_table.h      |   10 ++++++
 src/remote/remote_driver.c          |   57 +++++++++++++++++++++++++++++++++-
 src/remote/remote_protocol.c        |   33 ++++++++++++++++++++
 src/remote/remote_protocol.h        |   26 ++++++++++++++++
 src/remote/remote_protocol.x        |   19 +++++++++++-
 src/remote_protocol-structs         |   12 +++++++
 10 files changed, 226 insertions(+), 3 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 6b67678..a3193b9 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -1751,6 +1751,33 @@ oom:
 }

 static int
+remoteDispatchDomainGetVcpusFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
+                                   struct qemud_client *client ATTRIBUTE_UNUSED,
+                                   virConnectPtr conn,
+                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                   remote_error *rerr,
+                                   remote_domain_get_vcpus_flags_args *args,
+                                   remote_domain_get_vcpus_flags_ret *ret)
+{
+    virDomainPtr dom;
+
+    dom = get_nonnull_domain (conn, args->dom);
+    if (dom == NULL) {
+        remoteDispatchConnError(rerr, conn);
+        return -1;
+    }
+
+    ret->num = virDomainGetVcpusFlags (dom, args->flags);
+    if (ret->num == -1) {
+        virDomainFree(dom);
+        remoteDispatchConnError(rerr, conn);
+        return -1;
+    }
+    virDomainFree(dom);
+    return 0;
+}
+
+static int
 remoteDispatchDomainMigratePrepare (struct qemud_server *server ATTRIBUTE_UNUSED,
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
                                     virConnectPtr conn,
@@ -2358,6 +2385,32 @@ remoteDispatchDomainSetVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
 }

 static int
+remoteDispatchDomainSetVcpusFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
+                                   struct qemud_client *client ATTRIBUTE_UNUSED,
+                                   virConnectPtr conn,
+                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                   remote_error *rerr,
+                                   remote_domain_set_vcpus_flags_args *args,
+                                   void *ret ATTRIBUTE_UNUSED)
+{
+    virDomainPtr dom;
+
+    dom = get_nonnull_domain (conn, args->dom);
+    if (dom == NULL) {
+        remoteDispatchConnError(rerr, conn);
+        return -1;
+    }
+
+    if (virDomainSetVcpusFlags (dom, args->nvcpus, args->flags) == -1) {
+        virDomainFree(dom);
+        remoteDispatchConnError(rerr, conn);
+        return -1;
+    }
+    virDomainFree(dom);
+    return 0;
+}
+
+static int
 remoteDispatchDomainShutdown (struct qemud_server *server ATTRIBUTE_UNUSED,
                               struct qemud_client *client ATTRIBUTE_UNUSED,
                               virConnectPtr conn,
diff --git a/daemon/remote_dispatch_args.h b/daemon/remote_dispatch_args.h
index ee95043..18cab30 100644
--- a/daemon/remote_dispatch_args.h
+++ b/daemon/remote_dispatch_args.h
@@ -165,3 +165,5 @@
     remote_domain_snapshot_delete_args val_remote_domain_snapshot_delete_args;
     remote_domain_get_block_info_args val_remote_domain_get_block_info_args;
     remote_domain_create_with_flags_args val_remote_domain_create_with_flags_args;
+    remote_domain_set_vcpus_flags_args val_remote_domain_set_vcpus_flags_args;
+    remote_domain_get_vcpus_flags_args val_remote_domain_get_vcpus_flags_args;
diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h
index cf1a0f9..2ba7907 100644
--- a/daemon/remote_dispatch_prototypes.h
+++ b/daemon/remote_dispatch_prototypes.h
@@ -298,6 +298,14 @@ static int remoteDispatchDomainGetVcpus(
     remote_error *err,
     remote_domain_get_vcpus_args *args,
     remote_domain_get_vcpus_ret *ret);
+static int remoteDispatchDomainGetVcpusFlags(
+    struct qemud_server *server,
+    struct qemud_client *client,
+    virConnectPtr conn,
+    remote_message_header *hdr,
+    remote_error *err,
+    remote_domain_get_vcpus_flags_args *args,
+    remote_domain_get_vcpus_flags_ret *ret);
 static int remoteDispatchDomainHasCurrentSnapshot(
     struct qemud_server *server,
     struct qemud_client *client,
@@ -538,6 +546,14 @@ static int remoteDispatchDomainSetVcpus(
     remote_error *err,
     remote_domain_set_vcpus_args *args,
     void *ret);
+static int remoteDispatchDomainSetVcpusFlags(
+    struct qemud_server *server,
+    struct qemud_client *client,
+    virConnectPtr conn,
+    remote_message_header *hdr,
+    remote_error *err,
+    remote_domain_set_vcpus_flags_args *args,
+    void *ret);
 static int remoteDispatchDomainShutdown(
     struct qemud_server *server,
     struct qemud_client *client,
diff --git a/daemon/remote_dispatch_ret.h b/daemon/remote_dispatch_ret.h
index 75ac0b2..5ecbeff 100644
--- a/daemon/remote_dispatch_ret.h
+++ b/daemon/remote_dispatch_ret.h
@@ -135,3 +135,4 @@
     remote_domain_snapshot_current_ret val_remote_domain_snapshot_current_ret;
     remote_domain_get_block_info_ret val_remote_domain_get_block_info_ret;
     remote_domain_create_with_flags_ret val_remote_domain_create_with_flags_ret;
+    remote_domain_get_vcpus_flags_ret val_remote_domain_get_vcpus_flags_ret;
diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h
index ef00edd..64191f3 100644
--- a/daemon/remote_dispatch_table.h
+++ b/daemon/remote_dispatch_table.h
@@ -987,3 +987,13 @@
     .args_filter = (xdrproc_t) xdr_remote_domain_create_with_flags_args,
     .ret_filter = (xdrproc_t) xdr_remote_domain_create_with_flags_ret,
 },
+{   /* DomainSetVcpusFlags => 197 */
+    .fn = (dispatch_fn) remoteDispatchDomainSetVcpusFlags,
+    .args_filter = (xdrproc_t) xdr_remote_domain_set_vcpus_flags_args,
+    .ret_filter = (xdrproc_t) xdr_void,
+},
+{   /* DomainGetVcpusFlags => 198 */
+    .fn = (dispatch_fn) remoteDispatchDomainGetVcpusFlags,
+    .args_filter = (xdrproc_t) xdr_remote_domain_get_vcpus_flags_args,
+    .ret_filter = (xdrproc_t) xdr_remote_domain_get_vcpus_flags_ret,
+},
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 274c1fe..3bf3336 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2411,6 +2411,59 @@ done:
 }

 static int
+remoteDomainSetVcpusFlags (virDomainPtr domain, unsigned int nvcpus,
+                           unsigned int flags)
+{
+    int rv = -1;
+    remote_domain_set_vcpus_flags_args args;
+    struct private_data *priv = domain->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    make_nonnull_domain (&args.dom, domain);
+    args.nvcpus = nvcpus;
+    args.flags = flags;
+
+    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS,
+              (xdrproc_t) xdr_remote_domain_set_vcpus_flags_args,
+              (char *) &args,
+              (xdrproc_t) xdr_void, (char *) NULL) == -1)
+        goto done;
+
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
+static int
+remoteDomainGetVcpusFlags (virDomainPtr domain, unsigned int flags)
+{
+    int rv = -1;
+    remote_domain_get_vcpus_flags_args args;
+    remote_domain_get_vcpus_flags_ret ret;
+    struct private_data *priv = domain->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    make_nonnull_domain (&args.dom, domain);
+    args.flags = flags;
+
+    memset (&ret, 0, sizeof ret);
+    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS,
+              (xdrproc_t) xdr_remote_domain_get_vcpus_flags_args, (char *) &args,
+              (xdrproc_t) xdr_remote_domain_get_vcpus_flags_ret, (char *) &ret) == -1)
+        goto done;
+
+    rv = ret.num;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
+static int
 remoteDomainPinVcpu (virDomainPtr domain,
                      unsigned int vcpu,
                      unsigned char *cpumap,
@@ -10299,8 +10352,8 @@ static virDriver remote_driver = {
     remoteDomainRestore, /* domainRestore */
     remoteDomainCoreDump, /* domainCoreDump */
     remoteDomainSetVcpus, /* domainSetVcpus */
-    NULL, /* domainSetVcpusFlags */
-    NULL, /* domainGetVcpusFlags */
+    remoteDomainSetVcpusFlags, /* domainSetVcpusFlags */
+    remoteDomainGetVcpusFlags, /* domainGetVcpusFlags */
     remoteDomainPinVcpu, /* domainPinVcpu */
     remoteDomainGetVcpus, /* domainGetVcpus */
     remoteDomainGetMaxVcpus, /* domainGetMaxVcpus */
diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
index 2483004..7f13412 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -1267,6 +1267,39 @@ xdr_remote_domain_set_vcpus_args (XDR *xdrs, remote_domain_set_vcpus_args *objp)
 }

 bool_t
+xdr_remote_domain_set_vcpus_flags_args (XDR *xdrs, remote_domain_set_vcpus_flags_args *objp)
+{
+
+         if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
+                 return FALSE;
+         if (!xdr_u_int (xdrs, &objp->nvcpus))
+                 return FALSE;
+         if (!xdr_u_int (xdrs, &objp->flags))
+                 return FALSE;
+        return TRUE;
+}
+
+bool_t
+xdr_remote_domain_get_vcpus_flags_args (XDR *xdrs, remote_domain_get_vcpus_flags_args *objp)
+{
+
+         if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
+                 return FALSE;
+         if (!xdr_u_int (xdrs, &objp->flags))
+                 return FALSE;
+        return TRUE;
+}
+
+bool_t
+xdr_remote_domain_get_vcpus_flags_ret (XDR *xdrs, remote_domain_get_vcpus_flags_ret *objp)
+{
+
+         if (!xdr_int (xdrs, &objp->num))
+                 return FALSE;
+        return TRUE;
+}
+
+bool_t
 xdr_remote_domain_pin_vcpu_args (XDR *xdrs, remote_domain_pin_vcpu_args *objp)
 {
         char **objp_cpp0 = (char **) (void *) &objp->cpumap.cpumap_val;
diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
index afe9287..43bf853 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -704,6 +704,24 @@ struct remote_domain_set_vcpus_args {
 };
 typedef struct remote_domain_set_vcpus_args remote_domain_set_vcpus_args;

+struct remote_domain_set_vcpus_flags_args {
+        remote_nonnull_domain dom;
+        u_int nvcpus;
+        u_int flags;
+};
+typedef struct remote_domain_set_vcpus_flags_args remote_domain_set_vcpus_flags_args;
+
+struct remote_domain_get_vcpus_flags_args {
+        remote_nonnull_domain dom;
+        u_int flags;
+};
+typedef struct remote_domain_get_vcpus_flags_args remote_domain_get_vcpus_flags_args;
+
+struct remote_domain_get_vcpus_flags_ret {
+        int num;
+};
+typedef struct remote_domain_get_vcpus_flags_ret remote_domain_get_vcpus_flags_ret;
+
 struct remote_domain_pin_vcpu_args {
         remote_nonnull_domain dom;
         int vcpu;
@@ -2233,6 +2251,8 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_GET_BLOCK_INFO = 194,
         REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON = 195,
         REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS = 196,
+        REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS = 197,
+        REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS = 198,
 };
 typedef enum remote_procedure remote_procedure;

@@ -2369,6 +2389,9 @@ extern  bool_t xdr_remote_domain_define_xml_args (XDR *, remote_domain_define_xm
 extern  bool_t xdr_remote_domain_define_xml_ret (XDR *, remote_domain_define_xml_ret*);
 extern  bool_t xdr_remote_domain_undefine_args (XDR *, remote_domain_undefine_args*);
 extern  bool_t xdr_remote_domain_set_vcpus_args (XDR *, remote_domain_set_vcpus_args*);
+extern  bool_t xdr_remote_domain_set_vcpus_flags_args (XDR *, remote_domain_set_vcpus_flags_args*);
+extern  bool_t xdr_remote_domain_get_vcpus_flags_args (XDR *, remote_domain_get_vcpus_flags_args*);
+extern  bool_t xdr_remote_domain_get_vcpus_flags_ret (XDR *, remote_domain_get_vcpus_flags_ret*);
 extern  bool_t xdr_remote_domain_pin_vcpu_args (XDR *, remote_domain_pin_vcpu_args*);
 extern  bool_t xdr_remote_domain_get_vcpus_args (XDR *, remote_domain_get_vcpus_args*);
 extern  bool_t xdr_remote_domain_get_vcpus_ret (XDR *, remote_domain_get_vcpus_ret*);
@@ -2704,6 +2727,9 @@ extern bool_t xdr_remote_domain_define_xml_args ();
 extern bool_t xdr_remote_domain_define_xml_ret ();
 extern bool_t xdr_remote_domain_undefine_args ();
 extern bool_t xdr_remote_domain_set_vcpus_args ();
+extern bool_t xdr_remote_domain_set_vcpus_flags_args ();
+extern bool_t xdr_remote_domain_get_vcpus_flags_args ();
+extern bool_t xdr_remote_domain_get_vcpus_flags_ret ();
 extern bool_t xdr_remote_domain_pin_vcpu_args ();
 extern bool_t xdr_remote_domain_get_vcpus_args ();
 extern bool_t xdr_remote_domain_get_vcpus_ret ();
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 8af469c..b5400af 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -728,6 +728,21 @@ struct remote_domain_set_vcpus_args {
     int nvcpus;
 };

+struct remote_domain_set_vcpus_flags_args {
+    remote_nonnull_domain dom;
+    unsigned int nvcpus;
+    unsigned int flags;
+};
+
+struct remote_domain_get_vcpus_flags_args {
+    remote_nonnull_domain dom;
+    unsigned int flags;
+};
+
+struct remote_domain_get_vcpus_flags_ret {
+    int num;
+};
+
 struct remote_domain_pin_vcpu_args {
     remote_nonnull_domain dom;
     int vcpu;
@@ -2020,7 +2035,9 @@ enum remote_procedure {
     REMOTE_PROC_DOMAIN_SNAPSHOT_DELETE = 193,
     REMOTE_PROC_DOMAIN_GET_BLOCK_INFO = 194,
     REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON = 195,
-    REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS = 196
+    REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS = 196,
+    REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS = 197,
+    REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS = 198

     /*
      * Notice how the entries are grouped in sets of 10 ?
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index a5fc6aa..fd056fe 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -426,6 +426,18 @@ struct remote_domain_set_vcpus_args {
 	remote_nonnull_domain      dom;
 	int                        nvcpus;
 };
+struct remote_domain_set_vcpus_flags_args {
+	remote_nonnull_domain      dom;
+	u_int                      nvcpus;
+	u_int                      flags;
+};
+struct remote_domain_get_vcpus_flags_args {
+	remote_nonnull_domain      dom;
+	u_int                      flags;
+};
+struct remote_domain_get_vcpus_flags_ret {
+	int                        num;
+};
 struct remote_domain_pin_vcpu_args {
 	remote_nonnull_domain      dom;
 	int                        vcpu;
-- 
1.7.2.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]