1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-23 21:34:54 +03:00

qemu: Introduce qemuMigrationSetParams

Several places in the code update qemuMonitorMigrationParams structure
and qemuMigrationSetParams is then used to set them all at once.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Jiri Denemark 2016-06-20 16:27:07 +02:00
parent f6e12b4029
commit 8d58952bed

View File

@ -3432,11 +3432,11 @@ static int
qemuMigrationSetCompression(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainAsyncJob job,
qemuMigrationCompressionPtr compression)
qemuMigrationCompressionPtr compression,
qemuMonitorMigrationParamsPtr migParams)
{
int ret = -1;
qemuDomainObjPrivatePtr priv = vm->privateData;
qemuMonitorMigrationParams migParams = { 0 };
if (qemuMigrationSetOption(driver, vm,
QEMU_MONITOR_MIGRATION_CAPS_XBZRLE,
@ -3455,17 +3455,14 @@ qemuMigrationSetCompression(virQEMUDriverPtr driver,
if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0)
return -1;
migParams.compressLevel_set = compression->level_set;
migParams.compressLevel = compression->level;
migParams->compressLevel_set = compression->level_set;
migParams->compressLevel = compression->level;
migParams.compressThreads_set = compression->threads_set;
migParams.compressThreads = compression->threads;
migParams->compressThreads_set = compression->threads_set;
migParams->compressThreads = compression->threads;
migParams.decompressThreads_set = compression->dthreads_set;
migParams.decompressThreads = compression->dthreads;
if (qemuMonitorSetMigrationParams(priv->mon, &migParams) < 0)
goto cleanup;
migParams->decompressThreads_set = compression->dthreads_set;
migParams->decompressThreads = compression->dthreads;
if (compression->xbzrle_cache_set &&
qemuMonitorSetMigrationCacheSize(priv->mon,
@ -3481,6 +3478,32 @@ qemuMigrationSetCompression(virQEMUDriverPtr driver,
return ret;
}
static int
qemuMigrationSetParams(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainAsyncJob job,
qemuMonitorMigrationParamsPtr migParams)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
int ret = -1;
if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0)
return -1;
if (qemuMonitorSetMigrationParams(priv->mon, migParams) < 0)
goto cleanup;
ret = 0;
cleanup:
if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -1;
return ret;
}
static int
qemuMigrationPrepareAny(virQEMUDriverPtr driver,
virConnectPtr dconn,
@ -3516,6 +3539,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
bool stopProcess = false;
bool relabel = false;
int rv;
qemuMonitorMigrationParams migParams = { 0 };
virNWFilterReadLockFilterUpdates();
@ -3698,7 +3722,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
}
if (qemuMigrationSetCompression(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN,
compression) < 0)
compression, &migParams) < 0)
goto stopjob;
if (STREQ_NULLABLE(protocol, "rdma") &&
@ -3717,6 +3741,10 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
goto stopjob;
if (qemuMigrationSetParams(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN,
&migParams) < 0)
goto stopjob;
if (mig->nbd &&
flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC) &&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NBD_SERVER)) {
@ -4554,6 +4582,7 @@ qemuMigrationRun(virQEMUDriverPtr driver,
virDomainDefPtr persistDef = NULL;
char *timestamp;
int rc;
qemuMonitorMigrationParams migParams = { 0 };
VIR_DEBUG("driver=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
"cookieout=%p, cookieoutlen=%p, flags=%lx, resource=%lu, "
@ -4634,7 +4663,7 @@ qemuMigrationRun(virQEMUDriverPtr driver,
}
if (qemuMigrationSetCompression(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
compression) < 0)
compression, &migParams) < 0)
goto cleanup;
if (qemuMigrationSetOption(driver, vm,
@ -4654,6 +4683,10 @@ qemuMigrationRun(virQEMUDriverPtr driver,
QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
goto cleanup;
if (qemuMigrationSetParams(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
&migParams) < 0)
goto cleanup;
if (qemuDomainObjEnterMonitorAsync(driver, vm,
QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
goto cleanup;