Bug 1465320 - active block commit failed with nbd backend
active block commit failed with nbd backend
Status: NEW
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm-rhev (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Eric Blake
Longxiang Lyu
Depends On:
Blocks: 1473046
  Show dependency treegraph
Reported: 2017-06-27 04:14 EDT by Suqin Huang
Modified: 2018-02-13 22:31 EST (History)
10 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Suqin Huang 2017-06-27 04:14:07 EDT
Description of problem:
"Block format 'nbd' used by node '#block084' does not support reopening files" error when do active commit

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
{ "execute": "qmp_capabilities" }
{"return": {}}

{ "execute": "blockdev-snapshot-sync", "arguments": { "device": "drive_image1", "snapshot-file": "/root/sn1", "format": "qcow2" } }
{"return": {}}

{ "execute": "blockdev-snapshot-sync", "arguments": { "device": "drive_image1", "snapshot-file": "/root/sn2", "format": "qcow2" } }
{"return": {}}

{ "execute": "blockdev-snapshot-sync", "arguments": { "device": "drive_image1", "snapshot-file": "/root/sn3", "format": "qcow2" } }
{"return": {}}

{ "execute": "block-commit", "arguments": { "device": "drive_image1", "top": "/root/sn3", "speed": 1000000000 } }
{"error": {"class": "GenericError", "desc": "Block format 'nbd' used by node '#block084' does not support reopening files"}}

pass if run 
{ "execute": "block-commit", "arguments": { "device": "drive_image1", "top": "/root/sn2", "speed": 1000000000 } }

/usr/libexec/qemu-kvm \
    -S  \
    -name 'avocado-vt-vm1'  \
    -sandbox off  \
    -machine pc  \
    -nodefaults  \
    -vga std  \
    -chardev socket,id=qmp_id_qmpmonitor1,path=/tmp/monitor,server,nowait \
    -mon chardev=qmp_id_qmpmonitor1,mode=control  \
    -device pvpanic,ioport=0x505,id=id4FDckd  \
    -chardev socket,id=serial_id_serial0,path=/tmp/serial,server,nowait \
    -device isa-serial,chardev=serial_id_serial0  \
    -chardev socket,id=seabioslog_id_20160129-133009-OkYQqhNt,path=/tmp/seabios-20160129-133009-OkYQqhNt,server,nowait \
    -device isa-debugcon,chardev=seabioslog_id_20160129-133009-OkYQqhNt,iobase=0x402 \
    -device ich9-usb-ehci1,id=usb1,addr=1d.7,multifunction=on,bus=pci.0 \
    -device ich9-usb-uhci1,id=usb1.0,multifunction=on,masterbus=usb1.0,addr=1d.0,firstport=0,bus=pci.0 \
    -device ich9-usb-uhci2,id=usb1.1,multifunction=on,masterbus=usb1.0,addr=1d.2,firstport=2,bus=pci.0 \
    -device ich9-usb-uhci3,id=usb1.2,multifunction=on,masterbus=usb1.0,addr=1d.4,firstport=4,bus=pci.0 \
    -drive id=drive_image1,if=none,cache=none,snapshot=off,aio=native,format=qcow2,file=nbd:// \
    -device virtio-blk-pci,id=image1,drive=drive_image1,bootindex=0,bus=pci.0,addr=03 \
    -device virtio-net-pci,mac=9a:0d:0e:0f:10:11,id=idKK4Mdq,vectors=4,netdev=idgjGCvt,bus=pci.0,addr=05  \
    -netdev tap,id=idgjGCvt,vhost=on,script=/etc/qemu-ifup \
    -m 2048 \
    -smp 2,maxcpus=2,cores=2,threads=1,sockets=1  \
    -cpu Westmere \
    -vnc :2 \
    -rtc base=localtime,clock=host,driftfix=slew  \
    -boot order=cdn,once=c,menu=off,strict=off \
    -no-kvm \
    -monitor stdio 


Actual results:

Expected results:

Additional info:
Comment 3 Eric Blake 2017-06-28 09:15:55 EDT
Live commit has always required the ability to convert a backing file from read-only to read-write (if the backing file is not already read-write).  Specifying NBD as a backing file when starting qemu defaults to using NBD read-only, and there is no way to convert NBD from read-only to read-write at run-time.  But your use case is creating NBD as a read-write file (the initial active image), then adding snapshots on top:

>     -drive
> id=drive_image1,if=none,cache=none,snapshot=off,aio=native,format=qcow2,
> file=nbd:// \
>     -device
> virtio-blk-pci,id=image1,drive=drive_image1,bootindex=0,bus=pci.0,addr=03 \

Where it gets interesting is that you are showing a difference between live commit (merge the active image to the base NBD file, then make the base NBD file active again):

> { "execute": "block-commit", "arguments": { "device": "drive_image1", "top":
> "/root/sn3", "speed": 1000000000 } }
> {"error": {"class": "GenericError", "desc": "Block format 'nbd' used by node
> '#block084' does not support reopening files"}}

from intermediate commit (shrinking the backing chain, but keeping /root/sn3 as the live image):

> pass if run 
> { "execute": "block-commit", "arguments": { "device": "drive_image1", "top":
> "/root/sn2", "speed": 1000000000 } }

So you may have indeed discovered an oddity in the qemu code for live-commit (both versions of commit SHOULD be able to succeed, if the NBD image is indeed read-write).

I'll have to investigate further.
Comment 4 Suqin Huang 2017-06-28 19:15:47 EDT
reproduce with qemu-kvm-rhev-2.9.0-2.el7.x86_64, not regression
Comment 5 Eric Blake 2017-08-03 21:45:07 EDT
For my own notes, pared down reproducer:
window 1:
qemu-img create -f qcow2 bar 1m
qemu-nbd -t -f raw bar

window 2:
./x86_64-softmmu/qemu-system-x86_64 -nographic -nodefaults -qmp stdio \
-drive id=drive-image1,if=none,format=qcow2,file=nbd://localhost:10809 \
-device virtio-blk-pci,id=image1,drive=drive-image1


{'execute':'blockdev-snapshot-sync','arguments':{'device':'drive-image1', 'snapshot-file':'bar1','format':'qcow2'}}
{'execute':'blockdev-snapshot-sync','arguments':{'device':'drive-image1', 'snapshot-file':'bar2','format':'qcow2'}}
{'execute':'blockdev-snapshot-sync','arguments':{'device':'drive-image1', 'snapshot-file':'bar3','format':'qcow2'}}

intermediate works:

active fails:
Comment 6 Eric Blake 2018-01-17 16:00:17 EST
This may need a resolution similar to bug 1529666 where LUKS reports the same error message; it may also need to wait for upstream to revamp block job support.
Comment 7 yilzhang 2018-02-13 22:31:31 EST
The following case also hit this error:
1. Prepare a NBD backend image
# qemu-img info  nbd:
image: nbd://
file format: qcow2
virtual size: 2.0G (2147483648 bytes)
disk size: unavailable
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

2. Create snapshot sn1
# qemu-img create -f qcow2 -F qcow2 -b nbd:        sn1.qcow2
Formatting 'sn1.qcow2', fmt=qcow2 size=2147483648 backing_file=nbd: backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16

3. Create snapshot sn2
# qemu-img create -f qcow2 -F qcow2      -b sn1.qcow2 sn2.qcow2
Formatting 'sn2.qcow2', fmt=qcow2 size=2147483648 backing_file=sn1.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16

4. Commit sn2 to base
#  qemu-img commit -f qcow2   -b nbd://     sn2.qcow2
qemu-img: Block format 'nbd' used by node '#block474' does not support reopening files

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