Put the emitting of VIR_DOMAIN_EVENT_ID_BLOCK_JOB and
VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2 into a separate function.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_blockjob.c | 37 ++++++++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 11 deletions(-)
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 0f52996ade..ea327b83fe 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -42,6 +42,30 @@
VIR_LOG_INIT("qemu.qemu_blockjob");
+/**
+ * qemuBlockJobEmitEvents:
+ *
+ * Emits the VIR_DOMAIN_EVENT_ID_BLOCK_JOB and VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2
+ * for a block job.
+ */
+static void
+qemuBlockJobEmitEvents(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainDiskDefPtr disk,
+ virDomainBlockJobType type,
+ virConnectDomainEventBlockJobStatus status)
+{
+ virObjectEventPtr event = NULL;
+ virObjectEventPtr event2 = NULL;
+
+ event = virDomainEventBlockJobNewFromObj(vm, disk->src->path, type, status);
+ virObjectEventStateQueue(driver->domainEventState, event);
+
+ event2 = virDomainEventBlockJob2NewFromObj(vm, disk->dst, type, status);
+ virObjectEventStateQueue(driver->domainEventState, event2);
+}
+
+
/**
* qemuBlockJobUpdate:
* @vm: domain
@@ -101,9 +125,6 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver,
int type,
int status)
{
- virObjectEventPtr event = NULL;
- virObjectEventPtr event2 = NULL;
- const char *path;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
virDomainDiskDefPtr persistDisk = NULL;
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
@@ -114,14 +135,11 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver,
type,
status);
- /* Have to generate two variants of the event for old vs. new
- * client callbacks */
if (type == VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT &&
disk->mirrorJob == VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT)
type = disk->mirrorJob;
- path = virDomainDiskGetSource(disk);
- event = virDomainEventBlockJobNewFromObj(vm, path, type, status);
- event2 = virDomainEventBlockJob2NewFromObj(vm, disk->dst, type, status);
+
+ qemuBlockJobEmitEvents(driver, vm, disk, type, status);
/* If we completed a block pull or commit, then update the XML
* to match. */
@@ -210,9 +228,6 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver,
"after block job", vm->def->name);
}
- virObjectEventStateQueue(driver->domainEventState, event);
- virObjectEventStateQueue(driver->domainEventState, event2);
-
virObjectUnref(cfg);
}
--
2.19.2