You are not logged in.

#1 2012-07-25 04:04:15

neilzium
Member
Registered: 2011-12-17
Posts: 41

[SOLVED] QEMU: virtio block device as root partition

I'm currently trying to set up a Debian VM with QEMU, using the following script which has been modified from the wiki. This causes 100% cpu on one core, and QEMU simply hangs.

#!/bin/bash
USERID=`whoami`
IFACE=$(sudo tunctl -b -u $USERID)
printf -v macaddr "52:54:0E:8E:CC:7E"

qemu-kvm -netdev tap,id=vnet0,vhost=on,ifname=$IFACE -device virtio-net-pci,netdev=vnet0,id=net0,mac=$macaddr \
-kernel /boot/vmlinuz-debian -initrd /boot/initrd-debian -append root=/dev/vda -m 512 -vga none -display none -cpu host -daemonize -smp cores=2 -enable-kvm -nographic \
-drive file=/dev/sda8,if=none,id=virtio-disk0,format=raw,cache=none,aio=native -device virtio-blk-pci,scsi=off,drive=virtio-disk0,id=disk0 \
-device virtio-balloon-pci,id=balloon0

sudo tunctl -d $IFACE &> /dev/null

I've confirmed that I can load a virtio block device with the VM by modifying the qemu-kvm line as follows:

qemu-kvm -netdev tap,id=vnet0,vhost=on,ifname=$IFACE -device virtio-net-pci,netdev=vnet0,id=net0,mac=$macaddr \
-kernel /boot/vmlinuz-debian -initrd /boot/initrd-debian -append root=/dev/sda -m 512 -vga none -display none -cpu host -daemonize -smp cores=2 -enable-kvm -nographic \
-drive file=/dev/sda9,if=none,id=virtio-disk0,format=raw,cache=none,aio=native -device virtio-blk-pci,scsi=off,drive=virtio-disk0,id=disk0 \
-device virtio-balloon-pci,id=balloon0 /dev/sda8

this produces a device /dev/vda on the VM.

lspci -v

00:03.0 SCSI storage controller: Red Hat, Inc Virtio block device
        Subsystem: Red Hat, Inc Device 0002
        Flags: bus master, fast devsel, latency 0, IRQ 11
        I/O ports at c000 [size=64]
        Memory at febf1000 (32-bit, non-prefetchable) [size=4K]
        Capabilities: [40] MSI-X: Enable+ Count=2 Masked-
        Kernel driver in use: virtio-pci

lsmod|grep virtio

virtio_rng              1928  0
rng_core                3006  1 virtio_rng
virtio_blk              4209  0
virtio_balloon          2961  0
virtio_net             10573  0
virtio_pci              5511  0
virtio_ring             3258  1 virtio_pci
virtio                  3309  5 virtio_rng,virtio_blk,virtio_balloon,virtio_net,virtio_pci

I haven't found any information as to whether or not this is supported on a physical partition, however there are many examples where an image as the root partition with virtio. I'm not sure if this is a Debian issue or a QEMU issue.

EDIT:
I should mention that the VM's fstab is mounting root by the fs label. I've confirmed that e2label /dev/vda does report the correct label so this shouldn't be the issue

Last edited by neilzium (2012-08-19 07:37:18)

Offline

#2 2012-08-19 07:37:03

neilzium
Member
Registered: 2011-12-17
Posts: 41

Re: [SOLVED] QEMU: virtio block device as root partition

Finally solved this thanks to the bug report linked in this post. adding -global virtio-blk-pci.ioeventfd=off fixed the problem. Don't know if this has been fixed in QEMU already. If so, it's probably because of older virtio drivers in debian squeeze.

Offline

Board footer

Powered by FluxBB