Implement a `migrate_disks' parameters for the QEMU driver. This multi-
value parameter can be used to explicitly specify what block devices
are to be migrated using the NBD server. Tunnelled migration using NBD
is to be done.
Signed-off-by: Pavel Boldin <pboldin(a)mirantis.com>
---
include/libvirt/libvirt-domain.h | 9 ++
src/qemu/qemu_driver.c | 66 ++++++++++-----
src/qemu/qemu_migration.c | 174 +++++++++++++++++++++++++--------------
src/qemu/qemu_migration.h | 23 ++++--
4 files changed, 183 insertions(+), 89 deletions(-)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 0f465b9..6b48923 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -748,6 +748,15 @@ typedef enum {
*/
# define VIR_MIGRATE_PARAM_LISTEN_ADDRESS "listen_address"
+/**
+ * VIR_MIGRATE_PARAM_MIGRATE_DISKS:
+ *
+ * virDomainMigrate* params multiple field: The multiple values that list
+ * the block devices to be migrated. At the moment this is only supported
+ * by the QEMU driver but not for the tunnelled migration.
+ */
+# define VIR_MIGRATE_PARAM_MIGRATE_DISKS "migrate_disks"
+
/* Domain migration. */
virDomainPtr virDomainMigrate (virDomainPtr domain, virConnectPtr dconn,
unsigned long flags, const char *dname,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2668011..77b7d9d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12472,7 +12472,7 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
ret = qemuMigrationPrepareDirect(driver, dconn,
NULL, 0, NULL, NULL, /* No cookies */
uri_in, uri_out,
- &def, origname, NULL, flags);
+ &def, origname, NULL, flags, NULL);
cleanup:
VIR_FREE(origname);
@@ -12525,7 +12525,7 @@ qemuDomainMigratePerform(virDomainPtr dom,
* Consume any cookie we were able to decode though
*/
ret = qemuMigrationPerform(driver, dom->conn, vm,
- NULL, dconnuri, uri, NULL, NULL,
+ NULL, dconnuri, uri, NULL, NULL, NULL,
cookie, cookielen,
NULL, NULL, /* No output cookies in v2 */
flags, dname, resource, false);
@@ -12602,7 +12602,7 @@ qemuDomainMigrateBegin3(virDomainPtr domain,
}
return qemuMigrationBegin(domain->conn, vm, xmlin, dname,
- cookieout, cookieoutlen, flags);
+ cookieout, cookieoutlen, flags, NULL);
}
static char *
@@ -12615,11 +12615,13 @@ qemuDomainMigrateBegin3Params(virDomainPtr domain,
{
const char *xmlin = NULL;
const char *dname = NULL;
+ const char **migrate_disks = NULL;
+ char *ret = NULL;
virDomainObjPtr vm;
virCheckFlags(QEMU_MIGRATION_FLAGS, NULL);
if (virTypedParamsValidate(params, nparams, QEMU_MIGRATION_PARAMETERS) < 0)
- return NULL;
+ goto cleanup;
if (virTypedParamsGetString(params, nparams,
VIR_MIGRATE_PARAM_DEST_XML,
@@ -12627,18 +12629,26 @@ qemuDomainMigrateBegin3Params(virDomainPtr domain,
virTypedParamsGetString(params, nparams,
VIR_MIGRATE_PARAM_DEST_NAME,
&dname) < 0)
- return NULL;
+ goto cleanup;
+
+ migrate_disks = virTypedParamsPickStrings(params, nparams,
+ VIR_MIGRATE_PARAM_MIGRATE_DISKS,
+ NULL);
if (!(vm = qemuDomObjFromDomain(domain)))
- return NULL;
+ goto cleanup;
if (virDomainMigrateBegin3ParamsEnsureACL(domain->conn, vm->def) < 0) {
virDomainObjEndAPI(&vm);
- return NULL;
+ goto cleanup;
}
- return qemuMigrationBegin(domain->conn, vm, xmlin, dname,
- cookieout, cookieoutlen, flags);
+ ret = qemuMigrationBegin(domain->conn, vm, xmlin, dname,
+ cookieout, cookieoutlen, flags, migrate_disks);
+
+ cleanup:
+ VIR_FREE(migrate_disks);
+ return ret;
}
@@ -12682,7 +12692,8 @@ qemuDomainMigratePrepare3(virConnectPtr dconn,
cookiein, cookieinlen,
cookieout, cookieoutlen,
uri_in, uri_out,
- &def, origname, NULL, flags);
+ &def, origname, NULL, flags,
+ NULL);
cleanup:
VIR_FREE(origname);
@@ -12708,6 +12719,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
const char *dname = NULL;
const char *uri_in = NULL;
const char *listenAddress = cfg->migrationAddress;
+ const char **migrate_disks = NULL;
char *origname = NULL;
int ret = -1;
@@ -12729,6 +12741,10 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
&listenAddress) < 0)
goto cleanup;
+ migrate_disks = virTypedParamsPickStrings(params, nparams,
+ VIR_MIGRATE_PARAM_MIGRATE_DISKS,
+ NULL);
+
if (flags & VIR_MIGRATE_TUNNELLED) {
/* this is a logical error; we never should have gotten here with
* VIR_MIGRATE_TUNNELLED set
@@ -12749,9 +12765,11 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
cookiein, cookieinlen,
cookieout, cookieoutlen,
uri_in, uri_out,
- &def, origname, listenAddress, flags);
+ &def, origname, listenAddress, flags,
+ migrate_disks);
cleanup:
+ VIR_FREE(migrate_disks);
VIR_FREE(origname);
virDomainDefFree(def);
virObjectUnref(cfg);
@@ -12882,7 +12900,7 @@ qemuDomainMigratePerform3(virDomainPtr dom,
}
return qemuMigrationPerform(driver, dom->conn, vm, xmlin,
- dconnuri, uri, NULL, NULL,
+ dconnuri, uri, NULL, NULL, NULL,
cookiein, cookieinlen,
cookieout, cookieoutlen,
flags, dname, resource, true);
@@ -12906,7 +12924,9 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
const char *uri = NULL;
const char *graphicsuri = NULL;
const char *listenAddress = NULL;
+ const char **migrate_disks = NULL;
unsigned long long bandwidth = 0;
+ int ret = -1;
virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
if (virTypedParamsValidate(params, nparams, QEMU_MIGRATION_PARAMETERS) < 0)
@@ -12930,20 +12950,28 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
virTypedParamsGetString(params, nparams,
VIR_MIGRATE_PARAM_LISTEN_ADDRESS,
&listenAddress) < 0)
- return -1;
+ goto cleanup;
+
+ migrate_disks = virTypedParamsPickStrings(params, nparams,
+ VIR_MIGRATE_PARAM_MIGRATE_DISKS,
+ NULL);
if (!(vm = qemuDomObjFromDomain(dom)))
- return -1;
+ goto cleanup;
if (virDomainMigratePerform3ParamsEnsureACL(dom->conn, vm->def) < 0) {
virDomainObjEndAPI(&vm);
- return -1;
+ goto cleanup;
}
- return qemuMigrationPerform(driver, dom->conn, vm, dom_xml,
- dconnuri, uri, graphicsuri, listenAddress,
- cookiein, cookieinlen, cookieout, cookieoutlen,
- flags, dname, bandwidth, true);
+ ret = qemuMigrationPerform(driver, dom->conn, vm, dom_xml,
+ dconnuri, uri, graphicsuri, listenAddress,
+ migrate_disks,
+ cookiein, cookieinlen, cookieout, cookieoutlen,
+ flags, dname, bandwidth, true);
+ cleanup:
+ VIR_FREE(migrate_disks);
+ return ret;
}
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 8fe1cfb..708d1aa 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1579,12 +1579,32 @@ qemuMigrationPrecreateDisk(virConnectPtr conn,
return ret;
}
+static int
+qemuMigrateDisk(virDomainDiskDefPtr const disk, const char **migrate_disks)
+{
+ size_t i;
+ /* Check if the disk alias is in the list */
+ if (disk->info.alias && migrate_disks) {
+ for (i = 0; migrate_disks[i]; i++) {
+ if (STREQ(disk->info.alias, migrate_disks[i]))
+ return 1;
+ }
+ return 0;
+ }
+
+ /* Default is to migrate only non-shared non-readonly disks
+ * with source */
+ return !disk->src->shared && !disk->src->readonly &&
+ virDomainDiskGetSource(disk);
+}
+
static int
qemuMigrationPrecreateStorage(virConnectPtr conn,
virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
virDomainObjPtr vm,
- qemuMigrationCookieNBDPtr nbd)
+ qemuMigrationCookieNBDPtr nbd,
+ const char **migrate_disks)
{
int ret = -1;
size_t i = 0;
@@ -1611,9 +1631,9 @@ qemuMigrationPrecreateStorage(virConnectPtr conn,
disk = vm->def->disks[indx];
diskSrcPath = virDomainDiskGetSource(disk);
- if (disk->src->shared || disk->src->readonly ||
+ /* Skip disks we don't want to migrate and already existing disks. */
+ if (!qemuMigrateDisk(disk, migrate_disks) ||
(diskSrcPath && virFileExists(diskSrcPath))) {
- /* Skip shared, read-only and already existing disks. */
continue;
}
@@ -1644,7 +1664,8 @@ qemuMigrationPrecreateStorage(virConnectPtr conn,
static int
qemuMigrationStartNBDServer(virQEMUDriverPtr driver,
virDomainObjPtr vm,
- const char *listenAddr)
+ const char *listenAddr,
+ const char **migrate_disks)
{
int ret = -1;
qemuDomainObjPrivatePtr priv = vm->privateData;
@@ -1655,9 +1676,8 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver,
for (i = 0; i < vm->def->ndisks; i++) {
virDomainDiskDefPtr disk = vm->def->disks[i];
- /* skip shared, RO and source-less disks */
- if (disk->src->shared || disk->src->readonly ||
- !virDomainDiskGetSource(disk))
+ /* check whether disk should be migrated */
+ if (!qemuMigrateDisk(disk, migrate_disks))
continue;
VIR_FREE(diskAlias);
@@ -1916,7 +1936,8 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
qemuMigrationCookiePtr mig,
const char *host,
unsigned long speed,
- unsigned int *migrate_flags)
+ unsigned int *migrate_flags,
+ const char **migrate_disks)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
int ret = -1;
@@ -1947,9 +1968,8 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
int mon_ret;
- /* skip shared, RO and source-less disks */
- if (disk->src->shared || disk->src->readonly ||
- !virDomainDiskGetSource(disk))
+ /* check whether disk should be migrated */
+ if (!qemuMigrateDisk(disk, migrate_disks))
continue;
VIR_FREE(diskAlias);
@@ -2125,7 +2145,7 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm,
}
static bool
-qemuMigrationIsSafe(virDomainDefPtr def)
+qemuMigrationIsSafe(virDomainDefPtr def, const char **migrate_disks)
{
size_t i;
@@ -2135,9 +2155,7 @@ qemuMigrationIsSafe(virDomainDefPtr def)
/* Our code elsewhere guarantees shared disks are either readonly (in
* which case cache mode doesn't matter) or used with cache=none */
- if (src &&
- !disk->src->shared &&
- !disk->src->readonly &&
+ if (qemuMigrateDisk(disk, migrate_disks) &&
disk->cachemode != VIR_DOMAIN_DISK_CACHE_DISABLE) {
int rc;
@@ -2708,7 +2726,8 @@ static char
const char *dname,
char **cookieout,
int *cookieoutlen,
- unsigned long flags)
+ unsigned long flags,
+ const char **migrate_disks)
{
char *rv = NULL;
qemuMigrationCookiePtr mig = NULL;
@@ -2719,9 +2738,10 @@ static char
bool abort_on_error = !!(flags & VIR_MIGRATE_ABORT_ON_ERROR);
VIR_DEBUG("driver=%p, vm=%p, xmlin=%s, dname=%s,"
- " cookieout=%p, cookieoutlen=%p, flags=%lx",
+ " cookieout=%p, cookieoutlen=%p, flags=%lx,"
+ " migrate_disks=%p",
driver, vm, NULLSTR(xmlin), NULLSTR(dname),
- cookieout, cookieoutlen, flags);
+ cookieout, cookieoutlen, flags, migrate_disks);
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
@@ -2736,7 +2756,8 @@ static char
if (!qemuMigrationIsAllowed(driver, vm, NULL, true, abort_on_error))
goto cleanup;
- if (!(flags & VIR_MIGRATE_UNSAFE) && !qemuMigrationIsSafe(vm->def))
+ if (!(flags & VIR_MIGRATE_UNSAFE) &&
+ !qemuMigrationIsSafe(vm->def, migrate_disks))
goto cleanup;
if (flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC)
&&
@@ -2807,7 +2828,8 @@ qemuMigrationBegin(virConnectPtr conn,
const char *dname,
char **cookieout,
int *cookieoutlen,
- unsigned long flags)
+ unsigned long flags,
+ const char **migrate_disks)
{
virQEMUDriverPtr driver = conn->privateData;
char *xml = NULL;
@@ -2840,7 +2862,7 @@ qemuMigrationBegin(virConnectPtr conn,
if (!(xml = qemuMigrationBeginPhase(driver, vm, xmlin, dname,
cookieout, cookieoutlen,
- flags)))
+ flags, migrate_disks)))
goto endjob;
if ((flags & VIR_MIGRATE_CHANGE_PROTECTION)) {
@@ -2908,7 +2930,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
unsigned short port,
bool autoPort,
const char *listenAddress,
- unsigned long flags)
+ unsigned long flags,
+ const char **migrate_disks)
{
virDomainObjPtr vm = NULL;
virObjectEventPtr event = NULL;
@@ -3099,7 +3122,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
goto cleanup;
}
- if (qemuMigrationPrecreateStorage(dconn, driver, vm, mig->nbd) < 0)
+ if (qemuMigrationPrecreateStorage(dconn, driver, vm, mig->nbd,
+ migrate_disks) < 0)
goto cleanup;
if (qemuMigrationJobStart(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
@@ -3173,7 +3197,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
if (mig->nbd &&
flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC)
&&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NBD_SERVER)) {
- if (qemuMigrationStartNBDServer(driver, vm, listenAddress) < 0) {
+ if (qemuMigrationStartNBDServer(driver, vm, listenAddress,
+ migrate_disks) < 0) {
/* error already reported */
goto endjob;
}
@@ -3272,7 +3297,7 @@ qemuMigrationPrepareTunnel(virQEMUDriverPtr driver,
ret = qemuMigrationPrepareAny(driver, dconn, cookiein, cookieinlen,
cookieout, cookieoutlen, def, origname,
- st, NULL, 0, false, NULL, flags);
+ st, NULL, 0, false, NULL, flags, NULL);
return ret;
}
@@ -3312,7 +3337,8 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
virDomainDefPtr *def,
const char *origname,
const char *listenAddress,
- unsigned long flags)
+ unsigned long flags,
+ const char **migrate_disks)
{
unsigned short port = 0;
bool autoPort = true;
@@ -3324,10 +3350,12 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
VIR_DEBUG("driver=%p, dconn=%p, cookiein=%s, cookieinlen=%d, "
"cookieout=%p, cookieoutlen=%p, uri_in=%s, uri_out=%p, "
- "def=%p, origname=%s, listenAddress=%s, flags=%lx",
+ "def=%p, origname=%s, listenAddress=%s, flags=%lx, "
+ "migrate_disks=%p",
driver, dconn, NULLSTR(cookiein), cookieinlen,
cookieout, cookieoutlen, NULLSTR(uri_in), uri_out,
- *def, origname, NULLSTR(listenAddress), flags);
+ *def, origname, NULLSTR(listenAddress), flags,
+ migrate_disks);
*uri_out = NULL;
@@ -3431,7 +3459,8 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
ret = qemuMigrationPrepareAny(driver, dconn, cookiein, cookieinlen,
cookieout, cookieoutlen, def, origname,
NULL, uri ? uri->scheme : "tcp",
- port, autoPort, listenAddress, flags);
+ port, autoPort, listenAddress, flags,
+ migrate_disks);
cleanup:
virURIFree(uri);
VIR_FREE(hostname);
@@ -3903,7 +3932,8 @@ qemuMigrationRun(virQEMUDriverPtr driver,
unsigned long resource,
qemuMigrationSpecPtr spec,
virConnectPtr dconn,
- const char *graphicsuri)
+ const char *graphicsuri,
+ const char **migrate_disks)
{
int ret = -1;
unsigned int migrate_flags = QEMU_MONITOR_MIGRATE_BACKGROUND;
@@ -3919,11 +3949,12 @@ qemuMigrationRun(virQEMUDriverPtr driver,
VIR_DEBUG("driver=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
"cookieout=%p, cookieoutlen=%p, flags=%lx, resource=%lu, "
- "spec=%p (dest=%d, fwd=%d), dconn=%p, graphicsuri=%s",
+ "spec=%p (dest=%d, fwd=%d), dconn=%p, graphicsuri=%s, "
+ "migrate_disks=%p",
driver, vm, NULLSTR(cookiein), cookieinlen,
cookieout, cookieoutlen, flags, resource,
spec, spec->destType, spec->fwdType, dconn,
- NULLSTR(graphicsuri));
+ NULLSTR(graphicsuri), migrate_disks);
if (flags & VIR_MIGRATE_NON_SHARED_DISK) {
migrate_flags |= QEMU_MONITOR_MIGRATE_NON_SHARED_DISK;
@@ -3959,7 +3990,8 @@ qemuMigrationRun(virQEMUDriverPtr driver,
if (qemuMigrationDriveMirror(driver, vm, mig,
spec->dest.host.name,
migrate_speed,
- &migrate_flags) < 0) {
+ &migrate_flags,
+ migrate_disks) < 0) {
goto cleanup;
}
} else {
@@ -4193,7 +4225,8 @@ static int doNativeMigrate(virQEMUDriverPtr driver,
unsigned long flags,
unsigned long resource,
virConnectPtr dconn,
- const char *graphicsuri)
+ const char *graphicsuri,
+ const char **migrate_disks)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virURIPtr uribits = NULL;
@@ -4202,10 +4235,10 @@ static int doNativeMigrate(virQEMUDriverPtr driver,
VIR_DEBUG("driver=%p, vm=%p, uri=%s, cookiein=%s, cookieinlen=%d, "
"cookieout=%p, cookieoutlen=%p, flags=%lx, resource=%lu, "
- "graphicsuri=%s",
+ "graphicsuri=%s, migrate_disks=%p",
driver, vm, uri, NULLSTR(cookiein), cookieinlen,
cookieout, cookieoutlen, flags, resource,
- NULLSTR(graphicsuri));
+ NULLSTR(graphicsuri), migrate_disks);
if (!(uribits = qemuMigrationParseURI(uri, NULL)))
return -1;
@@ -4244,7 +4277,7 @@ static int doNativeMigrate(virQEMUDriverPtr driver,
ret = qemuMigrationRun(driver, vm, cookiein, cookieinlen, cookieout,
cookieoutlen, flags, resource, &spec, dconn,
- graphicsuri);
+ graphicsuri, migrate_disks);
if (spec.destType == MIGRATION_DEST_FD)
VIR_FORCE_CLOSE(spec.dest.fd.qemu);
@@ -4266,7 +4299,8 @@ static int doTunnelMigrate(virQEMUDriverPtr driver,
unsigned long flags,
unsigned long resource,
virConnectPtr dconn,
- const char *graphicsuri)
+ const char *graphicsuri,
+ const char **migrate_disks)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virNetSocketPtr sock = NULL;
@@ -4276,10 +4310,10 @@ static int doTunnelMigrate(virQEMUDriverPtr driver,
VIR_DEBUG("driver=%p, vm=%p, st=%p, cookiein=%s, cookieinlen=%d, "
"cookieout=%p, cookieoutlen=%p, flags=%lx, resource=%lu, "
- "graphicsuri=%s",
+ "graphicsuri=%s, migrate_disks=%p",
driver, vm, st, NULLSTR(cookiein), cookieinlen,
cookieout, cookieoutlen, flags, resource,
- NULLSTR(graphicsuri));
+ NULLSTR(graphicsuri), migrate_disks);
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_UNIX) &&
@@ -4332,7 +4366,7 @@ static int doTunnelMigrate(virQEMUDriverPtr driver,
ret = qemuMigrationRun(driver, vm, cookiein, cookieinlen, cookieout,
cookieoutlen, flags, resource, &spec, dconn,
- graphicsuri);
+ graphicsuri, migrate_disks);
cleanup:
if (spec.destType == MIGRATION_DEST_FD) {
@@ -4442,12 +4476,12 @@ static int doPeer2PeerMigrate2(virQEMUDriverPtr driver,
if (flags & VIR_MIGRATE_TUNNELLED)
ret = doTunnelMigrate(driver, vm, st,
NULL, 0, NULL, NULL,
- flags, resource, dconn, NULL);
+ flags, resource, dconn, NULL, NULL);
else
ret = doNativeMigrate(driver, vm, uri_out,
cookie, cookielen,
NULL, NULL, /* No out cookie with v2 migration */
- flags, resource, dconn, NULL);
+ flags, resource, dconn, NULL, NULL);
/* Perform failed. Make sure Finish doesn't overwrite the error */
if (ret < 0)
@@ -4509,6 +4543,7 @@ doPeer2PeerMigrate3(virQEMUDriverPtr driver,
const char *uri,
const char *graphicsuri,
const char *listenAddress,
+ const char **migrate_disks,
unsigned long long bandwidth,
bool useParams,
unsigned long flags)
@@ -4531,10 +4566,11 @@ doPeer2PeerMigrate3(virQEMUDriverPtr driver,
VIR_DEBUG("driver=%p, sconn=%p, dconn=%p, dconnuri=%s, vm=%p, xmlin=%s, "
"dname=%s, uri=%s, graphicsuri=%s, listenAddress=%s, "
- "bandwidth=%llu, useParams=%d, flags=%lx",
+ "migrate_disks=%p, bandwidth=%llu, useParams=%d, flags=%lx",
driver, sconn, dconn, NULLSTR(dconnuri), vm, NULLSTR(xmlin),
NULLSTR(dname), NULLSTR(uri), NULLSTR(graphicsuri),
- NULLSTR(listenAddress), bandwidth, useParams, flags);
+ NULLSTR(listenAddress), migrate_disks, bandwidth, useParams,
+ flags);
/* Unlike the virDomainMigrateVersion3 counterpart, we don't need
* to worry about auto-setting the VIR_MIGRATE_CHANGE_PROTECTION
@@ -4542,7 +4578,8 @@ doPeer2PeerMigrate3(virQEMUDriverPtr driver,
* a single job. */
dom_xml = qemuMigrationBeginPhase(driver, vm, xmlin, dname,
- &cookieout, &cookieoutlen, flags);
+ &cookieout, &cookieoutlen, flags,
+ migrate_disks);
if (!dom_xml)
goto cleanup;
@@ -4577,6 +4614,11 @@ doPeer2PeerMigrate3(virQEMUDriverPtr driver,
VIR_MIGRATE_PARAM_LISTEN_ADDRESS,
listenAddress) < 0)
goto cleanup;
+ if (migrate_disks &&
+ virTypedParamsAddStringList(¶ms, &nparams, &maxparams,
+ VIR_MIGRATE_PARAM_MIGRATE_DISKS,
+ migrate_disks) < 0)
+ goto cleanup;
}
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED)
@@ -4661,12 +4703,14 @@ doPeer2PeerMigrate3(virQEMUDriverPtr driver,
ret = doTunnelMigrate(driver, vm, st,
cookiein, cookieinlen,
&cookieout, &cookieoutlen,
- flags, bandwidth, dconn, graphicsuri);
+ flags, bandwidth, dconn, graphicsuri,
+ migrate_disks);
} else {
ret = doNativeMigrate(driver, vm, uri,
cookiein, cookieinlen,
&cookieout, &cookieoutlen,
- flags, bandwidth, dconn, graphicsuri);
+ flags, bandwidth, dconn, graphicsuri,
+ migrate_disks);
}
/* Perform failed. Make sure Finish doesn't overwrite the error */
@@ -4800,6 +4844,7 @@ static int doPeer2PeerMigrate(virQEMUDriverPtr driver,
const char *uri,
const char *graphicsuri,
const char *listenAddress,
+ const char **migrate_disks,
unsigned long flags,
const char *dname,
unsigned long resource,
@@ -4813,12 +4858,12 @@ static int doPeer2PeerMigrate(virQEMUDriverPtr driver,
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
bool useParams;
- VIR_DEBUG("driver=%p, sconn=%p, vm=%p, xmlin=%s, dconnuri=%s, "
- "uri=%s, graphicsuri=%s, listenAddress=%s, flags=%lx, "
- "dname=%s, resource=%lu",
+ VIR_DEBUG("driver=%p, sconn=%p, vm=%p, xmlin=%s, dconnuri=%s, uri=%s, "
+ "graphicsuri=%s, listenAddress=%s, migrate_disks=%p, "
+ "flags=%lx, dname=%s, resource=%lu",
driver, sconn, vm, NULLSTR(xmlin), NULLSTR(dconnuri),
NULLSTR(uri), NULLSTR(graphicsuri), NULLSTR(listenAddress),
- flags, NULLSTR(dname), resource);
+ migrate_disks, flags, NULLSTR(dname), resource);
if (flags & VIR_MIGRATE_TUNNELLED && uri) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
@@ -4877,7 +4922,7 @@ static int doPeer2PeerMigrate(virQEMUDriverPtr driver,
/* Only xmlin, dname, uri, and bandwidth parameters can be used with
* old-style APIs. */
- if (!useParams && (graphicsuri || listenAddress)) {
+ if (!useParams && (graphicsuri || listenAddress || migrate_disks)) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Migration APIs with extensible parameters are not "
"supported but extended parameters were passed"));
@@ -4908,7 +4953,7 @@ static int doPeer2PeerMigrate(virQEMUDriverPtr driver,
if (*v3proto) {
ret = doPeer2PeerMigrate3(driver, sconn, dconn, dconnuri, vm, xmlin,
dname, uri, graphicsuri, listenAddress,
- resource, useParams, flags);
+ migrate_disks, resource, useParams, flags);
} else {
ret = doPeer2PeerMigrate2(driver, sconn, dconn, vm,
dconnuri, flags, dname, resource);
@@ -4942,6 +4987,7 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
const char *uri,
const char *graphicsuri,
const char *listenAddress,
+ const char **migrate_disks,
const char *cookiein,
int cookieinlen,
char **cookieout,
@@ -4969,7 +5015,8 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
if (!qemuMigrationIsAllowed(driver, vm, NULL, true, abort_on_error))
goto endjob;
- if (!(flags & VIR_MIGRATE_UNSAFE) && !qemuMigrationIsSafe(vm->def))
+ if (!(flags & VIR_MIGRATE_UNSAFE) &&
+ !qemuMigrationIsSafe(vm->def, migrate_disks))
goto endjob;
qemuMigrationStoreDomainState(vm);
@@ -4977,12 +5024,13 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
if ((flags & (VIR_MIGRATE_TUNNELLED | VIR_MIGRATE_PEER2PEER))) {
ret = doPeer2PeerMigrate(driver, conn, vm, xmlin,
dconnuri, uri, graphicsuri, listenAddress,
+ migrate_disks,
flags, dname, resource, &v3proto);
} else {
qemuMigrationJobSetPhase(driver, vm, QEMU_MIGRATION_PHASE_PERFORM2);
ret = doNativeMigrate(driver, vm, uri, cookiein, cookieinlen,
cookieout, cookieoutlen,
- flags, resource, NULL, NULL);
+ flags, resource, NULL, NULL, NULL);
}
if (ret < 0)
goto endjob;
@@ -5041,6 +5089,7 @@ qemuMigrationPerformPhase(virQEMUDriverPtr driver,
virDomainObjPtr vm,
const char *uri,
const char *graphicsuri,
+ const char **migrate_disks,
const char *cookiein,
int cookieinlen,
char **cookieout,
@@ -5065,7 +5114,7 @@ qemuMigrationPerformPhase(virQEMUDriverPtr driver,
ret = doNativeMigrate(driver, vm, uri, cookiein, cookieinlen,
cookieout, cookieoutlen,
- flags, resource, NULL, graphicsuri);
+ flags, resource, NULL, graphicsuri, migrate_disks);
if (ret < 0) {
if (qemuMigrationRestoreDomainState(conn, vm)) {
@@ -5106,6 +5155,7 @@ qemuMigrationPerform(virQEMUDriverPtr driver,
const char *uri,
const char *graphicsuri,
const char *listenAddress,
+ const char **migrate_disks,
const char *cookiein,
int cookieinlen,
char **cookieout,
@@ -5116,13 +5166,13 @@ qemuMigrationPerform(virQEMUDriverPtr driver,
bool v3proto)
{
VIR_DEBUG("driver=%p, conn=%p, vm=%p, xmlin=%s, dconnuri=%s, "
- "uri=%s, graphicsuri=%s, listenAddress=%s"
+ "uri=%s, graphicsuri=%s, listenAddress=%s, migrate_disks=%p, "
"cookiein=%s, cookieinlen=%d, cookieout=%p, cookieoutlen=%p, "
"flags=%lx, dname=%s, resource=%lu, v3proto=%d",
driver, conn, vm, NULLSTR(xmlin), NULLSTR(dconnuri),
NULLSTR(uri), NULLSTR(graphicsuri), NULLSTR(listenAddress),
- NULLSTR(cookiein), cookieinlen, cookieout, cookieoutlen,
- flags, NULLSTR(dname), resource, v3proto);
+ migrate_disks, NULLSTR(cookiein), cookieinlen, cookieout,
+ cookieoutlen, flags, NULLSTR(dname), resource, v3proto);
if ((flags & (VIR_MIGRATE_TUNNELLED | VIR_MIGRATE_PEER2PEER))) {
if (cookieinlen) {
@@ -5133,6 +5183,7 @@ qemuMigrationPerform(virQEMUDriverPtr driver,
return qemuMigrationPerformJob(driver, conn, vm, xmlin, dconnuri, uri,
graphicsuri, listenAddress,
+ migrate_disks,
cookiein, cookieinlen,
cookieout, cookieoutlen,
flags, dname, resource, v3proto);
@@ -5145,13 +5196,14 @@ qemuMigrationPerform(virQEMUDriverPtr driver,
if (v3proto) {
return qemuMigrationPerformPhase(driver, conn, vm, uri,
- graphicsuri,
+ graphicsuri, migrate_disks,
cookiein, cookieinlen,
cookieout, cookieoutlen,
flags, resource);
} else {
return qemuMigrationPerformJob(driver, conn, vm, xmlin, dconnuri,
uri, graphicsuri, listenAddress,
+ migrate_disks,
cookiein, cookieinlen,
cookieout, cookieoutlen, flags,
dname, resource, v3proto);
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index 1726455..42d64e9 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -44,13 +44,15 @@
VIR_MIGRATE_RDMA_PIN_ALL)
/* All supported migration parameters and their types. */
-# define QEMU_MIGRATION_PARAMETERS \
- VIR_MIGRATE_PARAM_URI, VIR_TYPED_PARAM_STRING, \
- VIR_MIGRATE_PARAM_DEST_NAME, VIR_TYPED_PARAM_STRING, \
- VIR_MIGRATE_PARAM_DEST_XML, VIR_TYPED_PARAM_STRING, \
- VIR_MIGRATE_PARAM_BANDWIDTH, VIR_TYPED_PARAM_ULLONG, \
- VIR_MIGRATE_PARAM_GRAPHICS_URI, VIR_TYPED_PARAM_STRING, \
- VIR_MIGRATE_PARAM_LISTEN_ADDRESS, VIR_TYPED_PARAM_STRING, \
+# define QEMU_MIGRATION_PARAMETERS \
+ VIR_MIGRATE_PARAM_URI, VIR_TYPED_PARAM_STRING, \
+ VIR_MIGRATE_PARAM_DEST_NAME, VIR_TYPED_PARAM_STRING, \
+ VIR_MIGRATE_PARAM_DEST_XML, VIR_TYPED_PARAM_STRING, \
+ VIR_MIGRATE_PARAM_BANDWIDTH, VIR_TYPED_PARAM_ULLONG, \
+ VIR_MIGRATE_PARAM_GRAPHICS_URI, VIR_TYPED_PARAM_STRING, \
+ VIR_MIGRATE_PARAM_LISTEN_ADDRESS, VIR_TYPED_PARAM_STRING, \
+ VIR_MIGRATE_PARAM_MIGRATE_DISKS, VIR_TYPED_PARAM_STRING | \
+ VIR_TYPED_PARAM_MULTIPLE, \
NULL
@@ -99,7 +101,8 @@ char *qemuMigrationBegin(virConnectPtr conn,
const char *dname,
char **cookieout,
int *cookieoutlen,
- unsigned long flags);
+ unsigned long flags,
+ const char **migrate_disks);
virDomainDefPtr qemuMigrationPrepareDef(virQEMUDriverPtr driver,
const char *dom_xml,
@@ -128,7 +131,8 @@ int qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
virDomainDefPtr *def,
const char *origname,
const char *listenAddress,
- unsigned long flags);
+ unsigned long flags,
+ const char **migrate_disks);
int qemuMigrationPerform(virQEMUDriverPtr driver,
virConnectPtr conn,
@@ -138,6 +142,7 @@ int qemuMigrationPerform(virQEMUDriverPtr driver,
const char *uri,
const char *graphicsuri,
const char *listenAddress,
+ const char **migrate_disks,
const char *cookiein,
int cookieinlen,
char **cookieout,
--
1.9.1