[PATCH 2/3] qemu: Prevent two threshold events when it was registered with index

Peter Krempa pkrempa at redhat.com
Thu Jul 1 14:03:57 UTC 2021


Remember whether the user passed an explicit index when registering the
event so that we can avoid the top level event when it isn't needed.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_driver.c  | 4 ++++
 src/qemu/qemu_process.c | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 235f575901..eeca5074ce 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -19604,6 +19604,10 @@ qemuDomainSetBlockThreshold(virDomainPtr dom,
     if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
         goto endjob;

+    /* we need to remember whether the threshold was registered with an explicit
+     * index to fire the correct event */
+    src->thresholdEventWithIndex = !!strchr(dev, '[');
+
     ret = 0;

  endjob:
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 2b03b0ab98..f8916282bf 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1487,7 +1487,8 @@ qemuProcessHandleBlockThreshold(qemuMonitor *mon G_GNUC_UNUSED,
         if (virStorageSourceIsLocalStorage(src))
             path = src->path;

-        if (src == disk->src) {
+        if (src == disk->src &&
+            !src->thresholdEventWithIndex) {
             g_autofree char *dev = qemuDomainDiskBackingStoreGetName(disk, 0);

             eventDevice = virDomainEventBlockThresholdNewFromObj(vm, dev, path,
-- 
2.31.1




More information about the libvir-list mailing list