qemu: Prevent two threshold events when it was registered with index

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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2021-07-01 16:03:57 +02:00
parent 2ddff1cc40
commit a3edda6b9e
2 changed files with 6 additions and 1 deletions

View File

@ -19623,6 +19623,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:

View File

@ -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,