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 388a1f5804..94de0458f5 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -520,6 +520,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:
*
@@ -535,11 +568,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;
@@ -570,31 +601,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 3d1ada1a61..0a30dcd623 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