RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1086190 - fail to hot-unplug the storage device via 'device_del' after 'blockdev-add' in QMP
Summary: fail to hot-unplug the storage device via 'device_del' after 'blockdev-add' i...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm
Version: 7.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: ---
Assignee: Markus Armbruster
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-04-10 10:36 UTC by Sibiao Luo
Modified: 2014-04-11 12:02 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-04-11 12:02:32 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Sibiao Luo 2014-04-10 10:36:36 UTC
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

Comment 1 Sibiao Luo 2014-04-10 10:59:04 UTC
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

Comment 2 Sibiao Luo 2014-04-10 11:00:16 UTC
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)

Comment 3 Markus Armbruster 2014-04-11 12:02:32 UTC
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).


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