[PATCH 14/34] conf: Replace read accesses to def->vcpus with accessor

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

 



---
 src/conf/domain_audit.c    |  2 +-
 src/conf/domain_conf.c     | 19 +++++++++++++------
 src/conf/domain_conf.h     |  1 +
 src/libvirt_private.syms   |  1 +
 src/libxl/libxl_conf.c     |  2 +-
 src/libxl/libxl_driver.c   |  8 ++++----
 src/lxc/lxc_controller.c   |  2 +-
 src/lxc/lxc_driver.c       |  2 +-
 src/openvz/openvz_driver.c |  2 +-
 src/phyp/phyp_driver.c     |  5 +++--
 src/qemu/qemu_command.c    |  2 +-
 src/qemu/qemu_driver.c     | 36 ++++++++++++++++++------------------
 src/qemu/qemu_process.c    | 10 +++++-----
 src/test/test_driver.c     | 14 +++++++-------
 src/uml/uml_driver.c       |  2 +-
 src/vmware/vmware_driver.c |  2 +-
 src/vmx/vmx.c              | 14 ++++++++------
 src/xen/xm_internal.c      |  4 ++--
 src/xenapi/xenapi_utils.c  |  2 +-
 src/xenconfig/xen_common.c |  3 ++-
 src/xenconfig/xen_sxpr.c   |  5 +++--
 21 files changed, 76 insertions(+), 62 deletions(-)

diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index b842495..332d975 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -885,7 +885,7 @@ virDomainAuditStart(virDomainObjPtr vm, const char *reason, bool success)

     virDomainAuditMemory(vm, 0, virDomainDefGetMemoryActual(vm->def),
                          "start", true);
-    virDomainAuditVcpu(vm, 0, vm->def->vcpus, "start", true);
+    virDomainAuditVcpu(vm, 0, virDomainDefGetVCpus(vm->def), "start", true);
     if (vm->def->niothreadids)
         virDomainAuditIOThread(vm, 0, vm->def->niothreadids, "start", true);

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3062b3a..e8a3d10 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1474,6 +1474,13 @@ virDomainDefSetVCpus(virDomainDefPtr def,
 }


+unsigned int
+virDomainDefGetVCpus(const virDomainDef *def)
+{
+    return def->vcpus;
+}
+
+
 virDomainDiskDefPtr
 virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt)
 {
@@ -15200,7 +15207,7 @@ virDomainDefParseXML(xmlDocPtr xml,
             goto error;
         }

-        if (vcpupin->id >= def->vcpus) {
+        if (vcpupin->id >= virDomainDefGetVCpus(def)) {
             /* To avoid the regression when daemon loading
              * domain confs, we can't simply error out if
              * <vcpupin> nodes greater than current vcpus,
@@ -15218,10 +15225,10 @@ virDomainDefParseXML(xmlDocPtr xml,
      * the policy specified explicitly as def->cpuset.
      */
     if (def->cpumask) {
-        if (VIR_REALLOC_N(def->cputune.vcpupin, def->vcpus) < 0)
+        if (VIR_REALLOC_N(def->cputune.vcpupin, virDomainDefGetVCpus(def)) < 0)
             goto error;

-        for (i = 0; i < def->vcpus; i++) {
+        for (i = 0; i < virDomainDefGetVCpus(def); i++) {
             if (virDomainPinIsDuplicate(def->cputune.vcpupin,
                                         def->cputune.nvcpupin,
                                         i))
@@ -17858,10 +17865,10 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
         goto error;
     }

-    if (src->vcpus != dst->vcpus) {
+    if (virDomainDefGetVCpus(src) != virDomainDefGetVCpus(dst)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("Target domain vCPU count %d does not match source %d"),
-                       dst->vcpus, src->vcpus);
+                       virDomainDefGetVCpus(dst), virDomainDefGetVCpus(src));
         goto error;
     }
     if (virDomainDefGetVCpusMax(src) != virDomainDefGetVCpusMax(dst)) {
@@ -21826,7 +21833,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
         VIR_FREE(cpumask);
     }
     if (virDomainDefHasVCpusOffline(def))
-        virBufferAsprintf(buf, " current='%u'", def->vcpus);
+        virBufferAsprintf(buf, " current='%u'", virDomainDefGetVCpus(def));
     virBufferAsprintf(buf, ">%u</vcpu>\n", virDomainDefGetVCpusMax(def));

     if (def->niothreadids > 0) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 44f707f..0845b2b 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2329,6 +2329,7 @@ int virDomainDefSetVCpusMax(virDomainDefPtr def, unsigned int vcpus);
 bool virDomainDefHasVCpusOffline(const virDomainDef *def);
 unsigned int virDomainDefGetVCpusMax(const virDomainDef *def);
 int virDomainDefSetVCpus(virDomainDefPtr def, unsigned int vcpus);
+unsigned int virDomainDefGetVCpus(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 b08c9c7..d2c4945 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -217,6 +217,7 @@ virDomainDefGetDefaultEmulator;
 virDomainDefGetMemoryActual;
 virDomainDefGetMemoryInitial;
 virDomainDefGetSecurityLabelDef;
+virDomainDefGetVCpus;
 virDomainDefGetVCpusMax;
 virDomainDefHasDeviceAddress;
 virDomainDefHasMemoryHotplug;
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 82ccb89..7600b7e 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -647,7 +647,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr 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++)
+    for (i = 0; i < virDomainDefGetVCpus(def); i++)
         libxl_bitmap_set((&b_info->avail_vcpus), i);

     if (def->clock.ntimers > 0 &&
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 8b225a4..c8b2557 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1601,7 +1601,7 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
     }

     info->state = virDomainObjGetState(vm, NULL);
-    info->nrVirtCpu = vm->def->vcpus;
+    info->nrVirtCpu = virDomainDefGetVCpus(vm->def);
     ret = 0;

  cleanup:
@@ -2304,7 +2304,7 @@ libxlDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
     if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
         ret = virDomainDefGetVCpusMax(def);
     else
-        ret = def->vcpus;
+        ret = virDomainDefGetVCpus(def);

  cleanup:
     if (vm)
@@ -2441,8 +2441,8 @@ libxlDomainGetVcpuPinInfo(virDomainPtr dom, int ncpumaps,
     sa_assert(targetDef);

     /* Clamp to actual number of vcpus */
-    if (ncpumaps > targetDef->vcpus)
-        ncpumaps = targetDef->vcpus;
+    if (ncpumaps > virDomainDefGetVCpus(targetDef))
+        ncpumaps = virDomainDefGetVCpus(targetDef);

     if ((hostcpus = libxl_get_max_cpus(cfg->ctx)) < 0)
         goto cleanup;
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 3e5d2b4..b9500f4 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -771,7 +771,7 @@ static int virLXCControllerGetNumadAdvice(virLXCControllerPtr ctrl,
      * either <vcpu> or <numatune> is 'auto'.
      */
     if (virDomainDefNeedsPlacementAdvice(ctrl->def)) {
-        nodeset = virNumaGetAutoPlacementAdvice(ctrl->def->vcpus,
+        nodeset = virNumaGetAutoPlacementAdvice(virDomainDefGetVCpus(ctrl->def),
                                                 ctrl->def->mem.cur_balloon);
         if (!nodeset)
             goto cleanup;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 1a9550e..fc82b4c 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -617,7 +617,7 @@ static int lxcDomainGetInfo(virDomainPtr dom,
     }

     info->maxMem = virDomainDefGetMemoryActual(vm->def);
-    info->nrVirtCpu = vm->def->vcpus;
+    info->nrVirtCpu = virDomainDefGetVCpus(vm->def);
     ret = 0;

  cleanup:
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 37c00b2..9146b1b 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -465,7 +465,7 @@ static int openvzDomainGetInfo(virDomainPtr dom,

     info->maxMem = virDomainDefGetMemoryActual(vm->def);
     info->memory = vm->def->mem.cur_balloon;
-    info->nrVirtCpu = vm->def->vcpus;
+    info->nrVirtCpu = virDomainDefGetVCpus(vm->def);
     ret = 0;

  cleanup:
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index a60b8b2..7bdb910 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -3525,11 +3525,12 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def)
     if (system_type == HMC)
         virBufferAsprintf(&buf, " -m %s", managed_system);
     virBufferAsprintf(&buf, " -r lpar -p %s -i min_mem=%lld,desired_mem=%lld,"
-                      "max_mem=%lld,desired_procs=%d,virtual_scsi_adapters=%s",
+                      "max_mem=%lld,desired_procs=%u,virtual_scsi_adapters=%s",
                       def->name, def->mem.cur_balloon,
                       def->mem.cur_balloon,
                       virDomainDefGetMemoryInitial(def),
-                      (int) def->vcpus, virDomainDiskGetSource(def->disks[0]));
+                      virDomainDefGetVCpus(def),
+                      virDomainDiskGetSource(def->disks[0]));
     ret = phypExecBuffer(session, &buf, &exit_status, conn, false);

     if (exit_status < 0) {
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 4a67361..b4eeb1d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7849,7 +7849,7 @@ qemuBuildSmpArgStr(const virDomainDef *def,
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;

-    virBufferAsprintf(&buf, "%u", def->vcpus);
+    virBufferAsprintf(&buf, "%u", virDomainDefGetVCpus(def));

     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SMP_TOPOLOGY)) {
         if (virDomainDefHasVCpusOffline(def))
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 632ffb5..95b9ede 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2659,7 +2659,7 @@ qemuDomainGetInfo(virDomainPtr dom,
         }
     }

-    if (VIR_ASSIGN_IS_OVERFLOW(info->nrVirtCpu, vm->def->vcpus)) {
+    if (VIR_ASSIGN_IS_OVERFLOW(info->nrVirtCpu, virDomainDefGetVCpus(vm->def))) {
         virReportError(VIR_ERR_OVERFLOW, "%s", _("cpu count too large"));
         goto cleanup;
     }
@@ -4700,7 +4700,7 @@ qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
     size_t i;
     int rc = 1;
     int ret = -1;
-    int oldvcpus = vm->def->vcpus;
+    int oldvcpus = virDomainDefGetVCpus(vm->def);
     int vcpus = oldvcpus;
     pid_t *cpupids = NULL;
     int ncpupids;
@@ -4929,11 +4929,11 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
         if (!qemuDomainAgentAvailable(vm, true))
             goto endjob;

-        if (nvcpus > vm->def->vcpus) {
+        if (nvcpus > virDomainDefGetVCpus(vm->def)) {
             virReportError(VIR_ERR_INVALID_ARG,
                            _("requested vcpu count is greater than the count "
                              "of enabled vcpus in the domain: %d > %d"),
-                           nvcpus, vm->def->vcpus);
+                           nvcpus, virDomainDefGetVCpus(vm->def));
             goto endjob;
         }

@@ -4972,8 +4972,8 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,

         if (persistentDef) {
             /* remove vcpupin entries for vcpus that were unplugged */
-            if (nvcpus < persistentDef->vcpus) {
-                for (i = persistentDef->vcpus - 1; i >= nvcpus; i--)
+            if (nvcpus < virDomainDefGetVCpus(persistentDef)) {
+                for (i = virDomainDefGetVCpus(persistentDef) - 1; i >= nvcpus; i--)
                     virDomainPinDel(&persistentDef->cputune.vcpupin,
                                     &persistentDef->cputune.nvcpupin,
                                     i);
@@ -5067,17 +5067,17 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,

     priv = vm->privateData;

-    if (def && vcpu >= def->vcpus) {
+    if (def && vcpu >= virDomainDefGetVCpus(def)) {
         virReportError(VIR_ERR_INVALID_ARG,
                        _("vcpu %d is out of range of live cpu count %d"),
-                       vcpu, def->vcpus);
+                       vcpu, virDomainDefGetVCpus(def));
         goto endjob;
     }

-    if (persistentDef && vcpu >= persistentDef->vcpus) {
+    if (persistentDef && vcpu >= virDomainDefGetVCpus(persistentDef)) {
         virReportError(VIR_ERR_INVALID_ARG,
                        _("vcpu %d is out of range of persistent cpu count %d"),
-                       vcpu, persistentDef->vcpus);
+                       vcpu, virDomainDefGetVCpus(persistentDef));
         goto endjob;
     }

@@ -5246,8 +5246,8 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom,
     priv = vm->privateData;

     /* Clamp to actual number of vcpus */
-    if (ncpumaps > def->vcpus)
-        ncpumaps = def->vcpus;
+    if (ncpumaps > virDomainDefGetVCpus(def))
+        ncpumaps = virDomainDefGetVCpus(def);

     if (ncpumaps < 1)
         goto cleanup;
@@ -5561,7 +5561,7 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
         if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
             ret = virDomainDefGetVCpusMax(def);
         else
-            ret = def->vcpus;
+            ret = virDomainDefGetVCpus(def);
     }


@@ -10587,7 +10587,7 @@ qemuGetVcpusBWLive(virDomainObjPtr vm,
             goto cleanup;

         if (*quota > 0)
-            *quota /= vm->def->vcpus;
+            *quota /= virDomainDefGetVCpus(vm->def);
         goto out;
     }

@@ -19073,7 +19073,7 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
                               &record->nparams,
                               maxparams,
                               "vcpu.current",
-                              (unsigned) dom->def->vcpus) < 0)
+                              virDomainDefGetVCpus(dom->def)) < 0)
         return -1;

     if (virTypedParamsAddUInt(&record->params,
@@ -19083,17 +19083,17 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
                               virDomainDefGetVCpusMax(dom->def)) < 0)
         return -1;

-    if (VIR_ALLOC_N(cpuinfo, dom->def->vcpus) < 0)
+    if (VIR_ALLOC_N(cpuinfo, virDomainDefGetVCpus(dom->def)) < 0)
         return -1;

-    if (qemuDomainHelperGetVcpus(dom, cpuinfo, dom->def->vcpus,
+    if (qemuDomainHelperGetVcpus(dom, cpuinfo, virDomainDefGetVCpus(dom->def),
                                  NULL, 0) < 0) {
         virResetLastError();
         ret = 0; /* it's ok to be silent and go ahead */
         goto cleanup;
     }

-    for (i = 0; i < dom->def->vcpus; i++) {
+    for (i = 0; i < virDomainDefGetVCpus(dom->def); i++) {
         snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
                  "vcpu.%zu.state", i);
         if (virTypedParamsAddInt(&record->params,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 0706ee3..721647f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2072,11 +2072,11 @@ qemuProcessDetectVcpuPIDs(virQEMUDriverPtr driver,
         return 0;
     }

-    if (ncpupids != vm->def->vcpus) {
+    if (ncpupids != virDomainDefGetVCpus(vm->def)) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("got wrong number of vCPU pids from QEMU monitor. "
                          "got %d, wanted %d"),
-                       ncpupids, vm->def->vcpus);
+                       ncpupids, virDomainDefGetVCpus(vm->def));
         VIR_FREE(cpupids);
         return -1;
     }
@@ -2292,7 +2292,7 @@ qemuProcessSetVcpuAffinities(virDomainObjPtr vm)
     int n;
     int ret = -1;
     VIR_DEBUG("Setting affinity on CPUs nvcpupin=%zu nvcpus=%d nvcpupids=%d",
-              def->cputune.nvcpupin, def->vcpus, priv->nvcpupids);
+              def->cputune.nvcpupin, virDomainDefGetVCpus(def), priv->nvcpupids);
     if (!def->cputune.nvcpupin)
         return 0;

@@ -2311,7 +2311,7 @@ qemuProcessSetVcpuAffinities(virDomainObjPtr vm)
         return 0;
     }

-    for (n = 0; n < def->vcpus; n++) {
+    for (n = 0; n < virDomainDefGetVCpus(def); n++) {
         /* set affinity only for existing vcpus */
         if (!(pininfo = virDomainPinFind(def->cputune.vcpupin,
                                          def->cputune.nvcpupin,
@@ -4678,7 +4678,7 @@ int qemuProcessStart(virConnectPtr conn,
      * either <vcpu> or <numatune> is 'auto'.
      */
     if (virDomainDefNeedsPlacementAdvice(vm->def)) {
-        nodeset = virNumaGetAutoPlacementAdvice(vm->def->vcpus,
+        nodeset = virNumaGetAutoPlacementAdvice(virDomainDefGetVCpus(vm->def),
                                                 virDomainDefGetMemoryActual(vm->def));
         if (!nodeset)
             goto error;
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 00f5c1e..ff28fcd 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1927,7 +1927,7 @@ static int testDomainGetInfo(virDomainPtr domain,
     info->state = virDomainObjGetState(privdom, NULL);
     info->memory = privdom->def->mem.cur_balloon;
     info->maxMem = virDomainDefGetMemoryActual(privdom->def);
-    info->nrVirtCpu = privdom->def->vcpus;
+    info->nrVirtCpu = virDomainDefGetVCpus(privdom->def);
     info->cpuTime = ((tv.tv_sec * 1000ll * 1000ll  * 1000ll) + (tv.tv_usec * 1000ll));
     ret = 0;

@@ -2315,7 +2315,7 @@ testDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
     if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
         ret = virDomainDefGetVCpusMax(def);
     else
-        ret = def->vcpus;
+        ret = virDomainDefGetVCpus(def);

  cleanup:
     virDomainObjEndAPI(&vm);
@@ -2447,8 +2447,8 @@ static int testDomainGetVcpus(virDomainPtr domain,
     virBitmapSetAll(allcpumap);

     /* Clamp to actual number of vcpus */
-    if (maxinfo > privdom->def->vcpus)
-        maxinfo = privdom->def->vcpus;
+    if (maxinfo > virDomainDefGetVCpus(privdom->def))
+        maxinfo = virDomainDefGetVCpus(privdom->def);

     memset(info, 0, sizeof(*info) * maxinfo);
     memset(cpumaps, 0, maxinfo * maplen);
@@ -2506,7 +2506,7 @@ static int testDomainPinVcpu(virDomainPtr domain,
         goto cleanup;
     }

-    if (vcpu > privdom->def->vcpus) {
+    if (vcpu > virDomainDefGetVCpus(privdom->def)) {
         virReportError(VIR_ERR_INVALID_ARG, "%s",
                        _("requested vcpu is higher than allocated vcpus"));
         goto cleanup;
@@ -2560,8 +2560,8 @@ testDomainGetVcpuPinInfo(virDomainPtr dom,
     virBitmapSetAll(allcpumap);

     /* Clamp to actual number of vcpus */
-    if (ncpumaps > def->vcpus)
-        ncpumaps = def->vcpus;
+    if (ncpumaps > virDomainDefGetVCpus(def))
+        ncpumaps = virDomainDefGetVCpus(def);

     for (vcpu = 0; vcpu < ncpumaps; vcpu++) {
         virDomainPinDefPtr pininfo;
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 14598fc..aad4745 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -1916,7 +1916,7 @@ static int umlDomainGetInfo(virDomainPtr dom,

     info->maxMem = virDomainDefGetMemoryActual(vm->def);
     info->memory = vm->def->mem.cur_balloon;
-    info->nrVirtCpu = vm->def->vcpus;
+    info->nrVirtCpu = virDomainDefGetVCpus(vm->def);
     ret = 0;

  cleanup:
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index a12b03a..f793adc 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -1142,7 +1142,7 @@ vmwareDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
     info->cpuTime = 0;
     info->maxMem = virDomainDefGetMemoryActual(vm->def);
     info->memory = vm->def->mem.cur_balloon;
-    info->nrVirtCpu = vm->def->vcpus;
+    info->nrVirtCpu = virDomainDefGetVCpus(vm->def);
     ret = 0;

  cleanup:
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 62636a9..654e431 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -1539,13 +1539,14 @@ virVMXParseConfig(virVMXContext *ctx,
     }

     if (sched_cpu_shares != NULL) {
+        unsigned int vcpus = virDomainDefGetVCpus(def);
         /* See http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.SharesInfo.Level.html */
         if (STRCASEEQ(sched_cpu_shares, "low")) {
-            def->cputune.shares = def->vcpus * 500;
+            def->cputune.shares = vcpus * 500;
         } else if (STRCASEEQ(sched_cpu_shares, "normal")) {
-            def->cputune.shares = def->vcpus * 1000;
+            def->cputune.shares = vcpus * 1000;
         } else if (STRCASEEQ(sched_cpu_shares, "high")) {
-            def->cputune.shares = def->vcpus * 2000;
+            def->cputune.shares = vcpus * 2000;
         } else if (virStrToLong_ul(sched_cpu_shares, NULL, 10,
                                    &def->cputune.shares) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -3228,12 +3229,13 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe

     /* def:cputune.shares -> vmx:sched.cpu.shares */
     if (def->cputune.sharesSpecified) {
+        unsigned int vcpus = virDomainDefGetVCpus(def);
         /* See http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.SharesInfo.Level.html */
-        if (def->cputune.shares == def->vcpus * 500) {
+        if (def->cputune.shares == vcpus * 500) {
             virBufferAddLit(&buffer, "sched.cpu.shares = \"low\"\n");
-        } else if (def->cputune.shares == def->vcpus * 1000) {
+        } else if (def->cputune.shares == vcpus * 1000) {
             virBufferAddLit(&buffer, "sched.cpu.shares = \"normal\"\n");
-        } else if (def->cputune.shares == def->vcpus * 2000) {
+        } else if (def->cputune.shares == vcpus * 2000) {
             virBufferAddLit(&buffer, "sched.cpu.shares = \"high\"\n");
         } else {
             virBufferAsprintf(&buffer, "sched.cpu.shares = \"%lu\"\n",
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 374cc41..7e227bc 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -483,7 +483,7 @@ xenXMDomainGetInfo(virConnectPtr conn,
     memset(info, 0, sizeof(virDomainInfo));
     info->maxMem = virDomainDefGetMemoryActual(entry->def);
     info->memory = entry->def->mem.cur_balloon;
-    info->nrVirtCpu = entry->def->vcpus;
+    info->nrVirtCpu = virDomainDefGetVCpus(entry->def);
     info->state = VIR_DOMAIN_SHUTOFF;
     info->cpuTime = 0;

@@ -765,7 +765,7 @@ xenXMDomainGetVcpusFlags(virConnectPtr conn,
     if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
         ret = virDomainDefGetVCpusMax(entry->def);
     else
-        ret = entry->def->vcpus;
+        ret = virDomainDefGetVCpus(entry->def);

  cleanup:
     xenUnifiedUnlock(priv);
diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index d40f959..6f33e8a 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -505,7 +505,7 @@ createVMRecordFromXml(virConnectPtr conn, virDomainDefPtr def,
         (*record)->memory_dynamic_max = (*record)->memory_static_max;

     (*record)->vcpus_max = (int64_t) virDomainDefGetVCpusMax(def);
-    (*record)->vcpus_at_startup = (int64_t) def->vcpus;
+    (*record)->vcpus_at_startup = (int64_t) virDomainDefGetVCpus(def);
     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 d617773..cbde572 100644
--- a/src/xenconfig/xen_common.c
+++ b/src/xenconfig/xen_common.c
@@ -1535,7 +1535,8 @@ xenFormatCPUAllocation(virConfPtr conf, virDomainDefPtr 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) &&
-        xenConfigSetInt(conf, "vcpu_avail", (1UL << def->vcpus) - 1) < 0)
+        xenConfigSetInt(conf, "vcpu_avail",
+                        (1UL << virDomainDefGetVCpus(def)) - 1) < 0)
         goto cleanup;

     if ((def->cpumask != NULL) &&
diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c
index 534130e..32c5e08 100644
--- a/src/xenconfig/xen_sxpr.c
+++ b/src/xenconfig/xen_sxpr.c
@@ -2231,7 +2231,8 @@ xenFormatSxpr(virConnectPtr conn,
     /* 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))
-        virBufferAsprintf(&buf, "(vcpu_avail %lu)", (1UL << def->vcpus) - 1);
+        virBufferAsprintf(&buf, "(vcpu_avail %lu)",
+                          (1UL << virDomainDefGetVCpus(def)) - 1);

     if (def->cpumask) {
         char *ranges = virBitmapFormat(def->cpumask);
@@ -2314,7 +2315,7 @@ xenFormatSxpr(virConnectPtr conn,
             virBufferAsprintf(&buf, "(vcpus %u)", virDomainDefGetVCpusMax(def));
             if (virDomainDefHasVCpusOffline(def))
                 virBufferAsprintf(&buf, "(vcpu_avail %lu)",
-                                  (1UL << def->vcpus) - 1);
+                                  (1UL << virDomainDefGetVCpus(def)) - 1);

             for (i = 0; i < def->os.nBootDevs; i++) {
                 switch (def->os.bootDevs[i]) {
-- 
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]