2010/9/30 Eric Blake <eblake@xxxxxxxxxx>: > * 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@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list