mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: Allocate struct for migration parameters
It will get a bit more complicated soon and storing it on a stack with {0} initializer will no longer work. We need a proper constructor. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
3bc416018b
commit
163304c24f
@ -12219,7 +12219,7 @@ qemuDomainMigratePerform(virDomainPtr dom,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
const char *dconnuri = NULL;
|
const char *dconnuri = NULL;
|
||||||
qemuMigrationCompressionPtr compression = NULL;
|
qemuMigrationCompressionPtr compression = NULL;
|
||||||
qemuMonitorMigrationParams migParams = { 0 };
|
qemuMonitorMigrationParamsPtr migParams = NULL;
|
||||||
|
|
||||||
virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
|
virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
|
||||||
|
|
||||||
@ -12230,6 +12230,9 @@ qemuDomainMigratePerform(virDomainPtr dom,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(migParams = qemuMigrationParamsNew()))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags)))
|
if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -12254,12 +12257,12 @@ qemuDomainMigratePerform(virDomainPtr dom,
|
|||||||
*/
|
*/
|
||||||
ret = qemuMigrationSrcPerform(driver, dom->conn, vm, NULL,
|
ret = qemuMigrationSrcPerform(driver, dom->conn, vm, NULL,
|
||||||
NULL, dconnuri, uri, NULL, NULL, 0, NULL, 0,
|
NULL, dconnuri, uri, NULL, NULL, 0, NULL, 0,
|
||||||
compression, &migParams, cookie, cookielen,
|
compression, migParams, cookie, cookielen,
|
||||||
NULL, NULL, /* No output cookies in v2 */
|
NULL, NULL, /* No output cookies in v2 */
|
||||||
flags, dname, resource, false);
|
flags, dname, resource, false);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
qemuMigrationParamsClear(&migParams);
|
qemuMigrationParamsFree(migParams);
|
||||||
VIR_FREE(compression);
|
VIR_FREE(compression);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -12644,13 +12647,16 @@ qemuDomainMigratePerform3(virDomainPtr dom,
|
|||||||
virQEMUDriverPtr driver = dom->conn->privateData;
|
virQEMUDriverPtr driver = dom->conn->privateData;
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
qemuMigrationCompressionPtr compression = NULL;
|
qemuMigrationCompressionPtr compression = NULL;
|
||||||
qemuMonitorMigrationParams migParams = { 0 };
|
qemuMonitorMigrationParamsPtr migParams = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
|
virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
|
||||||
|
|
||||||
|
if (!(migParams = qemuMigrationParamsNew()))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags)))
|
if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags)))
|
||||||
return -1;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(vm = qemuDomObjFromDomain(dom)))
|
if (!(vm = qemuDomObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -12662,13 +12668,13 @@ qemuDomainMigratePerform3(virDomainPtr dom,
|
|||||||
|
|
||||||
ret = qemuMigrationSrcPerform(driver, dom->conn, vm, xmlin, NULL,
|
ret = qemuMigrationSrcPerform(driver, dom->conn, vm, xmlin, NULL,
|
||||||
dconnuri, uri, NULL, NULL, 0, NULL, 0,
|
dconnuri, uri, NULL, NULL, 0, NULL, 0,
|
||||||
compression, &migParams,
|
compression, migParams,
|
||||||
cookiein, cookieinlen,
|
cookiein, cookieinlen,
|
||||||
cookieout, cookieoutlen,
|
cookieout, cookieoutlen,
|
||||||
flags, dname, resource, true);
|
flags, dname, resource, true);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
qemuMigrationParamsClear(&migParams);
|
qemuMigrationParamsFree(migParams);
|
||||||
VIR_FREE(compression);
|
VIR_FREE(compression);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -2251,7 +2251,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
|
|||||||
int rv;
|
int rv;
|
||||||
char *tlsAlias = NULL;
|
char *tlsAlias = NULL;
|
||||||
char *secAlias = NULL;
|
char *secAlias = NULL;
|
||||||
qemuMonitorMigrationParams migParams = { 0 };
|
qemuMonitorMigrationParamsPtr migParams = NULL;
|
||||||
|
|
||||||
virNWFilterReadLockFilterUpdates();
|
virNWFilterReadLockFilterUpdates();
|
||||||
|
|
||||||
@ -2301,6 +2301,9 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
|
|||||||
if (!qemuMigrationSrcIsAllowedHostdev(*def))
|
if (!qemuMigrationSrcIsAllowedHostdev(*def))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (!(migParams = qemuMigrationParamsNew()))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
/* Let migration hook filter domain XML */
|
/* Let migration hook filter domain XML */
|
||||||
if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
|
if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
|
||||||
char *xml;
|
char *xml;
|
||||||
@ -2445,7 +2448,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (qemuMigrationParamsSetCompression(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN,
|
if (qemuMigrationParamsSetCompression(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN,
|
||||||
compression, &migParams) < 0)
|
compression, migParams) < 0)
|
||||||
goto stopjob;
|
goto stopjob;
|
||||||
|
|
||||||
/* Migrations using TLS need to add the "tls-creds-x509" object and
|
/* Migrations using TLS need to add the "tls-creds-x509" object and
|
||||||
@ -2458,17 +2461,17 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
if (qemuMigrationParamsAddTLSObjects(driver, vm, cfg, true,
|
if (qemuMigrationParamsAddTLSObjects(driver, vm, cfg, true,
|
||||||
QEMU_ASYNC_JOB_MIGRATION_IN,
|
QEMU_ASYNC_JOB_MIGRATION_IN,
|
||||||
&tlsAlias, &secAlias, &migParams) < 0)
|
&tlsAlias, &secAlias, migParams) < 0)
|
||||||
goto stopjob;
|
goto stopjob;
|
||||||
|
|
||||||
/* Force reset of 'tls-hostname', it's a source only parameter */
|
/* Force reset of 'tls-hostname', it's a source only parameter */
|
||||||
if (VIR_STRDUP(migParams.tlsHostname, "") < 0)
|
if (VIR_STRDUP(migParams->tlsHostname, "") < 0)
|
||||||
goto stopjob;
|
goto stopjob;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (qemuMigrationParamsSetEmptyTLS(driver, vm,
|
if (qemuMigrationParamsSetEmptyTLS(driver, vm,
|
||||||
QEMU_ASYNC_JOB_MIGRATION_IN,
|
QEMU_ASYNC_JOB_MIGRATION_IN,
|
||||||
&migParams) < 0)
|
migParams) < 0)
|
||||||
goto stopjob;
|
goto stopjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2489,7 +2492,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
|
|||||||
goto stopjob;
|
goto stopjob;
|
||||||
|
|
||||||
if (qemuMigrationParamsSet(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN,
|
if (qemuMigrationParamsSet(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN,
|
||||||
&migParams) < 0)
|
migParams) < 0)
|
||||||
goto stopjob;
|
goto stopjob;
|
||||||
|
|
||||||
if (mig->nbd &&
|
if (mig->nbd &&
|
||||||
@ -2577,7 +2580,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
|
|||||||
virDomainObjRemoveTransientDef(vm);
|
virDomainObjRemoveTransientDef(vm);
|
||||||
qemuDomainRemoveInactiveJob(driver, vm);
|
qemuDomainRemoveInactiveJob(driver, vm);
|
||||||
}
|
}
|
||||||
qemuMigrationParamsClear(&migParams);
|
qemuMigrationParamsFree(migParams);
|
||||||
virDomainObjEndAPI(&vm);
|
virDomainObjEndAPI(&vm);
|
||||||
qemuDomainEventQueue(driver, event);
|
qemuDomainEventQueue(driver, event);
|
||||||
qemuMigrationCookieFree(mig);
|
qemuMigrationCookieFree(mig);
|
||||||
@ -3881,7 +3884,7 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriverPtr driver,
|
|||||||
virStreamPtr st = NULL;
|
virStreamPtr st = NULL;
|
||||||
unsigned long destflags;
|
unsigned long destflags;
|
||||||
qemuMigrationCompressionPtr compression = NULL;
|
qemuMigrationCompressionPtr compression = NULL;
|
||||||
qemuMonitorMigrationParams migParams = { 0 };
|
qemuMonitorMigrationParamsPtr migParams = NULL;
|
||||||
|
|
||||||
VIR_DEBUG("driver=%p, sconn=%p, dconn=%p, vm=%p, dconnuri=%s, "
|
VIR_DEBUG("driver=%p, sconn=%p, dconn=%p, vm=%p, dconnuri=%s, "
|
||||||
"flags=0x%lx, dname=%s, resource=%lu",
|
"flags=0x%lx, dname=%s, resource=%lu",
|
||||||
@ -3903,6 +3906,9 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriverPtr driver,
|
|||||||
destflags = flags & ~(VIR_MIGRATE_ABORT_ON_ERROR |
|
destflags = flags & ~(VIR_MIGRATE_ABORT_ON_ERROR |
|
||||||
VIR_MIGRATE_AUTO_CONVERGE);
|
VIR_MIGRATE_AUTO_CONVERGE);
|
||||||
|
|
||||||
|
if (!(migParams = qemuMigrationParamsNew()))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags)))
|
if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -3958,13 +3964,13 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriverPtr driver,
|
|||||||
ret = qemuMigrationSrcPerformTunnel(driver, vm, st, NULL,
|
ret = qemuMigrationSrcPerformTunnel(driver, vm, st, NULL,
|
||||||
NULL, 0, NULL, NULL,
|
NULL, 0, NULL, NULL,
|
||||||
flags, resource, dconn,
|
flags, resource, dconn,
|
||||||
NULL, 0, NULL, compression, &migParams);
|
NULL, 0, NULL, compression, migParams);
|
||||||
else
|
else
|
||||||
ret = qemuMigrationSrcPerformNative(driver, vm, NULL, uri_out,
|
ret = qemuMigrationSrcPerformNative(driver, vm, NULL, uri_out,
|
||||||
cookie, cookielen,
|
cookie, cookielen,
|
||||||
NULL, NULL, /* No out cookie with v2 migration */
|
NULL, NULL, /* No out cookie with v2 migration */
|
||||||
flags, resource, dconn, NULL, 0, NULL,
|
flags, resource, dconn, NULL, 0, NULL,
|
||||||
compression, &migParams);
|
compression, migParams);
|
||||||
|
|
||||||
/* Perform failed. Make sure Finish doesn't overwrite the error */
|
/* Perform failed. Make sure Finish doesn't overwrite the error */
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -4004,7 +4010,7 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriverPtr driver,
|
|||||||
virSetError(orig_err);
|
virSetError(orig_err);
|
||||||
virFreeError(orig_err);
|
virFreeError(orig_err);
|
||||||
}
|
}
|
||||||
qemuMigrationParamsClear(&migParams);
|
qemuMigrationParamsFree(migParams);
|
||||||
VIR_FREE(uri_out);
|
VIR_FREE(uri_out);
|
||||||
VIR_FREE(cookie);
|
VIR_FREE(cookie);
|
||||||
VIR_FREE(compression);
|
VIR_FREE(compression);
|
||||||
|
@ -38,6 +38,18 @@ VIR_LOG_INIT("qemu.qemu_migration_params");
|
|||||||
#define QEMU_MIGRATION_TLS_ALIAS_BASE "libvirt_migrate"
|
#define QEMU_MIGRATION_TLS_ALIAS_BASE "libvirt_migrate"
|
||||||
|
|
||||||
|
|
||||||
|
qemuMonitorMigrationParamsPtr
|
||||||
|
qemuMigrationParamsNew(void)
|
||||||
|
{
|
||||||
|
qemuMonitorMigrationParamsPtr params;
|
||||||
|
|
||||||
|
if (VIR_ALLOC(params) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
qemuMigrationParamsClear(qemuMonitorMigrationParamsPtr migParams)
|
qemuMigrationParamsClear(qemuMonitorMigrationParamsPtr migParams)
|
||||||
{
|
{
|
||||||
@ -67,7 +79,7 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params,
|
|||||||
{
|
{
|
||||||
qemuMonitorMigrationParamsPtr migParams;
|
qemuMonitorMigrationParamsPtr migParams;
|
||||||
|
|
||||||
if (VIR_ALLOC(migParams) < 0)
|
if (!(migParams = qemuMigrationParamsNew()))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!params)
|
if (!params)
|
||||||
@ -151,16 +163,19 @@ qemuMigrationParamsCheckTLSCreds(virQEMUDriverPtr driver,
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
qemuMonitorMigrationParams migParams = { 0 };
|
qemuMonitorMigrationParamsPtr migParams = NULL;
|
||||||
|
|
||||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorGetMigrationParams(priv->mon, &migParams) < 0)
|
if (!(migParams = qemuMigrationParamsNew()))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (qemuMonitorGetMigrationParams(priv->mon, migParams) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* NB: Could steal NULL pointer too! Let caller decide what to do. */
|
/* NB: Could steal NULL pointer too! Let caller decide what to do. */
|
||||||
VIR_STEAL_PTR(priv->migTLSAlias, migParams.tlsCreds);
|
VIR_STEAL_PTR(priv->migTLSAlias, migParams->tlsCreds);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
@ -168,7 +183,7 @@ qemuMigrationParamsCheckTLSCreds(virQEMUDriverPtr driver,
|
|||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
qemuMigrationParamsClear(&migParams);
|
qemuMigrationParamsFree(migParams);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -384,7 +399,7 @@ qemuMigrationParamsResetTLS(virQEMUDriverPtr driver,
|
|||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
char *tlsAlias = NULL;
|
char *tlsAlias = NULL;
|
||||||
char *secAlias = NULL;
|
char *secAlias = NULL;
|
||||||
qemuMonitorMigrationParams migParams = { 0 };
|
qemuMonitorMigrationParamsPtr migParams = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (qemuMigrationParamsCheckTLSCreds(driver, vm, asyncJob) < 0)
|
if (qemuMigrationParamsCheckTLSCreds(driver, vm, asyncJob) < 0)
|
||||||
@ -395,6 +410,9 @@ qemuMigrationParamsResetTLS(virQEMUDriverPtr driver,
|
|||||||
if (!priv->migTLSAlias || !*priv->migTLSAlias)
|
if (!priv->migTLSAlias || !*priv->migTLSAlias)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (!(migParams = qemuMigrationParamsNew()))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
/* NB: If either or both fail to allocate memory we can still proceed
|
/* NB: If either or both fail to allocate memory we can still proceed
|
||||||
* since the next time we migrate another deletion attempt will be
|
* since the next time we migrate another deletion attempt will be
|
||||||
* made after successfully generating the aliases. */
|
* made after successfully generating the aliases. */
|
||||||
@ -404,9 +422,9 @@ qemuMigrationParamsResetTLS(virQEMUDriverPtr driver,
|
|||||||
qemuDomainDelTLSObjects(driver, vm, asyncJob, secAlias, tlsAlias);
|
qemuDomainDelTLSObjects(driver, vm, asyncJob, secAlias, tlsAlias);
|
||||||
qemuDomainSecretInfoFree(&priv->migSecinfo);
|
qemuDomainSecretInfoFree(&priv->migSecinfo);
|
||||||
|
|
||||||
if (VIR_STRDUP(migParams.tlsCreds, "") < 0 ||
|
if (VIR_STRDUP(migParams->tlsCreds, "") < 0 ||
|
||||||
VIR_STRDUP(migParams.tlsHostname, "") < 0 ||
|
VIR_STRDUP(migParams->tlsHostname, "") < 0 ||
|
||||||
qemuMigrationParamsSet(driver, vm, asyncJob, &migParams) < 0)
|
qemuMigrationParamsSet(driver, vm, asyncJob, migParams) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -414,7 +432,7 @@ qemuMigrationParamsResetTLS(virQEMUDriverPtr driver,
|
|||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(tlsAlias);
|
VIR_FREE(tlsAlias);
|
||||||
VIR_FREE(secAlias);
|
VIR_FREE(secAlias);
|
||||||
qemuMigrationParamsClear(&migParams);
|
qemuMigrationParamsFree(migParams);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,9 @@
|
|||||||
# include "qemu_conf.h"
|
# include "qemu_conf.h"
|
||||||
|
|
||||||
|
|
||||||
|
qemuMonitorMigrationParamsPtr
|
||||||
|
qemuMigrationParamsNew(void);
|
||||||
|
|
||||||
qemuMonitorMigrationParamsPtr
|
qemuMonitorMigrationParamsPtr
|
||||||
qemuMigrationParamsFromFlags(virTypedParameterPtr params,
|
qemuMigrationParamsFromFlags(virTypedParameterPtr params,
|
||||||
int nparams,
|
int nparams,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user