[libvirt] [PATCH] Various monitor cleanups related to migration.

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

 



The upcoming tunnelled migration needs to be able to set
a migration in progress in the background, as well as
be able to cancel a migration when a problem has happened.
This patch allows for both of these to properly work.

Signed-off-by: Chris Lalancette <clalance@xxxxxxxxxx>
---
 src/qemu/qemu_monitor_text.c |   26 ++++++++++++++++++++------
 src/qemu/qemu_monitor_text.h |    7 +++++++
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index f57460c..c72f919 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -123,7 +123,7 @@ static char *qemuMonitorEscape(const char *in, int shell)
     return out;
 }
 
-static char *qemuMonitorEscapeArg(const char *in)
+char *qemuMonitorEscapeArg(const char *in)
 {
     return qemuMonitorEscape(in, 0);
 }
@@ -1137,20 +1137,27 @@ cleanup:
 }
 
 
-static int qemuMonitorMigrate(const virDomainObjPtr vm,
-                              const char *dest)
+int qemuMonitorMigrate(const virDomainObjPtr vm,
+                       int background,
+                       const char *dest)
 {
     char *cmd = NULL;
     char *info = NULL;
     int ret = -1;
     char *safedest = qemuMonitorEscapeArg(dest);
+    const char *extra;
 
     if (!safedest) {
         virReportOOMError(NULL);
         return -1;
     }
 
-    if (virAsprintf(&cmd, "migrate \"%s\"", safedest) < 0) {
+    if (background)
+        extra = "-d ";
+    else
+        extra = " ";
+
+    if (virAsprintf(&cmd, "migrate %s\"%s\"", extra, safedest) < 0) {
         virReportOOMError(NULL);
         goto cleanup;
     }
@@ -1200,7 +1207,7 @@ int qemuMonitorMigrateToHost(const virDomainObjPtr vm,
         return -1;
     }
 
-    ret = qemuMonitorMigrate(vm, uri);
+    ret = qemuMonitorMigrate(vm, 0, uri);
 
     VIR_FREE(uri);
 
@@ -1238,7 +1245,7 @@ int qemuMonitorMigrateToCommand(const virDomainObjPtr vm,
         goto cleanup;
     }
 
-    ret = qemuMonitorMigrate(vm, dest);
+    ret = qemuMonitorMigrate(vm, 0, dest);
 
 cleanup:
     VIR_FREE(safe_target);
@@ -1248,6 +1255,13 @@ cleanup:
 }
 
 
+void qemuMonitorMigrateCancel(const virDomainObjPtr vm)
+{
+    char *info = NULL;
+    qemuMonitorCommand(vm, "migrate cancel", &info);
+    VIR_FREE(info);
+}
+
 int qemuMonitorAddUSBDisk(const virDomainObjPtr vm,
                           const char *path)
 {
diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h
index 82dc5df..4283570 100644
--- a/src/qemu/qemu_monitor_text.h
+++ b/src/qemu/qemu_monitor_text.h
@@ -104,6 +104,10 @@ int qemuMonitorMigrateToCommand(const virDomainObjPtr vm,
                                 const char *target);
 
 
+int qemuMonitorMigrate(const virDomainObjPtr vm,
+                       int background,
+                       const char *dest);
+
 /* XXX disk driver type eg,  qcow/etc.
  * XXX cache mode
  */
@@ -170,4 +174,7 @@ int qemuMonitorRemoveHostNetwork(const virDomainObjPtr vm,
                                  int vlan,
                                  const char *netname);
 
+char *qemuMonitorEscapeArg(const char *in);
+void qemuMonitorMigrateCancel(const virDomainObjPtr vm);
+
 #endif /* QEMU_MONITOR_TEXT_H */
-- 
1.6.0.6

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