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

[libvirt] [PATCH 3/8] Add virDomainBlockPull support to the remote driver



The generator can handle everything except virDomainGetBlockJobInfo().

* src/remote/remote_protocol.x: provide defines for the new entry points
* src/remote/remote_driver.c daemon/remote.c: implement the client and
  server side for virDomainGetBlockJobInfo.
* src/remote_protocol-structs: structure definitions for protocol verification
* src/rpc/gendispatch.pl: Permit some unsigned long parameters

Signed-off-by: Adam Litke <agl us ibm com>
---
 daemon/remote.c              |   42 ++++++++++++++++++++++++++++++++++++++++++
 src/remote/remote_driver.c   |   42 ++++++++++++++++++++++++++++++++++++++++++
 src/remote/remote_protocol.x |   41 ++++++++++++++++++++++++++++++++++++++++-
 src/remote_protocol-structs  |   34 ++++++++++++++++++++++++++++++++++
 src/rpc/gendispatch.pl       |    2 ++
 5 files changed, 160 insertions(+), 1 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index daad39d..b471abc 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -1587,6 +1587,48 @@ no_memory:
     goto cleanup;
 }
 
+static int
+remoteDispatchDomainGetBlockJobInfo(virNetServerPtr server ATTRIBUTE_UNUSED,
+                                    virNetServerClientPtr client ATTRIBUTE_UNUSED,
+                                    virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                    virNetMessageErrorPtr rerr,
+                                    remote_domain_get_block_job_info_args *args,
+                                    remote_domain_get_block_job_info_ret *ret)
+{
+    virDomainPtr dom = NULL;
+    virDomainBlockJobInfo tmp;
+    int rv = -1;
+    struct daemonClientPrivate *priv =
+        virNetServerClientGetPrivateData(client);
+
+    if (!priv->conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+        goto cleanup;
+
+    rv = virDomainGetBlockJobInfo(dom, args->path, &tmp, args->flags);
+    if (rv <= 0)
+        goto cleanup;
+
+    ret->type = tmp.type;
+    ret->bandwidth = tmp.bandwidth;
+    ret->cur = tmp.cur;
+    ret->end = tmp.end;
+    ret->found = 1;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        virNetMessageSaveError(rerr);
+    if (dom)
+        virDomainFree(dom);
+    return rv;
+}
+
+
 /*-------------------------------------------------------------*/
 
 static int
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index c2f8bbd..a70b455 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1995,6 +1995,44 @@ done:
     return rv;
 }
 
+static int remoteDomainGetBlockJobInfo(virDomainPtr domain,
+                                       const char *path,
+                                       virDomainBlockJobInfoPtr info,
+                                       unsigned int flags)
+{
+    int rv = -1;
+    remote_domain_get_block_job_info_args args;
+    remote_domain_get_block_job_info_ret ret;
+    struct private_data *priv = domain->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    make_nonnull_domain(&args.dom, domain);
+    args.path = (char *)path;
+    args.flags = flags;
+
+    if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_BLOCK_JOB_INFO,
+             (xdrproc_t)xdr_remote_domain_get_block_job_info_args,
+               (char *)&args,
+             (xdrproc_t)xdr_remote_domain_get_block_job_info_ret,
+               (char *)&ret) == -1)
+        goto done;
+
+    if (ret.found) {
+        info->type = ret.type;
+        info->bandwidth = ret.bandwidth;
+        info->cur = ret.cur;
+        info->end = ret.end;
+        rv = 1;
+    } else {
+        rv = 0;
+    }
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
 /*----------------------------------------------------------------------*/
 
 static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
@@ -4254,6 +4292,10 @@ static virDriver remote_driver = {
     .domainMigrateFinish3 = remoteDomainMigrateFinish3, /* 0.9.2 */
     .domainMigrateConfirm3 = remoteDomainMigrateConfirm3, /* 0.9.2 */
     .domainSendKey = remoteDomainSendKey, /* 0.9.3 */
+    .domainBlockJobAbort = remoteDomainBlockJobAbort, /* 0.9.4 */
+    .domainGetBlockJobInfo = remoteDomainGetBlockJobInfo, /* 0.9.4 */
+    .domainBlockJobSetSpeed = remoteDomainBlockJobSetSpeed, /* 0.9.4 */
+    .domainBlockPull = remoteDomainBlockPull, /* 0.9.4 */
 };
 
 static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index d72a60d..96113d8 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -980,6 +980,40 @@ struct remote_domain_set_autostart_args {
     int autostart;
 };
 
+struct remote_domain_block_job_abort_args {
+    remote_nonnull_domain dom;
+    remote_nonnull_string path;
+    unsigned int flags;
+};
+
+struct remote_domain_get_block_job_info_args {
+    remote_nonnull_domain dom;
+    remote_nonnull_string path;
+    unsigned int flags;
+};
+
+struct remote_domain_get_block_job_info_ret {
+    int found;
+    int type;
+    unsigned hyper bandwidth;
+    unsigned hyper cur;
+    unsigned hyper end;
+};
+
+struct remote_domain_block_job_set_speed_args {
+    remote_nonnull_domain dom;
+    remote_nonnull_string path;
+    unsigned hyper bandwidth;
+    unsigned int flags;
+};
+
+struct remote_domain_block_pull_args {
+    remote_nonnull_domain dom;
+    remote_nonnull_string path;
+    unsigned hyper bandwidth;
+    unsigned int flags;
+};
+
 /* Network calls: */
 
 struct remote_num_of_networks_ret {
@@ -2383,7 +2417,12 @@ enum remote_procedure {
     REMOTE_PROC_NODE_GET_CPU_STATS = 227, /* skipgen skipgen */
     REMOTE_PROC_NODE_GET_MEMORY_STATS = 228, /* skipgen skipgen */
     REMOTE_PROC_DOMAIN_GET_CONTROL_INFO = 229, /* autogen autogen */
-    REMOTE_PROC_DOMAIN_GET_VCPU_PIN_INFO = 230  /* skipgen skipgen */
+    REMOTE_PROC_DOMAIN_GET_VCPU_PIN_INFO = 230,  /* skipgen skipgen */
+
+    REMOTE_PROC_DOMAIN_BLOCK_JOB_ABORT = 231, /* autogen autogen */
+    REMOTE_PROC_DOMAIN_GET_BLOCK_JOB_INFO = 232, /* skipgen skipgen */
+    REMOTE_PROC_DOMAIN_BLOCK_JOB_SET_SPEED = 233, /* autogen autogen */
+    REMOTE_PROC_DOMAIN_BLOCK_PULL = 234 /* autogen autogen */
 
     /*
      * Notice how the entries are grouped in sets of 10 ?
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 221562d..d6bcdd0 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -680,6 +680,35 @@ struct remote_domain_set_autostart_args {
         remote_nonnull_domain      dom;
         int                        autostart;
 };
+struct remote_domain_block_job_abort_args {
+        remote_nonnull_domain      dom;
+        remote_nonnull_string      path;
+        u_int                      flags;
+};
+struct remote_domain_get_block_job_info_args {
+        remote_nonnull_domain      dom;
+        remote_nonnull_string      path;
+        u_int                      flags;
+};
+struct remote_domain_get_block_job_info_ret {
+        int                        found;
+        int                        type;
+        uint64_t                   bandwidth;
+        uint64_t                   cur;
+        uint64_t                   end;
+};
+struct remote_domain_block_job_set_speed_args {
+        remote_nonnull_domain      dom;
+        remote_nonnull_string      path;
+        uint64_t                   bandwidth;
+        u_int                      flags;
+};
+struct remote_domain_block_pull_args {
+        remote_nonnull_domain      dom;
+        remote_nonnull_string      path;
+        uint64_t                   bandwidth;
+        u_int                      flags;
+};
 struct remote_num_of_networks_ret {
         int                        num;
 };
@@ -1859,4 +1888,9 @@ enum remote_procedure {
         REMOTE_PROC_NODE_GET_MEMORY_STATS = 228,
         REMOTE_PROC_DOMAIN_GET_CONTROL_INFO = 229,
         REMOTE_PROC_DOMAIN_GET_VCPU_PIN_INFO = 230,
+        REMOTE_PROC_DOMAIN_BLOCK_JOB_ABORT = 231,
+        REMOTE_PROC_DOMAIN_GET_BLOCK_JOB_INFO = 232,
+        REMOTE_PROC_DOMAIN_BLOCK_JOB_SET_SPEED = 233,
+        REMOTE_PROC_DOMAIN_BLOCK_PULL = 234,
+
 };
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index e068b53..583e808 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -218,6 +218,8 @@ my $long_legacy = {
     GetLibVersion               => { ret => { lib_ver => 1 } },
     GetVersion                  => { ret => { hv_ver => 1 } },
     NodeGetInfo                 => { ret => { memory => 1 } },
+    DomainBlockPull             => { arg => { bandwidth => 1 } },
+    DomainBlockJobSetSpeed      => { arg => { bandwidth => 1 } },
 };
 
 sub hyper_to_long
-- 
1.7.3


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