mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-25 10:03:49 +03:00
qemu: Validate available slot count for memory devices
While qemu would reject the configuration we can check whether it makes sense to plug the device upfront.
This commit is contained in:
parent
6705d828fc
commit
a83b2e253f
@ -8822,6 +8822,14 @@ qemuBuildCommandLine(virConnectPtr conn,
|
||||
|
||||
/* memory hotplug requires NUMA to be enabled - we already checked
|
||||
* that memory devices are present only when NUMA is */
|
||||
|
||||
if (def->nmems > def->mem.memory_slots) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("memory device count '%zu' exceeds slots count '%u'"),
|
||||
def->nmems, def->mem.memory_slots);
|
||||
goto error;
|
||||
}
|
||||
|
||||
for (i = 0; i < def->nmems; i++) {
|
||||
char *backStr;
|
||||
char *dimmStr;
|
||||
|
@ -8489,6 +8489,12 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_MEMORY:
|
||||
if (vmdef->nmems == vmdef->mem.memory_slots) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("no free memory device slot available"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virDomainMemoryInsert(vmdef, dev->data.memory) < 0)
|
||||
return -1;
|
||||
dev->data.memory = NULL;
|
||||
|
@ -1730,6 +1730,12 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
|
||||
int id;
|
||||
int ret = -1;
|
||||
|
||||
if (vm->def->nmems == vm->def->mem.memory_slots) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("no free memory device slot available"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virAsprintf(&mem->info.alias, "dimm%zu", vm->def->nmems) < 0)
|
||||
goto cleanup;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user