[PATCH v2 7/7] qemu: Add support for job completed event

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

 



Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---

Notes:
    Version 2:
    - remove useless 'type' parameter from the event

 src/qemu/qemu_domain.c    | 24 ++++++++++++++++++++++++
 src/qemu/qemu_domain.h    |  2 ++
 src/qemu/qemu_migration.c |  7 +++++--
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 9044792..5165c97 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -149,6 +149,30 @@ 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;
+
+    if (qemuDomainJobInfoToParams(priv->job.completed, &type,
+                                  &params, &nparams) < 0) {
+        VIR_WARN("Could not get stats for completed job; domain %s",
+                 vm->def->name);
+    }
+
+    event = virDomainEventJobCompletedNewFromObj(vm, 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 fb05b8b..84ce6ba 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -263,6 +263,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 da0fc18..744bbe6 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]