--- daemon/remote_generator.pl | 93 ++++- src/remote/remote_client_bodies.c | 786 ++++++++++++++++++++++++++++++++++++- src/remote/remote_driver.c | 758 ----------------------------------- 3 files changed, 851 insertions(+), 786 deletions(-) diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl index 774188b..f5be8d6 100755 --- a/daemon/remote_generator.pl +++ b/daemon/remote_generator.pl @@ -755,29 +755,16 @@ elsif ($opt_k) { "NWFilterDefineXML", # public API and XDR protocol mismatch "DomainMigratePerform", "DomainMigrateFinish2", - "DomainSnapshotListNames", "FindStoragePoolSources", "IsSecure", - "ListDefinedDomains", - "ListDefinedInterfaces", - "ListNWFilters", "SupportsFeature", - "NodeListDevices", "NodeGetCellsFreeMemory", - "ListDefinedNetworks", - "StoragePoolListVolumes", "ListDomains", - "ListStoragePools", "SecretSetValue", "GetURI", - "ListInterfaces", - "ListDefinedStoragePools", "NodeDeviceDettach", - "ListNetworks", - "NodeDeviceListCaps", "NodeDeviceReset", "NodeDeviceReAttach", - "ListSecrets", "DomainBlockPeek", "DomainCreateWithFlags", @@ -925,8 +912,9 @@ elsif ($opt_k) { # fix priv_name for the NumOf* functions if ($priv_name eq "privateData" and - !($call->{ProcName} =~ m/Domains/) and - $call->{ProcName} =~ m/NumOf(Defined|Domain)*(\S+)s/) { + !($call->{ProcName} =~ m/(Domains|DomainSnapshot)/) and + ($call->{ProcName} =~ m/NumOf(Defined|Domain)*(\S+)s/ or + $call->{ProcName} =~ m/List(Defined|Domain)*(\S+)s/)) { my $prefix = lc $2; $prefix =~ s/(pool|vol)$//; $priv_name = "${prefix}PrivateData"; @@ -937,6 +925,11 @@ elsif ($opt_k) { my $call_ret = "&ret"; my $single_ret_var = "int rv = -1"; my $single_ret_type = "int"; + my $single_ret_as_list = 0; + my $single_ret_list_error_msg_type = "undefined"; + my $single_ret_list_name = "undefined"; + my $single_ret_list_max_var = "undefined"; + my $single_ret_list_max_define = "undefined"; my $multi_ret = 0; if ($call->{ret} ne "void" and @@ -961,6 +954,30 @@ elsif ($opt_k) { } else { die "unhandled type for multi-return-value: $ret_member"; } + } elsif ($ret_member =~ m/remote_nonnull_string (\S+)<(\S+)>;/) { + $single_ret_as_list = 1; + $single_ret_list_name = $1; + $single_ret_list_max_var = "max$1"; + $single_ret_list_max_define = $2; + + my $first_arg = shift(@args_list); + my $second_arg; + + if ($call->{ProcName} eq "NodeListDevices") { + $second_arg = shift(@args_list); + } + + unshift(@args_list, "char **const $1"); + + if (defined $second_arg) { + unshift(@args_list, $second_arg); + } + + unshift(@args_list, $first_arg); + + push(@ret_list, "rv = ret.$1.$1_len;"); + $single_ret_var = "int rv = -1"; + $single_ret_type = "int"; } elsif ($ret_member =~ m/remote_nonnull_string (\S+);/) { push(@ret_list, "rv = ret.$1;"); $single_ret_var = "char *rv = NULL"; @@ -1058,9 +1075,23 @@ elsif ($opt_k) { print " $var;\n"; } + if ($single_ret_as_list) { + print " int i;\n"; + } + print "\n"; print " remoteDriverLock(priv);\n"; + if ($single_ret_as_list) { + print "\n"; + print " if ($single_ret_list_max_var > $single_ret_list_max_define) {\n"; + print " remoteError(VIR_ERR_RPC,\n"; + print " _(\"too many remote ${single_ret_list_error_msg_type}s: %d > %d\"),\n"; + print " $single_ret_list_max_var, $single_ret_list_max_define);\n"; + print " goto done;\n"; + print " }\n"; + } + if (@setters_list) { print "\n"; print " "; @@ -1084,6 +1115,32 @@ elsif ($opt_k) { print " goto done;\n"; print "\n"; + if ($single_ret_as_list) { + print " if (ret.$single_ret_list_name.${single_ret_list_name}_len > $single_ret_list_max_var) {\n"; + print " remoteError(VIR_ERR_RPC,\n"; + print " _(\"too many remote ${single_ret_list_error_msg_type}s: %d > %d\"),\n"; + print " ret.$single_ret_list_name.${single_ret_list_name}_len, $single_ret_list_max_var);\n"; + print " goto cleanup;\n"; + print " }\n"; + print "\n"; + print " /* This call is caller-frees (although that isn't clear from\n"; + print " * the documentation). However xdr_free will free up both the\n"; + print " * names and the list of pointers, so we have to strdup the\n"; + print " * names here. */\n"; + print " for (i = 0; i < ret.$single_ret_list_name.${single_ret_list_name}_len; ++i) {\n"; + print " ${single_ret_list_name}[i] = strdup(ret.$single_ret_list_name.${single_ret_list_name}_val[i]);\n"; + print "\n"; + print " if (${single_ret_list_name}[i] == NULL) {\n"; + print " for (--i; i >= 0; --i)\n"; + print " VIR_FREE(${single_ret_list_name}[i]);\n"; + print "\n"; + print " virReportOOMError();\n"; + print " goto cleanup;\n"; + print " }\n"; + print " }\n"; + print "\n"; + } + if (@ret_list) { print " "; print join("\n ", @ret_list); @@ -1094,6 +1151,12 @@ elsif ($opt_k) { print " rv = 0;\n"; } + if ($single_ret_as_list) { + print "\n"; + print "cleanup:\n"; + print " xdr_free((xdrproc_t)xdr_remote_$call->{name}_ret, (char *)&ret);\n"; + } + print "\n"; print "done:\n"; print " remoteDriverUnlock(priv);\n"; diff --git a/src/remote/remote_client_bodies.c b/src/remote/remote_client_bodies.c index e61055b..4970c23 100644 --- a/src/remote/remote_client_bodies.c +++ b/src/remote/remote_client_bodies.c @@ -1330,7 +1330,67 @@ done: return rv; } -/* remoteDispatchDomainSnapshotListNames has to be implemented manually */ +static int +remoteDomainSnapshotListNames(virDomainPtr dom, char **const names, int maxnames, unsigned int flags) +{ + int rv = -1; + struct private_data *priv = dom->conn->privateData; + remote_domain_snapshot_list_names_args args; + remote_domain_snapshot_list_names_ret ret; + int i; + + remoteDriverLock(priv); + + if (maxnames > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX) { + remoteError(VIR_ERR_RPC, + _("too many remote undefined names: %d > %d"), + maxnames, REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX); + goto done; + } + + make_nonnull_domain(&args.dom, dom); + args.maxnames = maxnames; + args.flags = flags; + + memset(&ret, 0, sizeof ret); + + if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_NAMES, + (xdrproc_t)xdr_remote_domain_snapshot_list_names_args, (char *)&args, + (xdrproc_t)xdr_remote_domain_snapshot_list_names_ret, (char *)&ret) == -1) + goto done; + + if (ret.names.names_len > maxnames) { + remoteError(VIR_ERR_RPC, + _("too many remote undefineds: %d > %d"), + ret.names.names_len, maxnames); + goto cleanup; + } + + /* This call is caller-frees (although that isn't clear from + * the documentation). However xdr_free will free up both the + * names and the list of pointers, so we have to strdup the + * names here. */ + for (i = 0; i < ret.names.names_len; ++i) { + names[i] = strdup(ret.names.names_val[i]); + + if (names[i] == NULL) { + for (--i; i >= 0; --i) + VIR_FREE(names[i]); + + virReportOOMError(); + goto cleanup; + } + } + + rv = ret.names.names_len; + +cleanup: + xdr_free((xdrproc_t)xdr_remote_domain_snapshot_list_names_ret, (char *)&ret); + +done: + remoteDriverUnlock(priv); + return rv; +} static virDomainSnapshotPtr remoteDomainSnapshotLookupByName(virDomainPtr dom, const char *name, unsigned int flags) @@ -1875,25 +1935,547 @@ done: /* remoteDispatchIsSecure has to be implemented manually */ -/* remoteDispatchListDefinedDomains has to be implemented manually */ +static int +remoteListDefinedDomains(virConnectPtr conn, char **const names, int maxnames) +{ + int rv = -1; + struct private_data *priv = conn->privateData; + remote_list_defined_domains_args args; + remote_list_defined_domains_ret ret; + int i; + + remoteDriverLock(priv); + + if (maxnames > REMOTE_DOMAIN_NAME_LIST_MAX) { + remoteError(VIR_ERR_RPC, + _("too many remote undefined names: %d > %d"), + maxnames, REMOTE_DOMAIN_NAME_LIST_MAX); + goto done; + } + + args.maxnames = maxnames; + + memset(&ret, 0, sizeof ret); + + if (call(conn, priv, 0, REMOTE_PROC_LIST_DEFINED_DOMAINS, + (xdrproc_t)xdr_remote_list_defined_domains_args, (char *)&args, + (xdrproc_t)xdr_remote_list_defined_domains_ret, (char *)&ret) == -1) + goto done; + + if (ret.names.names_len > maxnames) { + remoteError(VIR_ERR_RPC, + _("too many remote undefineds: %d > %d"), + ret.names.names_len, maxnames); + goto cleanup; + } -/* remoteDispatchListDefinedInterfaces has to be implemented manually */ + /* This call is caller-frees (although that isn't clear from + * the documentation). However xdr_free will free up both the + * names and the list of pointers, so we have to strdup the + * names here. */ + for (i = 0; i < ret.names.names_len; ++i) { + names[i] = strdup(ret.names.names_val[i]); -/* remoteDispatchListDefinedNetworks has to be implemented manually */ + if (names[i] == NULL) { + for (--i; i >= 0; --i) + VIR_FREE(names[i]); -/* remoteDispatchListDefinedStoragePools has to be implemented manually */ + virReportOOMError(); + goto cleanup; + } + } + + rv = ret.names.names_len; + +cleanup: + xdr_free((xdrproc_t)xdr_remote_list_defined_domains_ret, (char *)&ret); + +done: + remoteDriverUnlock(priv); + return rv; +} + +static int +remoteListDefinedInterfaces(virConnectPtr conn, char **const names, int maxnames) +{ + int rv = -1; + struct private_data *priv = conn->interfacePrivateData; + remote_list_defined_interfaces_args args; + remote_list_defined_interfaces_ret ret; + int i; + + remoteDriverLock(priv); + + if (maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX) { + remoteError(VIR_ERR_RPC, + _("too many remote undefined names: %d > %d"), + maxnames, REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX); + goto done; + } + + args.maxnames = maxnames; + + memset(&ret, 0, sizeof ret); + + if (call(conn, priv, 0, REMOTE_PROC_LIST_DEFINED_INTERFACES, + (xdrproc_t)xdr_remote_list_defined_interfaces_args, (char *)&args, + (xdrproc_t)xdr_remote_list_defined_interfaces_ret, (char *)&ret) == -1) + goto done; + + if (ret.names.names_len > maxnames) { + remoteError(VIR_ERR_RPC, + _("too many remote undefineds: %d > %d"), + ret.names.names_len, maxnames); + goto cleanup; + } + + /* This call is caller-frees (although that isn't clear from + * the documentation). However xdr_free will free up both the + * names and the list of pointers, so we have to strdup the + * names here. */ + for (i = 0; i < ret.names.names_len; ++i) { + names[i] = strdup(ret.names.names_val[i]); + + if (names[i] == NULL) { + for (--i; i >= 0; --i) + VIR_FREE(names[i]); + + virReportOOMError(); + goto cleanup; + } + } + + rv = ret.names.names_len; + +cleanup: + xdr_free((xdrproc_t)xdr_remote_list_defined_interfaces_ret, (char *)&ret); + +done: + remoteDriverUnlock(priv); + return rv; +} + +static int +remoteListDefinedNetworks(virConnectPtr conn, char **const names, int maxnames) +{ + int rv = -1; + struct private_data *priv = conn->networkPrivateData; + remote_list_defined_networks_args args; + remote_list_defined_networks_ret ret; + int i; + + remoteDriverLock(priv); + + if (maxnames > REMOTE_NETWORK_NAME_LIST_MAX) { + remoteError(VIR_ERR_RPC, + _("too many remote undefined names: %d > %d"), + maxnames, REMOTE_NETWORK_NAME_LIST_MAX); + goto done; + } + + args.maxnames = maxnames; + + memset(&ret, 0, sizeof ret); + + if (call(conn, priv, 0, REMOTE_PROC_LIST_DEFINED_NETWORKS, + (xdrproc_t)xdr_remote_list_defined_networks_args, (char *)&args, + (xdrproc_t)xdr_remote_list_defined_networks_ret, (char *)&ret) == -1) + goto done; + + if (ret.names.names_len > maxnames) { + remoteError(VIR_ERR_RPC, + _("too many remote undefineds: %d > %d"), + ret.names.names_len, maxnames); + goto cleanup; + } + + /* This call is caller-frees (although that isn't clear from + * the documentation). However xdr_free will free up both the + * names and the list of pointers, so we have to strdup the + * names here. */ + for (i = 0; i < ret.names.names_len; ++i) { + names[i] = strdup(ret.names.names_val[i]); + + if (names[i] == NULL) { + for (--i; i >= 0; --i) + VIR_FREE(names[i]); + + virReportOOMError(); + goto cleanup; + } + } + + rv = ret.names.names_len; + +cleanup: + xdr_free((xdrproc_t)xdr_remote_list_defined_networks_ret, (char *)&ret); + +done: + remoteDriverUnlock(priv); + return rv; +} + +static int +remoteListDefinedStoragePools(virConnectPtr conn, char **const names, int maxnames) +{ + int rv = -1; + struct private_data *priv = conn->storagePrivateData; + remote_list_defined_storage_pools_args args; + remote_list_defined_storage_pools_ret ret; + int i; + + remoteDriverLock(priv); + + if (maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX) { + remoteError(VIR_ERR_RPC, + _("too many remote undefined names: %d > %d"), + maxnames, REMOTE_STORAGE_POOL_NAME_LIST_MAX); + goto done; + } + + args.maxnames = maxnames; + + memset(&ret, 0, sizeof ret); + + if (call(conn, priv, 0, REMOTE_PROC_LIST_DEFINED_STORAGE_POOLS, + (xdrproc_t)xdr_remote_list_defined_storage_pools_args, (char *)&args, + (xdrproc_t)xdr_remote_list_defined_storage_pools_ret, (char *)&ret) == -1) + goto done; + + if (ret.names.names_len > maxnames) { + remoteError(VIR_ERR_RPC, + _("too many remote undefineds: %d > %d"), + ret.names.names_len, maxnames); + goto cleanup; + } + + /* This call is caller-frees (although that isn't clear from + * the documentation). However xdr_free will free up both the + * names and the list of pointers, so we have to strdup the + * names here. */ + for (i = 0; i < ret.names.names_len; ++i) { + names[i] = strdup(ret.names.names_val[i]); + + if (names[i] == NULL) { + for (--i; i >= 0; --i) + VIR_FREE(names[i]); + + virReportOOMError(); + goto cleanup; + } + } + + rv = ret.names.names_len; + +cleanup: + xdr_free((xdrproc_t)xdr_remote_list_defined_storage_pools_ret, (char *)&ret); + +done: + remoteDriverUnlock(priv); + return rv; +} /* remoteDispatchListDomains has to be implemented manually */ -/* remoteDispatchListInterfaces has to be implemented manually */ +static int +remoteListInterfaces(virConnectPtr conn, char **const names, int maxnames) +{ + int rv = -1; + struct private_data *priv = conn->interfacePrivateData; + remote_list_interfaces_args args; + remote_list_interfaces_ret ret; + int i; + + remoteDriverLock(priv); + + if (maxnames > REMOTE_INTERFACE_NAME_LIST_MAX) { + remoteError(VIR_ERR_RPC, + _("too many remote undefined names: %d > %d"), + maxnames, REMOTE_INTERFACE_NAME_LIST_MAX); + goto done; + } + + args.maxnames = maxnames; + + memset(&ret, 0, sizeof ret); + + if (call(conn, priv, 0, REMOTE_PROC_LIST_INTERFACES, + (xdrproc_t)xdr_remote_list_interfaces_args, (char *)&args, + (xdrproc_t)xdr_remote_list_interfaces_ret, (char *)&ret) == -1) + goto done; + + if (ret.names.names_len > maxnames) { + remoteError(VIR_ERR_RPC, + _("too many remote undefineds: %d > %d"), + ret.names.names_len, maxnames); + goto cleanup; + } + + /* This call is caller-frees (although that isn't clear from + * the documentation). However xdr_free will free up both the + * names and the list of pointers, so we have to strdup the + * names here. */ + for (i = 0; i < ret.names.names_len; ++i) { + names[i] = strdup(ret.names.names_val[i]); + + if (names[i] == NULL) { + for (--i; i >= 0; --i) + VIR_FREE(names[i]); + + virReportOOMError(); + goto cleanup; + } + } + + rv = ret.names.names_len; + +cleanup: + xdr_free((xdrproc_t)xdr_remote_list_interfaces_ret, (char *)&ret); + +done: + remoteDriverUnlock(priv); + return rv; +} + +static int +remoteListNetworks(virConnectPtr conn, char **const names, int maxnames) +{ + int rv = -1; + struct private_data *priv = conn->networkPrivateData; + remote_list_networks_args args; + remote_list_networks_ret ret; + int i; + + remoteDriverLock(priv); + + if (maxnames > REMOTE_NETWORK_NAME_LIST_MAX) { + remoteError(VIR_ERR_RPC, + _("too many remote undefined names: %d > %d"), + maxnames, REMOTE_NETWORK_NAME_LIST_MAX); + goto done; + } + + args.maxnames = maxnames; + + memset(&ret, 0, sizeof ret); + + if (call(conn, priv, 0, REMOTE_PROC_LIST_NETWORKS, + (xdrproc_t)xdr_remote_list_networks_args, (char *)&args, + (xdrproc_t)xdr_remote_list_networks_ret, (char *)&ret) == -1) + goto done; + + if (ret.names.names_len > maxnames) { + remoteError(VIR_ERR_RPC, + _("too many remote undefineds: %d > %d"), + ret.names.names_len, maxnames); + goto cleanup; + } + + /* This call is caller-frees (although that isn't clear from + * the documentation). However xdr_free will free up both the + * names and the list of pointers, so we have to strdup the + * names here. */ + for (i = 0; i < ret.names.names_len; ++i) { + names[i] = strdup(ret.names.names_val[i]); + + if (names[i] == NULL) { + for (--i; i >= 0; --i) + VIR_FREE(names[i]); + + virReportOOMError(); + goto cleanup; + } + } + + rv = ret.names.names_len; + +cleanup: + xdr_free((xdrproc_t)xdr_remote_list_networks_ret, (char *)&ret); + +done: + remoteDriverUnlock(priv); + return rv; +} + +static int +remoteListNWFilters(virConnectPtr conn, char **const names, int maxnames) +{ + int rv = -1; + struct private_data *priv = conn->nwfilterPrivateData; + remote_list_nwfilters_args args; + remote_list_nwfilters_ret ret; + int i; + + remoteDriverLock(priv); + + if (maxnames > REMOTE_NWFILTER_NAME_LIST_MAX) { + remoteError(VIR_ERR_RPC, + _("too many remote undefined names: %d > %d"), + maxnames, REMOTE_NWFILTER_NAME_LIST_MAX); + goto done; + } + + args.maxnames = maxnames; + + memset(&ret, 0, sizeof ret); + + if (call(conn, priv, 0, REMOTE_PROC_LIST_NWFILTERS, + (xdrproc_t)xdr_remote_list_nwfilters_args, (char *)&args, + (xdrproc_t)xdr_remote_list_nwfilters_ret, (char *)&ret) == -1) + goto done; + + if (ret.names.names_len > maxnames) { + remoteError(VIR_ERR_RPC, + _("too many remote undefineds: %d > %d"), + ret.names.names_len, maxnames); + goto cleanup; + } + + /* This call is caller-frees (although that isn't clear from + * the documentation). However xdr_free will free up both the + * names and the list of pointers, so we have to strdup the + * names here. */ + for (i = 0; i < ret.names.names_len; ++i) { + names[i] = strdup(ret.names.names_val[i]); + + if (names[i] == NULL) { + for (--i; i >= 0; --i) + VIR_FREE(names[i]); + + virReportOOMError(); + goto cleanup; + } + } + + rv = ret.names.names_len; + +cleanup: + xdr_free((xdrproc_t)xdr_remote_list_nwfilters_ret, (char *)&ret); + +done: + remoteDriverUnlock(priv); + return rv; +} + +static int +remoteListSecrets(virConnectPtr conn, char **const uuids, int maxuuids) +{ + int rv = -1; + struct private_data *priv = conn->secretPrivateData; + remote_list_secrets_args args; + remote_list_secrets_ret ret; + int i; + + remoteDriverLock(priv); + + if (maxuuids > REMOTE_SECRET_UUID_LIST_MAX) { + remoteError(VIR_ERR_RPC, + _("too many remote undefined uuids: %d > %d"), + maxuuids, REMOTE_SECRET_UUID_LIST_MAX); + goto done; + } + + args.maxuuids = maxuuids; + + memset(&ret, 0, sizeof ret); + + if (call(conn, priv, 0, REMOTE_PROC_LIST_SECRETS, + (xdrproc_t)xdr_remote_list_secrets_args, (char *)&args, + (xdrproc_t)xdr_remote_list_secrets_ret, (char *)&ret) == -1) + goto done; + + if (ret.uuids.uuids_len > maxuuids) { + remoteError(VIR_ERR_RPC, + _("too many remote undefineds: %d > %d"), + ret.uuids.uuids_len, maxuuids); + goto cleanup; + } + + /* This call is caller-frees (although that isn't clear from + * the documentation). However xdr_free will free up both the + * names and the list of pointers, so we have to strdup the + * names here. */ + for (i = 0; i < ret.uuids.uuids_len; ++i) { + uuids[i] = strdup(ret.uuids.uuids_val[i]); -/* remoteDispatchListNetworks has to be implemented manually */ + if (uuids[i] == NULL) { + for (--i; i >= 0; --i) + VIR_FREE(uuids[i]); -/* remoteDispatchListNWFilters has to be implemented manually */ + virReportOOMError(); + goto cleanup; + } + } -/* remoteDispatchListSecrets has to be implemented manually */ + rv = ret.uuids.uuids_len; -/* remoteDispatchListStoragePools has to be implemented manually */ +cleanup: + xdr_free((xdrproc_t)xdr_remote_list_secrets_ret, (char *)&ret); + +done: + remoteDriverUnlock(priv); + return rv; +} + +static int +remoteListStoragePools(virConnectPtr conn, char **const names, int maxnames) +{ + int rv = -1; + struct private_data *priv = conn->storagePrivateData; + remote_list_storage_pools_args args; + remote_list_storage_pools_ret ret; + int i; + + remoteDriverLock(priv); + + if (maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX) { + remoteError(VIR_ERR_RPC, + _("too many remote undefined names: %d > %d"), + maxnames, REMOTE_STORAGE_POOL_NAME_LIST_MAX); + goto done; + } + + args.maxnames = maxnames; + + memset(&ret, 0, sizeof ret); + + if (call(conn, priv, 0, REMOTE_PROC_LIST_STORAGE_POOLS, + (xdrproc_t)xdr_remote_list_storage_pools_args, (char *)&args, + (xdrproc_t)xdr_remote_list_storage_pools_ret, (char *)&ret) == -1) + goto done; + + if (ret.names.names_len > maxnames) { + remoteError(VIR_ERR_RPC, + _("too many remote undefineds: %d > %d"), + ret.names.names_len, maxnames); + goto cleanup; + } + + /* This call is caller-frees (although that isn't clear from + * the documentation). However xdr_free will free up both the + * names and the list of pointers, so we have to strdup the + * names here. */ + for (i = 0; i < ret.names.names_len; ++i) { + names[i] = strdup(ret.names.names_val[i]); + + if (names[i] == NULL) { + for (--i; i >= 0; --i) + VIR_FREE(names[i]); + + virReportOOMError(); + goto cleanup; + } + } + + rv = ret.names.names_len; + +cleanup: + xdr_free((xdrproc_t)xdr_remote_list_storage_pools_ret, (char *)&ret); + +done: + remoteDriverUnlock(priv); + return rv; +} static int remoteNetworkCreate(virNetworkPtr net) @@ -2310,7 +2892,66 @@ done: /* remoteDispatchNodeDeviceGetParent has to be implemented manually */ -/* remoteDispatchNodeDeviceListCaps has to be implemented manually */ +static int +remoteNodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames) +{ + int rv = -1; + struct private_data *priv = dev->conn->devMonPrivateData; + remote_node_device_list_caps_args args; + remote_node_device_list_caps_ret ret; + int i; + + remoteDriverLock(priv); + + if (maxnames > REMOTE_NODE_DEVICE_CAPS_LIST_MAX) { + remoteError(VIR_ERR_RPC, + _("too many remote undefined names: %d > %d"), + maxnames, REMOTE_NODE_DEVICE_CAPS_LIST_MAX); + goto done; + } + + args.name = dev->name; + args.maxnames = maxnames; + + memset(&ret, 0, sizeof ret); + + if (call(dev->conn, priv, 0, REMOTE_PROC_NODE_DEVICE_LIST_CAPS, + (xdrproc_t)xdr_remote_node_device_list_caps_args, (char *)&args, + (xdrproc_t)xdr_remote_node_device_list_caps_ret, (char *)&ret) == -1) + goto done; + + if (ret.names.names_len > maxnames) { + remoteError(VIR_ERR_RPC, + _("too many remote undefineds: %d > %d"), + ret.names.names_len, maxnames); + goto cleanup; + } + + /* This call is caller-frees (although that isn't clear from + * the documentation). However xdr_free will free up both the + * names and the list of pointers, so we have to strdup the + * names here. */ + for (i = 0; i < ret.names.names_len; ++i) { + names[i] = strdup(ret.names.names_val[i]); + + if (names[i] == NULL) { + for (--i; i >= 0; --i) + VIR_FREE(names[i]); + + virReportOOMError(); + goto cleanup; + } + } + + rv = ret.names.names_len; + +cleanup: + xdr_free((xdrproc_t)xdr_remote_node_device_list_caps_ret, (char *)&ret); + +done: + remoteDriverUnlock(priv); + return rv; +} static virNodeDevicePtr remoteNodeDeviceLookupByName(virConnectPtr conn, const char *name) @@ -2427,7 +3068,67 @@ done: /* remoteDispatchNodeGetSecurityModel has to be implemented manually */ -/* remoteDispatchNodeListDevices has to be implemented manually */ +static int +remoteNodeListDevices(virConnectPtr conn, const char *cap, char **const names, int maxnames, unsigned int flags) +{ + int rv = -1; + struct private_data *priv = conn->devMonPrivateData; + remote_node_list_devices_args args; + remote_node_list_devices_ret ret; + int i; + + remoteDriverLock(priv); + + if (maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) { + remoteError(VIR_ERR_RPC, + _("too many remote undefined names: %d > %d"), + maxnames, REMOTE_NODE_DEVICE_NAME_LIST_MAX); + goto done; + } + + args.cap = cap ? (char **)&cap : NULL; + args.maxnames = maxnames; + args.flags = flags; + + memset(&ret, 0, sizeof ret); + + if (call(conn, priv, 0, REMOTE_PROC_NODE_LIST_DEVICES, + (xdrproc_t)xdr_remote_node_list_devices_args, (char *)&args, + (xdrproc_t)xdr_remote_node_list_devices_ret, (char *)&ret) == -1) + goto done; + + if (ret.names.names_len > maxnames) { + remoteError(VIR_ERR_RPC, + _("too many remote undefineds: %d > %d"), + ret.names.names_len, maxnames); + goto cleanup; + } + + /* This call is caller-frees (although that isn't clear from + * the documentation). However xdr_free will free up both the + * names and the list of pointers, so we have to strdup the + * names here. */ + for (i = 0; i < ret.names.names_len; ++i) { + names[i] = strdup(ret.names.names_val[i]); + + if (names[i] == NULL) { + for (--i; i >= 0; --i) + VIR_FREE(names[i]); + + virReportOOMError(); + goto cleanup; + } + } + + rv = ret.names.names_len; + +cleanup: + xdr_free((xdrproc_t)xdr_remote_node_list_devices_ret, (char *)&ret); + +done: + remoteDriverUnlock(priv); + return rv; +} static int remoteNodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int flags) @@ -3218,7 +3919,66 @@ done: return rv; } -/* remoteDispatchStoragePoolListVolumes has to be implemented manually */ +static int +remoteStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, int maxnames) +{ + int rv = -1; + struct private_data *priv = pool->conn->storagePrivateData; + remote_storage_pool_list_volumes_args args; + remote_storage_pool_list_volumes_ret ret; + int i; + + remoteDriverLock(priv); + + if (maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX) { + remoteError(VIR_ERR_RPC, + _("too many remote undefined names: %d > %d"), + maxnames, REMOTE_STORAGE_VOL_NAME_LIST_MAX); + goto done; + } + + make_nonnull_storage_pool(&args.pool, pool); + args.maxnames = maxnames; + + memset(&ret, 0, sizeof ret); + + if (call(pool->conn, priv, 0, REMOTE_PROC_STORAGE_POOL_LIST_VOLUMES, + (xdrproc_t)xdr_remote_storage_pool_list_volumes_args, (char *)&args, + (xdrproc_t)xdr_remote_storage_pool_list_volumes_ret, (char *)&ret) == -1) + goto done; + + if (ret.names.names_len > maxnames) { + remoteError(VIR_ERR_RPC, + _("too many remote undefineds: %d > %d"), + ret.names.names_len, maxnames); + goto cleanup; + } + + /* This call is caller-frees (although that isn't clear from + * the documentation). However xdr_free will free up both the + * names and the list of pointers, so we have to strdup the + * names here. */ + for (i = 0; i < ret.names.names_len; ++i) { + names[i] = strdup(ret.names.names_val[i]); + + if (names[i] == NULL) { + for (--i; i >= 0; --i) + VIR_FREE(names[i]); + + virReportOOMError(); + goto cleanup; + } + } + + rv = ret.names.names_len; + +cleanup: + xdr_free((xdrproc_t)xdr_remote_storage_pool_list_volumes_ret, (char *)&ret); + +done: + remoteDriverUnlock(priv); + return rv; +} static virStoragePoolPtr remoteStoragePoolLookupByName(virConnectPtr conn, const char *name) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 777a7bf..8a0fc0e 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -2607,65 +2607,6 @@ done: } static int -remoteListDefinedDomains (virConnectPtr conn, char **const names, int maxnames) -{ - int rv = -1; - int i; - remote_list_defined_domains_args args; - remote_list_defined_domains_ret ret; - struct private_data *priv = conn->privateData; - - remoteDriverLock(priv); - - if (maxnames > REMOTE_DOMAIN_NAME_LIST_MAX) { - remoteError(VIR_ERR_RPC, - _("too many remote domain names: %d > %d"), - maxnames, REMOTE_DOMAIN_NAME_LIST_MAX); - goto done; - } - args.maxnames = maxnames; - - memset (&ret, 0, sizeof ret); - if (call (conn, priv, 0, REMOTE_PROC_LIST_DEFINED_DOMAINS, - (xdrproc_t) xdr_remote_list_defined_domains_args, (char *) &args, - (xdrproc_t) xdr_remote_list_defined_domains_ret, (char *) &ret) == -1) - goto done; - - if (ret.names.names_len > maxnames) { - remoteError(VIR_ERR_RPC, - _("too many remote domain names: %d > %d"), - ret.names.names_len, maxnames); - goto cleanup; - } - - /* This call is caller-frees (although that isn't clear from - * the documentation). However xdr_free will free up both the - * names and the list of pointers, so we have to strdup the - * names here. - */ - for (i = 0; i < ret.names.names_len; ++i) { - names[i] = strdup (ret.names.names_val[i]); - - if (names[i] == NULL) { - for (--i; i >= 0; --i) - VIR_FREE(names[i]); - - virReportOOMError(); - goto cleanup; - } - } - - rv = ret.names.names_len; - -cleanup: - xdr_free ((xdrproc_t) xdr_remote_list_defined_domains_ret, (char *) &ret); - -done: - remoteDriverUnlock(priv); - return rv; -} - -static int remoteDomainCreate (virDomainPtr domain) { int rv = -1; @@ -3122,125 +3063,6 @@ remoteNetworkClose(virConnectPtr conn) return remoteGenericClose(conn, &conn->networkPrivateData); } -static int -remoteListNetworks (virConnectPtr conn, char **const names, int maxnames) -{ - int rv = -1; - int i; - remote_list_networks_args args; - remote_list_networks_ret ret; - struct private_data *priv = conn->networkPrivateData; - - remoteDriverLock(priv); - - if (maxnames > REMOTE_NETWORK_NAME_LIST_MAX) { - remoteError(VIR_ERR_RPC, - _("too many remote networks: %d > %d"), - maxnames, REMOTE_NETWORK_NAME_LIST_MAX); - goto done; - } - args.maxnames = maxnames; - - memset (&ret, 0, sizeof ret); - if (call (conn, priv, 0, REMOTE_PROC_LIST_NETWORKS, - (xdrproc_t) xdr_remote_list_networks_args, (char *) &args, - (xdrproc_t) xdr_remote_list_networks_ret, (char *) &ret) == -1) - goto done; - - if (ret.names.names_len > maxnames) { - remoteError(VIR_ERR_RPC, - _("too many remote networks: %d > %d"), - ret.names.names_len, maxnames); - goto cleanup; - } - - /* This call is caller-frees (although that isn't clear from - * the documentation). However xdr_free will free up both the - * names and the list of pointers, so we have to strdup the - * names here. - */ - for (i = 0; i < ret.names.names_len; ++i) { - names[i] = strdup (ret.names.names_val[i]); - - if (names[i] == NULL) { - for (--i; i >= 0; --i) - VIR_FREE(names[i]); - - virReportOOMError(); - goto cleanup; - } - } - - rv = ret.names.names_len; - -cleanup: - xdr_free ((xdrproc_t) xdr_remote_list_networks_ret, (char *) &ret); - -done: - remoteDriverUnlock(priv); - return rv; -} - -static int -remoteListDefinedNetworks (virConnectPtr conn, - char **const names, int maxnames) -{ - int rv = -1; - int i; - remote_list_defined_networks_args args; - remote_list_defined_networks_ret ret; - struct private_data *priv = conn->networkPrivateData; - - remoteDriverLock(priv); - - if (maxnames > REMOTE_NETWORK_NAME_LIST_MAX) { - remoteError(VIR_ERR_RPC, - _("too many remote networks: %d > %d"), - maxnames, REMOTE_NETWORK_NAME_LIST_MAX); - goto done; - } - args.maxnames = maxnames; - - memset (&ret, 0, sizeof ret); - if (call (conn, priv, 0, REMOTE_PROC_LIST_DEFINED_NETWORKS, - (xdrproc_t) xdr_remote_list_defined_networks_args, (char *) &args, - (xdrproc_t) xdr_remote_list_defined_networks_ret, (char *) &ret) == -1) - goto done; - - if (ret.names.names_len > maxnames) { - remoteError(VIR_ERR_RPC, - _("too many remote networks: %d > %d"), - ret.names.names_len, maxnames); - goto cleanup; - } - - /* This call is caller-frees (although that isn't clear from - * the documentation). However xdr_free will free up both the - * names and the list of pointers, so we have to strdup the - * names here. - */ - for (i = 0; i < ret.names.names_len; ++i) { - names[i] = strdup (ret.names.names_val[i]); - - if (names[i] == NULL) { - for (--i; i >= 0; --i) - VIR_FREE(names[i]); - - virReportOOMError(); - goto cleanup; - } - } - - rv = ret.names.names_len; - -cleanup: - xdr_free ((xdrproc_t) xdr_remote_list_defined_networks_ret, (char *) &ret); - -done: - remoteDriverUnlock(priv); - return rv; -} - /*----------------------------------------------------------------------*/ static virDrvOpenStatus ATTRIBUTE_NONNULL (1) @@ -3255,124 +3077,6 @@ remoteInterfaceClose(virConnectPtr conn) return remoteGenericClose(conn, &conn->interfacePrivateData); } -static int -remoteListInterfaces (virConnectPtr conn, char **const names, int maxnames) -{ - int rv = -1; - int i; - remote_list_interfaces_args args; - remote_list_interfaces_ret ret; - struct private_data *priv = conn->interfacePrivateData; - - remoteDriverLock(priv); - - if (maxnames > REMOTE_INTERFACE_NAME_LIST_MAX) { - remoteError(VIR_ERR_RPC, - _("too many remote interfaces: %d > %d"), - maxnames, REMOTE_INTERFACE_NAME_LIST_MAX); - goto done; - } - args.maxnames = maxnames; - - memset (&ret, 0, sizeof ret); - if (call (conn, priv, 0, REMOTE_PROC_LIST_INTERFACES, - (xdrproc_t) xdr_remote_list_interfaces_args, (char *) &args, - (xdrproc_t) xdr_remote_list_interfaces_ret, (char *) &ret) == -1) - goto done; - - if (ret.names.names_len > maxnames) { - remoteError(VIR_ERR_RPC, - _("too many remote interfaces: %d > %d"), - ret.names.names_len, maxnames); - goto cleanup; - } - - /* This call is caller-frees (although that isn't clear from - * the documentation). However xdr_free will free up both the - * names and the list of pointers, so we have to strdup the - * names here. - */ - for (i = 0; i < ret.names.names_len; ++i) { - names[i] = strdup (ret.names.names_val[i]); - - if (names[i] == NULL) { - for (--i; i >= 0; --i) - VIR_FREE(names[i]); - - virReportOOMError(); - goto cleanup; - } - } - - rv = ret.names.names_len; - -cleanup: - xdr_free ((xdrproc_t) xdr_remote_list_interfaces_ret, (char *) &ret); - -done: - remoteDriverUnlock(priv); - return rv; -} - -static int -remoteListDefinedInterfaces (virConnectPtr conn, char **const names, int maxnames) -{ - int rv = -1; - int i; - remote_list_defined_interfaces_args args; - remote_list_defined_interfaces_ret ret; - struct private_data *priv = conn->interfacePrivateData; - - remoteDriverLock(priv); - - if (maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX) { - remoteError(VIR_ERR_RPC, - _("too many remote interfaces: %d > %d"), - maxnames, REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX); - goto done; - } - args.maxnames = maxnames; - - memset (&ret, 0, sizeof ret); - if (call (conn, priv, 0, REMOTE_PROC_LIST_DEFINED_INTERFACES, - (xdrproc_t) xdr_remote_list_defined_interfaces_args, (char *) &args, - (xdrproc_t) xdr_remote_list_defined_interfaces_ret, (char *) &ret) == -1) - goto done; - - if (ret.names.names_len > maxnames) { - remoteError(VIR_ERR_RPC, - _("too many remote interfaces: %d > %d"), - ret.names.names_len, maxnames); - goto cleanup; - } - - /* This call is caller-frees (although that isn't clear from - * the documentation). However xdr_free will free up both the - * names and the list of pointers, so we have to strdup the - * names here. - */ - for (i = 0; i < ret.names.names_len; ++i) { - names[i] = strdup (ret.names.names_val[i]); - - if (names[i] == NULL) { - for (--i; i >= 0; --i) - VIR_FREE(names[i]); - - virReportOOMError(); - goto cleanup; - } - } - - rv = ret.names.names_len; - -cleanup: - xdr_free ((xdrproc_t) xdr_remote_list_defined_interfaces_ret, (char *) &ret); - -done: - remoteDriverUnlock(priv); - return rv; -} - /*----------------------------------------------------------------------*/ static virDrvOpenStatus ATTRIBUTE_NONNULL (1) @@ -3387,117 +3091,6 @@ remoteStorageClose(virConnectPtr conn) return remoteGenericClose(conn, &conn->storagePrivateData); } -static int -remoteListStoragePools (virConnectPtr conn, char **const names, int maxnames) -{ - int rv = -1; - int i; - remote_list_storage_pools_args args; - remote_list_storage_pools_ret ret; - struct private_data *priv = conn->storagePrivateData; - - remoteDriverLock(priv); - - if (maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX) { - remoteError(VIR_ERR_RPC, "%s", _("too many storage pools requested")); - goto done; - } - args.maxnames = maxnames; - - memset (&ret, 0, sizeof ret); - if (call (conn, priv, 0, REMOTE_PROC_LIST_STORAGE_POOLS, - (xdrproc_t) xdr_remote_list_storage_pools_args, (char *) &args, - (xdrproc_t) xdr_remote_list_storage_pools_ret, (char *) &ret) == -1) - goto done; - - if (ret.names.names_len > maxnames) { - remoteError(VIR_ERR_RPC, "%s", _("too many storage pools received")); - goto cleanup; - } - - /* This call is caller-frees (although that isn't clear from - * the documentation). However xdr_free will free up both the - * names and the list of pointers, so we have to strdup the - * names here. - */ - for (i = 0; i < ret.names.names_len; ++i) { - names[i] = strdup (ret.names.names_val[i]); - - if (names[i] == NULL) { - for (--i; i >= 0; --i) - VIR_FREE(names[i]); - - virReportOOMError(); - goto cleanup; - } - } - - rv = ret.names.names_len; - -cleanup: - xdr_free ((xdrproc_t) xdr_remote_list_storage_pools_ret, (char *) &ret); - -done: - remoteDriverUnlock(priv); - return rv; -} - -static int -remoteListDefinedStoragePools (virConnectPtr conn, - char **const names, int maxnames) -{ - int rv = -1; - int i; - remote_list_defined_storage_pools_args args; - remote_list_defined_storage_pools_ret ret; - struct private_data *priv = conn->storagePrivateData; - - remoteDriverLock(priv); - - if (maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX) { - remoteError(VIR_ERR_RPC, "%s", _("too many storage pools requested")); - goto done; - } - args.maxnames = maxnames; - - memset (&ret, 0, sizeof ret); - if (call (conn, priv, 0, REMOTE_PROC_LIST_DEFINED_STORAGE_POOLS, - (xdrproc_t) xdr_remote_list_defined_storage_pools_args, (char *) &args, - (xdrproc_t) xdr_remote_list_defined_storage_pools_ret, (char *) &ret) == -1) - goto done; - - if (ret.names.names_len > maxnames) { - remoteError(VIR_ERR_RPC, "%s", _("too many storage pools received")); - goto cleanup; - } - - /* This call is caller-frees (although that isn't clear from - * the documentation). However xdr_free will free up both the - * names and the list of pointers, so we have to strdup the - * names here. - */ - for (i = 0; i < ret.names.names_len; ++i) { - names[i] = strdup (ret.names.names_val[i]); - - if (names[i] == NULL) { - for (--i; i >= 0; --i) - VIR_FREE(names[i]); - - virReportOOMError(); - goto cleanup; - } - } - - rv = ret.names.names_len; - -cleanup: - xdr_free ((xdrproc_t) xdr_remote_list_defined_storage_pools_ret, (char *) &ret); - -done: - remoteDriverUnlock(priv); - return rv; -} - static char * remoteFindStoragePoolSources (virConnectPtr conn, const char *type, @@ -3543,62 +3136,6 @@ done: return rv; } -static int -remoteStoragePoolListVolumes (virStoragePoolPtr pool, char **const names, int maxnames) -{ - int rv = -1; - int i; - remote_storage_pool_list_volumes_args args; - remote_storage_pool_list_volumes_ret ret; - struct private_data *priv = pool->conn->storagePrivateData; - - remoteDriverLock(priv); - - if (maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX) { - remoteError(VIR_ERR_RPC, "%s", _("too many storage volumes requested")); - goto done; - } - args.maxnames = maxnames; - make_nonnull_storage_pool(&args.pool, pool); - - memset (&ret, 0, sizeof ret); - if (call (pool->conn, priv, 0, REMOTE_PROC_STORAGE_POOL_LIST_VOLUMES, - (xdrproc_t) xdr_remote_storage_pool_list_volumes_args, (char *) &args, - (xdrproc_t) xdr_remote_storage_pool_list_volumes_ret, (char *) &ret) == -1) - goto done; - - if (ret.names.names_len > maxnames) { - remoteError(VIR_ERR_RPC, "%s", _("too many storage volumes received")); - goto cleanup; - } - - /* This call is caller-frees (although that isn't clear from - * the documentation). However xdr_free will free up both the - * names and the list of pointers, so we have to strdup the - * names here. - */ - for (i = 0; i < ret.names.names_len; ++i) { - names[i] = strdup (ret.names.names_val[i]); - - if (names[i] == NULL) { - for (--i; i >= 0; --i) - VIR_FREE(names[i]); - - virReportOOMError(); - goto cleanup; - } - } - - rv = ret.names.names_len; - -cleanup: - xdr_free ((xdrproc_t) xdr_remote_storage_pool_list_volumes_ret, (char *) &ret); - -done: - remoteDriverUnlock(priv); - return rv; -} - /*----------------------------------------------------------------------*/ static virDrvOpenStatus ATTRIBUTE_NONNULL (1) @@ -3613,66 +3150,6 @@ remoteDevMonClose(virConnectPtr conn) return remoteGenericClose(conn, &conn->devMonPrivateData); } -static int remoteNodeListDevices(virConnectPtr conn, - const char *cap, - char **const names, - int maxnames, - unsigned int flags) -{ - int rv = -1; - int i; - remote_node_list_devices_args args; - remote_node_list_devices_ret ret; - struct private_data *priv = conn->devMonPrivateData; - - remoteDriverLock(priv); - - if (maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) { - remoteError(VIR_ERR_RPC, "%s", _("too many device names requested")); - goto done; - } - args.cap = cap ? (char **)&cap : NULL; - args.maxnames = maxnames; - args.flags = flags; - - memset (&ret, 0, sizeof ret); - if (call (conn, priv, 0, REMOTE_PROC_NODE_LIST_DEVICES, - (xdrproc_t) xdr_remote_node_list_devices_args, (char *) &args, - (xdrproc_t) xdr_remote_node_list_devices_ret, (char *) &ret) == -1) - goto done; - - if (ret.names.names_len > maxnames) { - remoteError(VIR_ERR_RPC, "%s", _("too many device names received")); - goto cleanup; - } - - /* This call is caller-frees (although that isn't clear from - * the documentation). However xdr_free will free up both the - * names and the list of pointers, so we have to strdup the - * names here. - */ - for (i = 0; i < ret.names.names_len; ++i) { - names[i] = strdup (ret.names.names_val[i]); - - if (names[i] == NULL) { - for (--i; i >= 0; --i) - VIR_FREE(names[i]); - - virReportOOMError(); - goto cleanup; - } - } - - rv = ret.names.names_len; - -cleanup: - xdr_free ((xdrproc_t) xdr_remote_node_list_devices_ret, (char *) &ret); - -done: - remoteDriverUnlock(priv); - return rv; -} - static char *remoteNodeDeviceGetParent(virNodeDevicePtr dev) { char *rv = NULL; @@ -3699,63 +3176,6 @@ done: return rv; } -static int remoteNodeDeviceListCaps(virNodeDevicePtr dev, - char **const names, - int maxnames) -{ - int rv = -1; - int i; - remote_node_device_list_caps_args args; - remote_node_device_list_caps_ret ret; - struct private_data *priv = dev->conn->devMonPrivateData; - - remoteDriverLock(priv); - - if (maxnames > REMOTE_NODE_DEVICE_CAPS_LIST_MAX) { - remoteError(VIR_ERR_RPC, "%s", _("too many capability names requested")); - goto done; - } - args.maxnames = maxnames; - args.name = dev->name; - - memset (&ret, 0, sizeof ret); - if (call (dev->conn, priv, 0, REMOTE_PROC_NODE_DEVICE_LIST_CAPS, - (xdrproc_t) xdr_remote_node_device_list_caps_args, (char *) &args, - (xdrproc_t) xdr_remote_node_device_list_caps_ret, (char *) &ret) == -1) - goto done; - - if (ret.names.names_len > maxnames) { - remoteError(VIR_ERR_RPC, "%s", _("too many capability names received")); - goto cleanup; - } - - /* This call is caller-frees (although that isn't clear from - * the documentation). However xdr_free will free up both the - * names and the list of pointers, so we have to strdup the - * names here. - */ - for (i = 0; i < ret.names.names_len; ++i) { - names[i] = strdup (ret.names.names_val[i]); - - if (names[i] == NULL) { - for (--i; i >= 0; --i) - VIR_FREE(names[i]); - - virReportOOMError(); - goto cleanup; - } - } - - rv = ret.names.names_len; - -cleanup: - xdr_free ((xdrproc_t) xdr_remote_node_device_list_caps_ret, (char *) &ret); - -done: - remoteDriverUnlock(priv); - return rv; -} - static int remoteNodeDeviceDettach (virNodeDevicePtr dev) { @@ -3872,65 +3292,6 @@ done: return net; } -static int -remoteListNWFilters (virConnectPtr conn, char **const names, int maxnames) -{ - int rv = -1; - int i; - remote_list_nwfilters_args args; - remote_list_nwfilters_ret ret; - struct private_data *priv = conn->nwfilterPrivateData; - - remoteDriverLock(priv); - - if (maxnames > REMOTE_NWFILTER_NAME_LIST_MAX) { - remoteError(VIR_ERR_RPC, - _("too many remote nwfilters: %d > %d"), - maxnames, REMOTE_NWFILTER_NAME_LIST_MAX); - goto done; - } - args.maxnames = maxnames; - - memset (&ret, 0, sizeof ret); - if (call (conn, priv, 0, REMOTE_PROC_LIST_NWFILTERS, - (xdrproc_t) xdr_remote_list_nwfilters_args, (char *) &args, - (xdrproc_t) xdr_remote_list_nwfilters_ret, (char *) &ret) == -1) - goto done; - - if (ret.names.names_len > maxnames) { - remoteError(VIR_ERR_RPC, - _("too many remote nwfilters: %d > %d"), - ret.names.names_len, maxnames); - goto cleanup; - } - - /* This call is caller-frees (although that isn't clear from - * the documentation). However xdr_free will free up both the - * names and the list of pointers, so we have to strdup the - * names here. - */ - for (i = 0; i < ret.names.names_len; ++i) { - names[i] = strdup (ret.names.names_val[i]); - - if (names[i] == NULL) { - for (--i; i >= 0; --i) - VIR_FREE(names[i]); - - virReportOOMError(); - goto cleanup; - } - } - - rv = ret.names.names_len; - -cleanup: - xdr_free ((xdrproc_t) xdr_remote_list_nwfilters_ret, (char *) &ret); - -done: - remoteDriverUnlock(priv); - return rv; -} - /*----------------------------------------------------------------------*/ static int @@ -4938,62 +4299,6 @@ remoteSecretClose (virConnectPtr conn) } static int -remoteListSecrets (virConnectPtr conn, char **uuids, int maxuuids) -{ - int rv = -1; - int i; - remote_list_secrets_args args; - remote_list_secrets_ret ret; - struct private_data *priv = conn->secretPrivateData; - - remoteDriverLock(priv); - - if (maxuuids > REMOTE_SECRET_UUID_LIST_MAX) { - remoteError(VIR_ERR_RPC, _("too many remote secret UUIDs: %d > %d"), - maxuuids, REMOTE_SECRET_UUID_LIST_MAX); - goto done; - } - args.maxuuids = maxuuids; - - memset (&ret, 0, sizeof ret); - if (call (conn, priv, 0, REMOTE_PROC_LIST_SECRETS, - (xdrproc_t) xdr_remote_list_secrets_args, (char *) &args, - (xdrproc_t) xdr_remote_list_secrets_ret, (char *) &ret) == -1) - goto done; - - if (ret.uuids.uuids_len > maxuuids) { - remoteError(VIR_ERR_RPC, _("too many remote secret UUIDs: %d > %d"), - ret.uuids.uuids_len, maxuuids); - goto cleanup; - } - - /* This call is caller-frees. However xdr_free will free up both the - * names and the list of pointers, so we have to strdup the - * names here. - */ - for (i = 0; i < ret.uuids.uuids_len; ++i) { - uuids[i] = strdup (ret.uuids.uuids_val[i]); - - if (uuids[i] == NULL) { - for (--i; i >= 0; --i) - VIR_FREE(uuids[i]); - - virReportOOMError(); - goto cleanup; - } - } - - rv = ret.uuids.uuids_len; - -cleanup: - xdr_free ((xdrproc_t) xdr_remote_list_secrets_ret, (char *) &ret); - -done: - remoteDriverUnlock(priv); - return rv; -} - -static int remoteSecretSetValue (virSecretPtr secret, const unsigned char *value, size_t value_size, unsigned int flags) { @@ -5626,69 +4931,6 @@ done: return cpu; } -static int -remoteDomainSnapshotListNames (virDomainPtr domain, char **const names, - int maxnames, unsigned int flags) -{ - int rv = -1; - int i; - remote_domain_snapshot_list_names_args args; - remote_domain_snapshot_list_names_ret ret; - struct private_data *priv = domain->conn->privateData; - - remoteDriverLock(priv); - - if (maxnames > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX) { - remoteError(VIR_ERR_RPC, - _("too many remote domain snapshot names: %d > %d"), - maxnames, REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX); - goto done; - } - - make_nonnull_domain(&args.dom, domain); - args.maxnames = maxnames; - args.flags = flags; - - memset (&ret, 0, sizeof ret); - if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_NAMES, - (xdrproc_t) xdr_remote_domain_snapshot_list_names_args, (char *) &args, - (xdrproc_t) xdr_remote_domain_snapshot_list_names_ret, (char *) &ret) == -1) - goto done; - - if (ret.names.names_len > maxnames) { - remoteError(VIR_ERR_RPC, - _("too many remote domain snapshots: %d > %d"), - ret.names.names_len, maxnames); - goto cleanup; - } - - /* This call is caller-frees (although that isn't clear from - * the documentation). However xdr_free will free up both the - * names and the list of pointers, so we have to strdup the - * names here. - */ - for (i = 0; i < ret.names.names_len; ++i) { - names[i] = strdup (ret.names.names_val[i]); - - if (names[i] == NULL) { - for (--i; i >= 0; --i) - VIR_FREE(names[i]); - - virReportOOMError(); - goto cleanup; - } - } - - rv = ret.names.names_len; - -cleanup: - xdr_free ((xdrproc_t) xdr_remote_domain_snapshot_list_names_ret, (char *) &ret); - -done: - remoteDriverUnlock(priv); - return rv; -} - static int remoteDomainEventRegisterAny(virConnectPtr conn, virDomainPtr dom, int eventID, -- 1.7.0.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list