Re: [PATCH 07/12] vcpu: make old API trivially wrap to new API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]