From 56cd4140d4f9a265f2c47864d0c4d10e4a7a169f Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 25 Jun 2007 08:23:10 +0000 Subject: [PATCH] Mon Jun 25 09:19:00 BST 2007 Richard W.M. Jones * qemud/remote.c, src/remote_internal.c: Fix virDomainGetVcpus in the remote case. * src/libvirt.c: Allow virConnectListDomains, virConnectListDefinedDomains, virConnectListNetworks and virConnectListDefinedNetworks to work in the case where they are called with maxids/maxnames == 0. * src/remote_internal.c: Fix virDomainGetMaxVcpus in remote case so that it copies sufficient data. * src/xen_unified.c: Remove autostart functions. --- ChangeLog | 12 ++++++++++++ qemud/remote.c | 8 ++++---- src/libvirt.c | 8 ++++---- src/remote_internal.c | 13 ++++++++----- src/xen_unified.c | 30 ------------------------------ 5 files changed, 28 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5fd45c52fb..bf25aaec7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Mon Jun 25 09:19:00 BST 2007 Richard W.M. Jones + + * qemud/remote.c, src/remote_internal.c: Fix virDomainGetVcpus + in the remote case. + * src/libvirt.c: Allow virConnectListDomains, + virConnectListDefinedDomains, virConnectListNetworks and + virConnectListDefinedNetworks to work in the case where + they are called with maxids/maxnames == 0. + * src/remote_internal.c: Fix virDomainGetMaxVcpus in remote + case so that it copies sufficient data. + * src/xen_unified.c: Remove autostart functions. + Fri Jun 22 14:15:00 BST 2007 Richard W.M. Jones * qemud/remote.c, qemud/remote_protocol.x, src/remote_internal.c: diff --git a/qemud/remote.c b/qemud/remote.c index acd72a2b50..f204326bb9 100644 --- a/qemud/remote.c +++ b/qemud/remote.c @@ -956,14 +956,14 @@ remoteDispatchDomainGetVcpus (struct qemud_client *client, return -2; } - if (args->maplen > REMOTE_CPUMAPS_MAX) { - remoteDispatchError (client, req, "maplen > REMOTE_CPUMAPS_MAX"); + if (args->maxinfo * args->maplen > REMOTE_CPUMAPS_MAX) { + remoteDispatchError (client, req, "maxinfo * maplen > REMOTE_CPUMAPS_MAX"); return -2; } /* Allocate buffers to take the results. */ info = calloc (args->maxinfo, sizeof (virVcpuInfo)); - cpumaps = calloc (args->maplen, sizeof (unsigned char)); + cpumaps = calloc (args->maxinfo * args->maplen, sizeof (unsigned char)); info_len = virDomainGetVcpus (dom, info, args->maxinfo, @@ -985,7 +985,7 @@ remoteDispatchDomainGetVcpus (struct qemud_client *client, * assumption that unsigned char and char are the same size. * Note that remoteDispatchClientRequest will free. */ - ret->cpumaps.cpumaps_len = args->maplen; + ret->cpumaps.cpumaps_len = args->maxinfo * args->maplen; ret->cpumaps.cpumaps_val = (char *) cpumaps; return 0; diff --git a/src/libvirt.c b/src/libvirt.c index 2dde3913e1..4e1d885b3e 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -510,7 +510,7 @@ virConnectListDomains(virConnectPtr conn, int *ids, int maxids) return (-1); } - if ((ids == NULL) || (maxids <= 0)) { + if ((ids == NULL) || (maxids < 0)) { virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__); return (-1); } @@ -1682,7 +1682,7 @@ virConnectListDefinedDomains(virConnectPtr conn, char **const names, return (-1); } - if ((names == NULL) || (maxnames <= 0)) { + if ((names == NULL) || (maxnames < 0)) { virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__); return (-1); } @@ -2077,7 +2077,7 @@ virConnectListNetworks(virConnectPtr conn, char **const names, int maxnames) return (-1); } - if ((names == NULL) || (maxnames <= 0)) { + if ((names == NULL) || (maxnames < 0)) { virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__); return (-1); } @@ -2131,7 +2131,7 @@ virConnectListDefinedNetworks(virConnectPtr conn, char **const names, return (-1); } - if ((names == NULL) || (maxnames <= 0)) { + if ((names == NULL) || (maxnames < 0)) { virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__); return (-1); } diff --git a/src/remote_internal.c b/src/remote_internal.c index 1ef81b4f41..8a0d968221 100644 --- a/src/remote_internal.c +++ b/src/remote_internal.c @@ -1472,8 +1472,8 @@ remoteDomainGetVcpus (virDomainPtr domain, error (domain->conn, VIR_ERR_RPC, "maxinfo > REMOTE_VCPUINFO_MAX"); return -1; } - if (maplen > REMOTE_CPUMAPS_MAX) { - error (domain->conn, VIR_ERR_RPC, "maplen > REMOTE_CPUMAPS_MAX"); + if (maxinfo * maplen > REMOTE_CPUMAPS_MAX) { + error (domain->conn, VIR_ERR_RPC, "maxinfo * maplen > REMOTE_CPUMAPS_MAX"); return -1; } @@ -1492,12 +1492,15 @@ remoteDomainGetVcpus (virDomainPtr domain, xdr_free ((xdrproc_t) xdr_remote_domain_get_vcpus_ret, (char *) &ret); return -1; } - if (ret.cpumaps.cpumaps_len > maplen) { - error (domain->conn, VIR_ERR_RPC, "ret.cpumaps.cpumaps_len > maplen"); + if (ret.cpumaps.cpumaps_len > maxinfo * maplen) { + error (domain->conn, VIR_ERR_RPC, "ret.cpumaps.cpumaps_len > maxinfo * maplen"); xdr_free ((xdrproc_t) xdr_remote_domain_get_vcpus_ret, (char *) &ret); return -1; } + memset (info, 0, sizeof (virVcpuInfo) * maxinfo); + memset (cpumaps, 0, maxinfo * maplen); + for (i = 0; i < ret.info.info_len; ++i) { info[i].number = ret.info.info_val[i].number; info[i].state = ret.info.info_val[i].state; @@ -1522,7 +1525,7 @@ remoteDomainGetMaxVcpus (virDomainPtr domain) make_nonnull_domain (&args.dom, domain); memset (&ret, 0, sizeof ret); - if (call (domain->conn, priv, 0, REMOTE_PROC_GET_MAX_VCPUS, + if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_MAX_VCPUS, (xdrproc_t) xdr_remote_domain_get_max_vcpus_args, (char *) &args, (xdrproc_t) xdr_remote_domain_get_max_vcpus_ret, (char *) &ret) == -1) return -1; diff --git a/src/xen_unified.c b/src/xen_unified.c index 0d10f6b64d..cc10a4fe5e 100644 --- a/src/xen_unified.c +++ b/src/xen_unified.c @@ -783,34 +783,6 @@ xenUnifiedDomainDetachDevice (virDomainPtr dom, char *xml) return -1; } -static int -xenUnifiedDomainGetAutostart (virDomainPtr dom, int *autostart) -{ - GET_PRIVATE(dom->conn); - int i; - - for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) - if (priv->opened[i] && drivers[i]->domainGetAutostart && - drivers[i]->domainGetAutostart (dom, autostart) == 0) - return 0; - - return -1; -} - -static int -xenUnifiedDomainSetAutostart (virDomainPtr dom, int autostart) -{ - GET_PRIVATE(dom->conn); - int i; - - for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) - if (priv->opened[i] && drivers[i]->domainSetAutostart && - drivers[i]->domainSetAutostart (dom, autostart) == 0) - return 0; - - return -1; -} - static char * xenUnifiedDomainGetSchedulerType (virDomainPtr dom, int *nparams) { @@ -912,8 +884,6 @@ static virDriver xenUnifiedDriver = { .domainUndefine = xenUnifiedDomainUndefine, .domainAttachDevice = xenUnifiedDomainAttachDevice, .domainDetachDevice = xenUnifiedDomainDetachDevice, - .domainGetAutostart = xenUnifiedDomainGetAutostart, - .domainSetAutostart = xenUnifiedDomainSetAutostart, .domainGetSchedulerType = xenUnifiedDomainGetSchedulerType, .domainGetSchedulerParameters = xenUnifiedDomainGetSchedulerParameters, .domainSetSchedulerParameters = xenUnifiedDomainSetSchedulerParameters,