Description of problem: qemu 4.0 added the shorthand 'qemu-nbd -B bitmap' to expose the dirty bitmap of a given qcow2 image over NBD (rather than having to fire up qemu-kvm and using QMP commands to do the same). For read-only images, this is fine, but for read-write images, it leaves the bitmap marked in-use, which in turn corrupts the bitmap for any further use after qemu-nbd completes. Version-Release number of selected component (if applicable): qemu-kvm-5.1.0-9.module+el8.3.0+8182+ac9ced32 How reproducible: 100% Steps to Reproduce: 1. qemu-img create -f qcow2 image 1M 2. qemu-img bitmap -add image b0 3. qemu-nbd -f qcow2 -B b0 image # followed by ^C 4. qemu-nbd -f qcow2 -B b0 image Actual results: On step 4: qemu-nbd: Bitmap 'b0' is inconsistent and cannot be used Expected results: The in-use flag should be cleared when qemu-nbd is exiting, regardless of whether a client has connected (or alternatively, not set until the first client actually connects...) Additional info: The problem does not happen if a client connects to qemu-nbd; it is only an issue when using SIGINT (ctrl-c) to kill qemu-nbd while it is waiting for a client.
It turns out the problem was a lack of a SIGINT handler. While I was trying to debug this, I discovered that an unrelated patch pending upstream review happens to fix it: https://lists.gnu.org/archive/html/qemu-devel/2020-09/msg10419.html
Another upstream patch proposal with fewer dependencies: https://lists.gnu.org/archive/html/qemu-devel/2020-09/msg10928.html
Eric - Assigning to you for now whether Stefan's or your fix are accepted upstream.
Fix is now upstream: commit 029a88c9a7e3210ba565c081471bd44ba8d5e397 Author: Eric Blake <eblake> Date: Wed Sep 30 07:11:01 2020 -0500 qemu-nbd: Honor SIGINT and SIGHUP Honoring just SIGTERM on Linux is too weak; we also want to handle other common signals, and do so even on BSD. Why? Because at least 'qemu-nbd -B bitmap' needs a chance to clean up the in-use bit on bitmaps when the server is shut down via a signal. See also: http://bugzilla.redhat.com/1883608 Signed-off-by: Eric Blake <eblake> Message-Id: <20200930121105.667049-2-eblake> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov> [eblake: apply comment tweak suggested by Vladimir; fix ifdef around termsig_handler] Signed-off-by: Eric Blake <eblake>
Moving to 8.4.0 and placing in POST since RHV doesn't require this for 8.3.1 and the code will be in qemu-5.2. Set the ITM to 11 just as a best guess for when rebase is complete and testing can be done from the rebase.
Test with qemu-kvm-5.2.0-1.module+el8.4.0+9091+650b220a.x86_64, not found this issue, change status to tested. Version: qemu-kvm-5.2.0-1.module+el8.4.0+9091+650b220a.x86_64 kernel-4.18.0-259.el8.dt4.x86_64 Steps to Reproduce: 1. qemu-img create -f qcow2 image 1M 2. qemu-img bitmap --add image b0 3. qemu-nbd -f qcow2 -B b0 image # followed by ^C 4. qemu-nbd -f qcow2 -B b0 image Actual result: After step 4, it can export image, checked image info successfully with command qemu-img info nbd:loclahost:10809 Expoected result: Same as above.
As qemu-kvm-5.2.0-1.module+el8.4.0+9091+650b220a.x86_64 already be tested with no issue found, change status to verified.
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:2098