Description of problem: virsh setmem run failed with " --current" when domain is not running Version-Release number of selected component (if applicable): libvirt-7.3.0-1.module+el8.5.0+11004+f4810536.x86_64 qemu-kvm-6.0.0-16.module+el8.5.0+10848+2dccc46d.x86_64 How reproducible: always Steps to Reproduce: 1. prepare vm - <memory unit='KiB'>2621439</memory> <currentMemory unit='KiB'>2621439</currentMemory> 2. try to run "virsh setmem *** --current" # virsh setmem avocado-vt-vm1 1G --current error: Requested operation is not valid: domain is not running Actual results: current memory can't be set when the domain is not running Expected results: current memory can be set Additional info: It can be set well with libvirt-7.0.0-10.module+el8.4.0+10417+37f6984d.x86_64 & qemu-kvm-5.2.0-14.module+el8.4.0+10425+ad586fa5.x86_64.
Caused by: commit b5e267e8c59a257652f88d034cb1e0ce1ed4b58a Author: Michal Prívozník <mprivozn> Date: Wed Nov 25 10:40:50 2020 +0100 virsh: Simplify @flags handing in cmdSetmem() and cmdSetmaxmem() What code tries to achieve is that if no flags were provided to either 'setmem' or 'setmaxmem' commands then the old (no flags) API is called to be able to communicate with older daemons. Well, the code can be simplified a bit. Note that with this change the old no flag version of APIs is used more often. Previously if --current argument was given it resulted in *Flags() version to be called even though it is not necessary - VIR_DOMAIN_AFFECT_CURRENT is implied. Therefore, this change in fact allows virsh to talk with broader set of daemons. No other user visible changes were made. Signed-off-by: Michal Privoznik <mprivozn> Reviewed-by: Daniel Henrique Barboza <danielhb413> The problem is that the legacy API virDomainSetMaxMemory implies VIR_DOMAIN_AFFECT_LIVE in it's internal call and since --current doesn't add any special flag the old API is used instead of the new one which handles CURRENT properly. This was a hack in virsh though, the public API behavior didn't change.
Ooops. Patch proposed upstream: https://listman.redhat.com/archives/libvir-list/2021-May/msg00484.html
v2: https://listman.redhat.com/archives/libvir-list/2021-May/msg00533.html
Setting to blocker- as while this has the "test blocker" keyword it will not be a blocker for a release.
Fixed upstream as: 168190e19c virsh: Fix logic wrt to --current flag in cmdSetmem v7.3.0-222-g168190e19c
Tested with libvirt upstream version v7.3.0-257-gd8c468d58c & qemu-kvm-5.2.0-0.7.rc2.fc34.x86_64. S1. Run "virsh setmem x x --current" on a stopped vm. 1. Prepare a vm with below configuration. <maxMemory slots='16' unit='KiB'>8388608</maxMemory> <memory unit='KiB'>2621439</memory> <currentMemory unit='KiB'>2097152</currentMemory> <vcpu placement='static'>2</vcpu> 2. ✗ virsh setmem pc 2GiB --current 3. ✗ virsh dumpxml pc |grep -i memory <maxMemory slots='16' unit='KiB'>8388608</maxMemory> <memory unit='KiB'>2621439</memory> <currentMemory unit='KiB'>2097152</currentMemory> <cell id='0' cpus='0-1' memory='2097152' unit='KiB'/> <memory model='dimm' access='private' discard='yes'> </memory>
Verified with libvirt-daemon-7.4.0-1.module+el8.5.0+11218+83343022.x86_64 & qemu-kvm-6.0.0-19.module+el8.5.0+11385+6e7d542e.x86_64 Passed and test steps are the same as Comment 9.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (virt:av bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2021:4684