Bug 813793 - Cant add a ide device with index option when virtio-blk/usb-storage device exists
Cant add a ide device with index option when virtio-blk/usb-storage device ex...
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
x86_64 Linux
unspecified Severity medium
: rc
: ---
Assigned To: Markus Armbruster
Virtualization Bugs
Depends On:
  Show dependency treegraph
Reported: 2012-04-18 08:53 EDT by Qingtang Zhou
Modified: 2013-01-09 19:52 EST (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-04-26 04:05:50 EDT
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 Qingtang Zhou 2012-04-18 08:53:46 EDT
Description of problem:
When adding a ide device with 'index=1' in qemu-kvm cli which contains 2 virtio-blk devices, qemu-kvm reports a error like:
qemu: -drive file=winutils.iso,index=1,if=none,id=drive-ide0-0-0,media=cdrom,boot=off,snapshot=off,readonly=on,format=raw: drive with bus=0, unit=1 (index=1) exists

I also tried with usb-storage device, adding a ide device with 'index=1' to qemu cli which has one virtio-blk and one usb-storage device, qemu also reports this error.

I think drives for virtio-blk/usb-storage aren't related to drives for ide device, so the index for ide should not be affected by other types of device. If there are more than 4 virtio-blk/usb-storage, I even could not add a ide device.

Version-Release number of selected component (if applicable):
# rpm -q kernel

# rpm -qa|grep qemu

How reproducible:

Steps to Reproduce:
Actual results:

Expected results:

Additional info:
Full qemu-kvm cli:

/home/autotest-devel/client/tests/kvm/qemu \
-name 'vm1' \
-nodefaults \
-chardev socket,id=qmp_monitor_id_qmpmonitor1,path=/tmp/monitor,server,nowait \
-mon chardev=qmp_monitor_id_qmpmonitor1,mode=control \
-chardev socket,id=serial_id_20120417-201603-0CS2,path=/tmp/serial,server,nowait \
-device isa-serial,chardev=serial_id_20120417-201603-0CS2 \
-device usb-ehci,id=usb1,bus=pci.0,addr=0x4 \
-drive file='winXP-32-virtio.qcow2',index=0,if=none,id=drive-virtio-disk1,media=disk,cache=none,boot=on,snapshot=off,readonly=off,format=qcow2,aio=native \
-device virtio-blk-pci,bus=pci.0,addr=0x8,drive=drive-virtio-disk1,id=virtio-disk1 \
-device virtio-net-pci,netdev=idGrDvvY,mac=9a:92:75:37:59:1c,id=ndev00idGrDvvY,bus=pci.0,addr=0x3 \
-netdev tap,id=idGrDvvY,vhost=on,fd=19 \
-m 4096 \
-smp 2,cores=1,threads=1,sockets=2 \
-cpu 'Penryn' \
-drive file='stg0.qcow2',if=none,id=drive-virtio-disk2,media=disk,cache=none,boot=off,snapshot=off,readonly=off,format=qcow2,aio=native \
-device virtio-blk-pci,bus=pci.0,addr=0x9,drive=drive-virtio-disk2,id=virtio-disk2 \
-drive file='winutils.iso',index=1,if=none,id=drive-ide0-0-0,media=cdrom,boot=off,snapshot=off,readonly=on,format=raw \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-spice port=8000,disable-ticketing \
-vga qxl \
-rtc base=localtime,clock=host,driftfix=slew \
-M rhel6.3.0 \
-boot order=cdn,once=c,menu=off   \
-enable-kvm \
-monitor stdio
Comment 2 Markus Armbruster 2012-04-26 03:45:21 EDT

$ rhel6-qemu-kvm \
-nodefaults \
-drive file='foo.qcow2',index=0,if=none,id=drive-virtio-disk1 \
-device virtio-blk-pci,drive=drive-virtio-disk1,id=virtio-disk1 \
-drive file='bar.qcow2',if=none,id=drive-virtio-disk2,format=qcow2 \
-device virtio-blk-pci,drive=drive-virtio-disk2,id=virtio-disk2 \
-drive file='baz.iso',index=1,if=none,id=drive-ide0-0-0,media=cdrom,format=raw \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-enable-kvm \
-monitor stdio 
rhel6-qemu-kvm: -drive file=baz.iso,index=1,if=none,id=drive-ide0-0-0,media=cdrom,format=raw: drive with bus=0, unit=1 (index=1) exists
Comment 3 Markus Armbruster 2012-04-26 04:05:50 EDT
TL;DR: Works as designed, closing NOTABUG.  If you think this is a bug, feel free to reopen; just make sure to explain why you think it's a bug.

Detailed explanation of how this works:

-drive defines a drive with a unique (if, index). You can also specify the index as bus and unit, for convenience.

If you don't specify an index (directly or via bus, unit), the next unused index is assigned automatically.

Your test case defines three drives:

1. index=0,if=none,id=drive-virtio-disk1
2. if=none,id=drive-virtio-disk2
3. index=1,if=none,id=drive-ide0-0-0

The second one doesn't specify index, so the next unused index is assigned automatically, which happens to be index=1.

The third one then asks for index=1, and fails, because that's already in use.

With if=none, the index is actually meaningless.  Nevertheless, it needs to be unique.

I recommend not to use option index with if=none.

If you're looking for a way to control the IDE CD-ROM device address, use ide-drive qdev properties bus and unit.  Actually, you do that already.

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