Bug 1458699
| Summary: | io-error when dd 50M file to 2G nbd disk | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Suqin Huang <shuang> |
| Component: | qemu-kvm-rhev | Assignee: | Eric Blake <eblake> |
| Status: | CLOSED NOTABUG | QA Contact: | Suqin Huang <shuang> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 7.4 | CC: | aliang, chayang, coli, eblake, juzhang, knoel, michen, pbonzini, shuang, virt-maint |
| Target Milestone: | rc | Keywords: | Reopened |
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2017-06-09 11:49:49 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
(In reply to Suqin Huang from comment #0) > Description of problem: > > > Version-Release number of selected component (if applicable): > > qemu-kvm-rhev-2.9.0-7.el7.x86_64 > > How reproducible: > 100% > > Steps to Reproduce: > 1. > Server: > #qemu-nbd -f raw stg.qcow2 -t I'm assuming you used -k /tmp/unix_socket as well? How was stg.qcow2 created; what does 'qemu-img info stg.qcow2' say? > > 2. > Client: > > cmd: > -drive > id=drive_image2,if=none,cache=none,format=qcow2,file=nbd:unix:/tmp/ > unix_socket,werror=stop,rerror=stop \ > -device > virtio-blk-pci,id=image2,drive=drive_image2,serial=TARGET_DISK0,bootindex=3, > bus=pci.0,addr=08 \ This is only a subset of the qemu command line; but I'm presuming you are trying to demonstrate that a full-blown guest with a secondary NBD drive is experiencing the problem, right? But it DOES look like you are correctly requesting format=qcow2, which matches well with the qemu-nbd -f raw (that is, qemu rather than NBD will be the one applying the qcow2 format). > > > 3. format attached nbd disk > #lsblk I'm assuming that this instruction is run within the guest? Which means knowing the guest OS installed (presumably on vda, since your NBD drive is vdb) is also useful information. > NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT > vda 252:0 0 20G 0 disk > ├─vda1 252:1 0 1G 0 part /boot > └─vda2 252:2 0 19G 0 part > ├─rhel_bootp--73--199--96-root 253:0 0 17G 0 lvm / > └─rhel_bootp--73--199--96-swap 253:1 0 2G 0 lvm [SWAP] > vdb 252:16 0 2G 0 disk > > #fdisk /dev/vdb > > Disk identifier: 0xfcbfdc42 > > Device Boot Start End Blocks Id System > /dev/vdb1 2048 4194303 2096128 83 Linux > > Command (m for help): w > The partition table has been altered! > > > Actual results: > > Guest status is paused after w the table > (qemu) info status > VM status: paused (io-error) > Well, you DID ask for werror=stop to stop the guest on any write errors, and the log makes it look like the guest DID try to write something that is not physically possible... > > Expected results: > > > Additional info: > > 1. > (qemu) info block -n > > #block919: nbd+unix://?socket=/tmp/unix_socket (nbd) > Cache mode: writeback, direct > > 2. Server: > nbd/server.c:nbd_co_receive_request():L1156: operation past EOF; From: > 327680, Len: 65536, Size: 197120 Are we sure the guest is issuing a valid write command that isn't exceeding the disk? On the other hand, the lsblk said vdb is 2G in size, and From+Len in the error message is nowhere near 2G. But then again, when you have the NBD image mounted in qcow2 format, it is not the guest offsets that matter, but the host offsets. It sounds like you are attempting a qcow2 write at a host offset beyond the bounds of the raw file being served over NBD. And that totally explains it: when you are using a regular file system, when a qcow2 file needs more space, it grows the underlying file automatically. But NBD _cannot_ (yet) resize the underlying file over the wire. You _have_ to pre-allocate the stg.qcow2 file to be large enough to hold all the guest data and all the qcow2 metadata that the qemu process will ever want to use. There are plans to add volume resizing to NBD, but right now it is still in the early design phase: https://lists.gnu.org/archive/html/qemu-devel/2017-01/msg05369.html But since the problem is NOT in qemu-nbd, but rather that you didn't pre-allocate a large enough file to be interpreted as qcow2 by qemu, I'm inclined to close this as not a bug. Note that we probably DO want to create an RFE bug (for 7.5 or later) to enable the use of online NBD resize. But as that feature has not stabilized in upstream NBD nor landed in upstream qemu yet, it is distinct from this one. re-open this bug
as when I run dd 50M file in a 2G ndb disk, get this issue as well.
1. #lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 20G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 19G 0 part
├─rhel_bootp--73--199--22-root 253:0 0 17G 0 lvm /
└─rhel_bootp--73--199--22-swap 253:1 0 2G 0 lvm [SWAP]
vdb 252:16 0 2G 0 disk
2. Run dd
#dd if=/dev/urandom of=/dev/vdb bs=512K count=100
3. cmd:
Server:
# qemu-nbd -f raw /root/stg.qcow2 -p 9000 -t --share=4
Client:
/usr/libexec/qemu-kvm \
-S \
-name 'avocado-vt-vm1' \
-sandbox off \
-machine pc \
-nodefaults \
-vga std \
-chardev socket,id=qmp_id_qmpmonitor1,path=/tmp/src,server,nowait \
-mon chardev=qmp_id_qmpmonitor1,mode=control \
-device pvpanic,ioport=0x505,id=id4FDckd \
-chardev socket,id=serial_id_serial0,path=/tmp/serial-src0,server,nowait \
-device isa-serial,chardev=serial_id_serial0 \
-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=/usr/share/avocado/data/avocado-vt/images/rhel74-64-virtio-scsi.qcow2 \
-device virtio-blk-pci,id=image1,drive=drive_image1,bootindex=0,bus=pci.0,addr=03 \
-drive id=drive_image2,if=none,cache=none,format=qcow2,file=nbd:10.73.196.131:9000,werror=stop,rerror=stop \
-device virtio-blk-pci,id=image2,drive=drive_image2,serial=TARGET_DISK0,bootindex=3,bus=pci.0,addr=08 \
-device virtio-net-pci,mac=9a:5d:0e:0f:10:59,id=idKK4Mdq,vectors=4,netdev=idgjGCvt,bus=pci.0,addr=05 \
-netdev tap,id=idgjGCvt,vhost=on,script=/etc/qemu-ifup \
-m 2048 \
-smp 4,maxcpus=4,cores=2,threads=1,sockets=2 \
-cpu Westmere \
-device usb-tablet,id=usb-tablet1,bus=usb1.0,port=1 \
-vnc :0 \
-rtc base=localtime,clock=host,driftfix=slew \
-boot order=cdn,once=c,menu=off,strict=off \
-enable-kvm \
-monitor stdio
4. image info
# qemu-img /root/stg.qcow2
qemu-img: Command not found: /root/stg.qcow2
Try 'qemu-img --help' for more information
[root@ibm-x3650m3-05 ~]# qemu-img info /root/stg.qcow2
image: /root/stg.qcow2
file format: qcow2
virtual size: 2.0G (2147483648 bytes)
disk size: 196K
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
# qemu-img info nbd:10.73.196.131:9000
image: nbd://10.73.196.131:9000
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
Re-open it as I could not wrote any data to nbd disk with qcow2 format currently. 1. I create 2G, 5G, 30G image the server part always show "Size: 197120" nbd/server.c:nbd_co_receive_request():L1156: operation past EOF; From: 262144, Len: 65536, Size: 197120 Seems that's what you mention in comment 3: "it is not the guest offsets that matter, but the host offsets" 2. Format the disk first and then export to nbd 1). boot with /root/stg.qcow2 and format the disk vdb 252:16 0 5G 0 disk └─vdb1 252:17 0 5G 0 part 2). boot with nbd://10.73.196.131:9000 # dd if=/dev/urandom of=/dev/vdb1 bs=1M count=500 The server show nbd/server.c:nbd_co_receive_request():L1156: operation past EOF; From: 44630016, Len: 8126464, Size: 11599872 (In reply to Suqin Huang from comment #6) > re-open this bug > > 4. image info > > [root@ibm-x3650m3-05 ~]# qemu-img info /root/stg.qcow2 > image: /root/stg.qcow2 > file format: qcow2 > virtual size: 2.0G (2147483648 bytes) > disk size: 196K There's your bug. You are not pre-allocating space for your qcow2 image. (In reply to Suqin Huang from comment #7) > Re-open it as I could not wrote any data to nbd disk with qcow2 format > currently. > > > 1. I create 2G, 5G, 30G image the server part always show "Size: 197120" $ qemu-img create -f qcow2 try1 1M Formatting 'try1', fmt=qcow2 size=1048576 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 $ qemu-img create -f qcow2 -o preallocation=full try2 1M Formatting 'try2', fmt=qcow2 size=1048576 encryption=off cluster_size=65536 preallocation=full lazy_refcounts=off refcount_bits=16 $ qemu-img info try1 image: try1 file format: qcow2 virtual size: 1.0M (1048576 bytes) disk size: 196K cluster_size: 65536 Format specific information: compat: 1.1 lazy refcounts: false refcount bits: 16 corrupt: false $ qemu-img info try2 image: try2 file format: qcow2 virtual size: 1.0M (1048576 bytes) disk size: 1.3M cluster_size: 65536 Format specific information: compat: 1.1 lazy refcounts: false refcount bits: 16 corrupt: false See the difference? -o preallocation=full is absolutely essential to making a qcow2 image large enough to be used across an interface that cannot be dynamically resized. I'm reclosing this, as it is an error in your test setup, and not a qemu bug. |
Description of problem: Version-Release number of selected component (if applicable): qemu-kvm-rhev-2.9.0-7.el7.x86_64 How reproducible: 100% Steps to Reproduce: 1. Server: #qemu-nbd -f raw stg.qcow2 -t 2. Client: cmd: -drive id=drive_image2,if=none,cache=none,format=qcow2,file=nbd:unix:/tmp/unix_socket,werror=stop,rerror=stop \ -device virtio-blk-pci,id=image2,drive=drive_image2,serial=TARGET_DISK0,bootindex=3,bus=pci.0,addr=08 \ 3. format attached nbd disk #lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 252:0 0 20G 0 disk ├─vda1 252:1 0 1G 0 part /boot └─vda2 252:2 0 19G 0 part ├─rhel_bootp--73--199--96-root 253:0 0 17G 0 lvm / └─rhel_bootp--73--199--96-swap 253:1 0 2G 0 lvm [SWAP] vdb 252:16 0 2G 0 disk #fdisk /dev/vdb Disk identifier: 0xfcbfdc42 Device Boot Start End Blocks Id System /dev/vdb1 2048 4194303 2096128 83 Linux Command (m for help): w The partition table has been altered! Actual results: Guest status is paused after w the table (qemu) info status VM status: paused (io-error) Expected results: Additional info: 1. (qemu) info block -n #block919: nbd+unix://?socket=/tmp/unix_socket (nbd) Cache mode: writeback, direct 2. Server: nbd/server.c:nbd_co_receive_request():L1156: operation past EOF; From: 327680, Len: 65536, Size: 197120