[libvirt PATCH v2 09/81] qemu: Introduce qemuProcessCleanupMigrationJob

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

 



The function can be used as a callback for qemuDomainCleanupAdd to
automatically clean up a migration job when a domain is destroyed.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
Reviewed-by: Peter Krempa <pkrempa@xxxxxxxxxx>
Reviewed-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---

Notes:
    Version 2:
    - no change

 src/qemu/qemu_process.c | 25 +++++++++++++++++++++++++
 src/qemu/qemu_process.h |  3 +++
 2 files changed, 28 insertions(+)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 0d39c67dfc..2f0167299f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3360,6 +3360,31 @@ qemuProcessUpdateState(virQEMUDriver *driver, virDomainObj *vm)
     return 0;
 }
 
+
+void
+qemuProcessCleanupMigrationJob(virQEMUDriver *driver,
+                               virDomainObj *vm)
+{
+    qemuDomainObjPrivate *priv = vm->privateData;
+    virDomainState state;
+    int reason;
+
+    state = virDomainObjGetState(vm, &reason);
+
+    VIR_DEBUG("driver=%p, vm=%s, asyncJob=%s, state=%s, reason=%s",
+              driver, vm->def->name,
+              virDomainAsyncJobTypeToString(priv->job.asyncJob),
+              virDomainStateTypeToString(state),
+              virDomainStateReasonToString(state, reason));
+
+    if (priv->job.asyncJob != VIR_ASYNC_JOB_MIGRATION_IN &&
+        priv->job.asyncJob != VIR_ASYNC_JOB_MIGRATION_OUT)
+        return;
+
+    qemuDomainObjDiscardAsyncJob(vm);
+}
+
+
 static int
 qemuProcessRecoverMigrationIn(virQEMUDriver *driver,
                               virDomainObj *vm,
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index 9866d2bf35..8641534be4 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -241,3 +241,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuProcessQMP, qemuProcessQMPFree);
 int qemuProcessQMPStart(qemuProcessQMP *proc);
 
 bool qemuProcessRebootAllowed(const virDomainDef *def);
+
+void qemuProcessCleanupMigrationJob(virQEMUDriver *driver,
+                                    virDomainObj *vm);
-- 
2.35.1




[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]

  Powered by Linux