[PATCH v2 08/15] virsh: Add support for post-copy migration

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

 



From: Cristian Klein <cristiklein@xxxxxxxxx>

Signed-off-by: Cristian Klein <cristiklein@xxxxxxxxx>
Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---

Notes:
    Version 2:
    - no change

 tools/virsh-domain.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/virsh.pod      | 11 ++++++++++-
 2 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index f3f4b8b..bcb6809 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9623,6 +9623,10 @@ static const vshCmdOptDef opts_migrate[] = {
      .type = VSH_OT_BOOL,
      .help = N_("abort on soft errors during migration")
     },
+    {.name = "postcopy",
+     .type = VSH_OT_BOOL,
+     .help = N_("enable post-copy migration; switch to it using migrate-postcopy command")
+    },
     {.name = "migrateuri",
      .type = VSH_OT_STRING,
      .help = N_("migration URI, usually can be omitted")
@@ -9789,6 +9793,9 @@ doMigrate(void *opaque)
     if (vshCommandOptBool(cmd, "abort-on-error"))
         flags |= VIR_MIGRATE_ABORT_ON_ERROR;
 
+    if (vshCommandOptBool(cmd, "postcopy"))
+        flags |= VIR_MIGRATE_POSTCOPY;
+
     if (flags & VIR_MIGRATE_PEER2PEER || vshCommandOptBool(cmd, "direct")) {
         if (virDomainMigrateToURI3(dom, desturi, params, nparams, flags) == 0)
             ret = '0';
@@ -10092,6 +10099,48 @@ cmdMigrateGetMaxSpeed(vshControl *ctl, const vshCmd *cmd)
 }
 
 /*
+ * "migrate-postcopy" command
+ */
+static const vshCmdInfo info_migrate_postcopy[] = {
+    {.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. "
+                "The migration must have been started with --postcopy option.")
+    },
+    {.name = NULL}
+};
+
+static const vshCmdOptDef opts_migrate_postcopy[] = {
+    {.name = "domain",
+     .type = VSH_OT_DATA,
+     .flags = VSH_OFLAG_REQ,
+     .help = N_("domain name, id or uuid")
+    },
+    {.name = NULL}
+};
+
+static bool
+cmdMigratePostCopy(vshControl *ctl, const vshCmd *cmd)
+{
+    virDomainPtr dom;
+    bool ret = false;
+
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+        return false;
+
+    if (virDomainMigrateStartPostCopy(dom, 0) < 0)
+        goto cleanup;
+
+    ret = true;
+
+ cleanup:
+    virDomainFree(dom);
+    return ret;
+}
+
+/*
  * "domdisplay" command
  */
 static const vshCmdInfo info_domdisplay[] = {
@@ -12902,6 +12951,12 @@ const vshCmdDef domManagementCmds[] = {
      .info = info_migrate_getspeed,
      .flags = 0
     },
+    {.name = "migrate-postcopy",
+     .handler = cmdMigratePostCopy,
+     .opts = opts_migrate_postcopy,
+     .info = info_migrate_postcopy,
+     .flags = 0
+    },
     {.name = "numatune",
      .handler = cmdNumatune,
      .opts = opts_numatune,
diff --git a/tools/virsh.pod b/tools/virsh.pod
index e830c59..109c608 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1529,7 +1529,7 @@ to the I<uri> namespace is displayed instead of being modified.
 =item B<migrate> [I<--live>] [I<--offline>] [I<--direct>] [I<--p2p> [I<--tunnelled>]]
 [I<--persistent>] [I<--undefinesource>] [I<--suspend>] [I<--copy-storage-all>]
 [I<--copy-storage-inc>] [I<--change-protection>] [I<--unsafe>] [I<--verbose>]
-[I<--compressed>] [I<--abort-on-error>] [I<--auto-converge>]
+[I<--compressed>] [I<--abort-on-error>] [I<--auto-converge>] [I<--postcopy>]
 I<domain> I<desturi> [I<migrateuri>] [I<graphicsuri>] [I<listen-address>]
 [I<dname>] [I<--timeout> B<seconds>] [I<--xml> B<file>]
 [I<--migrate-disks> B<disk-list>]
@@ -1559,6 +1559,10 @@ of migration.  I<--compressed> activates compression of memory pages that have
 to be transferred repeatedly during live migration. I<--abort-on-error> cancels
 the migration if a soft error (for example I/O error) happens during the
 migration. I<--auto-converge> forces convergence during live migration.
+I<--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 is running, the user may switch to post-copy using the
+B<migrate-postcopy> command sent from another virsh instance.
 
 B<Note>: Individual hypervisors usually do not support all possible types of
 migration. For example, QEMU does not support direct migration.
@@ -1689,6 +1693,11 @@ reject the value or convert it to the maximum value allowed.
 
 Get the maximum migration bandwidth (in MiB/s) for a domain.
 
+=item B<migrate-postcopy> I<domain>
+
+Switch the current migration from pre-copy to post-copy. This is only
+supported for a migration started with I<--postcopy> option.
+
 =item B<numatune> I<domain> [I<--mode> B<mode>] [I<--nodeset> B<nodeset>]
 [[I<--config>] [I<--live>] | [I<--current>]]
 
-- 
2.7.0

--
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]