There are some cases when the internal state of disks can change without qemu sending events about it (e.g. a disk can close during reset). In case this happens, we should emit an event about the modified disk. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1824722#c20 Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx> --- src/qemu/qemu_process.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 5de55435d2..601e9694b6 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8675,6 +8675,7 @@ qemuProcessRefreshDisks(virDomainObj *vm, qemuDomainObjPrivate *priv = vm->privateData; g_autoptr(GHashTable) table = NULL; size_t i; + virQEMUDriver *driver = QEMU_DOMAIN_PRIVATE(vm)->driver; if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) == 0) { table = qemuMonitorGetBlockInfo(priv->mon); @@ -8697,14 +8698,26 @@ qemuProcessRefreshDisks(virDomainObj *vm, continue; if (info->removable) { + virObjectEvent *event = NULL; + int reason; + if (info->empty) virDomainDiskEmptySource(disk); if (info->tray) { - if (info->tray_open) + 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; - else + } else { + reason = VIR_DOMAIN_EVENT_TRAY_CHANGE_CLOSE; disk->tray_status = VIR_DOMAIN_DISK_TRAY_CLOSED; + } + + event = virDomainEventTrayChangeNewFromObj(vm, disk->info.alias, reason); + virObjectEventStateQueue(driver->domainEventState, event); } } -- 2.38.1