Virtio On Xen - Legacy: GSoC
This page is about a legacy project. For current work being done for VirtIO on Xen, see Virtio On Xen.
VirtIO-GSOC: 2011 Google Summer of Code Project
A Google Summer of Code project by Wei Liu investigated enabling VirtIO on Xen.
A working prototype was produced for both PV and HVM guests, using XenBus and the Qemu VirtIO backends. PV guests require a guest kernel patch to translate guest physical addresses to machine addresses in VirtIO rings.
Status: project completed.
Using the prototype
This section is intended to guide people who might be interested giving it a try.
- Make sure you have the latest Xen unstable source (at least CS23728).
- Checkout Stefano Stabellini's QEMU repository: git://xenbits.xen.org/people/sstabellini/qemu-dm.git xen-stable-0.15
Virtio for HVM guest
In fact, there is nothing much to do.
- With this patch, we can enable libxl to support configuration for Virtio disk and nic.
- For disk configuration syntax, use 'vd*' as virtual identifier, see docs/misc/vbd-interface.txt for details.
- For nic configuration syntax, use 'model=virtio' in vif configuration. Latest QEMU may require 'model=virtio-net'. Just choose the one that works.
- Disable MSI in guest kernel, with 'pci=nomsi' option in guest kernel command line. Currently, MSI delivery is not supported by HVM guest (though Xen has one HVMOP to do this, QEMU is not yet ready for this).
- Also you might want to add 'xen_emul_unplug=never' in the guest kernel command line.
Use 'xl' to start the guest, not 'xm'.
Virtio for PV guest
First of all, you need the patch in the previous section to enable libxl to support configuration syntax for Virtio disk and nic.
Then apply the following patches to upstream QEMU and Linux kernel.
- Linux kernel
- VM config file
- Make sure you add device_model_args_pv=['-net', 'tap,vlan=0,script=no'] to make QEMU add a tap for you, or you won't be able to send packets via Virtio net.
- Linux kernel config
- Make sure you have 'iommu=soft' in your guest kernel command line.
Run 'xl' to startup VM, 'xm' doesn't understand virtio configuration. After the VM is up, load modified virtio_ring.ko and all the other modules manually in the following order:
Hopefully you will get Virtio devices without much trouble.
- Enable xen-mapcache for Virtio for PV, improve performance.
- Squash two evtchns into one, hopefully we can eliminate locking in transport layer and improve performance.
- Enable Virtio device DMA capability
- Bug fixes, transport layer crashes sometimes under heavy workload.
For those who encounter problems, please contact Wei Liu <liuw AT liuw SPAMFREE dot name>