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

[libvirt] [PATCH 3/6] Remote protocol impl for virDomainGetBlockInfo



* daemon/remote.c: Server side dispatcher
* daemon/remote_dispatch_args.h, daemon/remote_dispatch_prototypes.h,
  daemon/remote_dispatch_ret.h, daemon/remote_dispatch_table.h: Update
  with new API
* src/remote/remote_driver.c: Client side dispatcher
* src/remote/remote_protocol.c, src/remote/remote_protocol.h: Update
* src/remote/remote_protocol.x: Define new wire protocol
---
 daemon/remote.c                     |   34 +++++++++++++++++++++++++++++++++
 daemon/remote_dispatch_args.h       |    1 +
 daemon/remote_dispatch_prototypes.h |    8 +++++++
 daemon/remote_dispatch_ret.h        |    1 +
 daemon/remote_dispatch_table.h      |    5 ++++
 src/remote/remote_driver.c          |   36 ++++++++++++++++++++++++++++++++++-
 src/remote/remote_protocol.c        |   26 +++++++++++++++++++++++++
 src/remote/remote_protocol.h        |   19 ++++++++++++++++++
 src/remote/remote_protocol.x        |   15 +++++++++++++-
 9 files changed, 143 insertions(+), 2 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 98abd33..6dbe7ee 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -6434,6 +6434,40 @@ remoteDispatchNumOfNwfilters (struct qemud_server *server ATTRIBUTE_UNUSED,
 }
 
 
+static int
+remoteDispatchDomainGetBlockInfo (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_block_info_args *args,
+                                  remote_domain_get_block_info_ret *ret)
+{
+    virDomainPtr dom;
+    virDomainBlockInfo info;
+
+    dom = get_nonnull_domain (conn, args->dom);
+    if (dom == NULL) {
+        remoteDispatchConnError(rerr, conn);
+        return -1;
+    }
+
+    if (virDomainGetBlockInfo (dom, args->path, &info, args->flags) == -1) {
+        virDomainFree(dom);
+        remoteDispatchConnError(rerr, conn);
+        return -1;
+    }
+
+    ret->capacity = info.capacity;
+    ret->allocation = info.allocation;
+    ret->physical = info.physical;
+
+    virDomainFree(dom);
+
+    return 0;
+}
+
+
 /*----- Helpers. -----*/
 
 /* get_nonnull_domain and get_nonnull_network turn an on-wire
diff --git a/daemon/remote_dispatch_args.h b/daemon/remote_dispatch_args.h
index 85ebedf..b0c52d2 100644
--- a/daemon/remote_dispatch_args.h
+++ b/daemon/remote_dispatch_args.h
@@ -163,3 +163,4 @@
     remote_domain_snapshot_current_args val_remote_domain_snapshot_current_args;
     remote_domain_revert_to_snapshot_args val_remote_domain_revert_to_snapshot_args;
     remote_domain_snapshot_delete_args val_remote_domain_snapshot_delete_args;
+    remote_domain_get_block_info_args val_remote_domain_get_block_info_args;
diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h
index f6fcff8..79d1eec 100644
--- a/daemon/remote_dispatch_prototypes.h
+++ b/daemon/remote_dispatch_prototypes.h
@@ -210,6 +210,14 @@ static int remoteDispatchDomainGetAutostart(
     remote_error *err,
     remote_domain_get_autostart_args *args,
     remote_domain_get_autostart_ret *ret);
+static int remoteDispatchDomainGetBlockInfo(
+    struct qemud_server *server,
+    struct qemud_client *client,
+    virConnectPtr conn,
+    remote_message_header *hdr,
+    remote_error *err,
+    remote_domain_get_block_info_args *args,
+    remote_domain_get_block_info_ret *ret);
 static int remoteDispatchDomainGetInfo(
     struct qemud_server *server,
     struct qemud_client *client,
diff --git a/daemon/remote_dispatch_ret.h b/daemon/remote_dispatch_ret.h
index 895b511..f9d6237 100644
--- a/daemon/remote_dispatch_ret.h
+++ b/daemon/remote_dispatch_ret.h
@@ -133,3 +133,4 @@
     remote_domain_snapshot_lookup_by_name_ret val_remote_domain_snapshot_lookup_by_name_ret;
     remote_domain_has_current_snapshot_ret val_remote_domain_has_current_snapshot_ret;
     remote_domain_snapshot_current_ret val_remote_domain_snapshot_current_ret;
+    remote_domain_get_block_info_ret val_remote_domain_get_block_info_ret;
diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h
index ebe8da4..984634f 100644
--- a/daemon/remote_dispatch_table.h
+++ b/daemon/remote_dispatch_table.h
@@ -972,3 +972,8 @@
     .args_filter = (xdrproc_t) xdr_remote_domain_snapshot_delete_args,
     .ret_filter = (xdrproc_t) xdr_void,
 },
+{   /* DomainGetBlockInfo => 194 */
+    .fn = (dispatch_fn) remoteDispatchDomainGetBlockInfo,
+    .args_filter = (xdrproc_t) xdr_remote_domain_get_block_info_args,
+    .ret_filter = (xdrproc_t) xdr_remote_domain_get_block_info_ret,
+},
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 0494d82..e589f8e 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3622,6 +3622,40 @@ done:
 }
 
 static int
+remoteDomainGetBlockInfo (virDomainPtr domain,
+                          const char *path,
+                          virDomainBlockInfoPtr info,
+                          unsigned int flags)
+{
+    int rv = -1;
+    remote_domain_get_block_info_args args;
+    remote_domain_get_block_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;
+
+    memset (&ret, 0, sizeof ret);
+    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_BLOCK_INFO,
+              (xdrproc_t) xdr_remote_domain_get_block_info_args, (char *) &args,
+              (xdrproc_t) xdr_remote_domain_get_block_info_ret, (char *) &ret) == -1)
+        goto done;
+
+    info->allocation = ret.allocation;
+    info->capacity = ret.capacity;
+    info->physical = ret.physical;
+
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
+static int
 remoteDomainManagedSave (virDomainPtr domain, unsigned int flags)
 {
     int rv = -1;
@@ -10144,7 +10178,7 @@ static virDriver remote_driver = {
     remoteDomainMemoryStats, /* domainMemoryStats */
     remoteDomainBlockPeek, /* domainBlockPeek */
     remoteDomainMemoryPeek, /* domainMemoryPeek */
-    NULL, /* domainBlockInfo */
+    remoteDomainGetBlockInfo, /* domainGetBlockInfo */
     remoteNodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
     remoteNodeGetFreeMemory, /* getFreeMemory */
     remoteDomainEventRegister, /* domainEventRegister */
diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
index eb0f9c3..71eed42 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -726,6 +726,32 @@ xdr_remote_domain_memory_peek_ret (XDR *xdrs, remote_domain_memory_peek_ret *obj
 }
 
 bool_t
+xdr_remote_domain_get_block_info_args (XDR *xdrs, remote_domain_get_block_info_args *objp)
+{
+
+         if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
+                 return FALSE;
+         if (!xdr_remote_nonnull_string (xdrs, &objp->path))
+                 return FALSE;
+         if (!xdr_u_int (xdrs, &objp->flags))
+                 return FALSE;
+        return TRUE;
+}
+
+bool_t
+xdr_remote_domain_get_block_info_ret (XDR *xdrs, remote_domain_get_block_info_ret *objp)
+{
+
+         if (!xdr_uint64_t (xdrs, &objp->allocation))
+                 return FALSE;
+         if (!xdr_uint64_t (xdrs, &objp->capacity))
+                 return FALSE;
+         if (!xdr_uint64_t (xdrs, &objp->physical))
+                 return FALSE;
+        return TRUE;
+}
+
+bool_t
 xdr_remote_list_domains_args (XDR *xdrs, remote_list_domains_args *objp)
 {
 
diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
index 92fd6df..8c4291f 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -389,6 +389,20 @@ struct remote_domain_memory_peek_ret {
 };
 typedef struct remote_domain_memory_peek_ret remote_domain_memory_peek_ret;
 
+struct remote_domain_get_block_info_args {
+        remote_nonnull_domain dom;
+        remote_nonnull_string path;
+        u_int flags;
+};
+typedef struct remote_domain_get_block_info_args remote_domain_get_block_info_args;
+
+struct remote_domain_get_block_info_ret {
+        uint64_t allocation;
+        uint64_t capacity;
+        uint64_t physical;
+};
+typedef struct remote_domain_get_block_info_ret remote_domain_get_block_info_ret;
+
 struct remote_list_domains_args {
         int maxids;
 };
@@ -2191,6 +2205,7 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_SNAPSHOT_CURRENT = 191,
         REMOTE_PROC_DOMAIN_REVERT_TO_SNAPSHOT = 192,
         REMOTE_PROC_DOMAIN_SNAPSHOT_DELETE = 193,
+        REMOTE_PROC_DOMAIN_GET_BLOCK_INFO = 194,
 };
 typedef enum remote_procedure remote_procedure;
 
@@ -2277,6 +2292,8 @@ extern  bool_t xdr_remote_domain_block_peek_args (XDR *, remote_domain_block_pee
 extern  bool_t xdr_remote_domain_block_peek_ret (XDR *, remote_domain_block_peek_ret*);
 extern  bool_t xdr_remote_domain_memory_peek_args (XDR *, remote_domain_memory_peek_args*);
 extern  bool_t xdr_remote_domain_memory_peek_ret (XDR *, remote_domain_memory_peek_ret*);
+extern  bool_t xdr_remote_domain_get_block_info_args (XDR *, remote_domain_get_block_info_args*);
+extern  bool_t xdr_remote_domain_get_block_info_ret (XDR *, remote_domain_get_block_info_ret*);
 extern  bool_t xdr_remote_list_domains_args (XDR *, remote_list_domains_args*);
 extern  bool_t xdr_remote_list_domains_ret (XDR *, remote_list_domains_ret*);
 extern  bool_t xdr_remote_num_of_domains_ret (XDR *, remote_num_of_domains_ret*);
@@ -2607,6 +2624,8 @@ extern bool_t xdr_remote_domain_block_peek_args ();
 extern bool_t xdr_remote_domain_block_peek_ret ();
 extern bool_t xdr_remote_domain_memory_peek_args ();
 extern bool_t xdr_remote_domain_memory_peek_ret ();
+extern bool_t xdr_remote_domain_get_block_info_args ();
+extern bool_t xdr_remote_domain_get_block_info_ret ();
 extern bool_t xdr_remote_list_domains_args ();
 extern bool_t xdr_remote_list_domains_ret ();
 extern bool_t xdr_remote_num_of_domains_ret ();
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 60f93b2..ae306d2 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -484,6 +484,18 @@ struct remote_domain_memory_peek_ret {
     opaque buffer<REMOTE_DOMAIN_MEMORY_PEEK_BUFFER_MAX>;
 };
 
+struct remote_domain_get_block_info_args {
+    remote_nonnull_domain dom;
+    remote_nonnull_string path;
+    unsigned flags;
+};
+
+struct remote_domain_get_block_info_ret {
+    unsigned hyper allocation;
+    unsigned hyper capacity;
+    unsigned hyper physical;
+};
+
 struct remote_list_domains_args {
     int maxids;
 };
@@ -1983,7 +1995,8 @@ enum remote_procedure {
 
     REMOTE_PROC_DOMAIN_SNAPSHOT_CURRENT = 191,
     REMOTE_PROC_DOMAIN_REVERT_TO_SNAPSHOT = 192,
-    REMOTE_PROC_DOMAIN_SNAPSHOT_DELETE = 193
+    REMOTE_PROC_DOMAIN_SNAPSHOT_DELETE = 193,
+    REMOTE_PROC_DOMAIN_GET_BLOCK_INFO = 194
 
     /*
      * Notice how the entries are grouped in sets of 10 ?
-- 
1.6.6.1


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