Bug 1712636 - When shutdown vm with 65536 persistent bitmaps added, bitmaps would fail to save to qcow2 image
Summary: When shutdown vm with 65536 persistent bitmaps added, bitmaps would fail to s...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: qemu-kvm
Version: ---
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: rc
: ---
Assignee: Virtualization Maintenance
QA Contact: aihua liang
URL:
Whiteboard:
Depends On:
Blocks: 1846832
TreeView+ depends on / blocked
 
Reported: 2019-05-22 02:48 UTC by aihua liang
Modified: 2020-06-15 02:25 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1846832 (view as bug list)
Environment:
Last Closed: 2020-06-08 06:17:22 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description aihua liang 2019-05-22 02:48:00 UTC
Description of problem:
  When shutdown vm with 65536 persistent bitmaps added, bitmaps would fail to save to qcow2 image

Version-Release number of selected component (if applicable):
  kernel version:
  qemu-kvm-rhev version:qemu-kvm-rhev-2.12.0-27.el7.x86_64

How reproducible:
 100%

Steps to Reproduce:
1.Start guest with qemu cmds:
   /usr/libexec/qemu-kvm \
    -name 'avocado-vt-vm1',process=qemu:'avocado-vt-vm1' \
    -machine pc  \
    -nodefaults \
    -device VGA,bus=pci.0,addr=0x2  \
    -chardev socket,id=qmp_id_qmpmonitor1,path=/var/tmp/monitor-qmpmonitor1-20190123-032240-rOoB4cgD,server,nowait \
    -mon chardev=qmp_id_qmpmonitor1,mode=control  \
    -chardev socket,id=qmp_id_catch_monitor,path=/var/tmp/monitor-catch_monitor-20190123-032240-rOoB4cgD,server,nowait \
    -mon chardev=qmp_id_catch_monitor,mode=control \
    -device pvpanic,ioport=0x505,id=id8Ec4Bn  \
    -chardev socket,id=serial_id_serial0,path=/var/tmp/serial-serial0-20190123-032240-rOoB4cgD,server,nowait \
    -device isa-serial,chardev=serial_id_serial0  \
    -chardev socket,id=seabioslog_id_20190123-032240-rOoB4cgD,path=/var/tmp/seabios-20190123-032240-rOoB4cgD,server,nowait \
    -device isa-debugcon,chardev=seabioslog_id_20190123-032240-rOoB4cgD,iobase=0x402 \
    -device ich9-usb-ehci1,id=usb1,addr=0x1d.7,multifunction=on,bus=pci.0 \
    -device ich9-usb-uhci1,id=usb1.0,multifunction=on,masterbus=usb1.0,addr=0x1d.0,firstport=0,bus=pci.0 \
    -device ich9-usb-uhci2,id=usb1.1,multifunction=on,masterbus=usb1.0,addr=0x1d.2,firstport=2,bus=pci.0 \
    -device ich9-usb-uhci3,id=usb1.2,multifunction=on,masterbus=usb1.0,addr=0x1d.4,firstport=4,bus=pci.0 \
    -object iothread,id=iothread0 \
    -drive id=drive_image1,if=none,snapshot=off,aio=threads,cache=none,format=qcow2,file=/home/kvm_autotest_root/images/rhel77-64-virtio.qcow2 \
    -device virtio-blk-pci,id=image1,drive=drive_image1,bus=pci.0,iothread=iothread0 \
    -drive id=drive_data1,if=none,snapshot=off,aio=threads,cache=none,format=qcow2,file=/home/data1.qcow2 \
    -device virtio-blk-pci,id=data1,drive=drive_data1,bus=pci.0,iothread=iothread0 \
    -device virtio-net-pci,mac=9a:39:3a:3b:3c:3d,id=id1JNQsL,vectors=4,netdev=idVpZZ6A,bus=pci.0  \
    -netdev tap,id=idVpZZ6A,vhost=on \
    -m 4096  \
    -smp 2,maxcpus=2,cores=1,threads=1,sockets=2  \
    -cpu 'SandyBridge',+kvm_pv_unhalt \
    -device usb-tablet,id=usb-tablet1,bus=usb1.0,port=1  \
    -vnc :0  \
    -rtc base=utc,clock=host,driftfix=slew  \
    -boot order=cdn,once=c,menu=off,strict=off \
    -enable-kvm \
    -monitor stdio \
    -qmp tcp:0:3000,server,nowait \

2.Add 63336 persistent bitmaps on drive_image1.
   {'execute': 'block-dirty-bitmap-add','arguments':{ 'node': 'drive_image1', 'name': 'bitmap$i', 'persistent':true }}

3.After step2 finished, check bitmaps info:
  {"execute":"query-block"}
{"return": [{"io-status": "ok", "device": "drive_image1", "locked": false, "removable": false, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": {"virtual-size": 21474836480, "filename": "/home/kvm_autotest_root/images/rhel77-64-virtio.qcow2", "cluster-size": 65536, "format": "qcow2", "actual-size": 4664791040, "format-specific": {"type": "qcow2", "data": {"compat": "1.1", "lazy-refcounts": false, "refcount-bits": 16, "corrupt": false}}, "dirty-flag": false}, "iops_wr": 0, "ro": false, "node-name": "#block137", "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 0, "write_threshold": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "cache": {"no-flush": false, "direct": true, "writeback": true}, "file": "/home/kvm_autotest_root/images/rhel77-64-virtio.qcow2", "encryption_key_missing": false}, "qdev": "/machine/peripheral/image1/virtio-backend", "dirty-bitmaps": [{"name": "bitmap65535", "recording": true, "persistent": true, "busy": false, "status": "active", "granularity": 65536, "count": 96272384}, {"name": "bitmap65534", "recording": true, "persistent": true, "busy": false, "status": "active", "granularity": 65536, "count": 96272384}, {"name": "bitmap65533", "recording": true, "persistent": true, "busy": false, "status": "active", "granularity": 65536, "count": 96272384}, {"name": "bitmap65532", "recording": true, "persistent": true, "busy": false, "status": "active", "granularity": 65536, "count": 96272384} ...

4.Shutdown vm in guest:
 (qemu) qemu-kvm: Lost persistent bitmaps during inactivation of node '#block137': Too many persistent bitmaps

5.Check bitmap info offline:
 #qemu-img info /home/kvm_autotest_root/iamges/rhel77-64-virtio.qcow2

Actual results:
 After step4, bitmaps were failed to be saved.
 
Expected results:
 In step3, the 65536 persistent bitmap added will failed.
 And after step4, 65535 bitmaps can be saved to qcow2 image after guest shutdown

Additional info:
  In /docs/interop/qcow2.txt:line:243 ~ line:248
   Byte  0 -  3:  nb_bitmaps
                    The number of bitmaps contained in the image. Must be
                    greater than or equal to 1.
 
                    Note: Qemu currently only supports up to 65535 bitmaps per
                    image.

Comment 3 John Snow 2019-06-04 23:05:35 UTC
I see the problem, thanks.

Comment 5 John Snow 2019-06-06 21:00:28 UTC
Patches posted upstream: https://lists.gnu.org/archive/html/qemu-devel/2019-06/msg01182.html

Comment 8 aihua liang 2019-09-05 02:09:22 UTC
Test on qemu-kvm-4.1.0-5.module+el8.1.0+4076+b5e41ebc.x86_64, also hit this issue.

Comment 9 Eric Blake 2019-10-10 15:40:09 UTC
Vladimir's counter-proposal, still needs a v2 at this time:
https://lists.gnu.org/archive/html/qemu-devel/2019-06/msg01696.html

Comment 10 aihua liang 2019-11-08 05:34:36 UTC
In rhel7, qemu-kvm-common-rhev-2.12.0-38.el7.x86_64, also hit this issue.

Comment 12 Ademar Reis 2020-02-05 22:58:08 UTC
QEMU has been recently split into sub-components and as a one-time operation to avoid breakage of tools, we are setting the QEMU sub-component of this BZ to "General". Please review and change the sub-component if necessary the next time you review this BZ. Thanks

Comment 13 aihua liang 2020-03-04 01:31:04 UTC
Test on qemu-kvm-4.2.0-13.module+el8.2.0+5898+fb4bceae, still hit this issue

Add 65537 persistent bitmaps, then quit vm.
qemu-kvm: Lost persistent bitmaps during inactivation of node 'drive_image1': Too many persistent bitmaps

# qemu-img info /home/kvm_autotest_root/images/rhel820-64-virtio-scsi.qcow2 
image: /home/kvm_autotest_root/images/rhel820-64-virtio-scsi.qcow2
file format: qcow2
virtual size: 20 GiB (21474836480 bytes)
disk size: 7.97 GiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

Comment 14 aihua liang 2020-06-08 06:17:22 UTC
Test on qemu-kvm-5.0.0-0.module+el8.3.0+6620+5d5e1420, with kernel version:4.18.0-203.el8.x86_64, don't hit this issue any more, so close this bug as Currentrelease.


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