[libvirt] [PATCH] Fix macvtap device tear down problem on virsh destroy

Ed Swierk eswierk at aristanetworks.com
Wed Feb 17 07:05:44 UTC 2010


On Tue, Feb 16, 2010 at 5:22 AM, Stefan Berger <stefanb at us.ibm.com> wrote:
> As an RFC, now attached the patch that tears down the macvtap device upon
> termination of the Qemu process without checking whether the device(s)
> with the given MAC address are in use.

Another problem comes to mind: it is incorrect to assume that an
existing macvtap interface with a given MAC address has anything to do
with the one we want to delete. Consider a host with two NICs, eth0
and eth1. Suppose some application previously created macvtap0 with
MAC 52:54:00:12:34:56 from lower interface eth0. Now we want to create
macvtap1 with the same MAC address 52:54:00:12:34:56 from lower
interface eth1; this is fine as long as eth0 and eth1 are on different
LANs or VLANs. We would be unhappy if libvirt blew away macvtap0
before creating macvtap1.

This can be solved by comparing not only the MAC address but also the
lower interface name: if they both match, then it's safe to delete the
macvtap interface. It should be possible to query the name of the
lower interface for a given macvtap interface via netlink (ip link
show reveals this information).

I'd stick with just one function delMacvtap(char *macaddress, char
*linkdev, int checkTapInUse), which can be called from
qemudPhysIfaceConnect(), qemudDomainDetachNetDevice() and
qemudShutdownVMDaemon(). I don't see any reason for a separate
hasBusyDev parameter; it seems sufficient to return 1 if the tap
device is in use.

--Ed




More information about the libvir-list mailing list