Add handling of the 'id' field in the event which corresponds to the QDEV id of the device. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_monitor.c | 3 ++- src/qemu/qemu_monitor.h | 2 ++ src/qemu/qemu_monitor_json.c | 11 ++++++++--- src/qemu/qemu_process.c | 3 ++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 4dcbd69dce..cdfcbcea0b 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1460,13 +1460,14 @@ qemuMonitorEmitGraphics(qemuMonitorPtr mon, int qemuMonitorEmitTrayChange(qemuMonitorPtr mon, const char *devAlias, + const char *devid, int reason) { int ret = -1; VIR_DEBUG("mon=%p", mon); QEMU_MONITOR_CALLBACK(mon, ret, domainTrayChange, mon->vm, - devAlias, reason); + devAlias, devid, reason); return ret; } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index f8f6969ddb..1c66459e69 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -181,6 +181,7 @@ typedef int (*qemuMonitorDomainBlockJobCallback)(qemuMonitorPtr mon, typedef int (*qemuMonitorDomainTrayChangeCallback)(qemuMonitorPtr mon, virDomainObjPtr vm, const char *devAlias, + const char *devid, int reason, void *opaque); typedef int (*qemuMonitorDomainPMWakeupCallback)(qemuMonitorPtr mon, @@ -397,6 +398,7 @@ int qemuMonitorEmitGraphics(qemuMonitorPtr mon, const char *saslUsername); int qemuMonitorEmitTrayChange(qemuMonitorPtr mon, const char *devAlias, + const char *devid, int reason); int qemuMonitorEmitPMWakeup(qemuMonitorPtr mon); int qemuMonitorEmitPMSuspend(qemuMonitorPtr mon); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index de3fcd83d8..537cdfd19a 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1031,11 +1031,16 @@ static void qemuMonitorJSONHandleTrayChange(qemuMonitorPtr mon, virJSONValuePtr data) { - const char *devAlias = NULL; + const char *devAlias = virJSONValueObjectGetString(data, "device"); + const char *devid = virJSONValueObjectGetString(data, "id"); bool trayOpened; int reason; - if ((devAlias = virJSONValueObjectGetString(data, "device")) == NULL) { + /* drive alias is always reported but empty for -blockdev */ + if (*devAlias == '\0') + devAlias = NULL; + + if (!devAlias && !devid) { VIR_WARN("missing device in tray change event"); return; } @@ -1050,7 +1055,7 @@ qemuMonitorJSONHandleTrayChange(qemuMonitorPtr mon, else reason = VIR_DOMAIN_EVENT_TRAY_CHANGE_CLOSE; - qemuMonitorEmitTrayChange(mon, devAlias, reason); + qemuMonitorEmitTrayChange(mon, devAlias, devid, reason); } static void diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b713afa3a2..40e2589b37 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1061,6 +1061,7 @@ static int qemuProcessHandleTrayChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED, virDomainObjPtr vm, const char *devAlias, + const char *devid, int reason, void *opaque) { @@ -1070,7 +1071,7 @@ qemuProcessHandleTrayChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED, virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); virObjectLock(vm); - disk = qemuProcessFindDomainDiskByAliasOrQOM(vm, devAlias, NULL); + disk = qemuProcessFindDomainDiskByAliasOrQOM(vm, devAlias, devid); if (disk) { event = virDomainEventTrayChangeNewFromObj(vm, disk->info.alias, reason); -- 2.16.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list