description of problem: Improve error info when hotpulg/coldplug memory device without 'maxMemory' defined Version-Release number of selected component (if applicable): libvirt-4.5.0-7.el7.x86_64 qemu-kvm-rhev-2.12.0-12.el7.x86_64 How reproducible: 100% Steps to Reproduce: 1.Start a guest without 'maxMemory' defined: #virsh dumpxml iommu1 | grep -i 'maxmemory' no output 2.Prepare a memory device: #cat mem.xml <memory model='dimm'> <target> <size unit='KiB'>524288</size> <node>0</node> </target> </memory> 3.Hotplug the memory device to guest: #virsh attach-device iommu1 mem.xml error: Failed to attach device from mem.xml error: unsupported configuration: Attaching memory device with size '524288' would exceed domain's maxMemory config 4.Coldplug the memory device to guest: #virsh attach-device iommu1 mem.xml error: Failed to attach device from mem.xml error: unsupported configuration: Attaching memory device with size '524288' would exceed domain's maxMemory config Actual results: Expected results: Should report error more clearly, such as: cannot use/hotplug a memory device when domain 'maxMemory' is not defined Additional info:
Posted a couple of patches. Details in the cover letter and the actual desired fix in patch 2. Patch 1 just augments the message to display the max_memory size that's too small. https://www.redhat.com/archives/libvir-list/2018-December/msg00207.html
Patch pushed upstream: commit 3972a25f1d4f9c75d73faaac9106fc16037de645 Author: John Ferlan <jferlan> Date: Fri Dec 7 09:46:48 2018 -0500 conf: Add check/error for domain supports cold/hotplug ... Add a check during virDomainDefCompatibleDevice whether the domain supports cold/hotplug of a memory module even though this duplicates the qemuDomainDefValidateMemoryHotplug check. Without this check, the cold/hot plug would fail on the subsequent mem_memory check (since it's 0). Adding a check for max_memory > 0 would allow the subsequent hotplug check to fail, but would cause coldplug to fail with the somewhat opaque message "no free memory device slot available". Signed-off-by: John Ferlan <jferlan> ACKed-by: Michal Privoznik <mprivozn> $ git describe 3972a25f1d4f9c75d73faaac9106fc16037de645 v4.10.0-53-g3972a25f1d $
Verified with libvirt-daemon-5.0.0-7.module+el8+2887+effa3c42.x86_64 and qemu-kvm-3.1.0-20.module+el8+2888+cdc893a8.x86_64 mem.xml <memory model='dimm'> <target> <size unit='KiB'>524288</size> <node>0</node> </target> </memory> Start domain avocado-vt-vm2 - # virsh attach-device avocado-vt-vm2 ~/mem.xml error: Failed to attach device from /root/mem.xml error: unsupported configuration: cannot use/hotplug a memory device when domain 'maxMemory' is not defined Destroy domain - # virsh attach-device avocado-vt-vm2 ~/mem.xml --config error: Failed to attach device from /root/mem.xml error: unsupported configuration: cannot use/hotplug a memory device when domain 'maxMemory' is not defined
Verified with libvirt-5.0.0-11.module+el8.0.1+3459+e357ef2f.x86_64 & qemu-kvm-3.1.0-27.module+el8.0.1+3253+c5371cb3.x86_64 1. A domain without maxMemory element and dd below xml to the <devices> part in the domain <memory model='dimm'> <target> <size unit='KiB'>524288</size> <node>0</node> </target> </memory> # virsh start r1 error: Failed to start domain r1 error: unsupported configuration: cannot use/hotplug a memory device when domain 'maxMemory' is not defined 2. Save above xml to m.xml and attach device # virsh attach-device r1 ./m.xml error: Failed to attach device from ./m.xml error: unsupported configuration: cannot use/hotplug a memory device when domain 'maxMemory' is not defined # virsh attach-device r1 ./m.xml --config error: Failed to attach device from ./m.xml error: unsupported configuration: cannot use/hotplug a memory device when domain 'maxMemory' is not defined
This was verified and shipped long ago. Closing the bug report.