[PATCH 2/4] Allow virsh to pass in a custom XML document for migration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Switch virsh migrate over to use virDomainMigrate2 and
virDomainMigrateToURI2. This is still compatible with
older libvirts, because these methods dynamically choose
whether to perform v1, v2 or v3 migration based on declared
RPC support from the libvirtd instances

Add a --xml arg which allows the user to pass in a custom
XML document. This XML document must be ABI compatible
with the current *live* XML document for the running guest
on the source host. ABI compatibility will be enforced by
any driver supporting this function

* tools/virsh.c: Add '--xml' arg to migrate command
---
 tools/virsh.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index b43c167..fd32309 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -3786,6 +3786,7 @@ static const vshCmdOptDef opts_migrate[] = {
     {"migrateuri", VSH_OT_DATA, 0, N_("migration URI, usually can be omitted")},
     {"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")},
     {NULL, 0, 0, NULL}
 };
 
@@ -3809,6 +3810,8 @@ doMigrate (void *opaque)
     const vshCmd *cmd = data->cmd;
 #if HAVE_PTHREAD_SIGMASK
     sigset_t sigmask, oldsigmask;
+    const char *xmlfile = NULL;
+    char *xml = NULL;
 
     sigemptyset(&sigmask);
     sigaddset(&sigmask, SIGINT);
@@ -3829,6 +3832,11 @@ doMigrate (void *opaque)
         goto out;
     }
 
+    if (vshCommandOptString(cmd, "xml", &xmlfile) < 0) {
+        vshError(ctl, "%s", _("malformed xml argument"));
+        goto out;
+    }
+
     if (vshCommandOptBool (cmd, "live"))
         flags |= VIR_MIGRATE_LIVE;
     if (vshCommandOptBool (cmd, "p2p"))
@@ -3850,6 +3858,12 @@ doMigrate (void *opaque)
     if (vshCommandOptBool (cmd, "copy-storage-inc"))
         flags |= VIR_MIGRATE_NON_SHARED_INC;
 
+
+    if (xmlfile &&
+        virFileReadAll(xmlfile, 8192, &xml) < 0)
+        goto out;
+
+
     if ((flags & VIR_MIGRATE_PEER2PEER) ||
         vshCommandOptBool (cmd, "direct")) {
         /* For peer2peer migration or direct migration we only expect one URI
@@ -3860,7 +3874,7 @@ doMigrate (void *opaque)
             goto out;
         }
 
-        if (virDomainMigrateToURI (dom, desturi, flags, dname, 0) == 0)
+        if (virDomainMigrateToURI2(dom, desturi, NULL, xml, flags, dname, 0) == 0)
             ret = '0';
     } else {
         /* For traditional live migration, connect to the destination host directly. */
@@ -3870,7 +3884,7 @@ doMigrate (void *opaque)
         dconn = virConnectOpenAuth (desturi, virConnectAuthPtrDefault, 0);
         if (!dconn) goto out;
 
-        ddom = virDomainMigrate (dom, dconn, flags, dname, migrateuri, 0);
+        ddom = virDomainMigrate2(dom, dconn, xml, flags, dname, migrateuri, 0);
         if (ddom) {
             virDomainFree(ddom);
             ret = '0';
@@ -3884,6 +3898,7 @@ out:
 out_sig:
 #endif
     if (dom) virDomainFree (dom);
+    VIR_FREE(xml);
     ignore_value(safewrite(data->writefd, &ret, sizeof(ret)));
 }
 
-- 
1.7.4.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]