mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
qemu: alias: Fix calculation of memory device aliases
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
This commit is contained in:
parent
bd19b4b25b
commit
be6e92f541
@ -401,6 +401,26 @@ qemuAssignDeviceRNGAlias(virDomainDefPtr def,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuAssignDeviceMemoryAlias(virDomainDefPtr def,
|
||||
virDomainMemoryDefPtr mem)
|
||||
{
|
||||
size_t i;
|
||||
int maxidx = 0;
|
||||
int idx;
|
||||
|
||||
for (i = 0; i < def->nmems; i++) {
|
||||
if ((idx = qemuDomainDeviceAliasIndex(&def->mems[i]->info, "dimm")) >= maxidx)
|
||||
maxidx = idx + 1;
|
||||
}
|
||||
|
||||
if (virAsprintf(&mem->info.alias, "dimm%d", maxidx) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
|
@ -57,6 +57,9 @@ int qemuAssignDeviceRedirdevAlias(virDomainDefPtr def,
|
||||
int qemuAssignDeviceRNGAlias(virDomainDefPtr def,
|
||||
virDomainRNGDefPtr rng);
|
||||
|
||||
int qemuAssignDeviceMemoryAlias(virDomainDefPtr def,
|
||||
virDomainMemoryDefPtr mems);
|
||||
|
||||
int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps);
|
||||
|
||||
int qemuDomainDeviceAliasIndex(const virDomainDeviceInfo *info,
|
||||
|
@ -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) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virAsprintf(&objalias, "mem%s", mem->info.alias) < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user