[libvirt] [PATCH 06/11] virsh: added --enable-postcopy and migrate-start-postcopy

Cristian Klein cristiklein at gmail.com
Mon Dec 1 15:59:58 UTC 2014


Signed-off-by: Cristian Klein <cristiklein at gmail.com>
---
 tools/virsh-domain.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/virsh.pod      | 11 +++++++++++
 2 files changed, 61 insertions(+)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 750411b..1753f6e 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9435,6 +9435,10 @@ static const vshCmdOptDef opts_migrate[] = {
      .type = VSH_OT_INT,
      .help = N_("force guest to suspend if live migration exceeds timeout (in seconds)")
     },
+    {.name = "enable-postcopy",
+     .type = VSH_OT_BOOL,
+     .help = N_("enable (but do not start) post-copy migration; to start post-copy use migrate-start-postcopy")
+    },
     {.name = "xml",
      .type = VSH_OT_STRING,
      .help = N_("filename containing updated XML for the target")
@@ -9516,6 +9520,8 @@ doMigrate(void *opaque)
         VIR_FREE(xml);
     }
 
+    if (vshCommandOptBool(cmd, "enable-postcopy"))
+        flags |= VIR_MIGRATE_ENABLE_POSTCOPY;
     if (vshCommandOptBool(cmd, "live"))
         flags |= VIR_MIGRATE_LIVE;
     if (vshCommandOptBool(cmd, "p2p"))
@@ -12289,6 +12295,44 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
     return ret >= 0;
 }
 
+/*
+ * "migrate-start-postcopy" command
+ */
+static const vshCmdInfo info_migratestartpostcopy[] = {
+    {.name = "help",
+     .data = N_("Switch running migration from pre-copy to post-copy")
+    },
+    {.name = "desc",
+     .data = N_("Switch running migration from pre-copy to post-copy")
+    },
+    {.name = NULL}
+};
+
+static const vshCmdOptDef opts_migratestartpostcopy[] = {
+    {.name = "domain",
+     .type = VSH_OT_DATA,
+     .flags = VSH_OFLAG_REQ,
+     .help = N_("domain name, id or uuid")
+    },
+    {.name = NULL}
+};
+
+static bool
+cmdMigrateStartPostCopy(vshControl *ctl, const vshCmd *cmd)
+{
+    virDomainPtr dom;
+    bool ret = true;
+
+    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+        return false;
+
+    if (virDomainMigrateStartPostCopy(dom, 0) < 0)
+        ret = false;
+
+    virDomainFree(dom);
+    return ret;
+}
+
 const vshCmdDef domManagementCmds[] = {
     {.name = "attach-device",
      .handler = cmdAttachDevice,
@@ -12808,5 +12852,11 @@ const vshCmdDef domManagementCmds[] = {
      .info = info_vncdisplay,
      .flags = 0
     },
+    {.name = "migrate-start-postcopy",
+     .handler = cmdMigrateStartPostCopy,
+     .opts = opts_migratestartpostcopy,
+     .info = info_migratestartpostcopy,
+     .flags = 0
+    },
     {.name = NULL}
 };
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 7cde3fd..18c6a23 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1428,6 +1428,7 @@ to the I<uri> namespace is displayed instead of being modified.
 [I<--compressed>] [I<--abort-on-error>] [I<--auto-converge>]
 I<domain> I<desturi> [I<migrateuri>] [I<graphicsuri>] [I<listen-address>]
 [I<dname>] [I<--timeout> B<seconds>] [I<--xml> B<file>]
+[I<--enable-postcopy>]
 
 Migrate domain to another host.  Add I<--live> for live migration; <--p2p>
 for peer-2-peer migration; I<--direct> for direct migration; or I<--tunnelled>
@@ -1475,6 +1476,11 @@ I<--timeout> B<seconds> forces guest to suspend when live migration exceeds
 that many seconds, and
 then the migration will complete offline. It can only be used with I<--live>.
 
+I<--enable-postcopy> enables post-copy logic in migration, but does not
+actually start post-copy, i.e., migration is started in pre-copy mode.
+Once migration started, the user may switch to post-copy using the
+B<migrate-start-postcopy> command sent from another virsh instance.
+
 Running migration can be canceled by interrupting virsh (usually using
 C<Ctrl-C>) or by B<domjobabort> command sent from another virsh instance.
 
@@ -1552,6 +1558,11 @@ addresses are accepted as well as hostnames (the resolving is done on
 destination). Some hypervisors do not support this feature and will return an
 error if this parameter is used.
 
+=item B<migrate-start-postcopy> I<domain>
+
+Switch the current migration from pre-copy to post-copy. A migration needs
+to be in progress, that has been started with I<--enable-postcopy>.
+
 =item B<migrate-setmaxdowntime> I<domain> I<downtime>
 
 Set maximum tolerable downtime for a domain which is being live-migrated to
-- 
1.9.1




More information about the libvir-list mailing list