slot id, if specified, has to be less than the slots count. --- src/qemu/qemu_command.c | 11 ++++++++++- src/qemu/qemu_command.h | 1 + src/qemu/qemu_hotplug.c | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ba15dc9..21daf18 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4946,6 +4946,7 @@ qemuBuildMemoryDimmBackendStr(virDomainMemoryDefPtr mem, char * qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem, + virDomainDefPtr def, virQEMUCapsPtr qemuCaps) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -4972,6 +4973,14 @@ qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem, return NULL; } + if (mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM && + mem->info.addr.dimm.slot >= def->mem.memory_slots) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("memory device slot '%u' exceeds slots count '%u'"), + mem->info.addr.dimm.slot, def->mem.memory_slots); + return NULL; + } + virBufferAsprintf(&buf, "pc-dimm,node=%d,memdev=mem%s,id=%s", mem->targetNode, mem->info.alias, mem->info.alias); @@ -8821,7 +8830,7 @@ qemuBuildCommandLine(virConnectPtr conn, qemuCaps, cfg))) goto error; - if (!(dimmStr = qemuBuildMemoryDeviceStr(def->mems[i], qemuCaps))) { + if (!(dimmStr = qemuBuildMemoryDeviceStr(def->mems[i], def, qemuCaps))) { VIR_FREE(backStr); goto error; } diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index a29db41..675eb62 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -175,6 +175,7 @@ int qemuBuildMemoryBackendStr(unsigned long long size, bool force); char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem, + virDomainDefPtr def, virQEMUCapsPtr qemuCaps); /* Legacy, pre device support */ diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 58224bf..ba92320 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1736,7 +1736,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver, if (virAsprintf(&objalias, "mem%s", mem->info.alias) < 0) goto cleanup; - if (!(devstr = qemuBuildMemoryDeviceStr(mem, priv->qemuCaps))) + if (!(devstr = qemuBuildMemoryDeviceStr(mem, vm->def, priv->qemuCaps))) goto cleanup; qemuDomainMemoryDeviceAlignSize(mem); -- 2.3.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list