File 086-virtManager-ignore-agen-livecycle-event-for-shutoff-VMs.patch of Package virt-manager

Subject: virtManager: ignore agen livecycle event for shutoff VMs
From: Pavel Hrdina phrdina@redhat.com Wed Jan 24 10:40:24 2024 +0100
Date: Mon Mar 25 13:21:50 2024 +0100:
Git: e95ca453c49516aa5c291ce4839ecef6769852c9

This event is mainly to refresh the VM XML to figure out the state of
virtio channels and that should happen only for running VMs.

This affects external snapshot behavior in virtManager. If the VM is
offline and user deletes external snapshot libvirt needs to start QEMU
process to delete the snapshot. The QEMU process is started with stopped
CPUs so it is visible as online and paused. It also emits the agent
lifecycle event but there is no other domain lifecycle event so after
the snapshot deletion the VM stays paused in virtManager even if it is
already offline in libvirt.

To mitigate this behavior we can ignore agent lifecycle event for
shutoff VMs.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

--- a/virtManager/connection.py
+++ b/virtManager/connection.py
@@ -648,6 +648,13 @@ class vmmConnection(vmmGObject):
 
         obj = self.get_vm_by_name(name)
 
+        # This event is triggered when deleting external snapshots and it changes
+        # shutoff VM into paused and makes that VM unusable until virt-manager is
+        # restarted so we need to ignore it in case VM is shutoff.
+        if obj.is_shutoff():
+            log.debug("received agent lifecycle event but domain is shutoff, ignoring it")
+            return
+
         if obj:
             self.idle_add(obj.recache_from_event_loop)
         else:
openSUSE Build Service is sponsored by