mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
conf: Replace read accesses to def->vcpus with accessor
This commit is contained in:
parent
80a8ac3c1e
commit
71c89ac9df
@ -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");
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
||||
|
@ -1328,6 +1328,13 @@ virDomainDefSetVcpus(virDomainDefPtr def,
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
virDomainDefGetVcpus(const virDomainDef *def)
|
||||
{
|
||||
return def->vcpus;
|
||||
}
|
||||
|
||||
|
||||
virDomainDiskDefPtr
|
||||
virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt)
|
||||
{
|
||||
@ -14918,7 +14925,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,
|
||||
@ -14936,10 +14943,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))
|
||||
@ -17572,10 +17579,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)) {
|
||||
@ -21551,7 +21558,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) {
|
||||
|
@ -2347,6 +2347,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);
|
||||
|
@ -217,6 +217,7 @@ virDomainDefGetDefaultEmulator;
|
||||
virDomainDefGetMemoryActual;
|
||||
virDomainDefGetMemoryInitial;
|
||||
virDomainDefGetSecurityLabelDef;
|
||||
virDomainDefGetVcpus;
|
||||
virDomainDefGetVcpusMax;
|
||||
virDomainDefHasDeviceAddress;
|
||||
virDomainDefHasMemoryHotplug;
|
||||
|
@ -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 &&
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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) {
|
||||
|
@ -7959,7 +7959,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))
|
||||
|
@ -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,
|
||||
|
@ -2020,11 +2020,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;
|
||||
}
|
||||
@ -2240,7 +2240,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;
|
||||
|
||||
@ -2259,7 +2259,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,
|
||||
@ -4670,7 +4670,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;
|
||||
|
@ -1928,7 +1928,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;
|
||||
|
||||
@ -2316,7 +2316,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);
|
||||
@ -2448,8 +2448,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);
|
||||
@ -2507,7 +2507,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;
|
||||
@ -2561,8 +2561,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;
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -1540,13 +1540,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,
|
||||
@ -3233,12 +3234,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",
|
||||
|
@ -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)
|
||||
|
@ -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)))
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -1537,7 +1537,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) &&
|
||||
|
@ -2246,7 +2246,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);
|
||||
@ -2329,7 +2330,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]) {
|
||||
|
Loading…
Reference in New Issue
Block a user