Supports migrating a domain that is currently inactive. This patchset adds a new migration flag called VIR_MIGRATE_OFFLINE, which can only be used on domains that are inactive. Offline migration does not support copying non-shared storage in any case. --- src/qemu/qemu_driver.c | 29 ++++++++++++++++------------- src/qemu/qemu_migration.c | 5 ++++- tools/virsh-domain.c | 9 ++++++--- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6e3747f..f53bf3d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9624,34 +9624,37 @@ qemuDomainMigrateBegin3(virDomainPtr domain, asyncJob = QEMU_ASYNC_JOB_NONE; } + /* Domain is not active */ if (!virDomainObjIsActive(vm)) { + /* Domain is not active and offline migration requested */ if (flags & VIR_MIGRATE_OFFLINE) { - if (flags & (VIR_MIGRATE_NON_SHARED_DISK| + if (flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("migrating storage handled by volume APIs")); + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("offline migration cannot copy non-shared storage")); goto endjob; } if (!(flags & VIR_MIGRATE_PERSIST_DEST)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("VIR_MIGRATE_OFFLINE should combined with VIR_MIGRATE_PERSIST_DEST")); + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("offline migration must be specified with the persistent flag set")); goto endjob; } - goto offline; + } else { + /* Domain is not active and NO offline migration */ + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); + goto endjob; } - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); - goto endjob; } /* Check if there is any ejected media. * We don't want to require them on the destination. */ + if (virDomainObjIsActive(vm)) { + if (qemuDomainCheckEjectableMedia(driver, vm, asyncJob) < 0) + goto endjob; + } - if (qemuDomainCheckEjectableMedia(driver, vm, asyncJob) < 0) - goto endjob; - -offline: if (!(xml = qemuMigrationBegin(driver, vm, xmlin, dname, cookieout, cookieoutlen, flags))) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index de9d55d..54e94a4 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1904,8 +1904,10 @@ qemuMigrationRun(struct qemud_driver *driver, virLockManagerPluginGetName(driver->lockManager)); return -1; } + if (flags & VIR_MIGRATE_OFFLINE) return 0; + if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen, QEMU_MIGRATION_COOKIE_GRAPHICS))) goto cleanup; @@ -3008,7 +3010,7 @@ qemuMigrationFinish(struct qemud_driver *driver, goto endjob; } - offline: +offline: if (flags & VIR_MIGRATE_PERSIST_DEST) { virDomainDefPtr vmdef; if (vm->persistent) @@ -3176,6 +3178,7 @@ int qemuMigrationConfirm(struct qemud_driver *driver, if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen, 0))) return -1; + if (flags & VIR_MIGRATE_OFFLINE) goto offline; diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 4d5a242..8196ba6 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6644,6 +6644,7 @@ static const vshCmdInfo info_migrate[] = { static const vshCmdOptDef opts_migrate[] = { {"live", VSH_OT_BOOL, 0, N_("live migration")}, + {"offline", VSH_OT_BOOL, 0, N_("offline (inactive domain) migration")}, {"p2p", VSH_OT_BOOL, 0, N_("peer-2-peer migration")}, {"direct", VSH_OT_BOOL, 0, N_("direct migration")}, {"tunneled", VSH_OT_ALIAS, 0, "tunnelled"}, @@ -6663,7 +6664,6 @@ static const vshCmdOptDef opts_migrate[] = { {"dname", VSH_OT_DATA, 0, N_("rename to new name during migration (if supported)")}, {"timeout", VSH_OT_INT, 0, N_("force guest to suspend if live migration exceeds timeout (in seconds)")}, {"xml", VSH_OT_STRING, 0, N_("filename containing updated XML for the target")}, - {"offline", VSH_OT_BOOL, 0, N_("for offline migration")}, {NULL, 0, 0, NULL} }; @@ -6730,9 +6730,12 @@ doMigrate(void *opaque) if (vshCommandOptBool(cmd, "unsafe")) flags |= VIR_MIGRATE_UNSAFE; - if (vshCommandOptBool(cmd, "offline")) { - if (!virDomainIsActive(dom)) + if (vshCommandOptBool(cmd, "offline")) flags |= VIR_MIGRATE_OFFLINE; + + if (virDomainIsActive(dom) && (flags & VIR_MIGRATE_OFFLINE)) { + vshError(ctl, "%s", _("unable to perform offline migration when the domain is active")); + goto out; } if (xmlfile && -- 1.7.8.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list