[PATCH] qemuProcessRefreshDisks: Don't skip filling of disk information if tray state didn't change

Peter Krempa posted 1 patch 1 year, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/963dcc1272fb19a2b87d1e07d9066073c9196543.1675932635.git.pkrempa@redhat.com
src/qemu/qemu_process.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
[PATCH] qemuProcessRefreshDisks: Don't skip filling of disk information if tray state didn't change
Posted by Peter Krempa 1 year, 1 month ago
Commit 5ef2582646eb98 added emitting of even when refreshign disk state,
where it wanted to avoid sending the event if disk state didn't change.
This was achieved by using 'continue' in the loop filling the
information. Unfortunately this skips extraction of whether the device
has a tray which is propagated into internal structures, which in turn
broke cdrom media change as the code thought there's no tray for the
device.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2166411
Fixes: 5ef2582646eb98af208ce37355f82bdef39931fa
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_process.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index e96b7689a3..59aa3f02aa 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8711,16 +8711,13 @@ qemuProcessRefreshDisks(virDomainObj *vm,
             continue;

         if (info->removable) {
-            virObjectEvent *event = NULL;
+            bool emitEvent = info->tray_open != disk->tray_status;
             int reason;

             if (info->empty)
                 virDomainDiskEmptySource(disk);

             if (info->tray) {
-                if (info->tray_open == disk->tray_status)
-                    continue;
-
                 if (info->tray_open) {
                     reason = VIR_DOMAIN_EVENT_TRAY_CHANGE_OPEN;
                     disk->tray_status = VIR_DOMAIN_DISK_TRAY_OPEN;
@@ -8729,8 +8726,10 @@ qemuProcessRefreshDisks(virDomainObj *vm,
                     disk->tray_status = VIR_DOMAIN_DISK_TRAY_CLOSED;
                 }

-                event = virDomainEventTrayChangeNewFromObj(vm, disk->info.alias, reason);
-                virObjectEventStateQueue(driver->domainEventState, event);
+                if (emitEvent) {
+                    virObjectEvent *event = virDomainEventTrayChangeNewFromObj(vm, disk->info.alias, reason);
+                    virObjectEventStateQueue(driver->domainEventState, event);
+                }
             }
         }

-- 
2.39.1
Re: [PATCH] qemuProcessRefreshDisks: Don't skip filling of disk information if tray state didn't change
Posted by Ján Tomko 1 year, 1 month ago
On a Thursday in 2023, Peter Krempa wrote:
>Commit 5ef2582646eb98 added emitting of even when refreshign disk state,

*refreshing

>where it wanted to avoid sending the event if disk state didn't change.
>This was achieved by using 'continue' in the loop filling the
>information. Unfortunately this skips extraction of whether the device
>has a tray which is propagated into internal structures, which in turn
>broke cdrom media change as the code thought there's no tray for the
>device.
>
>Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2166411
>Fixes: 5ef2582646eb98af208ce37355f82bdef39931fa
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_process.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)

Commit-message-spellchecked-by: Ján Tomko <jtomko@redhat.com>

Jano
Re: [PATCH] qemuProcessRefreshDisks: Don't skip filling of disk information if tray state didn't change
Posted by Kristina Hanicova 1 year, 1 month ago
On Thu, Feb 9, 2023 at 9:50 AM Peter Krempa <pkrempa@redhat.com> wrote:

> Commit 5ef2582646eb98 added emitting of even when refreshign disk state,
> where it wanted to avoid sending the event if disk state didn't change.
> This was achieved by using 'continue' in the loop filling the
> information. Unfortunately this skips extraction of whether the device
> has a tray which is propagated into internal structures, which in turn
> broke cdrom media change as the code thought there's no tray for the
> device.
>
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2166411
> Fixes: 5ef2582646eb98af208ce37355f82bdef39931fa
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  src/qemu/qemu_process.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>


Reviewed-by: Kristina Hanicova <khanicov@redhat.com>