Blame SOURCES/libvirt-qemuProcessRefreshDisks-Don-t-skip-filling-of-disk-information-if-tray-state-didn-t-change.patch

acda74
From b53d7b7150f81ee6f014815fa7ee3f1106c491d5 Mon Sep 17 00:00:00 2001
acda74
Message-Id: <b53d7b7150f81ee6f014815fa7ee3f1106c491d5@dist-git>
acda74
From: Peter Krempa <pkrempa@redhat.com>
acda74
Date: Thu, 9 Feb 2023 09:40:32 +0100
acda74
Subject: [PATCH] qemuProcessRefreshDisks: Don't skip filling of disk
acda74
 information if tray state didn't change
acda74
acda74
Commit 5ef2582646eb98 added emitting of even when refreshign disk state,
acda74
where it wanted to avoid sending the event if disk state didn't change.
acda74
This was achieved by using 'continue' in the loop filling the
acda74
information. Unfortunately this skips extraction of whether the device
acda74
has a tray which is propagated into internal structures, which in turn
acda74
broke cdrom media change as the code thought there's no tray for the
acda74
device.
acda74
acda74
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2166411
acda74
Fixes: 5ef2582646eb98af208ce37355f82bdef39931fa
acda74
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
acda74
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
acda74
(cherry picked from commit 86cfe93ef7fdc2d665a2fc88b79af89e7978ba78)
acda74
---
acda74
 src/qemu/qemu_process.c | 11 +++++------
acda74
 1 file changed, 5 insertions(+), 6 deletions(-)
acda74
acda74
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
acda74
index 32083de563..7ae859d68f 100644
acda74
--- a/src/qemu/qemu_process.c
acda74
+++ b/src/qemu/qemu_process.c
acda74
@@ -8713,16 +8713,13 @@ qemuProcessRefreshDisks(virDomainObj *vm,
acda74
             continue;
acda74
 
acda74
         if (info->removable) {
acda74
-            virObjectEvent *event = NULL;
acda74
+            bool emitEvent = info->tray_open != disk->tray_status;
acda74
             int reason;
acda74
 
acda74
             if (info->empty)
acda74
                 virDomainDiskEmptySource(disk);
acda74
 
acda74
             if (info->tray) {
acda74
-                if (info->tray_open == disk->tray_status)
acda74
-                    continue;
acda74
-
acda74
                 if (info->tray_open) {
acda74
                     reason = VIR_DOMAIN_EVENT_TRAY_CHANGE_OPEN;
acda74
                     disk->tray_status = VIR_DOMAIN_DISK_TRAY_OPEN;
acda74
@@ -8731,8 +8728,10 @@ qemuProcessRefreshDisks(virDomainObj *vm,
acda74
                     disk->tray_status = VIR_DOMAIN_DISK_TRAY_CLOSED;
acda74
                 }
acda74
 
acda74
-                event = virDomainEventTrayChangeNewFromObj(vm, disk->info.alias, reason);
acda74
-                virObjectEventStateQueue(driver->domainEventState, event);
acda74
+                if (emitEvent) {
acda74
+                    virObjectEvent *event = virDomainEventTrayChangeNewFromObj(vm, disk->info.alias, reason);
acda74
+                    virObjectEventStateQueue(driver->domainEventState, event);
acda74
+                }
acda74
             }
acda74
         }
acda74
 
acda74
-- 
acda74
2.39.1
acda74