On 15.04.2016 21:12, Jiri Denemark wrote:
On Thu, Mar 17, 2016 at 19:31:45 +0300, Dmitry Andreev wrote:
Migration API allows to specify a destination domain configuration.
Offline domain has only inactive XML and it is replaced by configuration
specified using VIR_MIGRATE_PARAM_DEST_XML param. In case of live
migration VIR_MIGRATE_PARAM_DEST_XML param is applied for active XML.
This commit introduces the new VIR_MIGRATE_PARAM_PERSIST_XML param
that can be used within live migration to replace persistent/inactive
configuration.
Required for: https://bugzilla.redhat.com/show_bug.cgi?id=835300
---
include/libvirt/libvirt-domain.h | 15 +++++++++++++
src/qemu/qemu_driver.c | 12 ++++++----
src/qemu/qemu_migration.c | 47 ++++++++++++++++++++++++++--------------
src/qemu/qemu_migration.h | 2 ++
4 files changed, 56 insertions(+), 20 deletions(-)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 4ac29cd..f9dae22 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -723,6 +723,21 @@ typedef enum {
# define VIR_MIGRATE_PARAM_DEST_XML "destination_xml"
/**
+ * VIR_MIGRATE_PARAM_PERSIST_XML:
+ *
+ * virDomainMigrate* params field: the new persistant configuration to be used
s/persistant/persistent/
+ * for the domain on the destination host as VIR_TYPED_PARAM_STRING.
+ * This field cannot be used to rename the domain during migration (use
+ * VIR_MIGRATE_PARAM_DEST_NAME field for that purpose). Domain name in the
+ * destination XML must match the original domain name.
+ *
+ * Omitting this parameter keeps the original domain persistent configuration.
+ * Using this field with hypervisors that do not support changing domain
+ * configuration during migration will result in a failure.
+ */
+# define VIR_MIGRATE_PARAM_PERSIST_XML "persistent_xml"
+
+/**
* VIR_MIGRATE_PARAM_BANDWIDTH:
*
* virDomainMigrate* params field: the maximum bandwidth (in MiB/s) that will
...
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index f723a52..5624633 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
...
@@ -4566,14 +4568,20 @@ qemuMigrationRun(virQEMUDriverPtr driver,
cookieFlags |= QEMU_MIGRATION_COOKIE_NETWORK |
QEMU_MIGRATION_COOKIE_STATS;
+ if (flags & VIR_MIGRATE_PERSIST_DEST && persist_xml &&
+ !(def = qemuMigrationPrepareDef(driver, persist_xml, NULL, NULL)))
+ ret = -1;
+
I think this should be done before we start migration.
if (ret == 0 &&
(((flags & VIR_MIGRATE_PERSIST_DEST &&
- qemuMigrationCookieAddPersistent(mig, vm->newDef) < 0)) ||
+ qemuMigrationCookieAddPersistent(mig,
+ def ? def : vm->newDef) < 0)) ||
And we can use a single variable for both vm->newDef and def depending
on persist_xml.
qemuMigrationBakeCookie(mig, driver, vm, cookieout,
cookieoutlen, cookieFlags) < 0)) {
VIR_WARN("Unable to encode migration cookie");
}
+ virDomainDefFree(def);
qemuMigrationCookieFree(mig);
if (events)
...
@@ -4683,6 +4692,7 @@ static int doNativeMigrate(virQEMUDriverPtr driver,
static int doTunnelMigrate(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virStreamPtr st,
+ const char *xml_persist,
s/xml_persist/persist_xml/ to keep the name consistent accros the file.
const char *cookiein,
int cookieinlen,
char **cookieout,
...
To avoid sending another version of this patch for review, which already
took too long (this is my fault, sorry for that), I suggest squashing
the following patch in and pushing the result.
I'm OK with the following patch. Thanks!
Jirka
diff --git i/include/libvirt/libvirt-domain.h w/include/libvirt/libvirt-domain.h
index 697670f..9936cb2 100644
--- i/include/libvirt/libvirt-domain.h
+++ w/include/libvirt/libvirt-domain.h
@@ -729,7 +729,7 @@ typedef enum {
/**
* VIR_MIGRATE_PARAM_PERSIST_XML:
*
- * virDomainMigrate* params field: the new persistant configuration to be used
+ * virDomainMigrate* params field: the new persistent configuration to be used
* for the domain on the destination host as VIR_TYPED_PARAM_STRING.
* This field cannot be used to rename the domain during migration (use
* VIR_MIGRATE_PARAM_DEST_NAME field for that purpose). Domain name in the
diff --git i/src/qemu/qemu_migration.c w/src/qemu/qemu_migration.c
index eee8ec2..680c9ba 100644
--- i/src/qemu/qemu_migration.c
+++ w/src/qemu/qemu_migration.c
@@ -4504,7 +4504,6 @@ qemuMigrationRun(virQEMUDriverPtr driver,
{
int ret = -1;
unsigned int migrate_flags = QEMU_MONITOR_MIGRATE_BACKGROUND;
- virDomainDefPtr def = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
qemuMigrationCookiePtr mig = NULL;
qemuMigrationIOThreadPtr iothread = NULL;
@@ -4516,6 +4515,7 @@ qemuMigrationRun(virQEMUDriverPtr driver,
bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
bool inPostCopy = false;
unsigned int waitFlags;
+ virDomainDefPtr persistDef = NULL;
int rc;
VIR_DEBUG("driver=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
@@ -4549,6 +4549,17 @@ qemuMigrationRun(virQEMUDriverPtr driver,
if (events)
priv->signalIOError = abort_on_error;
+ if (flags & VIR_MIGRATE_PERSIST_DEST) {
+ if (persist_xml) {
+ persistDef = qemuMigrationPrepareDef(driver, persist_xml,
+ NULL, NULL);
+ if (!persistDef)
+ goto cleanup;
+ } else {
+ persistDef = vm->newDef;
+ }
+ }
+
mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen,
cookieFlags | QEMU_MIGRATION_COOKIE_GRAPHICS);
if (!mig)
@@ -4769,20 +4780,15 @@ qemuMigrationRun(virQEMUDriverPtr driver,
cookieFlags |= QEMU_MIGRATION_COOKIE_NETWORK |
QEMU_MIGRATION_COOKIE_STATS;
- if (flags & VIR_MIGRATE_PERSIST_DEST && persist_xml &&
- !(def = qemuMigrationPrepareDef(driver, persist_xml, NULL, NULL)))
- ret = -1;
-
if (ret == 0 &&
- (((flags & VIR_MIGRATE_PERSIST_DEST &&
- qemuMigrationCookieAddPersistent(mig,
- def ? def : vm->newDef) < 0)) ||
- qemuMigrationBakeCookie(mig, driver, vm, cookieout,
- cookieoutlen, cookieFlags) < 0)) {
+ (qemuMigrationCookieAddPersistent(mig, persistDef) < 0 ||
+ qemuMigrationBakeCookie(mig, driver, vm, cookieout,
+ cookieoutlen, cookieFlags) < 0)) {
VIR_WARN("Unable to encode migration cookie");
}
- virDomainDefFree(def);
+ if (persistDef != vm->newDef)
+ virDomainDefFree(persistDef);
qemuMigrationCookieFree(mig);
if (events)
@@ -4902,7 +4908,7 @@ static int doNativeMigrate(virQEMUDriverPtr driver,
static int doTunnelMigrate(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virStreamPtr st,
- const char *xml_persist,
+ const char *persist_xml,
const char *cookiein,
int cookieinlen,
char **cookieout,
@@ -4948,9 +4954,9 @@ static int doTunnelMigrate(virQEMUDriverPtr driver,
goto cleanup;
}
- ret = qemuMigrationRun(driver, vm, xml_persist, cookiein, cookieinlen, cookieout,
- cookieoutlen, flags, resource, &spec, dconn,
- graphicsuri, nmigrate_disks, migrate_disks,
+ ret = qemuMigrationRun(driver, vm, persist_xml, cookiein, cookieinlen,
+ cookieout, cookieoutlen, flags, resource, &spec,
+ dconn, graphicsuri, nmigrate_disks, migrate_disks,
compression);
cleanup:
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list