On 03/29/2012 07:15 AM, D. Herrendoerfer wrote:
From: "D. Herrendoerfer"
<d.herrendoerfer(a)herrendoerfer.name>
This patch adds a netlink callback when migrating a VEPA enabled
virtual machine.
It fixes a Bug where a VM would not request a port association when
it was cleared by lldpad.
This patch requires the latest git version of lldpad to work.
Signed-off-by: D. Herrendoerfer <d.herrendoerfer(a)herrendoerfer.name>
---
src/qemu/qemu_migration.c | 6 ++++++
src/util/virnetdevmacvlan.c | 14 +++++++++++++-
src/util/virnetdevmacvlan.h | 8 ++++++++
3 files changed, 27 insertions(+), 1 deletions(-)
Sorry for the delay in pushing this. When it came in we were well into
the pre-release freeze for 0.9.11, and I didn't want to take the chance
of breaking the build, and by the time the release was done I'd
forgotten it.
Note that this patch actually would have broken the build on some
platforms as delivered, since you forgot to add
virNetDevMacVLanVPortProfileRegisterCallback to libvirt_private.syms
(the problems only show up if you build with driver modules enabled).
ACK with that omission corrected; I've done that and pushed the result.
Something I noticed this time when looking at the code - it seems like
clients might be getting registered at times when they aren't needed;
specifically - as I understand it, lldpad is only a part of the picture
for 802..1Qbg, is that correct? Unless I'm reading the code wrong,
callbacks are registered for any direct interface that has a port
profile, regardless of type. That's most likely harmless, but if my
suppositions are correct, we should probably clean this up so it only
registers for those interfaces that are actually going to get an event.
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 77d40c0..7a8a7c4 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2654,6 +2654,12 @@ qemuMigrationVPAssociatePortProfiles(virDomainDefPtr def) {
def->uuid,
VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_FINISH, false) < 0)
goto err_exit;
+
+ if (virNetDevMacVLanVPortProfileRegisterCallback(net->ifname,
net->mac,
+
virDomainNetGetActualDirectDev(net), def->uuid,
+
virDomainNetGetActualVirtPortProfile(net),
+
VIR_NETDEV_VPORT_PROFILE_OP_CREATE))
+ goto err_exit;
}
last_good_net = i;
}
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index 90888b0..b259e00 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -769,7 +769,7 @@ virNetDevMacVLanVPortProfileDestroyCallback(int watch
ATTRIBUTE_UNUSED,
virNetlinkCallbackDataFree((virNetlinkCallbackDataPtr)opaque);
}
-static int
+int
virNetDevMacVLanVPortProfileRegisterCallback(const char *ifname,
const unsigned char *macaddress,
const char *linkdev,
@@ -1125,4 +1125,16 @@ int virNetDevMacVLanRestartWithVPortProfile(const char *cr_ifname
ATTRIBUTE_UNUS
_("Cannot create macvlan devices on this
platform"));
return -1;
}
+
+int virNetDevMacVLanVPortProfileRegisterCallback(const char *ifname ATTRIBUTE_UNUSED,
+ const unsigned char *macaddress
ATTRIBUTE_UNUSED,
+ const char *linkdev ATTRIBUTE_UNUSED,
+ const unsigned char *vmuuid
ATTRIBUTE_UNUSED,
+ virNetDevVPortProfilePtr virtPortProfile
ATTRIBUTE_UNUSED,
+ enum virNetDevVPortProfileOp vmOp
ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Cannot create macvlan devices on this
platform"));
+ return -1;
+}
#endif /* ! WITH_MACVTAP */
diff --git a/src/util/virnetdevmacvlan.h b/src/util/virnetdevmacvlan.h
index 14640cf..2299f1d 100644
--- a/src/util/virnetdevmacvlan.h
+++ b/src/util/virnetdevmacvlan.h
@@ -84,4 +84,12 @@ int virNetDevMacVLanRestartWithVPortProfile(const char *cr_ifname,
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5) ATTRIBUTE_RETURN_CHECK;
+int virNetDevMacVLanVPortProfileRegisterCallback(const char *ifname,
+ const unsigned char *macaddress ,
+ const char *linkdev,
+ const unsigned char *vmuuid,
+ virNetDevVPortProfilePtr virtPortProfile,
+ enum virNetDevVPortProfileOp vmOp)
+ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
+ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5) ATTRIBUTE_RETURN_CHECK;
#endif /* __UTIL_MACVTAP_H__ */