Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_domain.c | 25 +++++++++++++++++++++++++
src/qemu/qemu_domain.h | 2 ++
src/qemu/qemu_migration.c | 7 +++++--
3 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c56f9f1..2eba8c2 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -149,6 +149,31 @@ void qemuDomainEventQueue(virQEMUDriverPtr driver,
}
+void
+qemuDomainEventEmitJobCompleted(virQEMUDriverPtr driver,
+ virDomainObjPtr vm)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ virObjectEventPtr event;
+ virTypedParameterPtr params = NULL;
+ int nparams = 0;
+ int type;
+
+ if (!priv->job.completed)
+ return;
+
+ type = priv->job.completed->type;
+ if (qemuDomainJobInfoToParams(priv->job.completed, &type,
+ ¶ms, &nparams) < 0) {
+ VIR_WARN("Could not get stats for completed job; domain %s",
+ vm->def->name);
+ }
+
+ event = virDomainEventJobCompletedNewFromObj(vm, type, params, nparams);
+ qemuDomainEventQueue(driver, event);
+}
+
+
static int
qemuDomainObjInitJob(qemuDomainObjPrivatePtr priv)
{
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 84e9735..9ecf6c9 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -261,6 +261,8 @@ void qemuDomainEventFlush(int timer, void *opaque);
void qemuDomainEventQueue(virQEMUDriverPtr driver,
virObjectEventPtr event);
+void qemuDomainEventEmitJobCompleted(virQEMUDriverPtr driver,
+ virDomainObjPtr vm);
int qemuDomainObjBeginJob(virQEMUDriverPtr driver,
virDomainObjPtr obj,
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 1cfeb51..b37565d 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3864,7 +3864,7 @@ qemuMigrationConfirmPhase(virQEMUDriverPtr driver,
int retcode)
{
qemuMigrationCookiePtr mig;
- virObjectEventPtr event = NULL;
+ virObjectEventPtr event;
int rv = -1;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
qemuDomainObjPrivatePtr priv = vm->privateData;
@@ -3919,6 +3919,8 @@ qemuMigrationConfirmPhase(virQEMUDriverPtr driver,
event = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_MIGRATED);
+ qemuDomainEventQueue(driver, event);
+ qemuDomainEventEmitJobCompleted(driver, vm);
} else {
virErrorPtr orig_err = virSaveLastError();
@@ -3933,6 +3935,7 @@ qemuMigrationConfirmPhase(virQEMUDriverPtr driver,
event = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_RESUMED,
VIR_DOMAIN_EVENT_RESUMED_MIGRATED);
+ qemuDomainEventQueue(driver, event);
}
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps)
< 0)
@@ -3944,7 +3947,6 @@ qemuMigrationConfirmPhase(virQEMUDriverPtr driver,
rv = 0;
cleanup:
- qemuDomainEventQueue(driver, event);
virObjectUnref(cfg);
return rv;
}
@@ -6069,6 +6071,7 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
if (cmd && virCommandWait(cmd, NULL) < 0)
goto cleanup;
+ qemuDomainEventEmitJobCompleted(driver, vm);
ret = 0;
cleanup:
--
2.7.2