Virsh restore/migration fails on a VM which has gone through a series of memory attach and detach where the sequence of detach is random(not in LIFO order). With memory hotplug, the dimms are looked up using the object-id and so, the restore/migration fails because the qemu command that gets generated has memdev and id values which wouldn't exist for the given slotid. This patch ensures that the source and destination would always have same memdev-objectid-slotid values. Steps to hit the issue: 1. Hot add two memory dimms twice. virsh attach-device VMName memHotplug.xml --live virsh attach-device VMName memHotplug.xml --live 2. cat memHotplug.xml <memory model='dimm' > <target> <size unit='MiB'>128</size> <node>0</node> </target> </memory> 3. Now hot unplug the first memory module attached. virsh detach-device VMName detach.xml --live 4. cat detach.xml <memory model='dimm'> <target> <size unit='MiB'>128</size> <node>0</node> </target> <alias name='dimm0'/> <address type='dimm' slot='0' base='0x100000000'/> </memory> 5.Save the VM and then restore. Restore fails.. virsh save VMName ./VMName.vmsav virsh restore ./VMName.vmsav Error: Unknown ramblock "memdimm1". 6. Example qemu log without current patch. dimm,node=0,memdev=memdimm0,id=dimm0,slot=1,addr=4429185024 -object memory-backend-ram,id=memdimm1,size=134217728 -device pc-dimm,node=0,memdev=memdimm1,id=dimm1,slot=2,addr=4563402752 -object memory-backend-ram,id=memdimm2,size=134217728 -device pc-dimm,node=0,memdev=memdimm2,id=dimm2,slot=3,addr=4697620480 -object memory-backend-ram,id=memdimm3,size=134217728 -device pc-dimm,node=0,memdev=memdimm3,id=dimm3,slot=4,addr=4831838208 -object memory-backend-ram,id=memdimm4,size=134217728 -device pc-dimm,node=0,memdev=memdimm4,id=dimm4,slot=5,addr=4966055936 7. With the current patch we have kept the dimm name as dimmX where X=slot number.In such a case the memdev and id generated are always correct w.r.t the slotid and the virsh restore/ migrate succeeds. dimm,node=0,memdev=memdimm1,id=dimm1,slot=1,addr=4429185024 -object memory-backend-ram,id=memdimm2,size=134217728 -device pc-dimm,node=0,memdev=memdimm2,id=dimm2,slot=2,addr=4563402752 -object memory-backend-ram,id=memdimm3,size=134217728 -device pc-dimm,node=0,memdev=memdimm3,id=dimm3,slot=3,addr=4697620480 -object memory-backend-ram,id=memdimm4,size=134217728 -device pc-dimm,node=0,memdev=memdimm4,id=dimm4,slot=4,addr=4831838208 -object memory-backend-ram,id=memdimm5,size=134217728 -device pc-dimm,node=0,memdev=memdimm5,id=dimm5,slot=5,addr=4966055936 Nitesh Konkar (2): qemu_alias:Set dimm alias name to dimmX where X=slot number. tests/qemuxml2argvdata:Add a testcase src/qemu/qemu_alias.c | 51 +++++++++--- .../qemuxml2argv-memory-hotplug-dimm-alias.args | 35 ++++++++ .../qemuxml2argv-memory-hotplug-dimm-alias.xml | 94 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 2 + 4 files changed, 172 insertions(+), 10 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-dimm-alias.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-dimm-alias.xml -- 1.9.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list