virDomainDefCheckUnsupportedMemoryHotplug(virDomainDefPtr def)
{
/* memory hotplug tunables are not supported by this driver */
- if (def->mem.max_memory > 0 || def->mem.memory_slots > 0) {
+ if (virDomainDefHasMemoryHotplug(def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("memory hotplug tunables <maxMemory> are not "
"supported by this hypervisor driver"));
}
+bool
+virDomainDefHasMemoryHotplug(const virDomainDef *def)
+{
+ return def->mem.memory_slots > 0 || def->mem.max_memory > 0;
+}
+
+
/**
* virDomainDefGetMemoryInitial:
* @def: domain definition
xmlIndentTreeOutput = oldIndentTreeOutput;
}
- if (def->mem.max_memory) {
+ if (virDomainDefHasMemoryHotplug(def)) {
virBufferAsprintf(buf,
"<maxMemory slots='%u' unit='KiB'>%llu</maxMemory>\n",
def->mem.memory_slots, def->mem.max_memory);
unsigned long long virDomainDefGetMemoryInitial(virDomainDefPtr def);
void virDomainDefSetMemoryInitial(virDomainDefPtr def, unsigned long long size);
unsigned long long virDomainDefGetMemoryActual(virDomainDefPtr def);
+bool virDomainDefHasMemoryHotplug(const virDomainDef *def);
typedef enum {
VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_AES,
virDomainDefGetMemoryInitial;
virDomainDefGetSecurityLabelDef;
virDomainDefHasDeviceAddress;
+virDomainDefHasMemoryHotplug;
virDomainDefMaybeAddController;
virDomainDefMaybeAddInput;
virDomainDefNeedsPlacementAdvice;
virCommandAddArg(cmd, "-m");
- if (def->mem.max_memory) {
+ if (virDomainDefHasMemoryHotplug(def)) {
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PC_DIMM)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("memory hotplug isn't supported by this QEMU binary"));
}
if (dev->type == VIR_DOMAIN_DEVICE_MEMORY &&
- def->mem.max_memory == 0) {
+ !virDomainDefHasMemoryHotplug(def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("maxMemory has to be specified when using memory "
"devices "));
}
}
- if (vm->def->mem.max_memory ||
+ if (virDomainDefHasMemoryHotplug(vm->def) ||
((flags & VIR_MIGRATE_PERSIST_DEST) &&
- vm->newDef &&
- vm->newDef->mem.max_memory))
+ vm->newDef && virDomainDefHasMemoryHotplug(vm->newDef)))
cookieFlags |= QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG;
if (!(mig = qemuMigrationEatCookie(driver, vm, NULL, 0, 0)))