Bug 1086190
| Summary: | fail to hot-unplug the storage device via 'device_del' after 'blockdev-add' in QMP | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Sibiao Luo <sluo> |
| Component: | qemu-kvm | Assignee: | Markus Armbruster <armbru> |
| Status: | CLOSED NOTABUG | QA Contact: | Virtualization Bugs <virt-bugs> |
| Severity: | high | Docs Contact: | |
| Priority: | high | ||
| Version: | 7.0 | CC: | acathrow, chayang, famz, hhuang, juzhang, kwolf, michen, qzhang, virt-maint, xfu |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2014-04-11 12:02:32 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: | |||
HMP drive_del also hit the same issue. (qemu) info block drive-ide-disk: removable=0 io-status=ok file=/mnt/RHEL-7.0-20140409.0_Server_x86_64.qcow2 ro=0 drv=qcow2 encrypted=0 bps=0 bps_rd=0 bps_wr=0 iops=0 iops_rd=0 iops_wr=0 floppy0: removable=1 locked=0 tray-open=0 [not inserted] sd0: removable=1 locked=0 tray-open=0 [not inserted] disk2: removable=0 io-status=ok file=/dev/sdb ro=0 drv=raw encrypted=0 bps=0 bps_rd=0 bps_wr=0 iops=0 iops_rd=0 iops_wr=0 (qemu) devi device_add device_del (qemu) device_del disk2 (qemu) info block drive-ide-disk: removable=0 io-status=ok file=/mnt/RHEL-7.0-20140409.0_Server_x86_64.qcow2 ro=0 drv=qcow2 encrypted=0 bps=0 bps_rd=0 bps_wr=0 iops=0 iops_rd=0 iops_wr=0 floppy0: removable=1 locked=0 tray-open=0 [not inserted] sd0: removable=1 locked=0 tray-open=0 [not inserted] disk2: removable=1 locked=0 tray-open=0 io-status=ok file=/dev/sdb ro=0 drv=raw encrypted=0 bps=0 bps_rd=0 bps_wr=0 iops=0 iops_rd=0 iops_wr=0 Best Regards, sluo If execute two steps: device_del and then drive_del cam remove it correctly. (qemu) device_del disk2 (qemu) info block drive-ide-disk: removable=0 io-status=ok file=/mnt/RHEL-7.0-20140409.0_Server_x86_64.qcow2 ro=0 drv=qcow2 encrypted=0 bps=0 bps_rd=0 bps_wr=0 iops=0 iops_rd=0 iops_wr=0 floppy0: removable=1 locked=0 tray-open=0 [not inserted] sd0: removable=1 locked=0 tray-open=0 [not inserted] disk2: removable=1 locked=0 tray-open=0 io-status=ok file=/dev/sdb ro=0 drv=raw encrypted=0 bps=0 bps_rd=0 bps_wr=0 iops=0 iops_rd=0 iops_wr=0 (qemu) drive_del disk2 (qemu) info block drive-ide-disk: removable=0 io-status=ok file=/mnt/RHEL-7.0-20140409.0_Server_x86_64.qcow2 ro=0 drv=qcow2 encrypted=0 bps=0 bps_rd=0 bps_wr=0 iops=0 iops_rd=0 iops_wr=0 floppy0: removable=1 locked=0 tray-open=0 [not inserted] sd0: removable=1 locked=0 tray-open=0 [not inserted] (qemu) Short story: Works as designed, closing NOTABUG Longer story: many virtual devices, including block devices, consist of a frontend (a.k.a. device model) and a backend. -drive, drive_add, drive_del and blockdev-add all operate on block backends. query-block lists block backends. device_add, device_del operate on frontends. In particular, device_del only deletes the frontend, but leaves the backend alone. Ugly exception: *if* the frontend is connected to a *block* backend, device_del also deletes the backend. This is an ugly wart we can't clean up without breaking backward compatibility. However, there's no need to replicate old warts in new interfaces, where backward compatibility is not an issue. In this case, we restricted the wart to block backends created the traditional ways, and got rid of id for block backends created the new way, i.e. with blockdev-add. Old live cycle: 1. drive_add 2. device_add 3. device_del 4. wait for QEVENT_DEVICE_DELETED or timeout 5. if timeout drive_del Note there's a race: if the automatic deletion happens between timeout and 5., then the drive_del fails. New live cycle: 1. blockdev-add 2. device_add 3. device_del 4. wait for QEVENT_DEVICE_DELETED or timeout 5. blockdev-del This is how other device types work, e.g. network. blockdev-del doesn't exist, yet (bug 1086193). |
Description of problem: 'blockdev-add' a virtio-blk device correctly, than fail to 'device_del' unplug it in QMP, the disk can still existing in QMP but it can disappear in guest. Version-Release number of selected component (if applicable): host info: # uname -r && rpm -q qemu-kvm 3.10.0-121.el7.x86_64 qemu-kvm-1.5.3-60.el7.x86_64 guest info: # uname -r 3.10.0-121.el7.x86_64 How reproducible: 100% Steps to Reproduce: 1.'blockdev-add' a virtio-blk device. { "execute": "blockdev-add", "arguments": {'options' : {'driver': 'raw', 'id':'disk1', 'file': {'driver': 'file', 'filename': '/home/my-data-disk.raw'}}} } {"execute":"device_add","arguments":{"driver":"virtio-blk-pci","drive":"disk1","id":"disk1","bus":"pci.0","scsi":"off","addr":"0x8"}} {"execute":"query-block"} guest ]# fdisk -l guest ]# dmesg 2.try 'device_del' to unplug it. {"execute":"device_del","arguments":{"id":"disk1"}} {"execute":"query-block"} guest ]# fdisk -l guest ]# dmesg Actual results: after step 1, blockdev-add a virtio-blk storage successfully. { "execute": "blockdev-add", "arguments": {'options' : {'driver': 'raw', 'id':'disk1', 'file': {'driver': 'file', 'filename': '/home/my-data-disk.raw'}}} } {"return": {}} {"execute":"device_add","arguments":{"driver":"virtio-blk-pci","drive":"disk1","id":"disk1","bus":"pci.0","scsi":"off","addr":"0x8"}} {"return": {}} {"execute":"query-block"} {"return": [...{"io-status": "ok", "device": "disk1", "locked": false, "removable": false, "inserted": {"iops_rd": 0, "image": {"virtual-size": 10737418240, "filename": "/home/my-data-disk.raw", "format": "raw", "actual-size": 0}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "raw", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "/home/my-data-disk.raw", "encryption_key_missing": false}, "type": "unknown"}]} guest ]# fdisk -l ... Disk /dev/vda: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes guest ]# dmesg [ 30.283067] end_request: I/O error, dev fd0, sector 0 [ 52.586352] ACPI: Device does not support D3cold [ 52.586572] pci 0000:00:08.0: [1af4:1001] type 00 class 0x010000 [ 52.586700] pci 0000:00:08.0: reg 0x10: [io 0x0000-0x003f] [ 52.586756] pci 0000:00:08.0: reg 0x14: [mem 0x00000000-0x00000fff] [ 52.587470] pci 0000:00:08.0: BAR 1: assigned [mem 0x80000000-0x80000fff] [ 52.587501] pci 0000:00:08.0: BAR 0: assigned [io 0x1000-0x103f] [ 52.587532] pci 0000:00:00.0: no hotplug settings from platform [ 52.587534] pci 0000:00:00.0: using default PCI settings [ 52.587582] pci 0000:00:01.0: no hotplug settings from platform [ 52.587584] pci 0000:00:01.0: using default PCI settings [ 52.587629] ata_piix 0000:00:01.1: no hotplug settings from platform [ 52.587631] ata_piix 0000:00:01.1: using default PCI settings [ 52.587676] uhci_hcd 0000:00:01.2: no hotplug settings from platform [ 52.587679] uhci_hcd 0000:00:01.2: using default PCI settings [ 52.587723] piix4_smbus 0000:00:01.3: no hotplug settings from platform [ 52.587725] piix4_smbus 0000:00:01.3: using default PCI settings [ 52.587771] cirrus 0000:00:02.0: no hotplug settings from platform [ 52.587773] cirrus 0000:00:02.0: using default PCI settings [ 52.587817] virtio-pci 0000:00:03.0: no hotplug settings from platform [ 52.587819] virtio-pci 0000:00:03.0: using default PCI settings [ 52.587864] virtio-pci 0000:00:05.0: no hotplug settings from platform [ 52.587866] virtio-pci 0000:00:05.0: using default PCI settings [ 52.587911] virtio-pci 0000:00:06.0: no hotplug settings from platform [ 52.587913] virtio-pci 0000:00:06.0: using default PCI settings [ 52.587958] pci 0000:00:08.0: no hotplug settings from platform [ 52.587960] pci 0000:00:08.0: using default PCI settings [ 52.588209] virtio-pci 0000:00:08.0: enabling device (0000 -> 0003) [ 52.615095] virtio-pci 0000:00:08.0: irq 43 for MSI/MSI-X [ 52.615141] virtio-pci 0000:00:08.0: irq 44 for MSI/MSI-X [ 52.617705] vda: unknown partition table after step 2, fail to remove the virtio-blk storage, the disk still existing in QMP. {"execute":"device_del","arguments":{"id":"disk1"}} {"return": {}} {"timestamp": {"seconds": 1397124413, "microseconds": 825303}, "event": "DEVICE_DELETED", "data": {"path": "/machine/peripheral/disk1/virtio-backend"}} {"timestamp": {"seconds": 1397124413, "microseconds": 827897}, "event": "DEVICE_DELETED", "data": {"device": "disk1", "path": "/machine/peripheral/disk1"}} {"execute":"query-block"} {"return": [...{"io-status": "ok", "device": "disk1", "locked": false, "removable": true, "inserted": {"iops_rd": 0, "image": {"virtual-size": 10737418240, "filename": "/home/my-data-disk.raw", "format": "raw", "actual-size": 0}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "raw", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "/home/my-data-disk.raw", "encryption_key_missing": false}, "tray_open": false, "type": "unknown"}]} guest ]# fdisk -l <------cann't display /dev/vda in guest. guest ]# dmesg [ 62.814063] end_request: I/O error, dev fd0, sector 0 [ 131.926569] ACPI: Device does not support D3cold Expected results: it can remove the disk successfully in QMP. Additional info: # /usr/libexec/qemu-kvm -M pc -S -cpu host -enable-kvm -m 2048 -smp 2,sockets=2,cores=1,threads=1 -no-kvm-pit-reinjection -usb -device usb-tablet,id=input0 -name sluo -uuid 990ea161-6b67-47b2-b803-19fb01d30d30 -rtc base=localtime,clock=host,driftfix=slew -device virtio-serial-pci,id=virtio-serial0,max_ports=16,vectors=0,bus=pci.0,addr=0x3 -chardev socket,id=channel1,path=/tmp/helloworld1,server,nowait -device virtserialport,chardev=channel1,name=com.redhat.rhevm.vdsm,bus=virtio-serial0.0,id=port1 -chardev socket,id=channel2,path=/tmp/helloworld2,server,nowait -device virtserialport,chardev=channel2,name=com.redhat.rhevm.vdsm,bus=virtio-serial0.0,id=port2 -drive file=/mnt/RHEL-7.0-20140409.0_Server_x86_64.qcow2,if=none,id=drive-ide-disk,format=qcow2,cache=none,aio=native,discard=on -device ide-hd,bus=ide.0,unit=0,drive=drive-ide-disk,id=ide-disk,bootindex=1 -netdev tap,id=hostnet0,vhost=on,script=/etc/qemu-ifup -device virtio-net-pci,netdev=hostnet0,id=virtio-net-pci0,mac=00:01:02:B6:40:21,bus=pci.0,addr=0x5 -device virtio-balloon-pci,id=ballooning,bus=pci.0,addr=0x6 -global PIIX4_PM.disable_s3=0 -global PIIX4_PM.disable_s4=0 -k en-us -boot menu=on -qmp tcp:0:4444,server,nowait -serial unix:/tmp/ttyS0,server,nowait -vnc :1 -spice disable-ticketing,port=5931 -monitor stdio