Sunday, May 10, 2009

New kvm toy received. Totally virtio and managed by virsh from libvirt.

Converting kvm arguments to virsh xml while browsing through libvirt spaghetti code for hints.

shell command
/usr/bin/kvm -boot c -m 1024 -smp 3 -vnc :1 -k en \
-drive index=0,if=virtio,boot=on,file=/data/kvm/kvm-slave.qcow2 \
-net nic,model=virtio -net tap,ifname=tap0,script=no,downscript=no

to virsh xml

<domain type='kvm'>
<name>kvm-slave</name>
<uuid>8974f244-f27b-40f5-a25c-628b91c02e4b</uuid>
<memory>1048576</memory>
<currentMemory>1048576</currentMemory>
<vcpu>3</vcpu>
<os>
<type>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/kvm</emulator>
<disk type='file' device='disk'>
<source file='/data/kvm/kvm-slave.qcow2,boot=on'/>
<target dev='vda' bus='virtio'/>
</disk>
<interface type='ethernet'>
<target dev='tap0'/>
<model type='virtio'/>
<script path='no'/>
</interface>
<graphics type='vnc' port='5902' listen=':' keymap='en'/>
</devices>
</domain>

Notice:
1) tap0 should not created by virsh so using type=ethernet instead of type=bridge
2) if using disk virtio from file, libvirt 0.6.2 is not adding boot=on, be dirty and using filename as option field (spaghetti code)

No comments:

Post a Comment