}
+int
+virDomainDefSetVcpusMax(virDomainDefPtr def,
+ unsigned int maxvcpus)
+{
+ def->maxvcpus = maxvcpus;
+
+ return 0;
+}
+
+
virDomainDiskDefPtr
virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt)
{
{
int n;
char *tmp = NULL;
+ unsigned int maxvcpus;
int ret = -1;
- if ((n = virXPathUInt("string(./vcpu[1])", ctxt, &def->maxvcpus)) < 0) {
+ if ((n = virXPathUInt("string(./vcpu[1])", ctxt, &maxvcpus)) < 0) {
if (n == -2) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("maximum vcpus count must be an integer"));
goto cleanup;
}
- def->maxvcpus = 1;
+ maxvcpus = 1;
}
+ if (virDomainDefSetVcpusMax(def, maxvcpus) < 0)
+ goto cleanup;
+
if ((n = virXPathUInt("string(./vcpu[1]/@current)", ctxt, &def->vcpus)) < 0) {
if (n == -2) {
virReportError(VIR_ERR_XML_ERROR, "%s",
xmlNodePtr metadata;
};
+int virDomainDefSetVcpusMax(virDomainDefPtr def, unsigned int vcpus);
+
unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def);
void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
void virDomainDefSetMemoryInitial(virDomainDefPtr def, unsigned long long size);
virDomainDefSetMemoryTotal(def, memorySettingData->data->Limit * 1024); /* megabyte to kilobyte */
def->mem.cur_balloon = memorySettingData->data->VirtualQuantity * 1024; /* megabyte to kilobyte */
+ if (virDomainDefSetVcpusMax(def,
+ processorSettingData->data->VirtualQuantity) < 0)
+ goto cleanup;
+
def->vcpus = processorSettingData->data->VirtualQuantity;
- def->maxvcpus = processorSettingData->data->VirtualQuantity;
def->os.type = VIR_DOMAIN_OSTYPE_HVM;
/* FIXME: devices section is totally missing */
virDomainDefPostParse;
virDomainDefSetMemoryInitial;
virDomainDefSetMemoryTotal;
+virDomainDefSetVcpusMax;
virDomainDeleteConfig;
virDomainDeviceAddressIsValid;
virDomainDeviceAddressTypeToString;
def = NULL;
virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_BOOTED);
+ if (virDomainDefSetVcpusMax(vm->def, d_info.vcpu_max_id + 1))
+ goto cleanup;
+
vm->def->vcpus = d_info.vcpu_online;
- vm->def->maxvcpus = d_info.vcpu_max_id + 1;
vm->def->mem.cur_balloon = d_info.current_memkb;
virDomainDefSetMemoryTotal(vm->def, d_info.max_memkb);
switch (flags) {
case VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_CONFIG:
- def->maxvcpus = nvcpus;
+ if (virDomainDefSetVcpusMax(def, nvcpus) < 0)
+ goto cleanup;
+
if (nvcpus < def->vcpus)
def->vcpus = nvcpus;
break;
/* Value not handled by the LXC driver, setting to
* minimum required to make XML parsing pass */
- vmdef->maxvcpus = 1;
+ if (virDomainDefSetVcpusMax(vmdef, 1) < 0)
+ goto error;
+
vmdef->vcpus = 1;
vmdef->nfss = 0;
if (ret == 0 || vcpus == 0)
vcpus = openvzGetNodeCPUs();
- def->maxvcpus = vcpus;
+ if (virDomainDefSetVcpusMax(def, vcpus) < 0)
+ goto cleanup;
+
def->vcpus = vcpus;
/* XXX load rest of VM config data .... */
if (virRun(prog, NULL) < 0)
return -1;
- vm->def->maxvcpus = vm->def->vcpus = nvcpus;
+ if (virDomainDefSetVcpusMax(vm->def, nvcpus) < 0)
+ return -1;
+
+ vm->def->vcpus = nvcpus;
return 0;
}
goto err;
}
- def.maxvcpus = vcpus;
+ if (virDomainDefSetVcpusMax(&def, vcpus) < 0)
+ goto err;
+
def.vcpus = vcpus;
return virDomainDefFormat(&def,
}
}
- dom->maxvcpus = maxcpus ? maxcpus : dom->vcpus;
+ if (maxcpus == 0)
+ maxcpus = dom->vcpus;
+
+ if (virDomainDefSetVcpusMax(dom, maxcpus) < 0)
+ goto error;
if (sockets && cores && threads) {
virCPUDefPtr cpu;
def->id = -1;
def->mem.cur_balloon = 64 * 1024;
virDomainDefSetMemoryTotal(def, def->mem.cur_balloon);
- def->maxvcpus = 1;
+ if (virDomainDefSetVcpusMax(def, 1) < 0)
+ goto error;
def->vcpus = 1;
def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_UTC;
}
if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
- persistentDef->maxvcpus = nvcpus;
+ if (virDomainDefSetVcpusMax(persistentDef, nvcpus) < 0)
+ goto endjob;
+
if (nvcpus < persistentDef->vcpus)
persistentDef->vcpus = nvcpus;
} else {
if (persistentDef) {
if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
- persistentDef->maxvcpus = nrCpus;
+ if (virDomainDefSetVcpusMax(persistentDef, nrCpus) < 0)
+ goto cleanup;
+
if (nrCpus < persistentDef->vcpus)
persistentDef->vcpus = nrCpus;
} else {
virDomainDefSetMemoryTotal(def, memorySize * 1024);
gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount);
- def->maxvcpus = def->vcpus = CPUCount;
+ if (virDomainDefSetVcpusMax(def, CPUCount) < 0)
+ goto cleanup;
+
+ def->vcpus = CPUCount;
/* Skip cpumasklen, cpumask, onReboot, onPoweroff, onCrash */
def->dom->os.type = VIR_DOMAIN_OSTYPE_HVM;
def->dom->os.arch = virArchFromHost();
gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount);
- def->dom->maxvcpus = def->dom->vcpus = CPUCount;
+ if (virDomainDefSetVcpusMax(def->dom, CPUCount) < 0)
+ goto cleanup;
+
+ def->dom->vcpus = CPUCount;
+
if (vboxSnapshotGetReadWriteDisks(def, snapshot) < 0)
VIR_DEBUG("Could not get read write disks for snapshot");
goto cleanup;
}
- def->maxvcpus = def->vcpus = numvcpus;
+ if (virDomainDefSetVcpusMax(def, numvcpus) < 0)
+ goto cleanup;
+
+ def->vcpus = numvcpus;
/* vmx:sched.cpu.affinity -> def:cpumask */
/* NOTE: maps to VirtualMachine:config.cpuAffinity.affinitySet */
if (cpuCount > hostcpus)
cpuCount = hostcpus;
+ if (virDomainDefSetVcpusMax(def, cpuCount) < 0)
+ goto cleanup;
+
def->vcpus = cpuCount;
- def->maxvcpus = cpuCount;
pret = PrlVmCfg_GetCpuMask(sdkdom, NULL, &buflen);
prlsdkCheckRetGoto(pret, cleanup);
}
if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
- entry->def->maxvcpus = vcpus;
+ if (virDomainDefSetVcpusMax(entry->def, vcpus) < 0)
+ goto cleanup;
+
if (entry->def->vcpus > vcpus)
entry->def->vcpus = vcpus;
} else {
vcpus = xenapiDomainGetMaxVcpus(dom);
- defPtr->maxvcpus = vcpus;
+ if (virDomainDefSetVcpusMax(defPtr, vcpus) < 0)
+ goto error;
+
defPtr->vcpus = vcpus;
enum xen_on_normal_exit action;
MAX_VIRT_CPUS < count)
return -1;
- def->maxvcpus = count;
+ if (virDomainDefSetVcpusMax(def, count) < 0)
+ return -1;
+
if (xenConfigGetULong(conf, "vcpu_avail", &count, -1) < 0)
return -1;
}
}
- def->maxvcpus = sexpr_int(root, "domain/vcpus");
+ if (virDomainDefSetVcpusMax(def, sexpr_int(root, "domain/vcpus")) < 0)
+ goto error;
def->vcpus = count_one_bits_l(sexpr_u64(root, "domain/vcpu_avail"));
if (!def->vcpus || def->maxvcpus < def->vcpus)
def->vcpus = def->maxvcpus;