---
src/bhyve/bhyve_command.c | 2 +-
src/bhyve/bhyve_driver.c | 2 +-
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/vz/vz_driver.c | 6 +++---
src/vz/vz_sdk.c | 4 ++--
src/xen/xm_internal.c | 4 ++--
src/xenapi/xenapi_utils.c | 2 +-
src/xenconfig/xen_common.c | 3 ++-
src/xenconfig/xen_sxpr.c | 5 +++--
25 files changed, 83 insertions(+), 69 deletions(-)
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index 6576029..5f3055d 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -232,7 +232,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
/* CPUs */
virCommandAddArg(cmd, "-c");
- virCommandAddArgFormat(cmd, "%d", def->vcpus);
+ virCommandAddArgFormat(cmd, "%d", virDomainDefGetVcpus(def));
/* Memory */
virCommandAddArg(cmd, "-m");
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 4840a0e..0289e4a 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -304,7 +304,7 @@ bhyveDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
info->state = virDomainObjGetState(vm, NULL);
info->maxMem = virDomainDefGetMemoryActual(vm->def);
- info->nrVirtCpu = vm->def->vcpus;
+ info->nrVirtCpu = virDomainDefGetVcpus(vm->def);
ret = 0;
cleanup:
diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index b842495..bd2eeb6 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 a2cb894..890e1c7 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)
{
@@ -15235,7 +15242,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,
@@ -15253,10 +15260,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))
@@ -17879,10 +17886,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)) {
@@ -21851,7 +21858,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 bab8a5e..d7630c4 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2341,6 +2341,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 d9a0d4b..6fb36c3 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 35089ea..23c74e7 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 905b392..1c3da06 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..438103a 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..567dc1d 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 2a9e6ac..3a4a342 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 3d086e3..cf674a0 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 ccea41b..7ecaa66 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7863,7 +7863,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 f07d7a7..cfcc789 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 a2d2bfd..a3ddb4a 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2021,11 +2021,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;
}
@@ -2241,7 +2241,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;
@@ -2260,7 +2260,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,
@@ -4667,7 +4667,7 @@ qemuProcessLaunch(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 cleanup;
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index c9e3eba..f135365 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..fc0ca67 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..f23b67f 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 bcc4034..b020b6f 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/v...
*/
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/v...
*/
- 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/vz/vz_driver.c b/src/vz/vz_driver.c
index 994720c..2ef47e4 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -560,14 +560,14 @@ vzDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
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 = 0;
if (virDomainObjIsActive(privdom)) {
unsigned long long vtime;
size_t i;
- for (i = 0; i < privdom->def->vcpus; ++i) {
+ for (i = 0; i < virDomainDefGetVcpus(privdom->def); ++i) {
if (prlsdkGetVcpuStats(privdom, i, &vtime) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("cannot read cputime for domain"));
@@ -1374,7 +1374,7 @@ vzDomainGetVcpusFlags(virDomainPtr dom,
if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
ret = virDomainDefGetVcpusMax(privdom->def);
else
- ret = privdom->def->vcpus;
+ ret = virDomainDefGetVcpus(privdom->def);
cleanup:
if (privdom)
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 890dd52..970c258 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -1958,7 +1958,7 @@ prlsdkCheckUnsupportedParams(PRL_HANDLE sdkdom, virDomainDefPtr
def)
}
if (def->cputune.vcpupin) {
- for (i = 0; i < def->vcpus; i++) {
+ for (i = 0; i < virDomainDefGetVcpus(def); i++) {
if (!virBitmapEqual(def->cpumask,
def->cputune.vcpupin[i]->cpumask)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -3501,7 +3501,7 @@ prlsdkDoApplyConfig(virConnectPtr conn,
pret = PrlVmCfg_SetRamSize(sdkdom, virDomainDefGetMemoryActual(def) >> 10);
prlsdkCheckRetGoto(pret, error);
- pret = PrlVmCfg_SetCpuCount(sdkdom, def->vcpus);
+ pret = PrlVmCfg_SetCpuCount(sdkdom, virDomainDefGetVcpus(def));
prlsdkCheckRetGoto(pret, error);
if (!(mask = virBitmapFormat(def->cpumask)))
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 4a7d0de..0b7c71d 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 7ceb56a..5d6da36 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -506,7 +506,7 @@ createVMRecordFromXml(virConnectPtr conn, virDomainDefPtr def,
if (virDomainDefGetVcpusMax(def) > 0) {
(*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);
diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index d11a919..c8cb848 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 28b8e4e..a6938c6 100644
--- a/src/xenconfig/xen_sxpr.c
+++ b/src/xenconfig/xen_sxpr.c
@@ -2232,7 +2232,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);
@@ -2315,7 +2316,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