[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 2/5] qemu: blockjob: Make sure that internal states are not reported as event



While the callers should make sure that they don't call
qemuBlockJobEmitEvents for any internal state or job, let's add checks
that prevents us from emitting wrong events altogether.

Signed-off-by: Peter Krempa <pkrempa redhat com>
---
 src/qemu/qemu_blockjob.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 9b638b7ef6..ba98ef2259 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -214,6 +214,10 @@ qemuBlockJobEmitEvents(virQEMUDriverPtr driver,
     virObjectEventPtr event = NULL;
     virObjectEventPtr event2 = NULL;

+    if (type >= VIR_DOMAIN_BLOCK_JOB_TYPE_LAST ||
+        status >= VIR_DOMAIN_BLOCK_JOB_LAST)
+        return;
+
     if (virStorageSourceIsLocalStorage(disk->src) &&
         !virStorageSourceIsEmpty(disk->src)) {
         event = virDomainEventBlockJobNewFromObj(vm, virDomainDiskGetSource(disk),
-- 
2.20.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]