mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 03:21:19 +00:00
conf: Add helper to determine whether memory hotplug is enabled for a vm
Add a simple helper so that the code doesn't have to rewrite the same condition multiple times.
This commit is contained in:
parent
5dd61a168f
commit
1891cad542
@ -1154,7 +1154,7 @@ int
|
|||||||
virDomainDefCheckUnsupportedMemoryHotplug(virDomainDefPtr def)
|
virDomainDefCheckUnsupportedMemoryHotplug(virDomainDefPtr def)
|
||||||
{
|
{
|
||||||
/* memory hotplug tunables are not supported by this driver */
|
/* 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",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("memory hotplug tunables <maxMemory> are not "
|
_("memory hotplug tunables <maxMemory> are not "
|
||||||
"supported by this hypervisor driver"));
|
"supported by this hypervisor driver"));
|
||||||
@ -7671,6 +7671,13 @@ virDomainParseMemoryLimit(const char *xpath,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
virDomainDefHasMemoryHotplug(const virDomainDef *def)
|
||||||
|
{
|
||||||
|
return def->mem.memory_slots > 0 || def->mem.max_memory > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virDomainDefGetMemoryInitial:
|
* virDomainDefGetMemoryInitial:
|
||||||
* @def: domain definition
|
* @def: domain definition
|
||||||
@ -21537,7 +21544,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
|
|||||||
xmlIndentTreeOutput = oldIndentTreeOutput;
|
xmlIndentTreeOutput = oldIndentTreeOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->mem.max_memory) {
|
if (virDomainDefHasMemoryHotplug(def)) {
|
||||||
virBufferAsprintf(buf,
|
virBufferAsprintf(buf,
|
||||||
"<maxMemory slots='%u' unit='KiB'>%llu</maxMemory>\n",
|
"<maxMemory slots='%u' unit='KiB'>%llu</maxMemory>\n",
|
||||||
def->mem.memory_slots, def->mem.max_memory);
|
def->mem.memory_slots, def->mem.max_memory);
|
||||||
|
@ -2324,6 +2324,7 @@ struct _virDomainDef {
|
|||||||
unsigned long long virDomainDefGetMemoryInitial(virDomainDefPtr def);
|
unsigned long long virDomainDefGetMemoryInitial(virDomainDefPtr def);
|
||||||
void virDomainDefSetMemoryInitial(virDomainDefPtr def, unsigned long long size);
|
void virDomainDefSetMemoryInitial(virDomainDefPtr def, unsigned long long size);
|
||||||
unsigned long long virDomainDefGetMemoryActual(virDomainDefPtr def);
|
unsigned long long virDomainDefGetMemoryActual(virDomainDefPtr def);
|
||||||
|
bool virDomainDefHasMemoryHotplug(const virDomainDef *def);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_AES,
|
VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_AES,
|
||||||
|
@ -217,6 +217,7 @@ virDomainDefGetMemoryActual;
|
|||||||
virDomainDefGetMemoryInitial;
|
virDomainDefGetMemoryInitial;
|
||||||
virDomainDefGetSecurityLabelDef;
|
virDomainDefGetSecurityLabelDef;
|
||||||
virDomainDefHasDeviceAddress;
|
virDomainDefHasDeviceAddress;
|
||||||
|
virDomainDefHasMemoryHotplug;
|
||||||
virDomainDefMaybeAddController;
|
virDomainDefMaybeAddController;
|
||||||
virDomainDefMaybeAddInput;
|
virDomainDefMaybeAddInput;
|
||||||
virDomainDefNeedsPlacementAdvice;
|
virDomainDefNeedsPlacementAdvice;
|
||||||
|
@ -9323,7 +9323,7 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
|
|
||||||
virCommandAddArg(cmd, "-m");
|
virCommandAddArg(cmd, "-m");
|
||||||
|
|
||||||
if (def->mem.max_memory) {
|
if (virDomainDefHasMemoryHotplug(def)) {
|
||||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PC_DIMM)) {
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PC_DIMM)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("memory hotplug isn't supported by this QEMU binary"));
|
_("memory hotplug isn't supported by this QEMU binary"));
|
||||||
|
@ -1361,7 +1361,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dev->type == VIR_DOMAIN_DEVICE_MEMORY &&
|
if (dev->type == VIR_DOMAIN_DEVICE_MEMORY &&
|
||||||
def->mem.max_memory == 0) {
|
!virDomainDefHasMemoryHotplug(def)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("maxMemory has to be specified when using memory "
|
_("maxMemory has to be specified when using memory "
|
||||||
"devices "));
|
"devices "));
|
||||||
|
@ -3000,10 +3000,9 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm->def->mem.max_memory ||
|
if (virDomainDefHasMemoryHotplug(vm->def) ||
|
||||||
((flags & VIR_MIGRATE_PERSIST_DEST) &&
|
((flags & VIR_MIGRATE_PERSIST_DEST) &&
|
||||||
vm->newDef &&
|
vm->newDef && virDomainDefHasMemoryHotplug(vm->newDef)))
|
||||||
vm->newDef->mem.max_memory))
|
|
||||||
cookieFlags |= QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG;
|
cookieFlags |= QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG;
|
||||||
|
|
||||||
if (!(mig = qemuMigrationEatCookie(driver, vm, NULL, 0, 0)))
|
if (!(mig = qemuMigrationEatCookie(driver, vm, NULL, 0, 0)))
|
||||||
|
Loading…
Reference in New Issue
Block a user