2010/9/30 Eric Blake <ebl...@redhat.com>: > * src/esx/esx_driver.c (esxDomainSetVcpus, escDomainGetMaxVpcus): > Move guts... > (esxDomainSetVcpusFlags, esxDomainGetVcpusFlags): ...to new > functions. > (esxDriver): Trivially support the new API. > * src/openvz/openvz_driver.c (openvzDomainSetVcpus) > (openvzDomainSetVcpusFlags, openvzDomainGetMaxVcpus) > (openvzDomainGetVcpusFlags, openvzDriver): Likewise. > * src/phyp/phyp_driver.c (phypDomainSetCPU) > (phypDomainSetVcpusFlags, phypGetLparCPUMAX) > (phypDomainGetVcpusFlags, phypDriver): Likewise. > * src/qemu/qemu_driver.c (qemudDomainSetVcpus) > (qemudDomainSetVcpusFlags, qemudDomainGetMaxVcpus) > (qemudDomainGetVcpusFlags, qemuDriver): Likewise. > * src/test/test_driver.c (testSetVcpus, testDomainSetVcpusFlags) > (testDomainGetMaxVcpus, testDomainGetVcpusFlags, testDriver): > Likewise. > * src/vbox/vbox_tmpl.c (vboxDomainSetVcpus) > (vboxDomainSetVcpusFlags, virDomainGetMaxVcpus) > (virDomainGetVcpusFlags, virDriver): Likewise. > * src/xen/xen_driver.c (xenUnifiedDomainSetVcpus) > (xenUnifiedDomainSetVcpusFlags, xenUnifiedDomainGetMaxVcpus) > (xenUnifiedDomainGetVcpusFlags, xenUnifiedDriver): Likewise. > * src/xenapi/xenapi_driver.c (xenapiDomainSetVcpus) > (xenapiDomainSetVcpusFlags, xenapiDomainGetMaxVcpus) > (xenapiDomainGetVcpusFlags, xenapiDriver): Likewise. > (xenapiError): New helper macro. > --- > > Long, but consistent - anywhere the old API exists, this implements > the new API, makes the old one a wrapper around the new, and makes > the new API fail for any flag combinations not yet implemented. > > src/esx/esx_driver.c | 32 +++++++++++++++++++--- > src/openvz/openvz_driver.c | 34 +++++++++++++++++++++--- > src/phyp/phyp_driver.c | 32 ++++++++++++++++++++--- > src/qemu/qemu_driver.c | 38 +++++++++++++++++++++++++--- > src/test/test_driver.c | 36 ++++++++++++++++++++++--- > src/vbox/vbox_tmpl.c | 36 +++++++++++++++++++++++--- > src/xen/xen_driver.c | 34 ++++++++++++++++++++++--- > src/xenapi/xenapi_driver.c | 60 > ++++++++++++++++++++++++++++++++++++++------ > 8 files changed, 263 insertions(+), 39 deletions(-) > > diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c > index 1db3a90..3d13d74 100644 > --- a/src/esx/esx_driver.c > +++ b/src/esx/esx_driver.c > @@ -2382,7 +2382,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr > info) > > > static int > -esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus) > +esxDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus, > + unsigned int flags) > { > int result = -1; > esxPrivate *priv = domain->conn->privateData; > @@ -2392,6 +2393,11 @@ esxDomainSetVcpus(virDomainPtr domain, unsigned int > nvcpus) > esxVI_ManagedObjectReference *task = NULL; > esxVI_TaskInfoState taskInfoState; > > + if (flags != VIR_DOMAIN_VCPU_ACTIVE) { > + ESX_ERROR(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), > flags); > + return -1; > + } > +
Why not use virCheckFlags here? > if (nvcpus < 1) { > ESX_ERROR(VIR_ERR_INVALID_ARG, "%s", > _("Requested number of virtual CPUs must at least be 1")); > @@ -2451,15 +2457,26 @@ esxDomainSetVcpus(virDomainPtr domain, unsigned int > nvcpus) > } > > > +static int > +esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus) > +{ > + return esxDomainSetVcpusFlags(domain, nvcpus, VIR_DOMAIN_VCPU_ACTIVE); > +} > + > > static int > -esxDomainGetMaxVcpus(virDomainPtr domain) > +esxDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags) > { > esxPrivate *priv = domain->conn->privateData; > esxVI_String *propertyNameList = NULL; > esxVI_ObjectContent *hostSystem = NULL; > esxVI_DynamicProperty *dynamicProperty = NULL; > > + if (flags != (VIR_DOMAIN_VCPU_ACTIVE | VIR_DOMAIN_VCPU_MAXIMUM)) { > + ESX_ERROR(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), > flags); > + return -1; > + } > + virCheckFlags? This pattern reoccurs through the rest of the patch. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list