diff --git a/daemon/remote.c b/daemon/remote.c index 98abd33f5192864d9bfd5c97746a9f2f3c301b38..6dbe7eea49c97e63607fdb48c8f68bb33295a37c 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 85ebedfc243c07569eb024bb46c24e0ab9776639..b0c52d2608f960e03c3be277ed4a99c08bff0b5b 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 f6fcff8fbf2c9a764919f806d6466f80759f5904..79d1eeca2fcf62eef706d276e9b65f92b333a3cc 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 895b511e1186c498fa193b16523a0c094bac7faa..f9d62376afc3b2b8e95a560ad59cbb512901627a 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 ebe8da41ce29d957d69107b06d8b9c5a14809541..984634fae30cd9811503de3647a54fe25c44ba9d 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 0494d8260fc7bc51e121547b9cb20d92e66d6336..e589f8e4a48d1e977f5dea8142139d08ca8227d4 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 eb0f9c3dc5264de3d81e91487a15148fea523914..71eed42447b37ed71d990a3a09272fe289526af8 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 92fd6dfe3100bf1f44b78ef928ba5d44ed2969e2..8c4291f06514973d9b8dfc3f3ca69d23d569b21a 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 60f93b2cc68f8d71ec7a7504674f25f2f9f7d0de..ae306d2d26a0a7bed696f74953f890cca8a59487 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 ?