[libvirt] [PATCHv2] util: only register callbacks for CREATE operations in virnetdevmacvlan.c

Laine Stump laine at laine.org
Wed Apr 18 08:53:04 UTC 2012


From: "D. Herrendoerfer" <d.herrendoerfer at herrendoerfer.name>

I believe the following is the correct patch for this - when a guest
is started from a snapshot or from a saved image, qemuProcessStart is
called with VIR_NETDEV_VPORT_PROFILE_OP_RESTORE. From my reading of
the code, the callback will have been removed when the guest was
previously saved, so it will need to be re-added when it's restored.

Dirk - please test this and let me know if it behaves properly.

---------------------------------

Currently upon a migration a callback is created when a 802.1qbg link
is set to PREASSOCIATE, this should not happen because this is a no-op
on most switches, and does not lead to an ASSOCIATE state.  This patch
only creates callbacks when CREATE or RESTORE is requested.  Migration
and libvirtd restart scenarios are already handled elsewhere.

Signed-off-by: D. Herrendoerfer <d.herrendoerfer at herrendoerfer.name>
---
 src/util/virnetdevmacvlan.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index 326e29c..879d846 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -945,9 +945,18 @@ create_name:
         goto disassociate_exit;
     }
 
-    if (virNetDevMacVLanVPortProfileRegisterCallback(cr_ifname, macaddress,
-                                         linkdev, vmuuid, virtPortProfile, vmOp) < 0 )
+    if (vmOp == VIR_NETDEV_VPORT_PROFILE_OP_CREATE ||
+        vmOp == VIR_NETDEV_VPORT_PROFILE_OP_RESTORE) {
+        /* Only directly register upon a create or restore (restarting
+         * a saved image) - migration and libvirtd restart are handled
+         * elsewhere.
+         */
+        if (virNetDevMacVLanVPortProfileRegisterCallback(cr_ifname, macaddress,
+                                                         linkdev, vmuuid,
+                                                         virtPortProfile,
+                                                         vmOp) < 0 )
         goto disassociate_exit;
+    }
 
     return rc;
 
-- 
1.7.10




More information about the libvir-list mailing list