提交 a83b2e25 编写于 作者: P Peter Krempa

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.
上级 6705d828
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册