]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: reset MAC address of macvtap passthrough physdev after disassociate
authorLaine Stump <laine@laine.org>
Thu, 21 Jan 2016 19:19:56 +0000 (14:19 -0500)
committerLaine Stump <laine@laine.org>
Fri, 22 Jan 2016 18:16:24 +0000 (13:16 -0500)
libvirt always resets the MAC address of the physdev used for macvtap
passthrough when the guest is finished with it. This was happening
prior to the 802.1Qb[gh] DISASSOCIATE command, and was quite often
failing, presumably because the driver wouldn't allow the MAC address
to be reset while the association was still active, with a log message
like this:

virNetDevSetMAC:168 : Cannot set interface MAC to 00:00:00:00:00:00 on 'eth13': Cannot assign requested address

This patch changes the order - we now do the 802.1Qb[gh] disassociate
and delete the macvtap interface first, then and reset the MAC
address.

src/util/virnetdevmacvlan.c

index 496416e67a50b0949b6995fd56970de64d900f96..98da00969c60aa0a2725224264c9118e2ee263f4 100644 (file)
@@ -935,14 +935,6 @@ int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
     int ret = 0;
     int vf = -1;
 
-    if (mode == VIR_NETDEV_MACVLAN_MODE_PASSTHRU) {
-        if (virtPortProfile &&
-             virtPortProfile->virtPortType == VIR_NETDEV_VPORT_PROFILE_8021QBH)
-            ignore_value(virNetDevRestoreMacAddress(linkdev, stateDir));
-        else
-            ignore_value(virNetDevRestoreNetConfig(linkdev, vf, stateDir));
-    }
-
     if (ifname) {
         if (virNetDevVPortProfileDisassociate(ifname,
                                               virtPortProfile,
@@ -955,6 +947,14 @@ int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
             ret = -1;
     }
 
+    if (mode == VIR_NETDEV_MACVLAN_MODE_PASSTHRU) {
+        if (virtPortProfile &&
+             virtPortProfile->virtPortType == VIR_NETDEV_VPORT_PROFILE_8021QBH)
+            ignore_value(virNetDevRestoreMacAddress(linkdev, stateDir));
+        else
+            ignore_value(virNetDevRestoreNetConfig(linkdev, vf, stateDir));
+    }
+
     virNetlinkEventRemoveClient(0, macaddr, NETLINK_ROUTE);
 
     return ret;