Let's separate the code which queries QEMU for migration parameters from
qemuMigrationParamsCheck into a dedicated function.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
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, ¶ms->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