[libvirt] [PATCH 07/12] vcpu: make old API trivially wrap to new API
Daniel Veillard
veillard at redhat.com
Fri Oct 1 14:52:59 UTC 2010
On Wed, Sep 29, 2010 at 06:02:11PM -0600, Eric Blake wrote:
> * 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;
> + }
> +
> 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)
> }
that error catching will end up being preempted at the main entry point but
that's fine
[...]
> diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
> index f57759a..a5690a0 100644
> --- a/src/xenapi/xenapi_driver.c
> +++ b/src/xenapi/xenapi_driver.c
> @@ -40,6 +40,11 @@
> #include "xenapi_driver_private.h"
> #include "xenapi_utils.h"
>
> +#define VIR_FROM_THIS VIR_FROM_XENAPI
> +
> +#define xenapiError(code, ...) \
> + virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
> + __FUNCTION__, __LINE__, __VA_ARGS__)
ah, maybe we should check that module for other uses of this, but it's
independant from this patch
Looks fine, actual implementation for QEmu coming in a following patch,
ACK
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
More information about the libvir-list
mailing list