Bug 1086603

Summary: fail to repeat hot-plug and hot-unplg disk with same bootindex value specified
Product: Red Hat Enterprise Linux 7 Reporter: Sibiao Luo <sluo>
Component: qemu-kvm-rhevAssignee: Marcel Apfelbaum <marcel>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: chayang, famz, hhuang, jinzhao, juzhang, knoel, kwolf, marcel, michen, pbonzini, qzhang, rbalakri, virt-bugs, 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:
: 1314591 (view as bug list) Environment:
Last Closed: 2016-03-04 01:52:31 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:
Bug Depends On:    
Bug Blocks: 963588, 1314591    

Description Sibiao Luo 2014-04-11 07:49:30 UTC
Description of problem:
as subject, both the drive_add|del/device_del and blockdev_add/device_del hit the same issue, maybe hot-unplug not clear up some variable caused this issue.
btw, the issuse different to the bug 963588.

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.launch a QEMU guest.
2.hut-plug a disk using blockdev_add/__com.redhat_drive_add with bootindex specified.
3.hut-unplug the disk.
4.hut-plug the disk again using blockdev_add/__com.redhat_drive_add with the same bootindex in step2.

Actual results:
after step 4, fail to hot-plug again with the same bootindex value specified, QEMU will quit with message '(qemu) Two devices with same boot index 2'.

{"execute":"__com.redhat_drive_add","arguments": {"file":"/home/my-data-disk.raw","format":"raw","id":"drive-data-disk","aio":"native","werror":"stop","rerror":"stop"}}
{"return": {}}

{"execute":"device_add","arguments":{"driver":"virtio-blk-pci","drive":"drive-data-disk","id":"data-disk","bus":"pci.0","scsi":"off","addr":"0x9","bootindex":"2"}}
{"return": {}}

{"execute":"device_del","arguments":{"id":"data-disk"}}
{"return": {}}
{"timestamp": {"seconds": 1397200532, "microseconds": 784087}, "event": "DEVICE_DELETED", "data": {"path": "/machine/peripheral/data-disk/virtio-backend"}}
{"timestamp": {"seconds": 1397200532, "microseconds": 786714}, "event": "DEVICE_DELETED", "data": {"device": "data-disk", "path": "/machine/peripheral/data-disk"}}

{"execute":"__com.redhat_drive_add","arguments": {"file":"/home/my-data-disk.raw","format":"raw","id":"drive-data-disk","aio":"native","werror":"stop","rerror":"stop"}}
{"return": {}}

{"execute":"device_add","arguments":{"driver":"virtio-blk-pci","drive":"drive-data-disk","id":"data-disk","bus":"pci.0","scsi":"off","addr":"0x9","bootindex":"2"}}
Connection closed by foreign host.

Expected results:
it can repeat hot-plug and hot-unplg disk with the same bootindex value specified successfully.

Additional info:
use blockdev-add also fail to hot-plug again with the same bootindex value specified, QEMU will quit with message '(qemu) Two devices with same boot index 2'.
(qemu) Two devices with same boot index 2

{"execute":"qmp_capabilities"}
{"return": {}}
{ "execute": "blockdev-add", "arguments": {'options' : {'driver': 'raw', 'id':'drive-disk1', 'read-only': true, 'discard':'unmap', 'file': {'driver': 'file', 'filename': '/home/my-data-disk.raw'}, 'cache': { 'writeback': false, 'direct': true, 'no-flush': false }}} }
{"return": {}}
{"execute":"device_add","arguments":{"driver":"virtio-blk-pci","drive":"drive-disk1","id":"data-disk1","bus":"pci.0","scsi":"off","addr":"0x8","bootindex":"2"}}
{"return": {}}

{"execute":"device_del","arguments":{"id":"data-disk1"}}
{"return": {}}
{"timestamp": {"seconds": 1397202469, "microseconds": 383426}, "event": "DEVICE_DELETED", "data": {"path": "/machine/peripheral/data-disk1/virtio-backend"}}
{"timestamp": {"seconds": 1397202469, "microseconds": 385980}, "event": "DEVICE_DELETED", "data": {"device": "data-disk1", "path": "/machine/peripheral/data-disk1"}}
{"execute":"__com.redhat_drive_del","arguments":{"id":"drive-disk1"}}
{"return": {}}

{ "execute": "blockdev-add", "arguments": {'options' : {'driver': 'raw', 'id':'drive-disk1', 'read-only': true, 'discard':'unmap', 'file': {'driver': 'file', 'filename': '/home/my-data-disk.raw'}, 'cache': { 'writeback': false, 'direct': true, 'no-flush': false }}} }
{"return": {}}
{"execute":"device_add","arguments":{"driver":"virtio-blk-pci","drive":"drive-disk1","id":"data-disk1","bus":"pci.0","scsi":"off","addr":"0x8","bootindex":"2"}}
Connection closed by foreign host.

Comment 1 Sibiao Luo 2014-04-11 08:11:43 UTC
##
# @BlockdevOptionsBase
#
# Options that are available for all block devices, independent of the block
# driver.
#
# @driver:      block driver name
# @id:          #optional id by which the new block device can be referred to.
#               This is a required option on the top level of blockdev-add, and
#               currently not allowed on any other level.
# @node-name:   #optional the name of a block driver state node (Since 2.0)
# @discard:     #optional discard-related options (default: ignore)
# @cache:       #optional cache-related options
# @aio:         #optional AIO backend (default: threads)
# @rerror:      #optional how to handle read errors on the device
#               (default: report)
# @werror:      #optional how to handle write errors on the device
#               (default: enospc)
# @read-only:   #optional whether the block device should be read-only
#               (default: false)
#
# Since: 1.7

Comment 4 Markus Armbruster 2014-06-24 13:56:14 UTC
Assigning to Marcel, because he already has related bug 771545.

Comment 5 Ronen Hod 2014-07-13 13:17:07 UTC
*** Bug 1006384 has been marked as a duplicate of this bug. ***

Comment 7 Marcel Apfelbaum 2014-11-02 14:11:30 UTC
*** Bug 771545 has been marked as a duplicate of this bug. ***

Comment 14 jingzhao 2016-03-03 01:35:39 UTC
(In reply to Sibiao Luo from comment #0)
> Description of problem:
> as subject, both the drive_add|del/device_del and blockdev_add/device_del
> hit the same issue, maybe hot-unplug not clear up some variable caused this
> issue.
> btw, the issuse different to the bug 963588.
> 
> 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.launch a QEMU guest.
> 2.hut-plug a disk using blockdev_add/__com.redhat_drive_add with bootindex
> specified.
> 3.hut-unplug the disk.
> 4.hut-plug the disk again using blockdev_add/__com.redhat_drive_add with the
> same bootindex in step2.
> 
> Actual results:
> after step 4, fail to hot-plug again with the same bootindex value
> specified, QEMU will quit with message '(qemu) Two devices with same boot
> index 2'.
> 
> {"execute":"__com.redhat_drive_add","arguments":
> {"file":"/home/my-data-disk.raw","format":"raw","id":"drive-data-disk","aio":
> "native","werror":"stop","rerror":"stop"}}
> {"return": {}}
> 
> {"execute":"device_add","arguments":{"driver":"virtio-blk-pci","drive":
> "drive-data-disk","id":"data-disk","bus":"pci.0","scsi":"off","addr":"0x9",
> "bootindex":"2"}}
> {"return": {}}
> 
> {"execute":"device_del","arguments":{"id":"data-disk"}}
> {"return": {}}
> {"timestamp": {"seconds": 1397200532, "microseconds": 784087}, "event":
> "DEVICE_DELETED", "data": {"path":
> "/machine/peripheral/data-disk/virtio-backend"}}
> {"timestamp": {"seconds": 1397200532, "microseconds": 786714}, "event":
> "DEVICE_DELETED", "data": {"device": "data-disk", "path":
> "/machine/peripheral/data-disk"}}
> 
> {"execute":"__com.redhat_drive_add","arguments":
> {"file":"/home/my-data-disk.raw","format":"raw","id":"drive-data-disk","aio":
> "native","werror":"stop","rerror":"stop"}}
> {"return": {}}
> 
> {"execute":"device_add","arguments":{"driver":"virtio-blk-pci","drive":
> "drive-data-disk","id":"data-disk","bus":"pci.0","scsi":"off","addr":"0x9",
> "bootindex":"2"}}
> Connection closed by foreign host.
> 
> Expected results:
> it can repeat hot-plug and hot-unplg disk with the same bootindex value
> specified successfully.

--- Didn't reproduced with kernel-3.10.0-350.el7.x86_64 and qemu-kvm-rhev-2.3.0-31.el7_2.8.x86_64.

Following is the verified steps:
1. Boot vm with following cli:

/usr/libexec/qemu-kvm \
-M pc \
-cpu SandyBridge \
-nodefaults -rtc base=utc \
-m 4G \
-smp 2,sockets=2,cores=1,threads=1 \
-enable-kvm \
-name rhel7 \
-uuid 990ea161-6b67-47b2-b803-19fb01d30d12 \
-smbios type=1,manufacturer='Red Hat',product='RHEV Hypervisor',version=el6,serial=koTUXQrb,uuid=feebc8fd-f8b0-4e75-abc3-e63fcdb67170 \
-k en-us \
-monitor stdio \
-serial unix:/tmp/serial0,server,nowait \
-boot menu=on \
-bios /usr/share/seabios/bios.bin \
-vga std \
-vnc :0 \
-drive file=/home/rhel.img,if=none,id=drive-virtio-disk0,format=raw,cache=none,werror=stop,rerror=stop,aio=threads \
-device virtio-blk-pci,scsi=off,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=0 \
-netdev tap,id=hostnet1,vhost=on \
-device virtio-net-pci,netdev=hostnet1,id=net1,mac=54:52:00:B6:40:22 \
-qmp tcp::8887,server,nowait \

2. In qmp:

{"QMP": {"version": {"qemu": {"micro": 0, "minor": 3, "major": 2}, "package": " (qemu-kvm-rhev-2.3.0-31.el7_2.8)"}, "capabilities": []}}
{"execute":"qmp_capabilities"}
{"return": {}}
{"execute":"__com.redhat_drive_add","arguments": {"file":"/home/my-data-disk.raw","format":"raw","id":"drive-data-disk","aio":"native","werror":"stop","rerror":"stop"}}
{"return": {}}
{"execute":"device_add","arguments":{"driver":"virtio-blk-pci","drive":"drive-data-disk","id":"data-disk","bus":"pci.0","scsi":"off","addr":"0x9","bootindex":"2"}}
{"return": {}}
{"execute":"device_del","arguments":{"id":"data-disk"}}
{"return": {}}
{"timestamp": {"seconds": 1456967507, "microseconds": 298262}, "event": "DEVICE_DELETED", "data": {"path": "/machine/peripheral/data-disk/virtio-backend"}}
{"timestamp": {"seconds": 1456967507, "microseconds": 298758}, "event": "DEVICE_DELETED", "data": {"device": "data-disk", "path": "/machine/peripheral/data-disk"}}
{"execute":"__com.redhat_drive_add","arguments": {"file":"/home/my-data-disk.raw","format":"raw","id":"drive-data-disk","aio":"native","werror":"stop","rerror":"stop"}}
{"return": {}}
{"execute":"device_add","arguments":{"driver":"virtio-blk-pci","drive":"drive-data-disk","id":"data-disk","bus":"pci.0","scsi":"off","addr":"0x9","bootindex":"2"}}
{"return": {}}
{"timestamp": {"seconds": 1456967598, "microseconds": 339963}, "event": "SHUTDOWN"}
Connection closed by foreign host.

> 
> Additional info:
> use blockdev-add also fail to hot-plug again with the same bootindex value
> specified, QEMU will quit with message '(qemu) Two devices with same boot
> index 2'.
> (qemu) Two devices with same boot index 2
> 
> {"execute":"qmp_capabilities"}
> {"return": {}}
> { "execute": "blockdev-add", "arguments": {'options' : {'driver': 'raw',
> 'id':'drive-disk1', 'read-only': true, 'discard':'unmap', 'file': {'driver':
> 'file', 'filename': '/home/my-data-disk.raw'}, 'cache': { 'writeback':
> false, 'direct': true, 'no-flush': false }}} }
> {"return": {}}
> {"execute":"device_add","arguments":{"driver":"virtio-blk-pci","drive":
> "drive-disk1","id":"data-disk1","bus":"pci.0","scsi":"off","addr":"0x8",
> "bootindex":"2"}}
> {"return": {}}
> 
> {"execute":"device_del","arguments":{"id":"data-disk1"}}
> {"return": {}}
> {"timestamp": {"seconds": 1397202469, "microseconds": 383426}, "event":
> "DEVICE_DELETED", "data": {"path":
> "/machine/peripheral/data-disk1/virtio-backend"}}
> {"timestamp": {"seconds": 1397202469, "microseconds": 385980}, "event":
> "DEVICE_DELETED", "data": {"device": "data-disk1", "path":
> "/machine/peripheral/data-disk1"}}
> {"execute":"__com.redhat_drive_del","arguments":{"id":"drive-disk1"}}
> {"return": {}}
> 
> { "execute": "blockdev-add", "arguments": {'options' : {'driver': 'raw',
> 'id':'drive-disk1', 'read-only': true, 'discard':'unmap', 'file': {'driver':
> 'file', 'filename': '/home/my-data-disk.raw'}, 'cache': { 'writeback':
> false, 'direct': true, 'no-flush': false }}} }
> {"return": {}}
> {"execute":"device_add","arguments":{"driver":"virtio-blk-pci","drive":
> "drive-disk1","id":"data-disk1","bus":"pci.0","scsi":"off","addr":"0x8",
> "bootindex":"2"}}
> Connection closed by foreign host.

--Blocked with above steps because hit another issue.
  Hot-unplug the disk failed.(kernel-3.10.0-350.el7.x86_64 and qemu-kvm-rhev-2.3.0-31.el7_2.8.x86_64.)
Following is the reproduced steps
1. Boot vm with following cli:

/usr/libexec/qemu-kvm \
-M pc \
-cpu SandyBridge \
-nodefaults -rtc base=utc \
-m 4G \
-smp 2,sockets=2,cores=1,threads=1 \
-enable-kvm \
-name rhel7 \
-uuid 990ea161-6b67-47b2-b803-19fb01d30d12 \
-smbios type=1,manufacturer='Red Hat',product='RHEV Hypervisor',version=el6,serial=koTUXQrb,uuid=feebc8fd-f8b0-4e75-abc3-e63fcdb67170 \
-k en-us \
-monitor stdio \
-serial unix:/tmp/serial0,server,nowait \
-boot menu=on \
-bios /usr/share/seabios/bios.bin \
-vga std \
-vnc :0 \
-drive file=/home/rhel.img,if=none,id=drive-virtio-disk0,format=raw,cache=none,werror=stop,rerror=stop,aio=threads \
-device virtio-blk-pci,scsi=off,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=0 \
-netdev tap,id=hostnet1,vhost=on \
-device virtio-net-pci,netdev=hostnet1,id=net1,mac=54:52:00:B6:40:22 \
-qmp tcp::8887,server,nowait \

2. In qmp:

{ "execute": "blockdev-add", "arguments": {'options' : {'driver': 'raw', 'id':'drive-disk1', 'read-only': true, 'discard':'unmap', 'file': {'driver': 'file', 'filename': '/home/my-data-disk.raw'}, 'cache': { 'writeback': false, 'direct': true, 'no-flush': false }}} }
{"return": {}}
{"execute":"device_add","arguments":{"driver":"virtio-blk-pci","drive":"drive-disk1","id":"data-disk1","bus":"pci.0","scsi":"off","addr":"0x8","bootindex":"2"}}
{"return": {}}

3. In hmp:
(qemu) info block
drive-virtio-disk0: /home/rhel.img (raw)
    Cache mode:       writethrough, direct
(qemu) info block
drive-virtio-disk0: /home/rhel.img (raw)
    Cache mode:       writeback, direct

drive-disk1: /home/my-data-disk.raw (raw, read-only)
    Cache mode:       writethrough, direct

4.In qmp deleted the disk
{"execute":"device_del","arguments":{"id":"data-disk1"}}
{"return": {}}
{"timestamp": {"seconds": 1456968290, "microseconds": 66122}, "event": "DEVICE_DELETED", "data": {"path": "/machine/peripheral/data-disk1/virtio-backend"}}
{"timestamp": {"seconds": 1456968290, "microseconds": 66195}, "event": "DEVICE_DELETED", "data": {"device": "data-disk1", "path": "/machine/peripheral/data-disk1"}}


5.In guest, we can check the disk deleted through "fdisk -l"

6.But In hmp we can see the disk through "info block"
(qemu) info block
drive-virtio-disk0: /home/rhel.img (raw)
    Cache mode:       writeback, direct

drive-disk1: /home/my-data-disk.raw (raw, read-only)
    Removable device: not locked, tray closed
    Cache mode:       writethrough, direct

7. In qmp, add the disk again and we didn't add the disk
{ "execute": "blockdev-add", "arguments": {'options' : {'driver': 'raw', 'id':'drive-disk1', 'read-only': true, 'discard':'unmap', 'file': {'driver': 'file', 'filename': '/home/my-data-disk.raw'}, 'cache': { 'writeback': false, 'direct': true, 'no-flush': false }}} }
{"error": {"class": "GenericError", "desc": "Device with id 'drive-disk1' already exists"}}

Macel, should we file another bug for tracking the above issue?

Thanks
Jing

Comment 15 Marcel Apfelbaum 2016-03-03 11:53:46 UTC
Hi Jing,

Yes please, close this BZ and open a new one.

Thanks,
Marcel

Comment 16 jingzhao 2016-03-04 01:52:31 UTC
(In reply to Marcel Apfelbaum from comment #15)
> Hi Jing,
> 
> Yes please, close this BZ and open a new one.
> 
> Thanks,
> Marcel

According to comments14, closed this bug. Opened a new bug (bug1314591) for tracking the new issue.

Thanks
Jing