[libvirt] [REBASE PATCH v2 2/9] qemu: Introduce qemuProcessHandleDumpCompleted

John Ferlan posted 9 patches 7 years, 3 months ago
There is a newer version of this series
[libvirt] [REBASE PATCH v2 2/9] qemu: Introduce qemuProcessHandleDumpCompleted
Posted by John Ferlan 7 years, 3 months ago
Add a couple of booleans to mark when there's a dump completion event
waiting and when a dump completed event has been received.

To ensure the dump completed event from a non memory-only dump doesn't
cause the a dump completed event to be fired, only broadcast if there's
a completion event waiting.

Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 src/qemu/qemu_domain.c  |  2 ++
 src/qemu/qemu_domain.h  |  2 ++
 src/qemu/qemu_process.c | 23 +++++++++++++++++++++++
 3 files changed, 27 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 441bf5935..6f5b3337d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -334,6 +334,8 @@ qemuDomainObjResetAsyncJob(qemuDomainObjPrivatePtr priv)
     job->spiceMigration = false;
     job->spiceMigrated = false;
     job->postcopyEnabled = false;
+    job->dumpCompletion = false;
+    job->dumpCompleted = false;
     VIR_FREE(job->current);
 }
 
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index ddfc46dcd..5d856fb81 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -164,6 +164,8 @@ struct qemuDomainJobObj {
                                          * should wait for it to finish */
     bool spiceMigrated;                 /* spice migration completed */
     bool postcopyEnabled;               /* post-copy migration was enabled */
+    bool dumpCompletion;                /* waiting for dump completion */
+    bool dumpCompleted;                 /* dump completed */
 };
 
 typedef void (*qemuDomainCleanupCallback)(virQEMUDriverPtr driver,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 25ec464d3..44bd3ef9e 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1690,6 +1690,28 @@ qemuProcessHandleMigrationPass(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
 }
 
 
+static int
+qemuProcessHandleDumpCompleted(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
+                               virDomainObjPtr vm,
+                               qemuMonitorDumpStatus status,
+                               void *opaque ATTRIBUTE_UNUSED)
+{
+    qemuDomainObjPrivatePtr priv;
+
+    virObjectLock(vm);
+
+    VIR_DEBUG("Dump completed for domain %p %s with status=%s",
+              vm, vm->def->name, qemuMonitorDumpStatusTypeToString(status));
+
+    priv = vm->privateData;
+    priv->job.dumpCompleted = true;
+    if (priv->job.dumpCompletion)
+        virDomainObjBroadcast(vm);
+    virObjectUnlock(vm);
+    return 0;
+}
+
+
 static qemuMonitorCallbacks monitorCallbacks = {
     .eofNotify = qemuProcessHandleMonitorEOF,
     .errorNotify = qemuProcessHandleMonitorError,
@@ -1718,6 +1740,7 @@ static qemuMonitorCallbacks monitorCallbacks = {
     .domainMigrationPass = qemuProcessHandleMigrationPass,
     .domainAcpiOstInfo = qemuProcessHandleAcpiOstInfo,
     .domainBlockThreshold = qemuProcessHandleBlockThreshold,
+    .domainDumpCompleted = qemuProcessHandleDumpCompleted,
 };
 
 static void
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [REBASE PATCH v2 2/9] qemu: Introduce qemuProcessHandleDumpCompleted
Posted by Jiri Denemark 7 years, 3 months ago
On Fri, Jan 19, 2018 at 14:53:09 -0500, John Ferlan wrote:
> Add a couple of booleans to mark when there's a dump completion event
> waiting and when a dump completed event has been received.
> 
> To ensure the dump completed event from a non memory-only dump doesn't
> cause the a dump completed event to be fired, only broadcast if there's
> a completion event waiting.

I think you can just drop job->dumpCompletion as it doesn't seem to be
any useful. You set job->dumpCompleted even if dumpCompletion is false,
it's just guarding the broadcast, which is harmless. If you were
concerned about DUMP_COMPLETED event being send by some other command
than the one we call from qemuDumpToFd, you could just ignore the event
if the dump job was running, which you should probably do anyway (see
qemuProcessHandleMigration*) to make sure you job->dumpCompleted is not
unexpectedly set to true before a dump job starts.

Jirka

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