Bug 1883608 - 'qemu-nbd -B bitmap ...' without -r corrupts the bitmap
Summary: 'qemu-nbd -B bitmap ...' without -r corrupts the bitmap
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: qemu-kvm
Version: 8.3
Hardware: Unspecified
OS: Unspecified
medium
low
Target Milestone: rc
: 8.3
Assignee: Eric Blake
QA Contact: zixchen
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-09-29 17:07 UTC by Eric Blake
Modified: 2021-05-25 06:44 UTC (History)
9 users (show)

Fixed In Version: qemu-kvm-5.2.0-1.module+el8.4.0+9091+650b220a
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-05-25 06:43:36 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Eric Blake 2020-09-29 17:07:10 UTC
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.

Comment 1 Eric Blake 2020-09-29 17:38:25 UTC
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

Comment 4 Eric Blake 2020-09-30 14:06:13 UTC
Another upstream patch proposal with fewer dependencies:
https://lists.gnu.org/archive/html/qemu-devel/2020-09/msg10928.html

Comment 5 John Ferlan 2020-10-01 11:20:00 UTC
Eric - Assigning to you for now whether Stefan's or your fix are accepted upstream.

Comment 6 Eric Blake 2020-10-12 18:20:25 UTC
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>

Comment 7 John Ferlan 2020-11-24 21:27:30 UTC
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.

Comment 8 zixchen 2020-12-14 08:47:33 UTC
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.

Comment 11 zixchen 2020-12-17 13:00:58 UTC
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.

Comment 13 errata-xmlrpc 2021-05-25 06:43:36 UTC
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


Note You need to log in before you can comment on or make changes to this bug.