
Hello! The attached patch provides support for the Linux macvtap device for Qemu by passing a file descriptor to Qemu command line similar to how it is done with a regular tap device. I have modified the network XML code to understand a definition as the following one here: <network> <name>vepanet</name> <uuid>4ebd5168-6321-4757-8397-f6e83484f402</uuid> <extbridge mode='vepa' dev='eth0'/> </network> This XML indicates the device that links to the external bridge, here eth0, and the mode this device is supposed to be set into, here 'vepa'. If 'extbridge' is found in the XML, all other XML elements that have been used so far, i.e., bridge, ip, dhcp, etc., are ignored. The above network description can then be referenced from the virtual machine definition using the typical interface description of type 'network': <interface type='network'> <source network='vepanet'/> <model type='virtio'/> </interface> The above network XML holds the necessary parameters to open a macvtap device. Using command line, one would issue the following command to achieve the same what now libvirt does internally, using a patched version of the 'ip' command: ip link add link eth0 <optional name of if> type macvtap mode vepa This then creates the network interface, i.e., macvtap12, along with entries in /sys/class/net/macvtap12/ where the content of the ifindex file returns the integer necessary to build the /dev/tap%d device to open the file descriptor of and pass to qemu via command line argument. Some details: In libvirt I am first searching for an unused interface name following the template macvtap%d unless the user has provided a name explicitly or the previous macvtap%d is now taken by another VM. Once that has succeeded, I follow the path through the filesystem to open the corresponding /dev/tap%d. Unlike the regular tap device, where the network interface disappears once the corresponding file descriptor is closed, the macvtap device needs explicit tear-down. So, when a VM terminates, I am deleting all macvtap type interface with the MAC address as the interface of the terminating VM. Some further background on this device was recently given here: https://www.redhat.com/archives/libvir-list/2010-January/msg00721.html The macvtap patch for Linux was posted here: http://lkml.org/lkml/2009/12/3/239 I'd be curious about comments on the code. Signed-off-by: Stefan Berger <stefanb@us.ibm.com>