mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-20 22:51:10 +00:00
libxl: fix logic in P2P migration
libxlDoMigrateSrcP2P() performs all phases of the migration protocol for peer-to-peer migration. Unfortunately the logic was a bit flawed since it is possible to skip the confirm phase after a successfull begin and prepare phase. Fix the logic to always call the confirm phase after a successful begin and perform. Skip the confirm phase if begin or perform fail. Signed-off-by: Jim Fehlig <jfehlig@suse.com> ACKed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
60b4fd9021
commit
e39c66d3ce
@ -972,21 +972,13 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver,
|
|||||||
char *cookieout = NULL;
|
char *cookieout = NULL;
|
||||||
int cookieoutlen;
|
int cookieoutlen;
|
||||||
bool cancelled = true;
|
bool cancelled = true;
|
||||||
|
bool notify_source = true;
|
||||||
virErrorPtr orig_err = NULL;
|
virErrorPtr orig_err = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
/* For tunnel migration */
|
/* For tunnel migration */
|
||||||
virStreamPtr st = NULL;
|
virStreamPtr st = NULL;
|
||||||
struct libxlTunnelControl *tc = NULL;
|
struct libxlTunnelControl *tc = NULL;
|
||||||
|
|
||||||
dom_xml = libxlDomainMigrationSrcBegin(sconn, vm, xmlin,
|
|
||||||
&cookieout, &cookieoutlen);
|
|
||||||
if (!dom_xml)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (virTypedParamsAddString(¶ms, &nparams, &maxparams,
|
|
||||||
VIR_MIGRATE_PARAM_DEST_XML, dom_xml) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (dname &&
|
if (dname &&
|
||||||
virTypedParamsAddString(¶ms, &nparams, &maxparams,
|
virTypedParamsAddString(¶ms, &nparams, &maxparams,
|
||||||
VIR_MIGRATE_PARAM_DEST_NAME, dname) < 0)
|
VIR_MIGRATE_PARAM_DEST_NAME, dname) < 0)
|
||||||
@ -997,6 +989,19 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver,
|
|||||||
VIR_MIGRATE_PARAM_URI, uri) < 0)
|
VIR_MIGRATE_PARAM_URI, uri) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
dom_xml = libxlDomainMigrationSrcBegin(sconn, vm, xmlin,
|
||||||
|
&cookieout, &cookieoutlen);
|
||||||
|
/*
|
||||||
|
* If dom_xml is non-NULL the begin phase has succeeded, and the
|
||||||
|
* confirm phase must be called to cleanup the migration operation.
|
||||||
|
*/
|
||||||
|
if (!dom_xml)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virTypedParamsAddString(¶ms, &nparams, &maxparams,
|
||||||
|
VIR_MIGRATE_PARAM_DEST_XML, dom_xml) < 0)
|
||||||
|
goto confirm;
|
||||||
|
|
||||||
/* We don't require the destination to have P2P support
|
/* We don't require the destination to have P2P support
|
||||||
* as it looks to be normal migration from the receiver perpective.
|
* as it looks to be normal migration from the receiver perpective.
|
||||||
*/
|
*/
|
||||||
@ -1006,7 +1011,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver,
|
|||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
if (flags & VIR_MIGRATE_TUNNELLED) {
|
if (flags & VIR_MIGRATE_TUNNELLED) {
|
||||||
if (!(st = virStreamNew(dconn, 0)))
|
if (!(st = virStreamNew(dconn, 0)))
|
||||||
goto cleanup;
|
goto confirm;
|
||||||
ret = dconn->driver->domainMigratePrepareTunnel3Params
|
ret = dconn->driver->domainMigratePrepareTunnel3Params
|
||||||
(dconn, st, params, nparams, cookieout, cookieoutlen, NULL, NULL, destflags);
|
(dconn, st, params, nparams, cookieout, cookieoutlen, NULL, NULL, destflags);
|
||||||
} else {
|
} else {
|
||||||
@ -1016,7 +1021,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver,
|
|||||||
virObjectLock(vm);
|
virObjectLock(vm);
|
||||||
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
goto cleanup;
|
goto confirm;
|
||||||
|
|
||||||
if (!(flags & VIR_MIGRATE_TUNNELLED)) {
|
if (!(flags & VIR_MIGRATE_TUNNELLED)) {
|
||||||
if (uri_out) {
|
if (uri_out) {
|
||||||
@ -1038,8 +1043,10 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver,
|
|||||||
else
|
else
|
||||||
ret = libxlDomainMigrationSrcPerform(driver, vm, NULL, NULL,
|
ret = libxlDomainMigrationSrcPerform(driver, vm, NULL, NULL,
|
||||||
uri_out, NULL, flags);
|
uri_out, NULL, flags);
|
||||||
if (ret < 0)
|
if (ret < 0) {
|
||||||
|
notify_source = false;
|
||||||
orig_err = virSaveLastError();
|
orig_err = virSaveLastError();
|
||||||
|
}
|
||||||
|
|
||||||
cancelled = (ret < 0);
|
cancelled = (ret < 0);
|
||||||
|
|
||||||
@ -1067,12 +1074,15 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver,
|
|||||||
if (!orig_err)
|
if (!orig_err)
|
||||||
orig_err = virSaveLastError();
|
orig_err = virSaveLastError();
|
||||||
|
|
||||||
VIR_DEBUG("Confirm3 cancelled=%d vm=%p", cancelled, vm);
|
confirm:
|
||||||
ret = libxlDomainMigrationSrcConfirm(driver, vm, flags, cancelled);
|
if (notify_source) {
|
||||||
|
VIR_DEBUG("Confirm3 cancelled=%d vm=%p", cancelled, vm);
|
||||||
|
ret = libxlDomainMigrationSrcConfirm(driver, vm, flags, cancelled);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
VIR_WARN("Guest %s probably left in 'paused' state on source",
|
VIR_WARN("Guest %s probably left in 'paused' state on source",
|
||||||
vm->def->name);
|
vm->def->name);
|
||||||
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (flags & VIR_MIGRATE_TUNNELLED) {
|
if (flags & VIR_MIGRATE_TUNNELLED) {
|
||||||
|
Loading…
Reference in New Issue
Block a user