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

qemu: Generate memory device aliases according to slot number

The memory device alias needs to be treated as machine ABI as qemu is
using it in the migration stream for section labels. To simplify this
generate the alias from the slot number unless an existing broken
configuration is detected.

With this patch the aliases are predictable and even certain
configurations which would not be migratable previously are fixed.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1359135
上级 ce1ee02a
......@@ -332,17 +332,34 @@ qemuAssignDeviceRNGAlias(virDomainDefPtr def,
}
/**
* qemuAssignDeviceMemoryAlias:
* @def: domain definition. Necessary only if @oldAlias is true.
* @mem: memory device definition
* @oldAlias: Generate the alias according to the order of the device in @def
* rather than according to the slot number for legacy reasons.
*
* Generates alias for a memory device according to slot number if @oldAlias is
* false or according to order in @def->mems otherwise.
*
* Returns 0 on success, -1 on error.
*/
int
qemuAssignDeviceMemoryAlias(virDomainDefPtr def,
virDomainMemoryDefPtr mem)
virDomainMemoryDefPtr mem,
bool oldAlias)
{
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 (oldAlias) {
for (i = 0; i < def->nmems; i++) {
if ((idx = qemuDomainDeviceAliasIndex(&def->mems[i]->info, "dimm")) >= maxidx)
maxidx = idx + 1;
}
} else {
maxidx = mem->info.addr.dimm.slot;
}
if (virAsprintf(&mem->info.alias, "dimm%d", maxidx) < 0)
......@@ -475,7 +492,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
return -1;
}
for (i = 0; i < def->nmems; i++) {
if (virAsprintf(&def->mems[i]->info.alias, "dimm%zu", i) < 0)
if (qemuAssignDeviceMemoryAlias(NULL, def->mems[i], false) < 0)
return -1;
}
......
......@@ -58,7 +58,8 @@ int qemuAssignDeviceRNGAlias(virDomainDefPtr def,
virDomainRNGDefPtr rng);
int qemuAssignDeviceMemoryAlias(virDomainDefPtr def,
virDomainMemoryDefPtr mems);
virDomainMemoryDefPtr mems,
bool oldAlias);
int qemuAssignDeviceShmemAlias(virDomainDefPtr def,
virDomainShmemDefPtr shmem,
......
......@@ -2135,7 +2135,9 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
if (qemuDomainAssignMemoryDeviceSlot(vm->def, mem) < 0)
goto cleanup;
if (qemuAssignDeviceMemoryAlias(vm->def, mem) < 0)
/* in cases where we are using a VM with aliases generated according to the
* index of the memory device we need to keep continue using that scheme */
if (qemuAssignDeviceMemoryAlias(vm->def, mem, priv->memAliasOrderMismatch) < 0)
goto cleanup;
if (virAsprintf(&objalias, "mem%s", mem->info.alias) < 0)
......
......@@ -15,8 +15,8 @@ QEMU_AUDIO_DRV=none \
mem-path=/dev/hugepages2M/libvirt/qemu,size=536870912,host-nodes=1-3,\
policy=bind \
-device pc-dimm,node=0,memdev=memdimm0,id=dimm0,slot=0,addr=4294967296 \
-object memory-backend-ram,id=memdimm1,size=536870912 \
-device pc-dimm,node=0,memdev=memdimm1,id=dimm1,slot=2 \
-object memory-backend-ram,id=memdimm2,size=536870912 \
-device pc-dimm,node=0,memdev=memdimm2,id=dimm2,slot=2 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-nographic \
-nodefaults \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册