render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
6ae9ed
From cb7f9ed96f81aebcade2c42cbdb1bacf97bb611b Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <cb7f9ed96f81aebcade2c42cbdb1bacf97bb611b@dist-git>
6ae9ed
From: Peter Krempa <pkrempa@redhat.com>
6ae9ed
Date: Wed, 24 Aug 2016 16:10:48 -0400
6ae9ed
Subject: [PATCH] conf: Add private data for virDomainVcpuDef
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1097930
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1224341
6ae9ed
6ae9ed
Allow to store driver specific data on a per-vcpu basis.
6ae9ed
6ae9ed
Move of the virDomainDef*Vcpus* functions was necessary as
6ae9ed
virDomainXMLOptionPtr was declared below this block and I didn't want to
6ae9ed
split the function headers.
6ae9ed
6ae9ed
(cherry picked from commit 5fe0b6b0a7e0c900ab51927ee859c2c92cc92e5d)
6ae9ed
6ae9ed
  Conflicts:
6ae9ed
 	src/bhyve/bhyve_parse_command.c: file missing
6ae9ed
---
6ae9ed
 src/conf/domain_conf.c        | 30 ++++++++++++++++++++++--------
6ae9ed
 src/conf/domain_conf.h        | 22 ++++++++++++++--------
6ae9ed
 src/hyperv/hyperv_driver.c    |  3 ++-
6ae9ed
 src/libxl/libxl_driver.c      |  4 ++--
6ae9ed
 src/lxc/lxc_native.c          |  2 +-
6ae9ed
 src/openvz/openvz_conf.c      |  2 +-
6ae9ed
 src/openvz/openvz_driver.c    | 16 ++++++++++------
6ae9ed
 src/phyp/phyp_driver.c        |  2 +-
6ae9ed
 src/qemu/qemu_driver.c        |  2 +-
6ae9ed
 src/qemu/qemu_parse_command.c |  9 +++++----
6ae9ed
 src/test/test_driver.c        |  4 +++-
6ae9ed
 src/vbox/vbox_common.c        |  4 ++--
6ae9ed
 src/vmx/vmx.c                 |  2 +-
6ae9ed
 src/vz/vz_sdk.c               |  7 ++++---
6ae9ed
 src/xen/xm_internal.c         |  2 +-
6ae9ed
 src/xenapi/xenapi_driver.c    |  2 +-
6ae9ed
 src/xenconfig/xen_common.c    | 13 ++++++++-----
6ae9ed
 src/xenconfig/xen_common.h    |  3 ++-
6ae9ed
 src/xenconfig/xen_sxpr.c      |  2 +-
6ae9ed
 src/xenconfig/xen_xl.c        |  3 ++-
6ae9ed
 src/xenconfig/xen_xm.c        |  3 ++-
6ae9ed
 21 files changed, 86 insertions(+), 51 deletions(-)
6ae9ed
6ae9ed
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
6ae9ed
index 6d0f967..384059d 100644
6ae9ed
--- a/src/conf/domain_conf.c
6ae9ed
+++ b/src/conf/domain_conf.c
6ae9ed
@@ -1313,12 +1313,23 @@ void virDomainLeaseDefFree(virDomainLeaseDefPtr def)
6ae9ed
 
6ae9ed
 
6ae9ed
 static virDomainVcpuDefPtr
6ae9ed
-virDomainVcpuDefNew(void)
6ae9ed
+virDomainVcpuDefNew(virDomainXMLOptionPtr xmlopt)
6ae9ed
 {
6ae9ed
-    virDomainVcpuDefPtr ret;
6ae9ed
+    virObjectPtr priv = NULL;
6ae9ed
+    virDomainVcpuDefPtr ret = NULL;
6ae9ed
 
6ae9ed
-    ignore_value(VIR_ALLOC(ret));
6ae9ed
+    if (xmlopt && xmlopt->privateData.vcpuNew &&
6ae9ed
+        !(priv = xmlopt->privateData.vcpuNew()))
6ae9ed
+        goto cleanup;
6ae9ed
 
6ae9ed
+    if (VIR_ALLOC(ret) < 0)
6ae9ed
+        goto cleanup;
6ae9ed
+
6ae9ed
+    ret->privateData = priv;
6ae9ed
+    priv = NULL;
6ae9ed
+
6ae9ed
+ cleanup:
6ae9ed
+    virObjectUnref(priv);
6ae9ed
     return ret;
6ae9ed
 }
6ae9ed
 
6ae9ed
@@ -1331,13 +1342,15 @@ virDomainVcpuDefFree(virDomainVcpuDefPtr info)
6ae9ed
 
6ae9ed
     virBitmapFree(info->cpumask);
6ae9ed
     info->cpumask = NULL;
6ae9ed
+    virObjectUnref(info->privateData);
6ae9ed
     VIR_FREE(info);
6ae9ed
 }
6ae9ed
 
6ae9ed
 
6ae9ed
 int
6ae9ed
 virDomainDefSetVcpusMax(virDomainDefPtr def,
6ae9ed
-                        unsigned int maxvcpus)
6ae9ed
+                        unsigned int maxvcpus,
6ae9ed
+                        virDomainXMLOptionPtr xmlopt)
6ae9ed
 {
6ae9ed
     size_t oldmax = def->maxvcpus;
6ae9ed
     size_t i;
6ae9ed
@@ -1350,7 +1363,7 @@ virDomainDefSetVcpusMax(virDomainDefPtr def,
6ae9ed
             return -1;
6ae9ed
 
6ae9ed
         for (i = oldmax; i < def->maxvcpus; i++) {
6ae9ed
-            if (!(def->vcpus[i] = virDomainVcpuDefNew()))
6ae9ed
+            if (!(def->vcpus[i] = virDomainVcpuDefNew(xmlopt)))
6ae9ed
                 return -1;
6ae9ed
         }
6ae9ed
     } else {
6ae9ed
@@ -15569,7 +15582,8 @@ virDomainIOThreadSchedParse(xmlNodePtr node,
6ae9ed
 
6ae9ed
 static int
6ae9ed
 virDomainVcpuParse(virDomainDefPtr def,
6ae9ed
-                   xmlXPathContextPtr ctxt)
6ae9ed
+                   xmlXPathContextPtr ctxt,
6ae9ed
+                   virDomainXMLOptionPtr xmlopt)
6ae9ed
 {
6ae9ed
     int n;
6ae9ed
     char *tmp = NULL;
6ae9ed
@@ -15587,7 +15601,7 @@ virDomainVcpuParse(virDomainDefPtr def,
6ae9ed
         maxvcpus = 1;
6ae9ed
     }
6ae9ed
 
6ae9ed
-    if (virDomainDefSetVcpusMax(def, maxvcpus) < 0)
6ae9ed
+    if (virDomainDefSetVcpusMax(def, maxvcpus, xmlopt) < 0)
6ae9ed
         goto cleanup;
6ae9ed
 
6ae9ed
     if ((n = virXPathUInt("string(./vcpu[1]/@current)", ctxt, &vcpus)) < 0) {
6ae9ed
@@ -16056,7 +16070,7 @@ virDomainDefParseXML(xmlDocPtr xml,
6ae9ed
                                   &def->mem.swap_hard_limit) < 0)
6ae9ed
         goto error;
6ae9ed
 
6ae9ed
-    if (virDomainVcpuParse(def, ctxt) < 0)
6ae9ed
+    if (virDomainVcpuParse(def, ctxt, xmlopt) < 0)
6ae9ed
         goto error;
6ae9ed
 
6ae9ed
     /* Optional - iothreads */
6ae9ed
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
6ae9ed
index ac37382..e7ff401 100644
6ae9ed
--- a/src/conf/domain_conf.h
6ae9ed
+++ b/src/conf/domain_conf.h
6ae9ed
@@ -2043,6 +2043,8 @@ struct _virDomainVcpuDef {
6ae9ed
     virBitmapPtr cpumask;
6ae9ed
 
6ae9ed
     virDomainThreadSchedParam sched;
6ae9ed
+
6ae9ed
+    virObjectPtr privateData;
6ae9ed
 };
6ae9ed
 
6ae9ed
 typedef struct _virDomainBlkiotune virDomainBlkiotune;
6ae9ed
@@ -2261,14 +2263,6 @@ struct _virDomainDef {
6ae9ed
     xmlNodePtr metadata;
6ae9ed
 };
6ae9ed
 
6ae9ed
-int virDomainDefSetVcpusMax(virDomainDefPtr def, unsigned int vcpus);
6ae9ed
-bool virDomainDefHasVcpusOffline(const virDomainDef *def);
6ae9ed
-unsigned int virDomainDefGetVcpusMax(const virDomainDef *def);
6ae9ed
-int virDomainDefSetVcpus(virDomainDefPtr def, unsigned int vcpus);
6ae9ed
-unsigned int virDomainDefGetVcpus(const virDomainDef *def);
6ae9ed
-virBitmapPtr virDomainDefGetOnlineVcpumap(const virDomainDef *def);
6ae9ed
-virDomainVcpuDefPtr virDomainDefGetVcpu(virDomainDefPtr def, unsigned int vcpu)
6ae9ed
-    ATTRIBUTE_RETURN_CHECK;
6ae9ed
 
6ae9ed
 unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def);
6ae9ed
 void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
6ae9ed
@@ -2422,6 +2416,7 @@ struct _virDomainXMLPrivateDataCallbacks {
6ae9ed
     virDomainXMLPrivateDataFreeFunc   free;
6ae9ed
     virDomainXMLPrivateDataNewFunc    diskNew;
6ae9ed
     virDomainXMLPrivateDataNewFunc    hostdevNew;
6ae9ed
+    virDomainXMLPrivateDataNewFunc    vcpuNew;
6ae9ed
     virDomainXMLPrivateDataFormatFunc format;
6ae9ed
     virDomainXMLPrivateDataParseFunc  parse;
6ae9ed
 };
6ae9ed
@@ -2453,6 +2448,17 @@ virDomainObjIsActive(virDomainObjPtr dom)
6ae9ed
     return dom->def->id != -1;
6ae9ed
 }
6ae9ed
 
6ae9ed
+int virDomainDefSetVcpusMax(virDomainDefPtr def,
6ae9ed
+                            unsigned int vcpus,
6ae9ed
+                            virDomainXMLOptionPtr xmlopt);
6ae9ed
+bool virDomainDefHasVcpusOffline(const virDomainDef *def);
6ae9ed
+unsigned int virDomainDefGetVcpusMax(const virDomainDef *def);
6ae9ed
+int virDomainDefSetVcpus(virDomainDefPtr def, unsigned int vcpus);
6ae9ed
+unsigned int virDomainDefGetVcpus(const virDomainDef *def);
6ae9ed
+virBitmapPtr virDomainDefGetOnlineVcpumap(const virDomainDef *def);
6ae9ed
+virDomainVcpuDefPtr virDomainDefGetVcpu(virDomainDefPtr def, unsigned int vcpu)
6ae9ed
+    ATTRIBUTE_RETURN_CHECK;
6ae9ed
+
6ae9ed
 virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps)
6ae9ed
     ATTRIBUTE_NONNULL(1);
6ae9ed
 
6ae9ed
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
6ae9ed
index 9c7faf0..b642a02 100644
6ae9ed
--- a/src/hyperv/hyperv_driver.c
6ae9ed
+++ b/src/hyperv/hyperv_driver.c
6ae9ed
@@ -876,7 +876,8 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
6ae9ed
     def->mem.cur_balloon = memorySettingData->data->VirtualQuantity * 1024; /* megabyte to kilobyte */
6ae9ed
 
6ae9ed
     if (virDomainDefSetVcpusMax(def,
6ae9ed
-                                processorSettingData->data->VirtualQuantity) < 0)
6ae9ed
+                                processorSettingData->data->VirtualQuantity,
6ae9ed
+                                NULL) < 0)
6ae9ed
         goto cleanup;
6ae9ed
 
6ae9ed
     if (virDomainDefSetVcpus(def,
6ae9ed
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
6ae9ed
index be6017a..711e801 100644
6ae9ed
--- a/src/libxl/libxl_driver.c
6ae9ed
+++ b/src/libxl/libxl_driver.c
6ae9ed
@@ -557,7 +557,7 @@ libxlAddDom0(libxlDriverPrivatePtr driver)
6ae9ed
     def = NULL;
6ae9ed
 
6ae9ed
     virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_BOOTED);
6ae9ed
-    if (virDomainDefSetVcpusMax(vm->def, d_info.vcpu_max_id + 1))
6ae9ed
+    if (virDomainDefSetVcpusMax(vm->def, d_info.vcpu_max_id + 1, driver->xmlopt))
6ae9ed
         goto cleanup;
6ae9ed
 
6ae9ed
     if (virDomainDefSetVcpus(vm->def, d_info.vcpu_online) < 0)
6ae9ed
@@ -2152,7 +2152,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
6ae9ed
 
6ae9ed
     switch (flags) {
6ae9ed
     case VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_CONFIG:
6ae9ed
-        if (virDomainDefSetVcpusMax(def, nvcpus) < 0)
6ae9ed
+        if (virDomainDefSetVcpusMax(def, nvcpus, driver->xmlopt) < 0)
6ae9ed
             goto cleanup;
6ae9ed
         break;
6ae9ed
 
6ae9ed
diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
6ae9ed
index acbc20b..a34204e 100644
6ae9ed
--- a/src/lxc/lxc_native.c
6ae9ed
+++ b/src/lxc/lxc_native.c
6ae9ed
@@ -1020,7 +1020,7 @@ lxcParseConfigString(const char *config,
6ae9ed
 
6ae9ed
     /* Value not handled by the LXC driver, setting to
6ae9ed
      * minimum required to make XML parsing pass */
6ae9ed
-    if (virDomainDefSetVcpusMax(vmdef, 1) < 0)
6ae9ed
+    if (virDomainDefSetVcpusMax(vmdef, 1, xmlopt) < 0)
6ae9ed
         goto error;
6ae9ed
 
6ae9ed
     if (virDomainDefSetVcpus(vmdef, 1) < 0)
6ae9ed
diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
6ae9ed
index 50f4902..99ce95c 100644
6ae9ed
--- a/src/openvz/openvz_conf.c
6ae9ed
+++ b/src/openvz/openvz_conf.c
6ae9ed
@@ -572,7 +572,7 @@ int openvzLoadDomains(struct openvz_driver *driver)
6ae9ed
         if (ret == 0 || vcpus == 0)
6ae9ed
             vcpus = openvzGetNodeCPUs();
6ae9ed
 
6ae9ed
-        if (virDomainDefSetVcpusMax(def, vcpus) < 0)
6ae9ed
+        if (virDomainDefSetVcpusMax(def, vcpus, driver->xmlopt) < 0)
6ae9ed
             goto cleanup;
6ae9ed
 
6ae9ed
         if (virDomainDefSetVcpus(def, vcpus) < 0)
6ae9ed
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
6ae9ed
index 48c264b..78c91da 100644
6ae9ed
--- a/src/openvz/openvz_driver.c
6ae9ed
+++ b/src/openvz/openvz_driver.c
6ae9ed
@@ -70,7 +70,8 @@ static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid);
6ae9ed
 static int openvzConnectGetMaxVcpus(virConnectPtr conn, const char *type);
6ae9ed
 static int openvzDomainGetMaxVcpus(virDomainPtr dom);
6ae9ed
 static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
6ae9ed
-                                        unsigned int nvcpus);
6ae9ed
+                                        unsigned int nvcpus,
6ae9ed
+                                        virDomainXMLOptionPtr xmlopt);
6ae9ed
 static int openvzDomainSetMemoryInternal(virDomainObjPtr vm,
6ae9ed
                                          unsigned long long memory);
6ae9ed
 static int openvzGetVEStatus(virDomainObjPtr vm, int *status, int *reason);
6ae9ed
@@ -1032,7 +1033,8 @@ openvzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla
6ae9ed
         goto cleanup;
6ae9ed
     }
6ae9ed
     if (virDomainDefGetVcpusMax(vm->def)) {
6ae9ed
-        if (openvzDomainSetVcpusInternal(vm, virDomainDefGetVcpusMax(vm->def)) < 0) {
6ae9ed
+        if (openvzDomainSetVcpusInternal(vm, virDomainDefGetVcpusMax(vm->def),
6ae9ed
+                                         driver->xmlopt) < 0) {
6ae9ed
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
6ae9ed
                            _("Could not set number of vCPUs"));
6ae9ed
              goto cleanup;
6ae9ed
@@ -1130,7 +1132,8 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
6ae9ed
     virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_BOOTED);
6ae9ed
 
6ae9ed
     if (virDomainDefGetVcpusMax(vm->def) > 0) {
6ae9ed
-        if (openvzDomainSetVcpusInternal(vm, virDomainDefGetVcpusMax(vm->def)) < 0) {
6ae9ed
+        if (openvzDomainSetVcpusInternal(vm, virDomainDefGetVcpusMax(vm->def),
6ae9ed
+                                         driver->xmlopt) < 0) {
6ae9ed
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
6ae9ed
                            _("Could not set number of vCPUs"));
6ae9ed
             goto cleanup;
6ae9ed
@@ -1347,7 +1350,8 @@ static int openvzDomainGetMaxVcpus(virDomainPtr dom)
6ae9ed
 }
6ae9ed
 
6ae9ed
 static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
6ae9ed
-                                        unsigned int nvcpus)
6ae9ed
+                                        unsigned int nvcpus,
6ae9ed
+                                        virDomainXMLOptionPtr xmlopt)
6ae9ed
 {
6ae9ed
     char        str_vcpus[32];
6ae9ed
     const char *prog[] = { VZCTL, "--quiet", "set", PROGRAM_SENTINEL,
6ae9ed
@@ -1364,7 +1368,7 @@ static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
6ae9ed
     if (virRun(prog, NULL) < 0)
6ae9ed
         return -1;
6ae9ed
 
6ae9ed
-    if (virDomainDefSetVcpusMax(vm->def, nvcpus) < 0)
6ae9ed
+    if (virDomainDefSetVcpusMax(vm->def, nvcpus, xmlopt) < 0)
6ae9ed
         return -1;
6ae9ed
 
6ae9ed
     if (virDomainDefSetVcpus(vm->def, nvcpus) < 0)
6ae9ed
@@ -1402,7 +1406,7 @@ static int openvzDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
6ae9ed
         goto cleanup;
6ae9ed
     }
6ae9ed
 
6ae9ed
-    if (openvzDomainSetVcpusInternal(vm, nvcpus) < 0) {
6ae9ed
+    if (openvzDomainSetVcpusInternal(vm, nvcpus, driver->xmlopt) < 0) {
6ae9ed
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
6ae9ed
                        _("Could not set number of vCPUs"));
6ae9ed
         goto cleanup;
6ae9ed
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
6ae9ed
index dce20bc..3dd8927 100644
6ae9ed
--- a/src/phyp/phyp_driver.c
6ae9ed
+++ b/src/phyp/phyp_driver.c
6ae9ed
@@ -3296,7 +3296,7 @@ phypDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
6ae9ed
         goto err;
6ae9ed
     }
6ae9ed
 
6ae9ed
-    if (virDomainDefSetVcpusMax(&def, vcpus) < 0)
6ae9ed
+    if (virDomainDefSetVcpusMax(&def, vcpus, phyp_driver->xmlopt) < 0)
6ae9ed
         goto err;
6ae9ed
 
6ae9ed
     if (virDomainDefSetVcpus(&def, vcpus) < 0)
6ae9ed
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
6ae9ed
index 71f2fb6..d3cf267 100644
6ae9ed
--- a/src/qemu/qemu_driver.c
6ae9ed
+++ b/src/qemu/qemu_driver.c
6ae9ed
@@ -4863,7 +4863,7 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
6ae9ed
                 goto endjob;
6ae9ed
             }
6ae9ed
 
6ae9ed
-            if (virDomainDefSetVcpusMax(persistentDef, nvcpus) < 0)
6ae9ed
+            if (virDomainDefSetVcpusMax(persistentDef, nvcpus, driver->xmlopt) < 0)
6ae9ed
                 goto endjob;
6ae9ed
         } else {
6ae9ed
             if (virDomainDefSetVcpus(persistentDef, nvcpus) < 0)
6ae9ed
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
6ae9ed
index b1d8a1d..0bcd1ad 100644
6ae9ed
--- a/src/qemu/qemu_parse_command.c
6ae9ed
+++ b/src/qemu/qemu_parse_command.c
6ae9ed
@@ -1659,7 +1659,8 @@ qemuParseCommandLineMem(virDomainDefPtr dom,
6ae9ed
 
6ae9ed
 static int
6ae9ed
 qemuParseCommandLineSmp(virDomainDefPtr dom,
6ae9ed
-                        const char *val)
6ae9ed
+                        const char *val,
6ae9ed
+                        virDomainXMLOptionPtr xmlopt)
6ae9ed
 {
6ae9ed
     unsigned int sockets = 0;
6ae9ed
     unsigned int cores = 0;
6ae9ed
@@ -1701,7 +1702,7 @@ qemuParseCommandLineSmp(virDomainDefPtr dom,
6ae9ed
     if (maxcpus == 0)
6ae9ed
         maxcpus = vcpus;
6ae9ed
 
6ae9ed
-    if (virDomainDefSetVcpusMax(dom, maxcpus) < 0)
6ae9ed
+    if (virDomainDefSetVcpusMax(dom, maxcpus, xmlopt) < 0)
6ae9ed
         goto error;
6ae9ed
 
6ae9ed
     if (virDomainDefSetVcpus(dom, vcpus) < 0)
6ae9ed
@@ -1819,7 +1820,7 @@ qemuParseCommandLine(virCapsPtr caps,
6ae9ed
     def->id = -1;
6ae9ed
     def->mem.cur_balloon = 64 * 1024;
6ae9ed
     virDomainDefSetMemoryTotal(def, def->mem.cur_balloon);
6ae9ed
-    if (virDomainDefSetVcpusMax(def, 1) < 0)
6ae9ed
+    if (virDomainDefSetVcpusMax(def, 1, xmlopt) < 0)
6ae9ed
         goto error;
6ae9ed
     if (virDomainDefSetVcpus(def, 1) < 0)
6ae9ed
         goto error;
6ae9ed
@@ -1899,7 +1900,7 @@ qemuParseCommandLine(virCapsPtr caps,
6ae9ed
                 goto error;
6ae9ed
         } else if (STREQ(arg, "-smp")) {
6ae9ed
             WANT_VALUE();
6ae9ed
-            if (qemuParseCommandLineSmp(def, val) < 0)
6ae9ed
+            if (qemuParseCommandLineSmp(def, val, xmlopt) < 0)
6ae9ed
                 goto error;
6ae9ed
         } else if (STREQ(arg, "-uuid")) {
6ae9ed
             WANT_VALUE();
6ae9ed
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
6ae9ed
index e7bca81..36bbd7f 100644
6ae9ed
--- a/src/test/test_driver.c
6ae9ed
+++ b/src/test/test_driver.c
6ae9ed
@@ -2336,6 +2336,7 @@ static int
6ae9ed
 testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus,
6ae9ed
                         unsigned int flags)
6ae9ed
 {
6ae9ed
+    testDriverPtr driver = domain->conn->privateData;
6ae9ed
     virDomainObjPtr privdom = NULL;
6ae9ed
     virDomainDefPtr def;
6ae9ed
     virDomainDefPtr persistentDef;
6ae9ed
@@ -2383,7 +2384,8 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus,
6ae9ed
 
6ae9ed
     if (persistentDef) {
6ae9ed
         if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
6ae9ed
-            if (virDomainDefSetVcpusMax(persistentDef, nrCpus) < 0)
6ae9ed
+            if (virDomainDefSetVcpusMax(persistentDef, nrCpus,
6ae9ed
+                                        driver->xmlopt) < 0)
6ae9ed
                 goto cleanup;
6ae9ed
         } else {
6ae9ed
             if (virDomainDefSetVcpus(persistentDef, nrCpus) < 0)
6ae9ed
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
6ae9ed
index 8e49268..a14ab67 100644
6ae9ed
--- a/src/vbox/vbox_common.c
6ae9ed
+++ b/src/vbox/vbox_common.c
6ae9ed
@@ -3885,7 +3885,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
6ae9ed
     virDomainDefSetMemoryTotal(def, memorySize * 1024);
6ae9ed
 
6ae9ed
     gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount);
6ae9ed
-    if (virDomainDefSetVcpusMax(def, CPUCount) < 0)
6ae9ed
+    if (virDomainDefSetVcpusMax(def, CPUCount, data->xmlopt) < 0)
6ae9ed
         goto cleanup;
6ae9ed
 
6ae9ed
     if (virDomainDefSetVcpus(def, CPUCount) < 0)
6ae9ed
@@ -6044,7 +6044,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
6ae9ed
         def->dom->os.type = VIR_DOMAIN_OSTYPE_HVM;
6ae9ed
         def->dom->os.arch = virArchFromHost();
6ae9ed
         gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount);
6ae9ed
-        if (virDomainDefSetVcpusMax(def->dom, CPUCount) < 0)
6ae9ed
+        if (virDomainDefSetVcpusMax(def->dom, CPUCount, data->xmlopt) < 0)
6ae9ed
             goto cleanup;
6ae9ed
 
6ae9ed
         if (virDomainDefSetVcpus(def->dom, CPUCount) < 0)
6ae9ed
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
6ae9ed
index d443dd0..0f557a8 100644
6ae9ed
--- a/src/vmx/vmx.c
6ae9ed
+++ b/src/vmx/vmx.c
6ae9ed
@@ -1457,7 +1457,7 @@ virVMXParseConfig(virVMXContext *ctx,
6ae9ed
         goto cleanup;
6ae9ed
     }
6ae9ed
 
6ae9ed
-    if (virDomainDefSetVcpusMax(def, numvcpus) < 0)
6ae9ed
+    if (virDomainDefSetVcpusMax(def, numvcpus, xmlopt) < 0)
6ae9ed
         goto cleanup;
6ae9ed
 
6ae9ed
     if (virDomainDefSetVcpus(def, numvcpus) < 0)
6ae9ed
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
6ae9ed
index 9d0bc0d..7871230 100644
6ae9ed
--- a/src/vz/vz_sdk.c
6ae9ed
+++ b/src/vz/vz_sdk.c
6ae9ed
@@ -1309,7 +1309,8 @@ prlsdkConvertDomainState(VIRTUAL_MACHINE_STATE domainState,
6ae9ed
 
6ae9ed
 static int
6ae9ed
 prlsdkConvertCpuInfo(PRL_HANDLE sdkdom,
6ae9ed
-                     virDomainDefPtr def)
6ae9ed
+                     virDomainDefPtr def,
6ae9ed
+                     virDomainXMLOptionPtr xmlopt)
6ae9ed
 {
6ae9ed
     char *buf;
6ae9ed
     int hostcpus;
6ae9ed
@@ -1327,7 +1328,7 @@ prlsdkConvertCpuInfo(PRL_HANDLE sdkdom,
6ae9ed
     if (cpuCount > hostcpus)
6ae9ed
         cpuCount = hostcpus;
6ae9ed
 
6ae9ed
-    if (virDomainDefSetVcpusMax(def, cpuCount) < 0)
6ae9ed
+    if (virDomainDefSetVcpusMax(def, cpuCount, xmlopt) < 0)
6ae9ed
         goto cleanup;
6ae9ed
 
6ae9ed
     if (virDomainDefSetVcpus(def, cpuCount) < 0)
6ae9ed
@@ -1706,7 +1707,7 @@ prlsdkLoadDomain(vzDriverPtr driver, virDomainObjPtr dom)
6ae9ed
                                                      convert to Kbytes */
6ae9ed
     def->mem.cur_balloon = ram << 10;
6ae9ed
 
6ae9ed
-    if (prlsdkConvertCpuInfo(sdkdom, def) < 0)
6ae9ed
+    if (prlsdkConvertCpuInfo(sdkdom, def, driver->xmlopt) < 0)
6ae9ed
         goto error;
6ae9ed
 
6ae9ed
     if (prlsdkConvertCpuMode(sdkdom, def) < 0)
6ae9ed
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
6ae9ed
index 3c34652..8335078 100644
6ae9ed
--- a/src/xen/xm_internal.c
6ae9ed
+++ b/src/xen/xm_internal.c
6ae9ed
@@ -700,7 +700,7 @@ xenXMDomainSetVcpusFlags(virConnectPtr conn,
6ae9ed
     }
6ae9ed
 
6ae9ed
     if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
6ae9ed
-        if (virDomainDefSetVcpusMax(entry->def, vcpus) < 0)
6ae9ed
+        if (virDomainDefSetVcpusMax(entry->def, vcpus, priv->xmlopt) < 0)
6ae9ed
             goto cleanup;
6ae9ed
     } else {
6ae9ed
         if (virDomainDefSetVcpus(entry->def, vcpus) < 0)
6ae9ed
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
6ae9ed
index 676ed5b..9a861c1 100644
6ae9ed
--- a/src/xenapi/xenapi_driver.c
6ae9ed
+++ b/src/xenapi/xenapi_driver.c
6ae9ed
@@ -1505,7 +1505,7 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
6ae9ed
 
6ae9ed
     vcpus = xenapiDomainGetMaxVcpus(dom);
6ae9ed
 
6ae9ed
-    if (virDomainDefSetVcpusMax(defPtr, vcpus) < 0)
6ae9ed
+    if (virDomainDefSetVcpusMax(defPtr, vcpus, priv->xmlopt) < 0)
6ae9ed
         goto error;
6ae9ed
 
6ae9ed
     if (virDomainDefSetVcpus(defPtr, vcpus) < 0)
6ae9ed
diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
6ae9ed
index f62a5b1..8365a2c 100644
6ae9ed
--- a/src/xenconfig/xen_common.c
6ae9ed
+++ b/src/xenconfig/xen_common.c
6ae9ed
@@ -483,7 +483,9 @@ xenParsePCI(virConfPtr conf, virDomainDefPtr def)
6ae9ed
 
6ae9ed
 
6ae9ed
 static int
6ae9ed
-xenParseCPUFeatures(virConfPtr conf, virDomainDefPtr def)
6ae9ed
+xenParseCPUFeatures(virConfPtr conf,
6ae9ed
+                    virDomainDefPtr def,
6ae9ed
+                    virDomainXMLOptionPtr xmlopt)
6ae9ed
 {
6ae9ed
     unsigned long count = 0;
6ae9ed
     const char *str = NULL;
6ae9ed
@@ -492,7 +494,7 @@ xenParseCPUFeatures(virConfPtr conf, virDomainDefPtr def)
6ae9ed
     if (xenConfigGetULong(conf, "vcpus", &count, 1) < 0)
6ae9ed
         return -1;
6ae9ed
 
6ae9ed
-    if (virDomainDefSetVcpusMax(def, count) < 0)
6ae9ed
+    if (virDomainDefSetVcpusMax(def, count, xmlopt) < 0)
6ae9ed
         return -1;
6ae9ed
 
6ae9ed
     if (virDomainDefSetVcpus(def, count) < 0)
6ae9ed
@@ -502,7 +504,7 @@ xenParseCPUFeatures(virConfPtr conf, virDomainDefPtr def)
6ae9ed
         if (xenConfigGetULong(conf, "maxvcpus", &count, 0) < 0)
6ae9ed
             return -1;
6ae9ed
 
6ae9ed
-        if (virDomainDefSetVcpusMax(def, count) < 0)
6ae9ed
+        if (virDomainDefSetVcpusMax(def, count, xmlopt) < 0)
6ae9ed
             return -1;
6ae9ed
     }
6ae9ed
 
6ae9ed
@@ -1051,7 +1053,8 @@ int
6ae9ed
 xenParseConfigCommon(virConfPtr conf,
6ae9ed
                      virDomainDefPtr def,
6ae9ed
                      virCapsPtr caps,
6ae9ed
-                     const char *nativeFormat)
6ae9ed
+                     const char *nativeFormat,
6ae9ed
+                     virDomainXMLOptionPtr xmlopt)
6ae9ed
 {
6ae9ed
     if (xenParseGeneralMeta(conf, def, caps) < 0)
6ae9ed
         return -1;
6ae9ed
@@ -1062,7 +1065,7 @@ xenParseConfigCommon(virConfPtr conf,
6ae9ed
     if (xenParseEventsActions(conf, def) < 0)
6ae9ed
         return -1;
6ae9ed
 
6ae9ed
-    if (xenParseCPUFeatures(conf, def) < 0)
6ae9ed
+    if (xenParseCPUFeatures(conf, def, xmlopt) < 0)
6ae9ed
         return -1;
6ae9ed
 
6ae9ed
     if (xenParseTimeOffset(conf, def) < 0)
6ae9ed
diff --git a/src/xenconfig/xen_common.h b/src/xenconfig/xen_common.h
6ae9ed
index 1c74bee..9055692 100644
6ae9ed
--- a/src/xenconfig/xen_common.h
6ae9ed
+++ b/src/xenconfig/xen_common.h
6ae9ed
@@ -59,7 +59,8 @@ int xenConfigCopyStringOpt(virConfPtr conf,
6ae9ed
 int xenParseConfigCommon(virConfPtr conf,
6ae9ed
                          virDomainDefPtr def,
6ae9ed
                          virCapsPtr caps,
6ae9ed
-                         const char *nativeFormat);
6ae9ed
+                         const char *nativeFormat,
6ae9ed
+                         virDomainXMLOptionPtr xmlopt);
6ae9ed
 
6ae9ed
 int xenFormatConfigCommon(virConfPtr conf,
6ae9ed
                           virDomainDefPtr def,
6ae9ed
diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c
6ae9ed
index ea6c177..40dc53c 100644
6ae9ed
--- a/src/xenconfig/xen_sxpr.c
6ae9ed
+++ b/src/xenconfig/xen_sxpr.c
6ae9ed
@@ -1233,7 +1233,7 @@ xenParseSxpr(const struct sexpr *root,
6ae9ed
         }
6ae9ed
     }
6ae9ed
 
6ae9ed
-    if (virDomainDefSetVcpusMax(def, sexpr_int(root, "domain/vcpus")) < 0)
6ae9ed
+    if (virDomainDefSetVcpusMax(def, sexpr_int(root, "domain/vcpus"), xmlopt) < 0)
6ae9ed
         goto error;
6ae9ed
 
6ae9ed
     vcpus = count_one_bits_l(sexpr_u64(root, "domain/vcpu_avail"));
6ae9ed
diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
6ae9ed
index f8cebd2..25a3621 100644
6ae9ed
--- a/src/xenconfig/xen_xl.c
6ae9ed
+++ b/src/xenconfig/xen_xl.c
6ae9ed
@@ -594,7 +594,8 @@ xenParseXL(virConfPtr conf,
6ae9ed
     def->virtType = VIR_DOMAIN_VIRT_XEN;
6ae9ed
     def->id = -1;
6ae9ed
 
6ae9ed
-    if (xenParseConfigCommon(conf, def, caps, XEN_CONFIG_FORMAT_XL) < 0)
6ae9ed
+    if (xenParseConfigCommon(conf, def, caps, XEN_CONFIG_FORMAT_XL,
6ae9ed
+                             xmlopt) < 0)
6ae9ed
         goto cleanup;
6ae9ed
 
6ae9ed
     if (xenParseXLOS(conf, def, caps) < 0)
6ae9ed
diff --git a/src/xenconfig/xen_xm.c b/src/xenconfig/xen_xm.c
6ae9ed
index 1023ed2..124c94a 100644
6ae9ed
--- a/src/xenconfig/xen_xm.c
6ae9ed
+++ b/src/xenconfig/xen_xm.c
6ae9ed
@@ -447,7 +447,8 @@ xenParseXM(virConfPtr conf,
6ae9ed
     def->virtType = VIR_DOMAIN_VIRT_XEN;
6ae9ed
     def->id = -1;
6ae9ed
 
6ae9ed
-    if (xenParseConfigCommon(conf, def, caps, XEN_CONFIG_FORMAT_XM) < 0)
6ae9ed
+    if (xenParseConfigCommon(conf, def, caps, XEN_CONFIG_FORMAT_XM,
6ae9ed
+                             xmlopt) < 0)
6ae9ed
         goto cleanup;
6ae9ed
 
6ae9ed
     if (xenParseXMOS(conf, def) < 0)
6ae9ed
-- 
6ae9ed
2.10.0
6ae9ed