KVM & Virtio (disk/nic) on Scientific Linux 6 (alpha 3)

KVM as a “full virtualization” is a nice feature because it allows you to run any operating system virtualized. However, it’s relatively slow because the hypervisor has to emulate actual physical devices such as RTL8139 network cards and the most recent SeaBios emulates IDE interface.This fragment from KVM guest dmesg log is fair enough :-

[ 0.129740] ata_piix 0000:00:01.1: version 2.13
[ 0.129802] ata_piix 0000:00:01.1: setting latency timer to 64
[ 0.129954] scsi0 : ata_piix
[ 0.130522] scsi1 : ata_piix
[ 0.130552] ata1: PATA max MWDMA2 cmd 0x1f0 ctl 0x3f6 bmdma 0xc000 irq 14
[ 0.130554] ata2: PATA max MWDMA2 cmd 0x170 ctl 0x376 bmdma 0xc008 irq 15

Virtio is a Linux standard for network and disk device drivers where just the guest’s device driver “knows” it is running in a virtual environment, and cooperates with the hypervisor. This enables guests to get high performance network and disk operations, and gives most of the performance benefits of paravirtualization.
If you want to install a machine with virtio drivers you should add these lines to your virt-install command:

--os-type=linux \
--os-variant=virtio26 \

Using this command you enable the virtio drivers at install time on SL 6 (alpha 3)

# virt-install –connect qemu:///system -n UDSK10.10 -r 2048 –vcpus=2 \
> –os-type=linux –os-variant=virtio26 \
> -f /dev/vg_kvms/vm02 -c \
> /usr/tmp/u1010desk.iso –vnc \
> –accelerate –network=bridge:br0 –hvm –debug
Wed, 29 Dec 2010 18:53:06 DEBUG Launched with command line:
/usr/sbin/virt-install –connect qemu:///system -n UDSK10.10 -r 2048 –vcpus=2 –os-type=linux –os-variant=virtio26 -f /dev/vg_kvms/vm02 -c /usr/tmp/u1010desk.iso –vnc –accelerate –network=bridge:br0 –hvm –debug
Wed, 29 Dec 2010 18:53:06 DEBUG Requesting libvirt URI qemu:///system
Wed, 29 Dec 2010 18:53:06 DEBUG Received libvirt URI qemu:///system
Wed, 29 Dec 2010 18:53:06 DEBUG Requesting virt method ‘hvm’, hv type ‘default’.
Wed, 29 Dec 2010 18:53:06 DEBUG Received virt method ‘hvm’
Wed, 29 Dec 2010 18:53:06 DEBUG Hypervisor name is ‘kvm’
Wed, 29 Dec 2010 18:53:06 DEBUG DistroInstaller location is a local file/path: /usr/tmp/u1010desk.iso

Starting install…
Wed, 29 Dec 2010 18:53:07 DEBUG Generated install XML:
<domain type=’kvm’>
<name>UDSK10.10</name>
<currentMemory>2097152</currentMemory>
<memory>2097152</memory>
<uuid>017cec13-8c2f-56cf-6762-4575c26d988f</uuid>
<os>
<type arch=’x86_64′>hvm</type>
<boot dev=’cdrom’/>
</os>
<features>
<acpi/><apic/><pae/>
</features>
<clock offset=”utc”/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
<vcpu>2</vcpu>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type=’block’ device=’disk’>
<driver name=’qemu’ cache=’none’/>
<source dev=’/dev/vg_kvms/vm02’/>
<target dev=’vda’ bus=’virtio’/>
</disk>
<disk type=’file’ device=’cdrom’>
<driver name=’qemu’/>
<source file=’/usr/tmp/u1010desk.iso’/>
<target dev=’hdc’ bus=’ide’/>
<readonly/>
</disk>
<interface type=’bridge’>
<source bridge=’br0’/>
<mac address=’52:54:00:37:b9:0b’/>
<model type=’virtio’/>
</interface>
<input type=’mouse’ bus=’ps2’/>
<graphics type=’vnc’ port=’-1′ keymap=’en-us’/>
<console type=’pty’/>
<video>
<model type=’cirrus’/>
</video>
</devices>
</domain>

Creating domain… | 0 B 00:00
Wed, 29 Dec 2010 18:53:07 DEBUG Started guest, looking to see if it is running
Wed, 29 Dec 2010 18:53:07 DEBUG Launching console callback
Wed, 29 Dec 2010 18:53:07 DEBUG Generated boot XML:
<domain type=’kvm’>
<name>UDSK10.10</name>
<currentMemory>2097152</currentMemory>
<memory>2097152</memory>
<uuid>017cec13-8c2f-56cf-6762-4575c26d988f</uuid>
<os>
<type arch=’x86_64′>hvm</type>
<boot dev=’hd’/>
</os>
<features>
<acpi/><apic/><pae/>
</features>
<clock offset=”utc”/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<vcpu>2</vcpu>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type=’block’ device=’disk’>
<driver name=’qemu’ cache=’none’/>
<source dev=’/dev/vg_kvms/vm02’/>
<target dev=’vda’ bus=’virtio’/>
</disk>
<disk type=’block’ device=’cdrom’>
<target dev=’hdc’ bus=’ide’/>
<readonly/>
</disk>
<interface type=’bridge’>
<source bridge=’br0’/>
<mac address=’52:54:00:37:b9:0b’/>
<model type=’virtio’/>
</interface>
<input type=’mouse’ bus=’ps2’/>
<graphics type=’vnc’ port=’-1′ keymap=’en-us’/>
<console type=’pty’/>
<video>
<model type=’cirrus’/>
</video>
</devices>
</domain>
Guest installation complete… restarting guest.
Wed, 29 Dec 2010 19:00:27 DEBUG Launching console callback





Runtime profile of KVM Ubuntu 10.10 Desktop looks as follows :-
# virsh dumpxml UDSK10.10 > UDSK10.10.xml
# cat UDSK10.10.xml
<domain type=’kvm’>
<name>UDSK10.10</name>
<uuid>017cec13-8c2f-56cf-6762-4575c26d988f</uuid>
<memory>2097152</memory>
<currentMemory>2097152</currentMemory>
<vcpu>2</vcpu>
<os>
<type arch=’x86_64′ machine=’rhel6.0.0′>hvm</type>
<boot dev=’hd’/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset=’utc’/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type=’block’ device=’disk’>
<driver name=’qemu’ type=’raw’ cache=’none’/>
<source dev=’/dev/vg_kvms/vm02’/>
<target dev=’vda’ bus=’virtio’/>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x04′ function=’0x0’/>
</disk>
<disk type=’block’ device=’cdrom’>
<driver name=’qemu’ type=’raw’/>
<target dev=’hdc’ bus=’ide’/>
<readonly/>
<address type=’drive’ controller=’0′ bus=’1′ unit=’0’/>
</disk>
<controller type=’ide’ index=’0′>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x01′ function=’0x1’/>
</controller>
<interface type=’bridge’>
<mac address=’52:54:00:37:b9:0b’/>
<source bridge=’br0’/>
<target dev=’vnet0’/>
<model type=’virtio’/>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x03′ function=’0x0’/>
</interface>
<serial type=’pty’>
<target port=’0’/>
</serial>
<console type=’pty’>
<target port=’0’/>
</console>
<input type=’mouse’ bus=’ps2’/>
<graphics type=’vnc’ port=’-1′ autoport=’yes’ keymap=’en-us’/>
<video>
<model type=’cirrus’ vram=’9216′ heads=’1’/>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x02′ function=’0x0’/>
</video>
<memballoon model=’virtio’>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x05′ function=’0x0’/>
</memballoon>
</devices>
</domain>

Activating virtio driver via virt-manager






One Response to KVM & Virtio (disk/nic) on Scientific Linux 6 (alpha 3)

Leave a comment