The generator doesn't handle lists of virDomainSnapshotPtr, so this commit requires a bit more work than some RPC additions. * src/remote/remote_protocol.x (REMOTE_PROC_DOMAIN_LIST_ALL_SNAPSHOTS) (REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_ALL_CHILDREN): New RPC calls, with corresponding structs. * daemon/remote.c (remoteDispatchDomainListAllSnapshots) (remoteDispatchDomainSnapshotListAllChildren): New functions. * src/remote/remote_driver.c (remoteDomainListAllSnapshots) (remoteDomainSnapshotListAllChildren): Likewise. * src/remote_protocol-structs: Regenerate. --- v2: no real change daemon/remote.c | 126 ++++++++++++++++++++++++++++++++++++++++++ src/remote/remote_driver.c | 126 ++++++++++++++++++++++++++++++++++++++++++ src/remote/remote_protocol.x | 26 ++++++++- src/remote_protocol-structs | 26 +++++++++ 4 files changed, 303 insertions(+), 1 deletion(-) diff --git a/daemon/remote.c b/daemon/remote.c index 8dd5a4f..21bc3f6 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -3797,6 +3797,132 @@ cleanup: return rv; } +static int +remoteDispatchDomainListAllSnapshots(virNetServerPtr server ATTRIBUTE_UNUSED, + virNetServerClientPtr client, + virNetMessagePtr msg ATTRIBUTE_UNUSED, + virNetMessageErrorPtr rerr, + remote_domain_list_all_snapshots_args *args, + remote_domain_list_all_snapshots_ret *ret) +{ + virDomainSnapshotPtr *snaps = NULL; + int nsnaps = 0; + int i; + int rv = -1; + struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client); + virDomainPtr dom = NULL; + + 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; + + if ((nsnaps = virDomainListAllSnapshots(dom, + args->need_results ? &snaps : NULL, + args->flags)) < 0) + goto cleanup; + + if (snaps && nsnaps) { + if (VIR_ALLOC_N(ret->snapshots.snapshots_val, nsnaps) < 0) { + virReportOOMError(); + goto cleanup; + } + + ret->snapshots.snapshots_len = nsnaps; + + for (i = 0; i < nsnaps; i++) + make_nonnull_domain_snapshot(ret->snapshots.snapshots_val + i, + snaps[i]); + } else { + ret->snapshots.snapshots_len = 0; + ret->snapshots.snapshots_val = NULL; + } + + ret->ret = nsnaps; + rv = 0; + +cleanup: + if (rv < 0) + virNetMessageSaveError(rerr); + if (dom) + virDomainFree(dom); + if (snaps) { + for (i = 0; i < nsnaps; i++) + virDomainSnapshotFree(snaps[i]); + VIR_FREE(snaps); + } + return rv; +} + +static int +remoteDispatchDomainSnapshotListAllChildren(virNetServerPtr server ATTRIBUTE_UNUSED, + virNetServerClientPtr client, + virNetMessagePtr msg ATTRIBUTE_UNUSED, + virNetMessageErrorPtr rerr, + remote_domain_snapshot_list_all_children_args *args, + remote_domain_snapshot_list_all_children_ret *ret) +{ + virDomainSnapshotPtr *snaps = NULL; + int nsnaps = 0; + int i; + int rv = -1; + struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client); + virDomainPtr dom = NULL; + virDomainSnapshotPtr snapshot = NULL; + + if (!priv->conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if (!(dom = get_nonnull_domain(priv->conn, args->snapshot.dom))) + goto cleanup; + + if (!(snapshot = get_nonnull_domain_snapshot(dom, args->snapshot))) + goto cleanup; + + if ((nsnaps = virDomainSnapshotListAllChildren(snapshot, + args->need_results ? &snaps : NULL, + args->flags)) < 0) + goto cleanup; + + if (snaps && nsnaps) { + if (VIR_ALLOC_N(ret->snapshots.snapshots_val, nsnaps) < 0) { + virReportOOMError(); + goto cleanup; + } + + ret->snapshots.snapshots_len = nsnaps; + + for (i = 0; i < nsnaps; i++) + make_nonnull_domain_snapshot(ret->snapshots.snapshots_val + i, + snaps[i]); + } else { + ret->snapshots.snapshots_len = 0; + ret->snapshots.snapshots_val = NULL; + } + + ret->ret = nsnaps; + rv = 0; + +cleanup: + if (rv < 0) + virNetMessageSaveError(rerr); + if (snapshot) + virDomainSnapshotFree(snapshot); + if (dom) + virDomainFree(dom); + if (snaps) { + for (i = 0; i < nsnaps; i++) + virDomainSnapshotFree(snaps[i]); + VIR_FREE(snaps); + } + return rv; +} + /*----- Helpers. -----*/ /* get_nonnull_domain and get_nonnull_network turn an on-wire diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 28f12a4..7c1f0cc 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -4873,6 +4873,130 @@ done: return rv; } +static int +remoteDomainListAllSnapshots(virDomainPtr dom, + virDomainSnapshotPtr **snapshots, + unsigned int flags) +{ + int rv = -1; + int i; + virDomainSnapshotPtr *snaps = NULL; + remote_domain_list_all_snapshots_args args; + remote_domain_list_all_snapshots_ret ret; + + struct private_data *priv = dom->conn->privateData; + + remoteDriverLock(priv); + + args.need_results = !!snapshots; + args.flags = flags; + + memset(&ret, 0, sizeof(ret)); + if (call (dom->conn, + priv, + 0, + REMOTE_PROC_DOMAIN_LIST_ALL_SNAPSHOTS, + (xdrproc_t) xdr_remote_domain_list_all_snapshots_args, + (char *) &args, + (xdrproc_t) xdr_remote_domain_list_all_snapshots_ret, + (char *) &ret) == -1) + goto done; + + if (snapshots) { + if (VIR_ALLOC_N(snaps, ret.snapshots.snapshots_len + 1) < 0) { + virReportOOMError(); + goto cleanup; + } + for (i = 0; i < ret.snapshots.snapshots_len; i++) { + snaps[i] = get_nonnull_domain_snapshot(dom, ret.snapshots.snapshots_val[i]); + if (!snaps[i]) { + virReportOOMError(); + goto cleanup; + } + } + *snapshots = snaps; + snaps = NULL; + } + + rv = ret.ret; + +cleanup: + if (snaps) { + for (i = 0; i < ret.snapshots.snapshots_len; i++) + if (snaps[i]) + virDomainSnapshotFree(snaps[i]); + VIR_FREE(snaps); + } + + xdr_free((xdrproc_t) xdr_remote_domain_list_all_snapshots_ret, (char *) &ret); + +done: + remoteDriverUnlock(priv); + return rv; +} + +static int +remoteDomainSnapshotListAllChildren(virDomainSnapshotPtr parent, + virDomainSnapshotPtr **snapshots, + unsigned int flags) +{ + int rv = -1; + int i; + virDomainSnapshotPtr *snaps = NULL; + remote_domain_snapshot_list_all_children_args args; + remote_domain_snapshot_list_all_children_ret ret; + + struct private_data *priv = parent->domain->conn->privateData; + + remoteDriverLock(priv); + + args.need_results = !!snapshots; + args.flags = flags; + + memset(&ret, 0, sizeof(ret)); + if (call (parent->domain->conn, + priv, + 0, + REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_ALL_CHILDREN, + (xdrproc_t) xdr_remote_domain_snapshot_list_all_children_args, + (char *) &args, + (xdrproc_t) xdr_remote_domain_snapshot_list_all_children_ret, + (char *) &ret) == -1) + goto done; + + if (snapshots) { + if (VIR_ALLOC_N(snaps, ret.snapshots.snapshots_len + 1) < 0) { + virReportOOMError(); + goto cleanup; + } + for (i = 0; i < ret.snapshots.snapshots_len; i++) { + snaps[i] = get_nonnull_domain_snapshot(parent->domain, ret.snapshots.snapshots_val[i]); + if (!snaps[i]) { + virReportOOMError(); + goto cleanup; + } + } + *snapshots = snaps; + snaps = NULL; + } + + rv = ret.ret; + +cleanup: + if (snaps) { + for (i = 0; i < ret.snapshots.snapshots_len; i++) + if (snaps[i]) + virDomainSnapshotFree(snaps[i]); + VIR_FREE(snaps); + } + + xdr_free((xdrproc_t) xdr_remote_domain_snapshot_list_all_children_ret, (char *) &ret); + +done: + remoteDriverUnlock(priv); + return rv; +} + static void remoteDomainEventQueue(struct private_data *priv, virDomainEventPtr event) { @@ -5138,7 +5262,9 @@ static virDriver remote_driver = { .domainSnapshotGetXMLDesc = remoteDomainSnapshotGetXMLDesc, /* 0.8.0 */ .domainSnapshotNum = remoteDomainSnapshotNum, /* 0.8.0 */ .domainSnapshotListNames = remoteDomainSnapshotListNames, /* 0.8.0 */ + .domainListAllSnapshots = remoteDomainListAllSnapshots, /* 0.9.13 */ .domainSnapshotNumChildren = remoteDomainSnapshotNumChildren, /* 0.9.7 */ + .domainSnapshotListAllChildren = remoteDomainSnapshotListAllChildren, /* 0.9.13 */ .domainSnapshotListChildrenNames = remoteDomainSnapshotListChildrenNames, /* 0.9.7 */ .domainSnapshotLookupByName = remoteDomainSnapshotLookupByName, /* 0.8.0 */ .domainHasCurrentSnapshot = remoteDomainHasCurrentSnapshot, /* 0.8.0 */ diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 865cfe6..1da9f3e 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -2249,6 +2249,17 @@ struct remote_domain_snapshot_list_names_ret { remote_nonnull_string names<REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX>; /* insert@1 */ }; +struct remote_domain_list_all_snapshots_args { + remote_nonnull_domain dom; + int need_results; + unsigned int flags; +}; + +struct remote_domain_list_all_snapshots_ret { + remote_nonnull_domain_snapshot snapshots<>; + int ret; +}; + struct remote_domain_snapshot_num_children_args { remote_nonnull_domain_snapshot snap; unsigned int flags; @@ -2268,6 +2279,17 @@ struct remote_domain_snapshot_list_children_names_ret { remote_nonnull_string names<REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX>; /* insert@1 */ }; +struct remote_domain_snapshot_list_all_children_args { + remote_nonnull_domain_snapshot snapshot; + int need_results; + unsigned int flags; +}; + +struct remote_domain_snapshot_list_all_children_ret { + remote_nonnull_domain_snapshot snapshots<>; + int ret; +}; + struct remote_domain_snapshot_lookup_by_name_args { remote_nonnull_domain dom; remote_nonnull_string name; @@ -2814,7 +2836,9 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_SNAPSHOT_IS_CURRENT = 271, /* autogen autogen */ REMOTE_PROC_DOMAIN_SNAPSHOT_HAS_METADATA = 272, /* autogen autogen */ - REMOTE_PROC_CONNECT_LIST_ALL_DOMAINS = 273 /* skipgen skipgen priority:high */ + REMOTE_PROC_CONNECT_LIST_ALL_DOMAINS = 273, /* skipgen skipgen priority:high */ + REMOTE_PROC_DOMAIN_LIST_ALL_SNAPSHOTS = 274, /* skipgen skipgen priority:high */ + REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_ALL_CHILDREN = 275 /* skipgen skipgen priority:high */ /* * Notice how the entries are grouped in sets of 10 ? diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 63d70e0..b667527 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -1709,6 +1709,18 @@ struct remote_domain_snapshot_list_names_ret { remote_nonnull_string * names_val; } names; }; +struct remote_domain_list_all_snapshots_args { + remote_nonnull_domain dom; + int need_results; + u_int flags; +}; +struct remote_domain_list_all_snapshots_ret { + struct { + u_int snapshots_len; + remote_nonnull_domain_snapshot * snapshots_val; + } snapshots; + int ret; +}; struct remote_domain_snapshot_num_children_args { remote_nonnull_domain_snapshot snap; u_int flags; @@ -1727,6 +1739,18 @@ struct remote_domain_snapshot_list_children_names_ret { remote_nonnull_string * names_val; } names; }; +struct remote_domain_snapshot_list_all_children_args { + remote_nonnull_domain_snapshot snapshot; + int need_results; + u_int flags; +}; +struct remote_domain_snapshot_list_all_children_ret { + struct { + u_int snapshots_len; + remote_nonnull_domain_snapshot * snapshots_val; + } snapshots; + int ret; +}; struct remote_domain_snapshot_lookup_by_name_args { remote_nonnull_domain dom; remote_nonnull_string name; @@ -2220,4 +2244,6 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_SNAPSHOT_IS_CURRENT = 271, REMOTE_PROC_DOMAIN_SNAPSHOT_HAS_METADATA = 272, REMOTE_PROC_CONNECT_LIST_ALL_DOMAINS = 273, + REMOTE_PROC_DOMAIN_LIST_ALL_SNAPSHOTS = 274, + REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_ALL_CHILDREN = 275, }; -- 1.7.10.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list