From 9609ae0bab30675e184d1fc63aec849c1de020d0 Mon Sep 17 00:00:00 2001 From: Tobias Urdin Date: Thu, 16 Jul 2020 21:29:32 +0200 Subject: [PATCH] libvirt: Add announce-self post live-migration workaround NOTE(melwitt): This is the combination of two commits, the workaround config option and a followup change to add a note that enabling the workaround will cause the guest domain to be considered tainted by libvirt. This patch adds a workaround that can be enabled to send an announce_self QEMU monitor command post live-migration to send out RARP frames that was lost due to port binding or flows not being installed. Please note that this makes marks the domain in libvirt as tainted. See previous information about this issue in the [1] bug. [1] https://bugs.launchpad.net/nova/+bug/1815989 Related-Bug: 1815989 Update announce self workaround opt description This updates the announce self workaround config opt description to include info about instance being set as tainted by libvirt. Change-Id: I8140c8fe592dd54fc09a9510723892806db49a56 (cherry picked from commit 2aa1ed5810b67b9a8f18b2ec5e21004f93831168) Change-Id: I7a6a6fe5f5b23e76948b59a85ca9be075a1c2d6d (cherry picked from commit d44e24efe28e825fbfd2c75a032bf2d10109a439) (cherry picked from commit a8981422afdd09f8cfea053e592c15e771fbe969) --- nova/conf/workarounds.py | 13 ++++++++++++ nova/virt/libvirt/driver.py | 21 +++++++++++++++++++ nova/virt/libvirt/guest.py | 10 +++++++++ ...-post-live-migration-936721b1ab887514.yaml | 8 +++++++ 4 files changed, 52 insertions(+) create mode 100644 releasenotes/notes/announce-self-post-live-migration-936721b1ab887514.yaml diff --git a/nova/conf/workarounds.py b/nova/conf/workarounds.py index 26b834b47ef8..ea68b8e739ab 100644 --- a/nova/conf/workarounds.py +++ b/nova/conf/workarounds.py @@ -422,6 +422,19 @@ backend. Related options: * :oslo.config:option:`DEFAULT.vif_plugging_timeout` +"""), + cfg.BoolOpt('enable_qemu_monitor_announce_self', + default=False, + help=""" +If it is set to True the libvirt driver will try as a best effort to send +the announce-self command to the QEMU monitor so that it generates RARP frames +to update network switches in the post live migration phase on the destination. + +Please note that this causes the domain to be considered tainted by libvirt. + +Related options: + +* :oslo.config:option:`DEFAULT.compute_driver` (libvirt) """), ] diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index f86ad2e1617b..2c6dab389162 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -10410,6 +10410,26 @@ class LibvirtDriver(driver.ComputeDriver): """ self.unplug_vifs(instance, network_info) + def _qemu_monitor_announce_self(self, instance): + """Send announce_self command to QEMU monitor. + + This is to trigger generation of broadcast RARP frames to + update network switches. This is best effort. + """ + if not CONF.workarounds.enable_qemu_monitor_announce_self: + return + + LOG.info('Sending announce-self command to QEMU monitor', + instance=instance) + + try: + guest = self._host.get_guest(instance) + guest.announce_self() + except Exception: + LOG.warning('Failed to send announce-self command to QEMU monitor', + instance=instance) + LOG.exception() + def post_live_migration_at_destination(self, context, instance, network_info, @@ -10425,6 +10445,7 @@ class LibvirtDriver(driver.ComputeDriver): :param block_migration: if true, post operation of block_migration. """ self._reattach_instance_vifs(context, instance, network_info) + self._qemu_monitor_announce_self(instance) def _get_instance_disk_info_from_config(self, guest_config, block_device_info): diff --git a/nova/virt/libvirt/guest.py b/nova/virt/libvirt/guest.py index 54e63e42928c..53080e41f0b4 100644 --- a/nova/virt/libvirt/guest.py +++ b/nova/virt/libvirt/guest.py @@ -48,6 +48,12 @@ if ty.TYPE_CHECKING: else: libvirt = None +try: + import libvirtmod_qemu +except ImportError: + libvirtmod_qemu = None + + LOG = logging.getLogger(__name__) VIR_DOMAIN_NOSTATE = 0 @@ -632,6 +638,10 @@ class Guest(object): """Switch running live migration to post-copy mode""" self._domain.migrateStartPostCopy() + def announce_self(self): + libvirtmod_qemu.virDomainQemuMonitorCommand( + self._domain._o, 'announce_self', 1) + def get_job_info(self): """Get job info for the domain diff --git a/releasenotes/notes/announce-self-post-live-migration-936721b1ab887514.yaml b/releasenotes/notes/announce-self-post-live-migration-936721b1ab887514.yaml new file mode 100644 index 000000000000..f0ec39f196bd --- /dev/null +++ b/releasenotes/notes/announce-self-post-live-migration-936721b1ab887514.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + Added a new configuration option ``[workarounds]/enable_qemu_monitor_announce_self`` + that when enabled causes the Libvirt driver to send a announce_self QEMU + monitor command post live-migration. Please see `bug 1815989 `_ + for more details. Please note that this causes the domain to be considered + tainted by libvirt.