[PATCH 11/34] conf: Replace read access to def->maxvcpus with accessor

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

 



Finalize the refactor by adding the 'virDomainDefGetVCpusMax' getter and
reusing it accross libvirt.
---
 src/conf/domain_conf.c     | 22 +++++++++++++++-------
 src/conf/domain_conf.h     |  1 +
 src/libvirt_private.syms   |  1 +
 src/libxl/libxl_conf.c     |  4 ++--
 src/libxl/libxl_driver.c   |  9 ++++++---
 src/openvz/openvz_driver.c |  4 ++--
 src/qemu/qemu_command.c    |  4 ++--
 src/qemu/qemu_driver.c     | 10 +++++-----
 src/qemu/qemu_process.c    |  2 +-
 src/test/test_driver.c     | 13 ++++++++-----
 src/vbox/vbox_common.c     |  4 ++--
 src/vmx/vmx.c              | 16 +++++++++-------
 src/vz/vz_driver.c         |  2 +-
 src/xen/xm_internal.c      |  9 ++++++---
 src/xenapi/xenapi_utils.c  |  6 ++----
 src/xenconfig/xen_common.c |  4 ++--
 src/xenconfig/xen_sxpr.c   |  8 ++++----
 17 files changed, 69 insertions(+), 50 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6b16430..4e5b7b6 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1450,6 +1450,13 @@ virDomainDefHasVCpusOffline(const virDomainDef *def)
 }


+unsigned int
+virDomainDefGetVCpusMax(const virDomainDef *def)
+{
+    return def->maxvcpus;
+}
+
+
 virDomainDiskDefPtr
 virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt)
 {
@@ -15266,7 +15273,8 @@ virDomainDefParseXML(xmlDocPtr xml,

         for (i = 0; i < def->cputune.nvcpusched; i++) {
             if (virDomainThreadSchedParse(nodes[i],
-                                          0, def->maxvcpus - 1,
+                                          0,
+                                          virDomainDefGetVCpusMax(def) - 1,
                                           "vcpus",
                                           &def->cputune.vcpusched[i]) < 0)
                 goto error;
@@ -15343,7 +15351,7 @@ virDomainDefParseXML(xmlDocPtr xml,
             goto error;

         if (def->cpu->sockets &&
-            def->maxvcpus >
+            virDomainDefGetVCpusMax(def) >
             def->cpu->sockets * def->cpu->cores * def->cpu->threads) {
             virReportError(VIR_ERR_XML_DETAIL, "%s",
                            _("Maximum CPUs greater than topology limit"));
@@ -15355,14 +15363,14 @@ virDomainDefParseXML(xmlDocPtr xml,
     if (virDomainNumaDefCPUParseXML(def->numa, ctxt) < 0)
         goto error;

-    if (virDomainNumaGetCPUCountTotal(def->numa) > def->maxvcpus) {
+    if (virDomainNumaGetCPUCountTotal(def->numa) > virDomainDefGetVCpusMax(def)) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Number of CPUs in <numa> exceeds the"
                          " <vcpu> count"));
         goto error;
     }

-    if (virDomainNumaGetMaxCPUID(def->numa) >= def->maxvcpus) {
+    if (virDomainNumaGetMaxCPUID(def->numa) >= virDomainDefGetVCpusMax(def)) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("CPU IDs in <numa> exceed the <vcpu> count"));
         goto error;
@@ -17843,10 +17851,10 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
                        dst->vcpus, src->vcpus);
         goto error;
     }
-    if (src->maxvcpus != dst->maxvcpus) {
+    if (virDomainDefGetVCpusMax(src) != virDomainDefGetVCpusMax(dst)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("Target domain vCPU max %d does not match source %d"),
-                       dst->maxvcpus, src->maxvcpus);
+                       virDomainDefGetVCpusMax(dst), virDomainDefGetVCpusMax(src));
         goto error;
     }

@@ -21806,7 +21814,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     }
     if (virDomainDefHasVCpusOffline(def))
         virBufferAsprintf(buf, " current='%u'", def->vcpus);
-    virBufferAsprintf(buf, ">%u</vcpu>\n", def->maxvcpus);
+    virBufferAsprintf(buf, ">%u</vcpu>\n", virDomainDefGetVCpusMax(def));

     if (def->niothreadids > 0) {
         virBufferAsprintf(buf, "<iothreads>%u</iothreads>\n",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index de7412c..433e5c9 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2327,6 +2327,7 @@ struct _virDomainDef {

 int virDomainDefSetVCpusMax(virDomainDefPtr def, unsigned int vcpus);
 bool virDomainDefHasVCpusOffline(const virDomainDef *def);
+unsigned int virDomainDefGetVCpusMax(const virDomainDef *def);

 unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def);
 void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 7e6ea4b..d2993c1 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -217,6 +217,7 @@ virDomainDefGetDefaultEmulator;
 virDomainDefGetMemoryActual;
 virDomainDefGetMemoryInitial;
 virDomainDefGetSecurityLabelDef;
+virDomainDefGetVCpusMax;
 virDomainDefHasDeviceAddress;
 virDomainDefHasMemoryHotplug;
 virDomainDefHasVCpusOffline;
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 4eed5ca..82ccb89 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -643,8 +643,8 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
     else
         libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_PV);

-    b_info->max_vcpus = def->maxvcpus;
-    if (libxl_cpu_bitmap_alloc(ctx, &b_info->avail_vcpus, def->maxvcpus))
+    b_info->max_vcpus = virDomainDefGetVCpusMax(def);
+    if (libxl_cpu_bitmap_alloc(ctx, &b_info->avail_vcpus, b_info->max_vcpus))
         return -1;
     libxl_bitmap_set_none(&b_info->avail_vcpus);
     for (i = 0; i < def->vcpus; i++)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index e85874a..8b0fd39 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -2159,8 +2159,8 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
         goto endjob;
     }

-    if (!(flags & VIR_DOMAIN_VCPU_MAXIMUM) && vm->def->maxvcpus < max)
-        max = vm->def->maxvcpus;
+    if (!(flags & VIR_DOMAIN_VCPU_MAXIMUM) && virDomainDefGetVCpusMax(vm->def) < max)
+        max = virDomainDefGetVCpusMax(vm->def);

     if (nvcpus > max) {
         virReportError(VIR_ERR_INVALID_ARG,
@@ -2297,7 +2297,10 @@ libxlDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
         def = vm->newDef ? vm->newDef : vm->def;
     }

-    ret = (flags & VIR_DOMAIN_VCPU_MAXIMUM) ? def->maxvcpus : def->vcpus;
+    if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
+        ret = virDomainDefGetVCpusMax(def);
+    else
+        ret = def->vcpus;

  cleanup:
     if (vm)
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 53a2d57..90e2aad 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1035,7 +1035,7 @@ openvzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla
                        _("current vcpu count must equal maximum"));
         goto cleanup;
     }
-    if (openvzDomainSetVcpusInternal(vm, vm->def->maxvcpus) < 0) {
+    if (openvzDomainSetVcpusInternal(vm, virDomainDefGetVCpusMax(vm->def)) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Could not set number of vCPUs"));
          goto cleanup;
@@ -1131,7 +1131,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
     vm->def->id = vm->pid;
     virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_BOOTED);

-    if (openvzDomainSetVcpusInternal(vm, vm->def->maxvcpus) < 0) {
+    if (openvzDomainSetVcpusInternal(vm, virDomainDefGetVCpusMax(vm->def)) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Could not set number of vCPUs"));
         goto cleanup;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index cc6785f..b136314 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7853,7 +7853,7 @@ qemuBuildSmpArgStr(const virDomainDef *def,

     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SMP_TOPOLOGY)) {
         if (virDomainDefHasVCpusOffline(def))
-            virBufferAsprintf(&buf, ",maxcpus=%u", def->maxvcpus);
+            virBufferAsprintf(&buf, ",maxcpus=%u", virDomainDefGetVCpusMax(def));
         /* sockets, cores, and threads are either all zero
          * or all non-zero, thus checking one of them is enough */
         if (def->cpu && def->cpu->sockets) {
@@ -7861,7 +7861,7 @@ qemuBuildSmpArgStr(const virDomainDef *def,
             virBufferAsprintf(&buf, ",cores=%u", def->cpu->cores);
             virBufferAsprintf(&buf, ",threads=%u", def->cpu->threads);
         } else {
-            virBufferAsprintf(&buf, ",sockets=%u", def->maxvcpus);
+            virBufferAsprintf(&buf, ",sockets=%u", virDomainDefGetVCpusMax(def));
             virBufferAsprintf(&buf, ",cores=%u", 1);
             virBufferAsprintf(&buf, ",threads=%u", 1);
         }
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f879060..da66ee7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4911,10 +4911,10 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
     }

     if (def)
-        maxvcpus = def->maxvcpus;
+        maxvcpus = virDomainDefGetVCpusMax(def);
     if (persistentDef) {
-        if (!maxvcpus || maxvcpus > persistentDef->maxvcpus)
-            maxvcpus = persistentDef->maxvcpus;
+        if (!maxvcpus || maxvcpus > virDomainDefGetVCpusMax(persistentDef))
+            maxvcpus = virDomainDefGetVCpusMax(persistentDef);
     }
     if (!(flags & VIR_DOMAIN_VCPU_MAXIMUM) && nvcpus > maxvcpus) {
         virReportError(VIR_ERR_INVALID_ARG,
@@ -5557,7 +5557,7 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
         }
     } else {
         if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
-            ret = def->maxvcpus;
+            ret = virDomainDefGetVCpusMax(def);
         else
             ret = def->vcpus;
     }
@@ -19078,7 +19078,7 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
                               &record->nparams,
                               maxparams,
                               "vcpu.maximum",
-                              (unsigned) dom->def->maxvcpus) < 0)
+                              virDomainDefGetVCpusMax(dom->def)) < 0)
         return -1;

     if (VIR_ALLOC_N(cpuinfo, dom->def->vcpus) < 0)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 2192ad8..0706ee3 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3921,7 +3921,7 @@ qemuValidateCpuMax(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
     if (!maxCpus)
         return true;

-    if (def->maxvcpus > maxCpus) {
+    if (virDomainDefGetVCpusMax(def) > maxCpus) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        "%s", _("Maximum CPUs greater than specified machine type limit"));
         return false;
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index cfd7bdc..4043928 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2312,7 +2312,10 @@ testDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
     if (!(def = virDomainObjGetOneDef(vm, flags)))
         goto cleanup;

-    ret = (flags & VIR_DOMAIN_VCPU_MAXIMUM) ? def->maxvcpus : def->vcpus;
+    if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
+        ret = virDomainDefGetVCpusMax(def);
+    else
+        ret = def->vcpus;

  cleanup:
     virDomainObjEndAPI(&vm);
@@ -2355,19 +2358,19 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus,
     if (virDomainObjGetDefs(privdom, flags, &def, &persistentDef) < 0)
         goto cleanup;

-    if (def && def->maxvcpus < nrCpus) {
+    if (def && virDomainDefGetVCpusMax(def) < nrCpus) {
         virReportError(VIR_ERR_INVALID_ARG,
                        _("requested cpu amount exceeds maximum (%d > %d)"),
-                       nrCpus, def->maxvcpus);
+                       nrCpus, virDomainDefGetVCpusMax(def));
         goto cleanup;
     }

     if (persistentDef &&
         !(flags & VIR_DOMAIN_VCPU_MAXIMUM) &&
-        persistentDef->maxvcpus < nrCpus) {
+        virDomainDefGetVCpusMax(persistentDef) < nrCpus) {
         virReportError(VIR_ERR_INVALID_ARG,
                        _("requested cpu amount exceeds maximum (%d > %d)"),
-                       nrCpus, persistentDef->maxvcpus);
+                       nrCpus, virDomainDefGetVCpusMax(persistentDef));
         goto cleanup;
     }

diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 4c88fa9..a05b438 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -1895,11 +1895,11 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("current vcpu count must equal maximum"));
     }
-    rc = gVBoxAPI.UIMachine.SetCPUCount(machine, def->maxvcpus);
+    rc = gVBoxAPI.UIMachine.SetCPUCount(machine, virDomainDefGetVCpusMax(def));
     if (NS_FAILED(rc)) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("could not set the number of virtual CPUs to: %u, rc=%08x"),
-                       def->maxvcpus, (unsigned)rc);
+                       virDomainDefGetVCpusMax(def), (unsigned)rc);
     }

     rc = gVBoxAPI.UIMachine.SetCPUProperty(machine, CPUPropertyType_PAE,
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 0223e94..44f76f2 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -3066,6 +3066,7 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
     bool scsi_present[4] = { false, false, false, false };
     int scsi_virtualDev[4] = { -1, -1, -1, -1 };
     bool floppy_present[2] = { false, false };
+    unsigned int maxvcpus;

     if (ctx->formatFileName == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -3181,15 +3182,16 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
                          "'current'"));
         goto cleanup;
     }
-    if ((def->maxvcpus % 2 != 0 && def->maxvcpus != 1)) {
+    maxvcpus = virDomainDefGetVCpusMax(def);
+    if (maxvcpus % 2 != 0 && maxvcpus != 1) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Expecting domain XML entry 'vcpu' to be 1 or a "
-                         "multiple of 2 but found %d"),
-                       def->maxvcpus);
+                       _("Expecting domain XML entry 'vcpu' to be an unsigned "
+                         "integer (1 or a multiple of 2) but found %d"),
+                       maxvcpus);
         goto cleanup;
     }

-    virBufferAsprintf(&buffer, "numvcpus = \"%d\"\n", def->maxvcpus);
+    virBufferAsprintf(&buffer, "numvcpus = \"%d\"\n", maxvcpus);

     /* def:cpumask -> vmx:sched.cpu.affinity */
     if (def->cpumask && virBitmapSize(def->cpumask) > 0) {
@@ -3202,11 +3204,11 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
         while ((bit = virBitmapNextSetBit(def->cpumask, bit)) >= 0)
             ++sched_cpu_affinity_length;

-        if (sched_cpu_affinity_length < def->maxvcpus) {
+        if (sched_cpu_affinity_length < maxvcpus) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Expecting domain XML attribute 'cpuset' of entry "
                              "'vcpu' to contain at least %d CPU(s)"),
-                           def->maxvcpus);
+                           maxvcpus);
             goto cleanup;
         }

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 39f58a4..c4a46ee 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -1372,7 +1372,7 @@ vzDomainGetVcpusFlags(virDomainPtr dom,
         goto cleanup;

     if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
-        ret = privdom->def->maxvcpus;
+        ret = virDomainDefGetVCpusMax(privdom->def);
     else
         ret = privdom->def->vcpus;

diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 2838525..b7b78d7 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -695,7 +695,8 @@ xenXMDomainSetVcpusFlags(virConnectPtr conn,
     /* Can't specify a current larger than stored maximum; but
      * reducing maximum can silently reduce current.  */
     if (!(flags & VIR_DOMAIN_VCPU_MAXIMUM))
-        max = entry->def->maxvcpus;
+        max = virDomainDefGetVCpusMax(entry->def);
+
     if (vcpus > max) {
         virReportError(VIR_ERR_INVALID_ARG,
                        _("requested vcpus is greater than max allowable"
@@ -760,8 +761,10 @@ xenXMDomainGetVcpusFlags(virConnectPtr conn,
     if (!(entry = virHashLookup(priv->configCache, filename)))
         goto cleanup;

-    ret = ((flags & VIR_DOMAIN_VCPU_MAXIMUM) ? entry->def->maxvcpus
-           : entry->def->vcpus);
+    if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
+        ret = virDomainDefGetVCpusMax(entry->def);
+    else
+        ret = entry->def->vcpus;

  cleanup:
     xenUnifiedUnlock(priv);
diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index a80e084..d40f959 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -504,10 +504,8 @@ createVMRecordFromXml(virConnectPtr conn, virDomainDefPtr def,
     else
         (*record)->memory_dynamic_max = (*record)->memory_static_max;

-    if (def->maxvcpus) {
-        (*record)->vcpus_max = (int64_t) def->maxvcpus;
-        (*record)->vcpus_at_startup = (int64_t) def->vcpus;
-    }
+    (*record)->vcpus_max = (int64_t) virDomainDefGetVCpusMax(def);
+    (*record)->vcpus_at_startup = (int64_t) def->vcpus;
     if (def->onPoweroff)
         (*record)->actions_after_shutdown = actionShutdownLibvirt2XenapiEnum(def->onPoweroff);
     if (def->onReboot)
diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index e21576d..deea68b 100644
--- a/src/xenconfig/xen_common.c
+++ b/src/xenconfig/xen_common.c
@@ -508,7 +508,7 @@ xenParseCPUFeatures(virConfPtr conf, virDomainDefPtr def)
     if (xenConfigGetULong(conf, "vcpu_avail", &count, -1) < 0)
         return -1;

-    def->vcpus = MIN(count_one_bits_l(count), def->maxvcpus);
+    def->vcpus = MIN(count_one_bits_l(count), virDomainDefGetVCpusMax(def));
     if (xenConfigGetString(conf, "cpus", &str, NULL) < 0)
         return -1;

@@ -1526,7 +1526,7 @@ xenFormatCPUAllocation(virConfPtr conf, virDomainDefPtr def)
     int ret = -1;
     char *cpus = NULL;

-    if (xenConfigSetInt(conf, "vcpus", def->maxvcpus) < 0)
+    if (xenConfigSetInt(conf, "vcpus", virDomainDefGetVCpusMax(def)) < 0)
         goto cleanup;

     /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c
index 505ef76..d984305 100644
--- a/src/xenconfig/xen_sxpr.c
+++ b/src/xenconfig/xen_sxpr.c
@@ -1176,8 +1176,8 @@ xenParseSxpr(const struct sexpr *root,
     if (virDomainDefSetVCpusMax(def, sexpr_int(root, "domain/vcpus")) < 0)
         goto error;
     def->vcpus = count_one_bits_l(sexpr_u64(root, "domain/vcpu_avail"));
-    if (!def->vcpus || def->maxvcpus < def->vcpus)
-        def->vcpus = def->maxvcpus;
+    if (!def->vcpus || virDomainDefGetVCpusMax(def) < def->vcpus)
+        def->vcpus = virDomainDefGetVCpusMax(def);

     tmp = sexpr_node(root, "domain/on_poweroff");
     if (tmp != NULL) {
@@ -2223,7 +2223,7 @@ xenFormatSxpr(virConnectPtr conn,
     virBufferAsprintf(&buf, "(memory %llu)(maxmem %llu)",
                       VIR_DIV_UP(def->mem.cur_balloon, 1024),
                       VIR_DIV_UP(virDomainDefGetMemoryActual(def), 1024));
-    virBufferAsprintf(&buf, "(vcpus %u)", def->maxvcpus);
+    virBufferAsprintf(&buf, "(vcpus %u)", virDomainDefGetVCpusMax(def));
     /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
        either 32, or 64 on a platform where long is big enough.  */
     if (virDomainDefHasVCpusOffline(def))
@@ -2307,7 +2307,7 @@ xenFormatSxpr(virConnectPtr conn,
             else
                 virBufferEscapeSexpr(&buf, "(kernel '%s')", def->os.loader->path);

-            virBufferAsprintf(&buf, "(vcpus %u)", def->maxvcpus);
+            virBufferAsprintf(&buf, "(vcpus %u)", virDomainDefGetVCpusMax(def));
             if (virDomainDefHasVCpusOffline(def))
                 virBufferAsprintf(&buf, "(vcpu_avail %lu)",
                                   (1UL << def->vcpus) - 1);
-- 
2.6.2

--
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]