mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: Introduce qemuMigrationDstPrepareFresh
Moves most of the code from qemuMigrationDstPrepareAny to a new qemuMigrationDstPrepareFresh so that qemuMigrationDstPrepareAny can be shared with post-copy resume. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
491c9eff6c
commit
c7727296f8
@ -3084,27 +3084,26 @@ qemuMigrationDstPrepareAnyBlockDirtyBitmaps(virDomainObj *vm,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuMigrationDstPrepareAny(virQEMUDriver *driver,
|
qemuMigrationDstPrepareFresh(virQEMUDriver *driver,
|
||||||
virConnectPtr dconn,
|
virConnectPtr dconn,
|
||||||
const char *cookiein,
|
const char *cookiein,
|
||||||
int cookieinlen,
|
int cookieinlen,
|
||||||
char **cookieout,
|
char **cookieout,
|
||||||
int *cookieoutlen,
|
int *cookieoutlen,
|
||||||
virDomainDef **def,
|
virDomainDef **def,
|
||||||
const char *origname,
|
const char *origname,
|
||||||
virStreamPtr st,
|
virStreamPtr st,
|
||||||
const char *protocol,
|
const char *protocol,
|
||||||
unsigned short port,
|
unsigned short port,
|
||||||
bool autoPort,
|
bool autoPort,
|
||||||
const char *listenAddress,
|
const char *listenAddress,
|
||||||
size_t nmigrate_disks,
|
size_t nmigrate_disks,
|
||||||
const char **migrate_disks,
|
const char **migrate_disks,
|
||||||
int nbdPort,
|
int nbdPort,
|
||||||
const char *nbdURI,
|
const char *nbdURI,
|
||||||
qemuMigrationParams *migParams,
|
qemuMigrationParams *migParams,
|
||||||
unsigned long flags)
|
unsigned long flags)
|
||||||
{
|
{
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
|
||||||
virDomainObj *vm = NULL;
|
virDomainObj *vm = NULL;
|
||||||
virObjectEvent *event = NULL;
|
virObjectEvent *event = NULL;
|
||||||
virErrorPtr origErr;
|
virErrorPtr origErr;
|
||||||
@ -3124,55 +3123,18 @@ qemuMigrationDstPrepareAny(virQEMUDriver *driver,
|
|||||||
int rv;
|
int rv;
|
||||||
g_autofree char *tlsAlias = NULL;
|
g_autofree char *tlsAlias = NULL;
|
||||||
|
|
||||||
|
VIR_DEBUG("name=%s, origname=%s, protocol=%s, port=%hu, "
|
||||||
|
"listenAddress=%s, nbdPort=%d, nbdURI=%s, flags=0x%lx",
|
||||||
|
(*def)->name, NULLSTR(origname), protocol, port,
|
||||||
|
listenAddress, nbdPort, NULLSTR(nbdURI), flags);
|
||||||
|
|
||||||
if (flags & VIR_MIGRATE_OFFLINE) {
|
if (flags & VIR_MIGRATE_OFFLINE) {
|
||||||
if (flags & (VIR_MIGRATE_NON_SHARED_DISK |
|
|
||||||
VIR_MIGRATE_NON_SHARED_INC)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
||||||
_("offline migration cannot handle "
|
|
||||||
"non-shared storage"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
if (!(flags & VIR_MIGRATE_PERSIST_DEST)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
||||||
_("offline migration must be specified with "
|
|
||||||
"the persistent flag set"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
if (tunnel) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
||||||
_("tunnelled offline migration does not "
|
|
||||||
"make sense"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
cookieFlags = 0;
|
cookieFlags = 0;
|
||||||
} else {
|
} else {
|
||||||
cookieFlags = QEMU_MIGRATION_COOKIE_GRAPHICS |
|
cookieFlags = QEMU_MIGRATION_COOKIE_GRAPHICS |
|
||||||
QEMU_MIGRATION_COOKIE_CAPS;
|
QEMU_MIGRATION_COOKIE_CAPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_MIGRATE_POSTCOPY &&
|
|
||||||
(!(flags & VIR_MIGRATE_LIVE) ||
|
|
||||||
flags & VIR_MIGRATE_PAUSED)) {
|
|
||||||
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
|
||||||
_("post-copy migration is not supported with non-live "
|
|
||||||
"or paused migration"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & VIR_MIGRATE_POSTCOPY && flags & VIR_MIGRATE_TUNNELLED) {
|
|
||||||
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
|
||||||
_("post-copy is not supported with tunnelled migration"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cfg->migrateTLSForce &&
|
|
||||||
!(flags & VIR_MIGRATE_TUNNELLED) &&
|
|
||||||
!(flags & VIR_MIGRATE_TLS)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
||||||
_("this libvirtd instance allows migration only with VIR_MIGRATE_TLS flag"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!qemuMigrationSrcIsAllowedHostdev(*def))
|
if (!qemuMigrationSrcIsAllowedHostdev(*def))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -3464,6 +3426,81 @@ qemuMigrationDstPrepareAny(virQEMUDriver *driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuMigrationDstPrepareAny(virQEMUDriver *driver,
|
||||||
|
virConnectPtr dconn,
|
||||||
|
const char *cookiein,
|
||||||
|
int cookieinlen,
|
||||||
|
char **cookieout,
|
||||||
|
int *cookieoutlen,
|
||||||
|
virDomainDef **def,
|
||||||
|
const char *origname,
|
||||||
|
virStreamPtr st,
|
||||||
|
const char *protocol,
|
||||||
|
unsigned short port,
|
||||||
|
bool autoPort,
|
||||||
|
const char *listenAddress,
|
||||||
|
size_t nmigrate_disks,
|
||||||
|
const char **migrate_disks,
|
||||||
|
int nbdPort,
|
||||||
|
const char *nbdURI,
|
||||||
|
qemuMigrationParams *migParams,
|
||||||
|
unsigned long flags)
|
||||||
|
{
|
||||||
|
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
|
||||||
|
if (flags & VIR_MIGRATE_OFFLINE) {
|
||||||
|
if (flags & (VIR_MIGRATE_NON_SHARED_DISK |
|
||||||
|
VIR_MIGRATE_NON_SHARED_INC)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
|
_("offline migration cannot handle non-shared storage"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (!(flags & VIR_MIGRATE_PERSIST_DEST)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
|
_("offline migration must be specified with the persistent flag set"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (st) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
|
_("tunnelled offline migration does not make sense"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & VIR_MIGRATE_POSTCOPY &&
|
||||||
|
(!(flags & VIR_MIGRATE_LIVE) ||
|
||||||
|
flags & VIR_MIGRATE_PAUSED)) {
|
||||||
|
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
||||||
|
_("post-copy migration is not supported with non-live or paused migration"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & VIR_MIGRATE_POSTCOPY && flags & VIR_MIGRATE_TUNNELLED) {
|
||||||
|
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
||||||
|
_("post-copy is not supported with tunnelled migration"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cfg->migrateTLSForce &&
|
||||||
|
!(flags & VIR_MIGRATE_TUNNELLED) &&
|
||||||
|
!(flags & VIR_MIGRATE_TLS)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
|
_("this libvirtd instance allows migration only with VIR_MIGRATE_TLS flag"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return qemuMigrationDstPrepareFresh(driver, dconn,
|
||||||
|
cookiein, cookieinlen,
|
||||||
|
cookieout, cookieoutlen,
|
||||||
|
def, origname, st, protocol,
|
||||||
|
port, autoPort, listenAddress,
|
||||||
|
nmigrate_disks, migrate_disks,
|
||||||
|
nbdPort, nbdURI,
|
||||||
|
migParams, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This version starts an empty VM listening on a localhost TCP port, and
|
* This version starts an empty VM listening on a localhost TCP port, and
|
||||||
* sets up the corresponding virStream to handle the incoming data.
|
* sets up the corresponding virStream to handle the incoming data.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user