[PATCH v2 13/73] qemu: Store original migration params in job

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

 



Any job which touches migration parameters will first store their
original values (i.e., QEMU defaults) to qemuDomainJobObj to make it
easier to reset them back once the job finishes.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c           |  3 +++
 src/qemu/qemu_domain.h           |  3 +++
 src/qemu/qemu_migration.c        |  9 ++++++++
 src/qemu/qemu_migration_params.c | 38 ++++++++++++++++++++++++++++++++
 src/qemu/qemu_migration_params.h |  5 +++++
 5 files changed, 58 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 84476de11b..78f5dc360c 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -336,6 +336,8 @@ qemuDomainObjResetAsyncJob(qemuDomainObjPrivatePtr priv)
     job->dumpCompleted = false;
     VIR_FREE(job->error);
     VIR_FREE(job->current);
+    qemuMigrationParamsFree(job->migParams);
+    job->migParams = NULL;
 }
 
 void
@@ -350,6 +352,7 @@ qemuDomainObjRestoreJob(virDomainObjPtr obj,
     job->asyncJob = priv->job.asyncJob;
     job->asyncOwner = priv->job.asyncOwner;
     job->phase = priv->job.phase;
+    VIR_STEAL_PTR(job->migParams, priv->job.migParams);
 
     qemuDomainObjResetJob(priv);
     qemuDomainObjResetAsyncJob(priv);
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 415b2ca093..1828b64284 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -34,6 +34,7 @@
 # include "qemu_agent.h"
 # include "qemu_conf.h"
 # include "qemu_capabilities.h"
+# include "qemu_migration_params.h"
 # include "virmdev.h"
 # include "virchrdev.h"
 # include "virobject.h"
@@ -177,6 +178,8 @@ struct qemuDomainJobObj {
     bool postcopyEnabled;               /* post-copy migration was enabled */
     char *error;                        /* job event completion error */
     bool dumpCompleted;                 /* dump completed */
+
+    qemuMigrationParamsPtr migParams;
 };
 
 typedef void (*qemuDomainCleanupCallback)(virQEMUDriverPtr driver,
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index b7ef535b5d..96ca5593cf 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2448,6 +2448,9 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
         dataFD[1] = -1; /* 'st' owns the FD now & will close it */
     }
 
+    if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
+        goto stopjob;
+
     if (qemuMigrationParamsSetCompression(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN,
                                           compression, migParams) < 0)
         goto stopjob;
@@ -4597,6 +4600,9 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver,
 
     qemuMigrationSrcStoreDomainState(vm);
 
+    if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
+        goto endjob;
+
     if ((flags & (VIR_MIGRATE_TUNNELLED | VIR_MIGRATE_PEER2PEER))) {
         ret = qemuMigrationSrcPerformPeer2Peer(driver, conn, vm, xmlin, persist_xml,
                                                dconnuri, uri, graphicsuri, listenAddress,
@@ -4700,6 +4706,9 @@ qemuMigrationSrcPerformPhase(virQEMUDriverPtr driver,
     virCloseCallbacksUnset(driver->closeCallbacks, vm,
                            qemuMigrationSrcCleanup);
 
+    if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
+        goto endjob;
+
     ret = qemuMigrationSrcPerformNative(driver, vm, persist_xml, uri, cookiein, cookieinlen,
                                         cookieout, cookieoutlen,
                                         flags, resource, NULL, graphicsuri,
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index 3a1816c2b9..465132fd9c 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -428,6 +428,44 @@ qemuMigrationParamsResetTLS(virQEMUDriverPtr driver,
 }
 
 
+/**
+ * qemuMigrationParamsCheck:
+ *
+ * Check supported migration parameters and keep their original values in
+ * qemuDomainJobObj so that we can properly reset them at the end of migration.
+ */
+int
+qemuMigrationParamsCheck(virQEMUDriverPtr driver,
+                         virDomainObjPtr vm,
+                         int asyncJob)
+{
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    qemuMigrationParamsPtr origParams = NULL;
+    int ret = -1;
+
+    if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
+        return -1;
+
+    if (!(origParams = qemuMigrationParamsNew()))
+        goto cleanup;
+
+    if (qemuMonitorGetMigrationParams(priv->mon, &origParams->params) < 0)
+        goto cleanup;
+
+    ret = 0;
+
+ cleanup:
+    if (qemuDomainObjExitMonitor(driver, vm) < 0)
+        ret = -1;
+
+    if (ret == 0)
+        VIR_STEAL_PTR(priv->job.migParams, origParams);
+    qemuMigrationParamsFree(origParams);
+
+    return ret;
+}
+
+
 /*
  * qemuMigrationParamsReset:
  *
diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h
index 57b7dd6666..c283a81b51 100644
--- a/src/qemu/qemu_migration_params.h
+++ b/src/qemu/qemu_migration_params.h
@@ -100,6 +100,11 @@ qemuMigrationParamsSetCompression(virQEMUDriverPtr driver,
                                   qemuMigrationCompressionPtr compression,
                                   qemuMigrationParamsPtr migParams);
 
+int
+qemuMigrationParamsCheck(virQEMUDriverPtr driver,
+                         virDomainObjPtr vm,
+                         int asyncJob);
+
 void
 qemuMigrationParamsReset(virQEMUDriverPtr driver,
                          virDomainObjPtr vm,
-- 
2.17.0

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

  Powered by Linux