For device hotplug, the new alias ID needs to be checked in the list rather than using the count of devices. Unplugging a device that is not last in the array will make further hotplug impossible due to alias collision. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1324551 --- src/qemu/qemu_alias.c | 27 +++++++++++++++++++++++++++ src/qemu/qemu_alias.h | 4 ++++ src/qemu/qemu_hotplug.c | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 052a829..c56e5e4 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -409,6 +409,33 @@ qemuAssignDeviceRNGAlias(virDomainDefPtr def, int +qemuAssignDeviceMemoryAlias(virDomainDefPtr def, + virDomainMemoryDefPtr mem, + size_t idx) +{ + if (idx == -1) { + size_t i; + idx = 0; + for (i = 0; i < def->nmems; i++) { + int thisidx; + if ((thisidx = qemuDomainDeviceAliasIndex(&def->mems[i]->info, "dimm")) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to determine device index for memory device")); + return -1; + } + if (thisidx >= idx) + idx = thisidx + 1; + } + } + + if (virAsprintf(&mem->info.alias, "dimm%zu", idx) < 0) + return -1; + + return 0; +} + + +int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) { size_t i; diff --git a/src/qemu/qemu_alias.h b/src/qemu/qemu_alias.h index f311583..ba91d32 100644 --- a/src/qemu/qemu_alias.h +++ b/src/qemu/qemu_alias.h @@ -58,6 +58,10 @@ int qemuAssignDeviceRNGAlias(virDomainDefPtr def, virDomainRNGDefPtr rng, size_t idx); +int qemuAssignDeviceMemoryAlias(virDomainDefPtr def, + virDomainMemoryDefPtr mems, + size_t idx); + int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps); int qemuDomainDeviceAliasIndex(const virDomainDeviceInfo *info, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 93cc8e2..010eccd 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1751,7 +1751,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver, if (qemuDomainDefValidateMemoryHotplug(vm->def, priv->qemuCaps, mem) < 0) goto cleanup; - if (virAsprintf(&mem->info.alias, "dimm%zu", vm->def->nmems) < 0) + if (qemuAssignDeviceMemoryAlias(vm->def, mem, -1) < 0) goto cleanup; if (virAsprintf(&objalias, "mem%s", mem->info.alias) < 0) -- 2.8.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list