From 84a3269a154b4098418e5128c3727966cc14cfcc Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Tue, 27 Apr 2010 20:29:15 +0100 Subject: [PATCH] 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 98abd33f51..6dbe7eea49 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 85ebedfc24..b0c52d2608 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 f6fcff8fbf..79d1eeca2f 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 895b511e11..f9d62376af 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 ebe8da41ce..984634fae3 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 0494d8260f..e589f8e4a4 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -3621,6 +3621,40 @@ done: return rv; } +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) { @@ -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 eb0f9c3dc5..71eed42447 100644 --- a/src/remote/remote_protocol.c +++ b/src/remote/remote_protocol.c @@ -725,6 +725,32 @@ xdr_remote_domain_memory_peek_ret (XDR *xdrs, remote_domain_memory_peek_ret *obj return TRUE; } +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 92fd6dfe31..8c4291f065 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 60f93b2cc6..ae306d2d26 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; }; +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 ? -- GitLab