[libvirt] [PATCH 07/11] conf: Add private data for virDomainVcpuDef

Michal Privoznik mprivozn at redhat.com
Fri Jul 8 16:31:46 UTC 2016


On 07.07.2016 15:41, Peter Krempa wrote:
> Allow to store driver specific data on a per-vcpu basis.
> 
> Move of the virDomainDef*Vcpus* functions was necessary as
> virDomainXMLOptionPtr was declared below this block and I didn't want to
> split the function headers.
> ---
>  src/conf/domain_conf.c        | 28 +++++++++++++++++++++-------
>  src/conf/domain_conf.h        | 22 ++++++++++++++--------
>  src/hyperv/hyperv_driver.c    |  3 ++-
>  src/libxl/libxl_driver.c      |  4 ++--
>  src/lxc/lxc_native.c          |  2 +-
>  src/openvz/openvz_conf.c      |  2 +-
>  src/openvz/openvz_driver.c    | 16 ++++++++++------
>  src/phyp/phyp_driver.c        |  2 +-
>  src/qemu/qemu_driver.c        |  2 +-
>  src/qemu/qemu_parse_command.c |  9 +++++----
>  src/test/test_driver.c        |  4 +++-
>  src/vbox/vbox_common.c        |  4 ++--
>  src/vmx/vmx.c                 |  2 +-
>  src/xen/xm_internal.c         |  2 +-
>  src/xenapi/xenapi_driver.c    |  2 +-
>  src/xenconfig/xen_common.c    | 13 ++++++++-----
>  src/xenconfig/xen_common.h    |  3 ++-
>  src/xenconfig/xen_sxpr.c      |  2 +-
>  src/xenconfig/xen_xl.c        |  3 ++-
>  src/xenconfig/xen_xm.c        |  3 ++-
>  20 files changed, 81 insertions(+), 47 deletions(-)

You forgot to update Virtuozzo (vz) driver.

> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index c2d7259..e660f8e 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -1307,12 +1307,23 @@ void virDomainLeaseDefFree(virDomainLeaseDefPtr def)
> 
> 
>  static virDomainVcpuDefPtr
> -virDomainVcpuDefNew(void)
> +virDomainVcpuDefNew(virDomainXMLOptionPtr xmlopt)
>  {
> +    virObjectPtr priv = NULL;
>      virDomainVcpuDefPtr ret;
> 
> -    ignore_value(VIR_ALLOC(ret));
> +    if (xmlopt && xmlopt->privateData.vcpuNew &&
> +        !(priv = xmlopt->privateData.vcpuNew()))
> +        goto cleanup;
> +
> +    if (VIR_ALLOC(ret) < 0)
> +        goto cleanup;
> +
> +    ret->privateData = priv;
> +    priv = NULL;
> 
> + cleanup:
> +    virObjectUnref(priv);
>      return ret;

Funny, my compiler fails to see that @ret might be used uninitialized here.. All that's needed is just vcpuNew() function to fail. Initialize the @ret properly please.

>  }
> 

ACK if you squash this in:

diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 9d0bc0d..7871230 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -1309,7 +1309,8 @@ prlsdkConvertDomainState(VIRTUAL_MACHINE_STATE domainState,
 
 static int
 prlsdkConvertCpuInfo(PRL_HANDLE sdkdom,
-                     virDomainDefPtr def)
+                     virDomainDefPtr def,
+                     virDomainXMLOptionPtr xmlopt)
 {
     char *buf;
     int hostcpus;
@@ -1327,7 +1328,7 @@ prlsdkConvertCpuInfo(PRL_HANDLE sdkdom,
     if (cpuCount > hostcpus)
         cpuCount = hostcpus;
 
-    if (virDomainDefSetVcpusMax(def, cpuCount) < 0)
+    if (virDomainDefSetVcpusMax(def, cpuCount, xmlopt) < 0)
         goto cleanup;
 
     if (virDomainDefSetVcpus(def, cpuCount) < 0)
@@ -1706,7 +1707,7 @@ prlsdkLoadDomain(vzDriverPtr driver, virDomainObjPtr dom)
                                                      convert to Kbytes */
     def->mem.cur_balloon = ram << 10;
 
-    if (prlsdkConvertCpuInfo(sdkdom, def) < 0)
+    if (prlsdkConvertCpuInfo(sdkdom, def, driver->xmlopt) < 0)
         goto error;
 
     if (prlsdkConvertCpuMode(sdkdom, def) < 0)


Michal




More information about the libvir-list mailing list