[pve-devel] virtiodisk ordering bug in current implementation + proposal for new qemu device syntax

Alexandre DERUMIER aderumier at odiso.com
Mon Aug 29 06:58:42 CEST 2011


Hi,

I was playing this weekend with virtio disk, and I found a bug in current implemention.

Try a simple config:


name: test
ide2: cdrom,media=cdrom
bootdisk: virtio0
ostype: linux26
memory: 2000
sockets: 2
net0: virtio=16:CA:1F:89:97:8D,bridge=vmbr101
onboot: 1
cores: 1
virtio0: nexenta:0.0.28.scsi-3600144f0babf4a0000004d3ea1b40001,cache=none



It's launching vm with


/usr/bin/kvm -id 101 -monitor unix:/var/run/qemu-server/101.mon,server,nowait -vnc unix:/var/run/qemu-server/101.vnc,x509,password -pidfile /var/run/qemu-server/101.pid -daemonize -readconfig /usr/share/qemu-server/pve-usb.cfg -device usb-tablet,bus=ehci.0,port=6 -name nuxeo -smp sockets=2,cores=1 -nodefaults -boot menu=on -vga cirrus -tdf -k en-us 
-drive file=/dev/cdrom,if=ide,index=2,media=cdrom,aio=native 
-drive file=/dev/disk/by-id/scsi-3600144f0babf4a0000004d3ea1b40001,if=virtio,index=0,cache=none,aio=native,boot=on
 -m 2000 -netdev type=tap,id=net0,ifname=tap101i0,script=/var/lib/qemu-server/pve-bridge -device virtio-net-pci,romfile=,mac=6A:A0:91:E3:FF:98,netdev=net0


so, ok, no problem, we have 1 virtio disk, virtio0, index0 . guest side : /dev/vda


now add a second disk (in my case I add a local raw disk)


name: nuxeo
ide2: cdrom,media=cdrom
bootdisk: virtio0
ostype: linux26
memory: 2000
sockets: 2
net0: virtio=6A:A0:91:E3:FF:98,bridge=vmbr31
onboot: 1
cores: 1
virtio0: nexenta:0.0.28.scsi-3600144f0babf4a0000004d3ea1b40001,cache=none
virtio1: local:101/vm-101-disk-2.raw


so command line give

/usr/bin/kvm -id 101 -monitor unix:/var/run/qemu-server/101.mon,server,nowait -vnc unix:/var/run/qemu-server/101.vnc,x509,password -pidfile /var/run/qemu-server/101.pid -daemonize -readconfig /usr/share/qemu-server/pve-usb.cfg -device usb-tablet,bus=ehci.0,port=6 -name nuxeo -smp sockets=2,cores=1 -nodefaults -boot menu=on -vga cirrus -tdf -k en-us 
-drive file=/var/lib/vz/images/101/vm-101-disk-2.raw,if=virtio,index=1,aio=native 
-drive file=/dev/cdrom,if=ide,index=2,media=cdrom,aio=native
-drive file=/dev/disk/by-id/scsi-3600144f0babf4a0000004d3ea1b40001,if=virtio,index=0,cache=none,aio=native,boot=on 
-m 2000 -netdev type=tap,id=net0,ifname=tap101i0,script=/var/lib/qemu-server/pve-bridge -device virtio-net-pci,romfile=,mac=6A:A0:91:E3:FF:98,netdev=net0


so, normaly, no problem, virtio0 must be /dev/vda (index0)  and virtio1 /dev/vdb (index1)


but now, when i check on guest side.

virtio0  = /dev/vdb
virtio1  = /dev/vda


The reason is very simple, index option is not use with virtio disk. (you can remove it from drive options)

Each virtio disk has is own controller, so, order of the virtio disk, is the order of the controllers in pci slots.
Index is only use with disks on the same controller (like ide or scsi).
And qemu add controllers in the order of the command line (each time it add a controller,it assigne  the next free pci slot) !

I don't know why, in my case proxmox put the virtio1 before virtio0 in command line (don't have check the sourcecode).

For this old qemu syntax, we need to put command lines order, in virtio order.
(Maybe this bug exist in proxmox 1.8, don't have tested).
 





So , now for the new qemudevice syntax, here a new proposal:


The only way to order virtiodisk, is to choose pci slot order, so to not break current promox logic, and make it working better:

I propose to use index number of device, to assign pci slot.


virtio10: disk virtio slot 10
virtio11: disk virtio slot 11
net12: nic slot12
virtio13: disk virtio slot 13
pci14: pci passthrout slot 14
net13 : nic slot 13
...

No need to addr field, config file structure don't change.



So user can choose virtio disk from 10->31 , or nic from 10->31 or pci device from 10->31.
I one device already use the index, another device can't use it.
(example: we can't have virtio10 and nic10 at the same time).

In pve-manager side, 
- disk form is the same (only numbers for virtio disk index change).
- nic form, just add a "device number" field, like disks.

I think it's important to have the choice of slot device for nic too, because if you to order your nic you can (you can switch eth0/eth1 by changing slot number).


What do you think about it ?

Regards,

Alexandre




More information about the pve-devel mailing list