mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +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 */
|
/* CPUs */
|
||||||
virCommandAddArg(cmd, "-c");
|
virCommandAddArg(cmd, "-c");
|
||||||
virCommandAddArgFormat(cmd, "%d", def->vcpus);
|
virCommandAddArgFormat(cmd, "%d", virDomainDefGetVcpus(def));
|
||||||
|
|
||||||
/* Memory */
|
/* Memory */
|
||||||
virCommandAddArg(cmd, "-m");
|
virCommandAddArg(cmd, "-m");
|
||||||
|
@ -304,7 +304,7 @@ bhyveDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
|
|
||||||
info->state = virDomainObjGetState(vm, NULL);
|
info->state = virDomainObjGetState(vm, NULL);
|
||||||
info->maxMem = virDomainDefGetMemoryActual(vm->def);
|
info->maxMem = virDomainDefGetMemoryActual(vm->def);
|
||||||
info->nrVirtCpu = vm->def->vcpus;
|
info->nrVirtCpu = virDomainDefGetVcpus(vm->def);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -885,7 +885,7 @@ virDomainAuditStart(virDomainObjPtr vm, const char *reason, bool success)
|
|||||||
|
|
||||||
virDomainAuditMemory(vm, 0, virDomainDefGetMemoryActual(vm->def),
|
virDomainAuditMemory(vm, 0, virDomainDefGetMemoryActual(vm->def),
|
||||||
"start", true);
|
"start", true);
|
||||||
virDomainAuditVcpu(vm, 0, vm->def->vcpus, "start", true);
|
virDomainAuditVcpu(vm, 0, virDomainDefGetVcpus(vm->def), "start", true);
|
||||||
if (vm->def->niothreadids)
|
if (vm->def->niothreadids)
|
||||||
virDomainAuditIOThread(vm, 0, vm->def->niothreadids, "start", true);
|
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
|
virDomainDiskDefPtr
|
||||||
virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt)
|
virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt)
|
||||||
{
|
{
|
||||||
@ -14918,7 +14925,7 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vcpupin->id >= def->vcpus) {
|
if (vcpupin->id >= virDomainDefGetVcpus(def)) {
|
||||||
/* To avoid the regression when daemon loading
|
/* To avoid the regression when daemon loading
|
||||||
* domain confs, we can't simply error out if
|
* domain confs, we can't simply error out if
|
||||||
* <vcpupin> nodes greater than current vcpus,
|
* <vcpupin> nodes greater than current vcpus,
|
||||||
@ -14936,10 +14943,10 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|||||||
* the policy specified explicitly as def->cpuset.
|
* the policy specified explicitly as def->cpuset.
|
||||||
*/
|
*/
|
||||||
if (def->cpumask) {
|
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;
|
goto error;
|
||||||
|
|
||||||
for (i = 0; i < def->vcpus; i++) {
|
for (i = 0; i < virDomainDefGetVcpus(def); i++) {
|
||||||
if (virDomainPinIsDuplicate(def->cputune.vcpupin,
|
if (virDomainPinIsDuplicate(def->cputune.vcpupin,
|
||||||
def->cputune.nvcpupin,
|
def->cputune.nvcpupin,
|
||||||
i))
|
i))
|
||||||
@ -17572,10 +17579,10 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src->vcpus != dst->vcpus) {
|
if (virDomainDefGetVcpus(src) != virDomainDefGetVcpus(dst)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("Target domain vCPU count %d does not match source %d"),
|
_("Target domain vCPU count %d does not match source %d"),
|
||||||
dst->vcpus, src->vcpus);
|
virDomainDefGetVcpus(dst), virDomainDefGetVcpus(src));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (virDomainDefGetVcpusMax(src) != virDomainDefGetVcpusMax(dst)) {
|
if (virDomainDefGetVcpusMax(src) != virDomainDefGetVcpusMax(dst)) {
|
||||||
@ -21551,7 +21558,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
|
|||||||
VIR_FREE(cpumask);
|
VIR_FREE(cpumask);
|
||||||
}
|
}
|
||||||
if (virDomainDefHasVcpusOffline(def))
|
if (virDomainDefHasVcpusOffline(def))
|
||||||
virBufferAsprintf(buf, " current='%u'", def->vcpus);
|
virBufferAsprintf(buf, " current='%u'", virDomainDefGetVcpus(def));
|
||||||
virBufferAsprintf(buf, ">%u</vcpu>\n", virDomainDefGetVcpusMax(def));
|
virBufferAsprintf(buf, ">%u</vcpu>\n", virDomainDefGetVcpusMax(def));
|
||||||
|
|
||||||
if (def->niothreadids > 0) {
|
if (def->niothreadids > 0) {
|
||||||
|
@ -2347,6 +2347,7 @@ int virDomainDefSetVcpusMax(virDomainDefPtr def, unsigned int vcpus);
|
|||||||
bool virDomainDefHasVcpusOffline(const virDomainDef *def);
|
bool virDomainDefHasVcpusOffline(const virDomainDef *def);
|
||||||
unsigned int virDomainDefGetVcpusMax(const virDomainDef *def);
|
unsigned int virDomainDefGetVcpusMax(const virDomainDef *def);
|
||||||
int virDomainDefSetVcpus(virDomainDefPtr def, unsigned int vcpus);
|
int virDomainDefSetVcpus(virDomainDefPtr def, unsigned int vcpus);
|
||||||
|
unsigned int virDomainDefGetVcpus(const virDomainDef *def);
|
||||||
|
|
||||||
unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def);
|
unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def);
|
||||||
void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
|
void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
|
||||||
|
@ -217,6 +217,7 @@ virDomainDefGetDefaultEmulator;
|
|||||||
virDomainDefGetMemoryActual;
|
virDomainDefGetMemoryActual;
|
||||||
virDomainDefGetMemoryInitial;
|
virDomainDefGetMemoryInitial;
|
||||||
virDomainDefGetSecurityLabelDef;
|
virDomainDefGetSecurityLabelDef;
|
||||||
|
virDomainDefGetVcpus;
|
||||||
virDomainDefGetVcpusMax;
|
virDomainDefGetVcpusMax;
|
||||||
virDomainDefHasDeviceAddress;
|
virDomainDefHasDeviceAddress;
|
||||||
virDomainDefHasMemoryHotplug;
|
virDomainDefHasMemoryHotplug;
|
||||||
|
@ -647,7 +647,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
|
|||||||
if (libxl_cpu_bitmap_alloc(ctx, &b_info->avail_vcpus, b_info->max_vcpus))
|
if (libxl_cpu_bitmap_alloc(ctx, &b_info->avail_vcpus, b_info->max_vcpus))
|
||||||
return -1;
|
return -1;
|
||||||
libxl_bitmap_set_none(&b_info->avail_vcpus);
|
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);
|
libxl_bitmap_set((&b_info->avail_vcpus), i);
|
||||||
|
|
||||||
if (def->clock.ntimers > 0 &&
|
if (def->clock.ntimers > 0 &&
|
||||||
|
@ -1601,7 +1601,7 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
info->state = virDomainObjGetState(vm, NULL);
|
info->state = virDomainObjGetState(vm, NULL);
|
||||||
info->nrVirtCpu = vm->def->vcpus;
|
info->nrVirtCpu = virDomainDefGetVcpus(vm->def);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -2304,7 +2304,7 @@ libxlDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
|
|||||||
if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
|
if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
|
||||||
ret = virDomainDefGetVcpusMax(def);
|
ret = virDomainDefGetVcpusMax(def);
|
||||||
else
|
else
|
||||||
ret = def->vcpus;
|
ret = virDomainDefGetVcpus(def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
@ -2441,8 +2441,8 @@ libxlDomainGetVcpuPinInfo(virDomainPtr dom, int ncpumaps,
|
|||||||
sa_assert(targetDef);
|
sa_assert(targetDef);
|
||||||
|
|
||||||
/* Clamp to actual number of vcpus */
|
/* Clamp to actual number of vcpus */
|
||||||
if (ncpumaps > targetDef->vcpus)
|
if (ncpumaps > virDomainDefGetVcpus(targetDef))
|
||||||
ncpumaps = targetDef->vcpus;
|
ncpumaps = virDomainDefGetVcpus(targetDef);
|
||||||
|
|
||||||
if ((hostcpus = libxl_get_max_cpus(cfg->ctx)) < 0)
|
if ((hostcpus = libxl_get_max_cpus(cfg->ctx)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -771,7 +771,7 @@ static int virLXCControllerGetNumadAdvice(virLXCControllerPtr ctrl,
|
|||||||
* either <vcpu> or <numatune> is 'auto'.
|
* either <vcpu> or <numatune> is 'auto'.
|
||||||
*/
|
*/
|
||||||
if (virDomainDefNeedsPlacementAdvice(ctrl->def)) {
|
if (virDomainDefNeedsPlacementAdvice(ctrl->def)) {
|
||||||
nodeset = virNumaGetAutoPlacementAdvice(ctrl->def->vcpus,
|
nodeset = virNumaGetAutoPlacementAdvice(virDomainDefGetVcpus(ctrl->def),
|
||||||
ctrl->def->mem.cur_balloon);
|
ctrl->def->mem.cur_balloon);
|
||||||
if (!nodeset)
|
if (!nodeset)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -617,7 +617,7 @@ static int lxcDomainGetInfo(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
info->maxMem = virDomainDefGetMemoryActual(vm->def);
|
info->maxMem = virDomainDefGetMemoryActual(vm->def);
|
||||||
info->nrVirtCpu = vm->def->vcpus;
|
info->nrVirtCpu = virDomainDefGetVcpus(vm->def);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -465,7 +465,7 @@ static int openvzDomainGetInfo(virDomainPtr dom,
|
|||||||
|
|
||||||
info->maxMem = virDomainDefGetMemoryActual(vm->def);
|
info->maxMem = virDomainDefGetMemoryActual(vm->def);
|
||||||
info->memory = vm->def->mem.cur_balloon;
|
info->memory = vm->def->mem.cur_balloon;
|
||||||
info->nrVirtCpu = vm->def->vcpus;
|
info->nrVirtCpu = virDomainDefGetVcpus(vm->def);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -3525,11 +3525,12 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def)
|
|||||||
if (system_type == HMC)
|
if (system_type == HMC)
|
||||||
virBufferAsprintf(&buf, " -m %s", managed_system);
|
virBufferAsprintf(&buf, " -m %s", managed_system);
|
||||||
virBufferAsprintf(&buf, " -r lpar -p %s -i min_mem=%lld,desired_mem=%lld,"
|
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->name, def->mem.cur_balloon,
|
||||||
def->mem.cur_balloon,
|
def->mem.cur_balloon,
|
||||||
virDomainDefGetMemoryInitial(def),
|
virDomainDefGetMemoryInitial(def),
|
||||||
(int) def->vcpus, virDomainDiskGetSource(def->disks[0]));
|
virDomainDefGetVcpus(def),
|
||||||
|
virDomainDiskGetSource(def->disks[0]));
|
||||||
ret = phypExecBuffer(session, &buf, &exit_status, conn, false);
|
ret = phypExecBuffer(session, &buf, &exit_status, conn, false);
|
||||||
|
|
||||||
if (exit_status < 0) {
|
if (exit_status < 0) {
|
||||||
|
@ -7959,7 +7959,7 @@ qemuBuildSmpArgStr(const virDomainDef *def,
|
|||||||
{
|
{
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
virBufferAsprintf(&buf, "%u", def->vcpus);
|
virBufferAsprintf(&buf, "%u", virDomainDefGetVcpus(def));
|
||||||
|
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SMP_TOPOLOGY)) {
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SMP_TOPOLOGY)) {
|
||||||
if (virDomainDefHasVcpusOffline(def))
|
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"));
|
virReportError(VIR_ERR_OVERFLOW, "%s", _("cpu count too large"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -4700,7 +4700,7 @@ qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
|
|||||||
size_t i;
|
size_t i;
|
||||||
int rc = 1;
|
int rc = 1;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int oldvcpus = vm->def->vcpus;
|
int oldvcpus = virDomainDefGetVcpus(vm->def);
|
||||||
int vcpus = oldvcpus;
|
int vcpus = oldvcpus;
|
||||||
pid_t *cpupids = NULL;
|
pid_t *cpupids = NULL;
|
||||||
int ncpupids;
|
int ncpupids;
|
||||||
@ -4929,11 +4929,11 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|||||||
if (!qemuDomainAgentAvailable(vm, true))
|
if (!qemuDomainAgentAvailable(vm, true))
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (nvcpus > vm->def->vcpus) {
|
if (nvcpus > virDomainDefGetVcpus(vm->def)) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("requested vcpu count is greater than the count "
|
_("requested vcpu count is greater than the count "
|
||||||
"of enabled vcpus in the domain: %d > %d"),
|
"of enabled vcpus in the domain: %d > %d"),
|
||||||
nvcpus, vm->def->vcpus);
|
nvcpus, virDomainDefGetVcpus(vm->def));
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4972,8 +4972,8 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|||||||
|
|
||||||
if (persistentDef) {
|
if (persistentDef) {
|
||||||
/* remove vcpupin entries for vcpus that were unplugged */
|
/* remove vcpupin entries for vcpus that were unplugged */
|
||||||
if (nvcpus < persistentDef->vcpus) {
|
if (nvcpus < virDomainDefGetVcpus(persistentDef)) {
|
||||||
for (i = persistentDef->vcpus - 1; i >= nvcpus; i--)
|
for (i = virDomainDefGetVcpus(persistentDef) - 1; i >= nvcpus; i--)
|
||||||
virDomainPinDel(&persistentDef->cputune.vcpupin,
|
virDomainPinDel(&persistentDef->cputune.vcpupin,
|
||||||
&persistentDef->cputune.nvcpupin,
|
&persistentDef->cputune.nvcpupin,
|
||||||
i);
|
i);
|
||||||
@ -5067,17 +5067,17 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
|
|||||||
|
|
||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
|
|
||||||
if (def && vcpu >= def->vcpus) {
|
if (def && vcpu >= virDomainDefGetVcpus(def)) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("vcpu %d is out of range of live cpu count %d"),
|
_("vcpu %d is out of range of live cpu count %d"),
|
||||||
vcpu, def->vcpus);
|
vcpu, virDomainDefGetVcpus(def));
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (persistentDef && vcpu >= persistentDef->vcpus) {
|
if (persistentDef && vcpu >= virDomainDefGetVcpus(persistentDef)) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("vcpu %d is out of range of persistent cpu count %d"),
|
_("vcpu %d is out of range of persistent cpu count %d"),
|
||||||
vcpu, persistentDef->vcpus);
|
vcpu, virDomainDefGetVcpus(persistentDef));
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5246,8 +5246,8 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom,
|
|||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
|
|
||||||
/* Clamp to actual number of vcpus */
|
/* Clamp to actual number of vcpus */
|
||||||
if (ncpumaps > def->vcpus)
|
if (ncpumaps > virDomainDefGetVcpus(def))
|
||||||
ncpumaps = def->vcpus;
|
ncpumaps = virDomainDefGetVcpus(def);
|
||||||
|
|
||||||
if (ncpumaps < 1)
|
if (ncpumaps < 1)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -5561,7 +5561,7 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
|
|||||||
if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
|
if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
|
||||||
ret = virDomainDefGetVcpusMax(def);
|
ret = virDomainDefGetVcpusMax(def);
|
||||||
else
|
else
|
||||||
ret = def->vcpus;
|
ret = virDomainDefGetVcpus(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -10587,7 +10587,7 @@ qemuGetVcpusBWLive(virDomainObjPtr vm,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (*quota > 0)
|
if (*quota > 0)
|
||||||
*quota /= vm->def->vcpus;
|
*quota /= virDomainDefGetVcpus(vm->def);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19073,7 +19073,7 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
|||||||
&record->nparams,
|
&record->nparams,
|
||||||
maxparams,
|
maxparams,
|
||||||
"vcpu.current",
|
"vcpu.current",
|
||||||
(unsigned) dom->def->vcpus) < 0)
|
virDomainDefGetVcpus(dom->def)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virTypedParamsAddUInt(&record->params,
|
if (virTypedParamsAddUInt(&record->params,
|
||||||
@ -19083,17 +19083,17 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
|||||||
virDomainDefGetVcpusMax(dom->def)) < 0)
|
virDomainDefGetVcpusMax(dom->def)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(cpuinfo, dom->def->vcpus) < 0)
|
if (VIR_ALLOC_N(cpuinfo, virDomainDefGetVcpus(dom->def)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuDomainHelperGetVcpus(dom, cpuinfo, dom->def->vcpus,
|
if (qemuDomainHelperGetVcpus(dom, cpuinfo, virDomainDefGetVcpus(dom->def),
|
||||||
NULL, 0) < 0) {
|
NULL, 0) < 0) {
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
ret = 0; /* it's ok to be silent and go ahead */
|
ret = 0; /* it's ok to be silent and go ahead */
|
||||||
goto cleanup;
|
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,
|
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"vcpu.%zu.state", i);
|
"vcpu.%zu.state", i);
|
||||||
if (virTypedParamsAddInt(&record->params,
|
if (virTypedParamsAddInt(&record->params,
|
||||||
|
@ -2020,11 +2020,11 @@ qemuProcessDetectVcpuPIDs(virQEMUDriverPtr driver,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ncpupids != vm->def->vcpus) {
|
if (ncpupids != virDomainDefGetVcpus(vm->def)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("got wrong number of vCPU pids from QEMU monitor. "
|
_("got wrong number of vCPU pids from QEMU monitor. "
|
||||||
"got %d, wanted %d"),
|
"got %d, wanted %d"),
|
||||||
ncpupids, vm->def->vcpus);
|
ncpupids, virDomainDefGetVcpus(vm->def));
|
||||||
VIR_FREE(cpupids);
|
VIR_FREE(cpupids);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -2240,7 +2240,7 @@ qemuProcessSetVcpuAffinities(virDomainObjPtr vm)
|
|||||||
int n;
|
int n;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
VIR_DEBUG("Setting affinity on CPUs nvcpupin=%zu nvcpus=%d nvcpupids=%d",
|
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)
|
if (!def->cputune.nvcpupin)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -2259,7 +2259,7 @@ qemuProcessSetVcpuAffinities(virDomainObjPtr vm)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (n = 0; n < def->vcpus; n++) {
|
for (n = 0; n < virDomainDefGetVcpus(def); n++) {
|
||||||
/* set affinity only for existing vcpus */
|
/* set affinity only for existing vcpus */
|
||||||
if (!(pininfo = virDomainPinFind(def->cputune.vcpupin,
|
if (!(pininfo = virDomainPinFind(def->cputune.vcpupin,
|
||||||
def->cputune.nvcpupin,
|
def->cputune.nvcpupin,
|
||||||
@ -4670,7 +4670,7 @@ qemuProcessLaunch(virConnectPtr conn,
|
|||||||
* either <vcpu> or <numatune> is 'auto'.
|
* either <vcpu> or <numatune> is 'auto'.
|
||||||
*/
|
*/
|
||||||
if (virDomainDefNeedsPlacementAdvice(vm->def)) {
|
if (virDomainDefNeedsPlacementAdvice(vm->def)) {
|
||||||
nodeset = virNumaGetAutoPlacementAdvice(vm->def->vcpus,
|
nodeset = virNumaGetAutoPlacementAdvice(virDomainDefGetVcpus(vm->def),
|
||||||
virDomainDefGetMemoryActual(vm->def));
|
virDomainDefGetMemoryActual(vm->def));
|
||||||
if (!nodeset)
|
if (!nodeset)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -1928,7 +1928,7 @@ static int testDomainGetInfo(virDomainPtr domain,
|
|||||||
info->state = virDomainObjGetState(privdom, NULL);
|
info->state = virDomainObjGetState(privdom, NULL);
|
||||||
info->memory = privdom->def->mem.cur_balloon;
|
info->memory = privdom->def->mem.cur_balloon;
|
||||||
info->maxMem = virDomainDefGetMemoryActual(privdom->def);
|
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));
|
info->cpuTime = ((tv.tv_sec * 1000ll * 1000ll * 1000ll) + (tv.tv_usec * 1000ll));
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
@ -2316,7 +2316,7 @@ testDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
|
|||||||
if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
|
if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
|
||||||
ret = virDomainDefGetVcpusMax(def);
|
ret = virDomainDefGetVcpusMax(def);
|
||||||
else
|
else
|
||||||
ret = def->vcpus;
|
ret = virDomainDefGetVcpus(def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainObjEndAPI(&vm);
|
virDomainObjEndAPI(&vm);
|
||||||
@ -2448,8 +2448,8 @@ static int testDomainGetVcpus(virDomainPtr domain,
|
|||||||
virBitmapSetAll(allcpumap);
|
virBitmapSetAll(allcpumap);
|
||||||
|
|
||||||
/* Clamp to actual number of vcpus */
|
/* Clamp to actual number of vcpus */
|
||||||
if (maxinfo > privdom->def->vcpus)
|
if (maxinfo > virDomainDefGetVcpus(privdom->def))
|
||||||
maxinfo = privdom->def->vcpus;
|
maxinfo = virDomainDefGetVcpus(privdom->def);
|
||||||
|
|
||||||
memset(info, 0, sizeof(*info) * maxinfo);
|
memset(info, 0, sizeof(*info) * maxinfo);
|
||||||
memset(cpumaps, 0, maxinfo * maplen);
|
memset(cpumaps, 0, maxinfo * maplen);
|
||||||
@ -2507,7 +2507,7 @@ static int testDomainPinVcpu(virDomainPtr domain,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vcpu > privdom->def->vcpus) {
|
if (vcpu > virDomainDefGetVcpus(privdom->def)) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
_("requested vcpu is higher than allocated vcpus"));
|
_("requested vcpu is higher than allocated vcpus"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2561,8 +2561,8 @@ testDomainGetVcpuPinInfo(virDomainPtr dom,
|
|||||||
virBitmapSetAll(allcpumap);
|
virBitmapSetAll(allcpumap);
|
||||||
|
|
||||||
/* Clamp to actual number of vcpus */
|
/* Clamp to actual number of vcpus */
|
||||||
if (ncpumaps > def->vcpus)
|
if (ncpumaps > virDomainDefGetVcpus(def))
|
||||||
ncpumaps = def->vcpus;
|
ncpumaps = virDomainDefGetVcpus(def);
|
||||||
|
|
||||||
for (vcpu = 0; vcpu < ncpumaps; vcpu++) {
|
for (vcpu = 0; vcpu < ncpumaps; vcpu++) {
|
||||||
virDomainPinDefPtr pininfo;
|
virDomainPinDefPtr pininfo;
|
||||||
|
@ -1916,7 +1916,7 @@ static int umlDomainGetInfo(virDomainPtr dom,
|
|||||||
|
|
||||||
info->maxMem = virDomainDefGetMemoryActual(vm->def);
|
info->maxMem = virDomainDefGetMemoryActual(vm->def);
|
||||||
info->memory = vm->def->mem.cur_balloon;
|
info->memory = vm->def->mem.cur_balloon;
|
||||||
info->nrVirtCpu = vm->def->vcpus;
|
info->nrVirtCpu = virDomainDefGetVcpus(vm->def);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -1142,7 +1142,7 @@ vmwareDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
|
|||||||
info->cpuTime = 0;
|
info->cpuTime = 0;
|
||||||
info->maxMem = virDomainDefGetMemoryActual(vm->def);
|
info->maxMem = virDomainDefGetMemoryActual(vm->def);
|
||||||
info->memory = vm->def->mem.cur_balloon;
|
info->memory = vm->def->mem.cur_balloon;
|
||||||
info->nrVirtCpu = vm->def->vcpus;
|
info->nrVirtCpu = virDomainDefGetVcpus(vm->def);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -1540,13 +1540,14 @@ virVMXParseConfig(virVMXContext *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sched_cpu_shares != NULL) {
|
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 */
|
/* See http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.SharesInfo.Level.html */
|
||||||
if (STRCASEEQ(sched_cpu_shares, "low")) {
|
if (STRCASEEQ(sched_cpu_shares, "low")) {
|
||||||
def->cputune.shares = def->vcpus * 500;
|
def->cputune.shares = vcpus * 500;
|
||||||
} else if (STRCASEEQ(sched_cpu_shares, "normal")) {
|
} 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")) {
|
} 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,
|
} else if (virStrToLong_ul(sched_cpu_shares, NULL, 10,
|
||||||
&def->cputune.shares) < 0) {
|
&def->cputune.shares) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -3233,12 +3234,13 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
|
|||||||
|
|
||||||
/* def:cputune.shares -> vmx:sched.cpu.shares */
|
/* def:cputune.shares -> vmx:sched.cpu.shares */
|
||||||
if (def->cputune.sharesSpecified) {
|
if (def->cputune.sharesSpecified) {
|
||||||
|
unsigned int vcpus = virDomainDefGetVcpus(def);
|
||||||
/* See http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.SharesInfo.Level.html */
|
/* 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");
|
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");
|
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");
|
virBufferAddLit(&buffer, "sched.cpu.shares = \"high\"\n");
|
||||||
} else {
|
} else {
|
||||||
virBufferAsprintf(&buffer, "sched.cpu.shares = \"%lu\"\n",
|
virBufferAsprintf(&buffer, "sched.cpu.shares = \"%lu\"\n",
|
||||||
|
@ -560,14 +560,14 @@ vzDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
info->state = virDomainObjGetState(privdom, NULL);
|
info->state = virDomainObjGetState(privdom, NULL);
|
||||||
info->memory = privdom->def->mem.cur_balloon;
|
info->memory = privdom->def->mem.cur_balloon;
|
||||||
info->maxMem = virDomainDefGetMemoryActual(privdom->def);
|
info->maxMem = virDomainDefGetMemoryActual(privdom->def);
|
||||||
info->nrVirtCpu = privdom->def->vcpus;
|
info->nrVirtCpu = virDomainDefGetVcpus(privdom->def);
|
||||||
info->cpuTime = 0;
|
info->cpuTime = 0;
|
||||||
|
|
||||||
if (virDomainObjIsActive(privdom)) {
|
if (virDomainObjIsActive(privdom)) {
|
||||||
unsigned long long vtime;
|
unsigned long long vtime;
|
||||||
size_t i;
|
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) {
|
if (prlsdkGetVcpuStats(privdom, i, &vtime) < 0) {
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
||||||
_("cannot read cputime for domain"));
|
_("cannot read cputime for domain"));
|
||||||
@ -1374,7 +1374,7 @@ vzDomainGetVcpusFlags(virDomainPtr dom,
|
|||||||
if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
|
if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
|
||||||
ret = virDomainDefGetVcpusMax(privdom->def);
|
ret = virDomainDefGetVcpusMax(privdom->def);
|
||||||
else
|
else
|
||||||
ret = privdom->def->vcpus;
|
ret = virDomainDefGetVcpus(privdom->def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (privdom)
|
if (privdom)
|
||||||
|
@ -1958,7 +1958,7 @@ prlsdkCheckUnsupportedParams(PRL_HANDLE sdkdom, virDomainDefPtr def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (def->cputune.vcpupin) {
|
if (def->cputune.vcpupin) {
|
||||||
for (i = 0; i < def->vcpus; i++) {
|
for (i = 0; i < virDomainDefGetVcpus(def); i++) {
|
||||||
if (!virBitmapEqual(def->cpumask,
|
if (!virBitmapEqual(def->cpumask,
|
||||||
def->cputune.vcpupin[i]->cpumask)) {
|
def->cputune.vcpupin[i]->cpumask)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
@ -3501,7 +3501,7 @@ prlsdkDoApplyConfig(virConnectPtr conn,
|
|||||||
pret = PrlVmCfg_SetRamSize(sdkdom, virDomainDefGetMemoryActual(def) >> 10);
|
pret = PrlVmCfg_SetRamSize(sdkdom, virDomainDefGetMemoryActual(def) >> 10);
|
||||||
prlsdkCheckRetGoto(pret, error);
|
prlsdkCheckRetGoto(pret, error);
|
||||||
|
|
||||||
pret = PrlVmCfg_SetCpuCount(sdkdom, def->vcpus);
|
pret = PrlVmCfg_SetCpuCount(sdkdom, virDomainDefGetVcpus(def));
|
||||||
prlsdkCheckRetGoto(pret, error);
|
prlsdkCheckRetGoto(pret, error);
|
||||||
|
|
||||||
if (!(mask = virBitmapFormat(def->cpumask)))
|
if (!(mask = virBitmapFormat(def->cpumask)))
|
||||||
|
@ -483,7 +483,7 @@ xenXMDomainGetInfo(virConnectPtr conn,
|
|||||||
memset(info, 0, sizeof(virDomainInfo));
|
memset(info, 0, sizeof(virDomainInfo));
|
||||||
info->maxMem = virDomainDefGetMemoryActual(entry->def);
|
info->maxMem = virDomainDefGetMemoryActual(entry->def);
|
||||||
info->memory = entry->def->mem.cur_balloon;
|
info->memory = entry->def->mem.cur_balloon;
|
||||||
info->nrVirtCpu = entry->def->vcpus;
|
info->nrVirtCpu = virDomainDefGetVcpus(entry->def);
|
||||||
info->state = VIR_DOMAIN_SHUTOFF;
|
info->state = VIR_DOMAIN_SHUTOFF;
|
||||||
info->cpuTime = 0;
|
info->cpuTime = 0;
|
||||||
|
|
||||||
@ -765,7 +765,7 @@ xenXMDomainGetVcpusFlags(virConnectPtr conn,
|
|||||||
if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
|
if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
|
||||||
ret = virDomainDefGetVcpusMax(entry->def);
|
ret = virDomainDefGetVcpusMax(entry->def);
|
||||||
else
|
else
|
||||||
ret = entry->def->vcpus;
|
ret = virDomainDefGetVcpus(entry->def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
xenUnifiedUnlock(priv);
|
xenUnifiedUnlock(priv);
|
||||||
|
@ -506,7 +506,7 @@ createVMRecordFromXml(virConnectPtr conn, virDomainDefPtr def,
|
|||||||
|
|
||||||
if (virDomainDefGetVcpusMax(def) > 0) {
|
if (virDomainDefGetVcpusMax(def) > 0) {
|
||||||
(*record)->vcpus_max = (int64_t) virDomainDefGetVcpusMax(def);
|
(*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)
|
if (def->onPoweroff)
|
||||||
(*record)->actions_after_shutdown = actionShutdownLibvirt2XenapiEnum(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
|
/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
|
||||||
either 32, or 64 on a platform where long is big enough. */
|
either 32, or 64 on a platform where long is big enough. */
|
||||||
if (virDomainDefHasVcpusOffline(def) &&
|
if (virDomainDefHasVcpusOffline(def) &&
|
||||||
xenConfigSetInt(conf, "vcpu_avail", (1UL << def->vcpus) - 1) < 0)
|
xenConfigSetInt(conf, "vcpu_avail",
|
||||||
|
(1UL << virDomainDefGetVcpus(def)) - 1) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((def->cpumask != NULL) &&
|
if ((def->cpumask != NULL) &&
|
||||||
|
@ -2246,7 +2246,8 @@ xenFormatSxpr(virConnectPtr conn,
|
|||||||
/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
|
/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
|
||||||
either 32, or 64 on a platform where long is big enough. */
|
either 32, or 64 on a platform where long is big enough. */
|
||||||
if (virDomainDefHasVcpusOffline(def))
|
if (virDomainDefHasVcpusOffline(def))
|
||||||
virBufferAsprintf(&buf, "(vcpu_avail %lu)", (1UL << def->vcpus) - 1);
|
virBufferAsprintf(&buf, "(vcpu_avail %lu)",
|
||||||
|
(1UL << virDomainDefGetVcpus(def)) - 1);
|
||||||
|
|
||||||
if (def->cpumask) {
|
if (def->cpumask) {
|
||||||
char *ranges = virBitmapFormat(def->cpumask);
|
char *ranges = virBitmapFormat(def->cpumask);
|
||||||
@ -2329,7 +2330,7 @@ xenFormatSxpr(virConnectPtr conn,
|
|||||||
virBufferAsprintf(&buf, "(vcpus %u)", virDomainDefGetVcpusMax(def));
|
virBufferAsprintf(&buf, "(vcpus %u)", virDomainDefGetVcpusMax(def));
|
||||||
if (virDomainDefHasVcpusOffline(def))
|
if (virDomainDefHasVcpusOffline(def))
|
||||||
virBufferAsprintf(&buf, "(vcpu_avail %lu)",
|
virBufferAsprintf(&buf, "(vcpu_avail %lu)",
|
||||||
(1UL << def->vcpus) - 1);
|
(1UL << virDomainDefGetVcpus(def)) - 1);
|
||||||
|
|
||||||
for (i = 0; i < def->os.nBootDevs; i++) {
|
for (i = 0; i < def->os.nBootDevs; i++) {
|
||||||
switch (def->os.bootDevs[i]) {
|
switch (def->os.bootDevs[i]) {
|
||||||
|
Loading…
Reference in New Issue
Block a user