}
+bool
+virDomainDefHasVcpusOffline(const virDomainDef *def)
+{
+ return def->vcpus < def->maxvcpus;
+}
+
+
virDomainDiskDefPtr
virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt)
{
virBufferAsprintf(buf, " cpuset='%s'", cpumask);
VIR_FREE(cpumask);
}
- if (def->vcpus != def->maxvcpus)
+ if (virDomainDefHasVcpusOffline(def))
virBufferAsprintf(buf, " current='%u'", def->vcpus);
virBufferAsprintf(buf, ">%u</vcpu>\n", def->maxvcpus);
};
int virDomainDefSetVcpusMax(virDomainDefPtr def, unsigned int vcpus);
+bool virDomainDefHasVcpusOffline(const virDomainDef *def);
unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def);
void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
virDomainDefGetSecurityLabelDef;
virDomainDefHasDeviceAddress;
virDomainDefHasMemoryHotplug;
+virDomainDefHasVcpusOffline;
virDomainDefMaybeAddController;
virDomainDefMaybeAddInput;
virDomainDefNeedsPlacementAdvice;
if (openvzDomainSetNetworkConfig(conn, vm->def) < 0)
goto cleanup;
- if (vm->def->vcpus != vm->def->maxvcpus) {
+ if (virDomainDefHasVcpusOffline(vm->def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("current vcpu count must equal maximum"));
goto cleanup;
virBufferAsprintf(&buf, "%u", def->vcpus);
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SMP_TOPOLOGY)) {
- if (def->vcpus != def->maxvcpus)
+ if (virDomainDefHasVcpusOffline(def))
virBufferAsprintf(&buf, ",maxcpus=%u", def->maxvcpus);
/* sockets, cores, and threads are either all zero
* or all non-zero, thus checking one of them is enough */
virBufferAsprintf(&buf, ",cores=%u", 1);
virBufferAsprintf(&buf, ",threads=%u", 1);
}
- } else if (def->vcpus != def->maxvcpus) {
+ } else if (virDomainDefHasVcpusOffline(def)) {
virBufferFreeAndReset(&buf);
/* FIXME - consider hot-unplugging cpus after boot for older qemu */
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
def->mem.cur_balloon, (unsigned)rc);
}
- if (def->vcpus != def->maxvcpus) {
+ if (virDomainDefHasVcpusOffline(def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("current vcpu count must equal maximum"));
}
}
/* def:maxvcpus -> vmx:numvcpus */
- if (def->vcpus != def->maxvcpus) {
+ if (virDomainDefHasVcpusOffline(def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("No support for domain XML entry 'vcpu' attribute "
"'current'"));
return -1;
}
- if (def->vcpus != def->maxvcpus) {
+ if (virDomainDefHasVcpusOffline(def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("current vcpus must be equal to maxvcpus"));
return -1;
/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
either 32, or 64 on a platform where long is big enough. */
- if (def->vcpus < def->maxvcpus &&
+ if (virDomainDefHasVcpusOffline(def) &&
xenConfigSetInt(conf, "vcpu_avail", (1UL << def->vcpus) - 1) < 0)
goto cleanup;
virBufferAsprintf(&buf, "(vcpus %u)", def->maxvcpus);
/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
either 32, or 64 on a platform where long is big enough. */
- if (def->vcpus < def->maxvcpus)
+ if (virDomainDefHasVcpusOffline(def))
virBufferAsprintf(&buf, "(vcpu_avail %lu)", (1UL << def->vcpus) - 1);
if (def->cpumask) {
virBufferEscapeSexpr(&buf, "(kernel '%s')", def->os.loader->path);
virBufferAsprintf(&buf, "(vcpus %u)", def->maxvcpus);
- if (def->vcpus < def->maxvcpus)
+ if (virDomainDefHasVcpusOffline(def))
virBufferAsprintf(&buf, "(vcpu_avail %lu)",
(1UL << def->vcpus) - 1);