Hide Forgot
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 kernel-2.6.32-262.el6.x86_64 # rpm -qa|grep qemu qemu-kvm-tools-0.12.1.2-2.276.el6.x86_64 qemu-img-0.12.1.2-2.276.el6.x86_64 gpxe-roms-qemu-0.9.7-6.9.el6.noarch qemu-kvm-0.12.1.2-2.276.el6.x86_64 How reproducible: Steps to Reproduce: 1. 2. 3. 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
Reproduced: $ 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
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.