[PATCH 47/68] qemu: Introduce qemuMigrationParamsFetch

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

 



Let's separate the code which queries QEMU for migration parameters from
qemuMigrationParamsCheck into a dedicated function.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_migration_params.c | 56 +++++++++++++++++++-------------
 src/qemu/qemu_migration_params.h |  6 ++++
 2 files changed, 40 insertions(+), 22 deletions(-)

diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index f3cfb41952..642e4f314c 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -517,6 +517,39 @@ qemuMigrationParamsResetTLS(virQEMUDriverPtr driver,
 }
 
 
+int
+qemuMigrationParamsFetch(virQEMUDriverPtr driver,
+                         virDomainObjPtr vm,
+                         int asyncJob,
+                         qemuMigrationParamsPtr *migParams)
+{
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    qemuMigrationParamsPtr params = NULL;
+    int ret = -1;
+    int rc;
+
+    *migParams = NULL;
+
+    if (!(params = qemuMigrationParamsNew()))
+        return -1;
+
+    if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
+        goto cleanup;
+
+    rc = qemuMonitorGetMigrationParams(priv->mon, &params->params);
+
+    if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
+        goto cleanup;
+
+    VIR_STEAL_PTR(*migParams, params);
+    ret = 0;
+
+ cleanup:
+    qemuMigrationParamsFree(params);
+    return ret;
+}
+
+
 /**
  * qemuMigrationParamsCheck:
  *
@@ -532,11 +565,9 @@ qemuMigrationParamsCheck(virQEMUDriverPtr driver,
                          qemuMigrationParamsPtr migParams)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
-    qemuMigrationParamsPtr origParams = NULL;
     qemuMonitorMigrationCaps cap;
     qemuMigrationParty party;
     size_t i;
-    int ret = -1;
 
     if (asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT)
         party = QEMU_MIGRATION_SOURCE;
@@ -564,31 +595,12 @@ qemuMigrationParamsCheck(virQEMUDriverPtr driver,
         }
     }
 
-    if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
-        return -1;
-
-    if (!(origParams = qemuMigrationParamsNew()))
-        goto cleanup;
-
     /*
      * We want to disable all migration capabilities after migration, no need
      * to ask QEMU for their current settings.
      */
 
-    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;
+    return qemuMigrationParamsFetch(driver, vm, asyncJob, &priv->job.migParams);
 }
 
 
diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h
index 91863e0991..cabf4cebe6 100644
--- a/src/qemu/qemu_migration_params.h
+++ b/src/qemu/qemu_migration_params.h
@@ -73,6 +73,12 @@ int
 qemuMigrationParamsDisableTLS(virDomainObjPtr vm,
                               qemuMigrationParamsPtr migParams);
 
+int
+qemuMigrationParamsFetch(virQEMUDriverPtr driver,
+                         virDomainObjPtr vm,
+                         int asyncJob,
+                         qemuMigrationParamsPtr *migParams);
+
 int
 qemuMigrationParamsCheck(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