]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix migration in text mode and shared storage migration in json mode
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 24 Jun 2010 18:58:36 +0000 (14:58 -0400)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 25 Jun 2010 13:40:06 +0000 (14:40 +0100)
The patches for shared storage migration were not correctly written
for json mode. Thus the 'blk' and 'inc' parameters were never being
set. In addition they didn't set the QEMU_MONITOR_MIGRATE_BACKGROUND
so migration was synchronous. Due to multiple bugs in QEMU's JSON
impl this wasn't noticed because it treated the sync migration requst
as asynchronous anyway. Finally 'background' parameter was converted
to take arbitrary flags but not renamed, and not all uses were changed
to unsigned int.

* src/qemu/qemu_driver.c: Set QEMU_MONITOR_MIGRATE_BACKGROUND in
  doNativeMigrate
* src/qemu/qemu_monitor_json.c: Process QEMU_MONITOR_MIGRATE_NON_SHARED_DISK
  and QEMU_MONITOR_MIGRATE_NON_SHARED_INC flags
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.h, src/qemu/qemu_monitor_text.c,
  src/qemu/qemu_monitor_text.h: change 'int background' to
  'unsigned int flags' in migration APIs. Add logging of flags
  parameter

src/qemu/qemu_driver.c
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.h
src/qemu/qemu_monitor_text.c
src/qemu/qemu_monitor_text.h

index 6008c4e0b11281bf15d39407e593c12f20a6719e..1257c705117fad386a927e94204f897e6e9f081d 100644 (file)
@@ -10590,7 +10590,7 @@ static int doNativeMigrate(struct qemud_driver *driver,
     int ret = -1;
     xmlURIPtr uribits = NULL;
     qemuDomainObjPrivatePtr priv = vm->privateData;
-    unsigned int background_flags = 0;
+    unsigned int background_flags = QEMU_MONITOR_MIGRATE_BACKGROUND;
 
     /* Issue the migrate command. */
     if (STRPREFIX(uri, "tcp:") && !STRPREFIX(uri, "tcp://")) {
index ea0351ea828daf57b838f6ff4fb697dc13488cb4..f428665f22f9f7beb53f5e54e6ec4a7528976b1e 100644 (file)
@@ -1299,13 +1299,13 @@ int qemuMonitorGetMigrationStatus(qemuMonitorPtr mon,
 
 
 int qemuMonitorMigrateToHost(qemuMonitorPtr mon,
-                             unsigned int background,
+                             unsigned int flags,
                              const char *hostname,
                              int port)
 {
     int ret;
-    DEBUG("mon=%p hostname=%s port=%d",
-          mon, hostname, port);
+    DEBUG("mon=%p hostname=%s port=%d flags=%u",
+          mon, hostname, port, flags);
 
     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1314,20 +1314,20 @@ int qemuMonitorMigrateToHost(qemuMonitorPtr mon,
     }
 
     if (mon->json)
-        ret = qemuMonitorJSONMigrateToHost(mon, background, hostname, port);
+        ret = qemuMonitorJSONMigrateToHost(mon, flags, hostname, port);
     else
-        ret = qemuMonitorTextMigrateToHost(mon, background, hostname, port);
+        ret = qemuMonitorTextMigrateToHost(mon, flags, hostname, port);
     return ret;
 }
 
 
 int qemuMonitorMigrateToCommand(qemuMonitorPtr mon,
-                                unsigned int background,
+                                unsigned int flags,
                                 const char * const *argv)
 {
     int ret;
-    DEBUG("mon=%p argv=%p",
-          mon, argv);
+    DEBUG("mon=%p argv=%p flags=%u",
+          mon, argv, flags);
 
     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1336,21 +1336,21 @@ int qemuMonitorMigrateToCommand(qemuMonitorPtr mon,
     }
 
     if (mon->json)
-        ret = qemuMonitorJSONMigrateToCommand(mon, background, argv);
+        ret = qemuMonitorJSONMigrateToCommand(mon, flags, argv);
     else
-        ret = qemuMonitorTextMigrateToCommand(mon, background, argv);
+        ret = qemuMonitorTextMigrateToCommand(mon, flags, argv);
     return ret;
 }
 
 int qemuMonitorMigrateToFile(qemuMonitorPtr mon,
-                             unsigned int background,
+                             unsigned int flags,
                              const char * const *argv,
                              const char *target,
                              unsigned long long offset)
 {
     int ret;
-    DEBUG("mon=%p argv=%p target=%s offset=%llu",
-          mon, argv, target, offset);
+    DEBUG("mon=%p argv=%p target=%s offset=%llu flags=%u",
+          mon, argv, target, offset, flags);
 
     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1366,19 +1366,19 @@ int qemuMonitorMigrateToFile(qemuMonitorPtr mon,
     }
 
     if (mon->json)
-        ret = qemuMonitorJSONMigrateToFile(mon, background, argv, target, offset);
+        ret = qemuMonitorJSONMigrateToFile(mon, flags, argv, target, offset);
     else
-        ret = qemuMonitorTextMigrateToFile(mon, background, argv, target, offset);
+        ret = qemuMonitorTextMigrateToFile(mon, flags, argv, target, offset);
     return ret;
 }
 
 int qemuMonitorMigrateToUnix(qemuMonitorPtr mon,
-                             unsigned int background,
+                             unsigned int flags,
                              const char *unixfile)
 {
     int ret;
-    DEBUG("mon=%p, unixfile=%s",
-          mon, unixfile);
+    DEBUG("mon=%p, unixfile=%s flags=%u",
+          mon, unixfile, flags);
 
     if (!mon) {
         qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1387,9 +1387,9 @@ int qemuMonitorMigrateToUnix(qemuMonitorPtr mon,
     }
 
     if (mon->json)
-        ret = qemuMonitorJSONMigrateToUnix(mon, background, unixfile);
+        ret = qemuMonitorJSONMigrateToUnix(mon, flags, unixfile);
     else
-        ret = qemuMonitorTextMigrateToUnix(mon, background, unixfile);
+        ret = qemuMonitorTextMigrateToUnix(mon, flags, unixfile);
     return ret;
 }
 
index b6a8f9f6c5aee0c7c3cfbb41a83b102e4eacad52..459ccb70bdda902eff26a4303e97ae774e07f714 100644 (file)
@@ -256,12 +256,12 @@ typedef enum {
 } QEMU_MONITOR_MIGRATE;
 
 int qemuMonitorMigrateToHost(qemuMonitorPtr mon,
-                             unsigned int background,
+                             unsigned int flags,
                              const char *hostname,
                              int port);
 
 int qemuMonitorMigrateToCommand(qemuMonitorPtr mon,
-                                unsigned int background,
+                                unsigned int flags,
                                 const char * const *argv);
 
 /* In general, BS is the smallest fundamental block size we can use to
@@ -276,13 +276,13 @@ int qemuMonitorMigrateToCommand(qemuMonitorPtr mon,
 # define QEMU_MONITOR_MIGRATE_TO_FILE_TRANSFER_SIZE (1024llu * 1024)
 
 int qemuMonitorMigrateToFile(qemuMonitorPtr mon,
-                             unsigned int background,
+                             unsigned int flags,
                              const char * const *argv,
                              const char *target,
                              unsigned long long offset);
 
 int qemuMonitorMigrateToUnix(qemuMonitorPtr mon,
-                             unsigned int background,
+                             unsigned int flags,
                              const char *unixfile);
 
 int qemuMonitorMigrateCancel(qemuMonitorPtr mon);
index 40218aaf4ee6607aa9ff96e6558526a72db6d3a8..01be86d258004de4ac1751fcaeb0370543ea2127 100644 (file)
@@ -1599,14 +1599,17 @@ int qemuMonitorJSONGetMigrationStatus(qemuMonitorPtr mon,
 
 
 static int qemuMonitorJSONMigrate(qemuMonitorPtr mon,
-                                  int background,
+                                  unsigned int flags,
                                   const char *uri)
 {
     int ret;
-    virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("migrate",
-                                                     "i:detach", background ? 1 : 0,
-                                                     "s:uri", uri,
-                                                     NULL);
+    virJSONValuePtr cmd =
+      qemuMonitorJSONMakeCommand("migrate",
+                                 "i:detach", flags & QEMU_MONITOR_MIGRATE_BACKGROUND ? 1 : 0,
+                                 "i:blk", flags & QEMU_MONITOR_MIGRATE_NON_SHARED_DISK ? 1 : 0,
+                                 "i:inc", flags & QEMU_MONITOR_MIGRATE_NON_SHARED_INC ? 1 : 0,
+                                 "s:uri", uri,
+                                 NULL);
     virJSONValuePtr reply = NULL;
 
     if (!cmd)
@@ -1624,7 +1627,7 @@ static int qemuMonitorJSONMigrate(qemuMonitorPtr mon,
 
 
 int qemuMonitorJSONMigrateToHost(qemuMonitorPtr mon,
-                                 int background,
+                                 unsigned int flags,
                                  const char *hostname,
                                  int port)
 {
@@ -1636,7 +1639,7 @@ int qemuMonitorJSONMigrateToHost(qemuMonitorPtr mon,
         return -1;
     }
 
-    ret = qemuMonitorJSONMigrate(mon, background, uri);
+    ret = qemuMonitorJSONMigrate(mon, flags, uri);
 
     VIR_FREE(uri);
 
@@ -1645,7 +1648,7 @@ int qemuMonitorJSONMigrateToHost(qemuMonitorPtr mon,
 
 
 int qemuMonitorJSONMigrateToCommand(qemuMonitorPtr mon,
-                                    int background,
+                                    unsigned int flags,
                                     const char * const *argv)
 {
     char *argstr;
@@ -1663,7 +1666,7 @@ int qemuMonitorJSONMigrateToCommand(qemuMonitorPtr mon,
         goto cleanup;
     }
 
-    ret = qemuMonitorJSONMigrate(mon, background, dest);
+    ret = qemuMonitorJSONMigrate(mon, flags, dest);
 
 cleanup:
     VIR_FREE(argstr);
@@ -1672,7 +1675,7 @@ cleanup:
 }
 
 int qemuMonitorJSONMigrateToFile(qemuMonitorPtr mon,
-                                 int background,
+                                 unsigned int flags,
                                  const char * const *argv,
                                  const char *target,
                                  unsigned long long offset)
@@ -1709,7 +1712,7 @@ int qemuMonitorJSONMigrateToFile(qemuMonitorPtr mon,
         goto cleanup;
     }
 
-    ret = qemuMonitorJSONMigrate(mon, background, dest);
+    ret = qemuMonitorJSONMigrate(mon, flags, dest);
 
 cleanup:
     VIR_FREE(safe_target);
@@ -1719,7 +1722,7 @@ cleanup:
 }
 
 int qemuMonitorJSONMigrateToUnix(qemuMonitorPtr mon,
-                                 int background,
+                                 unsigned int flags,
                                  const char *unixfile)
 {
     char *dest = NULL;
@@ -1730,7 +1733,7 @@ int qemuMonitorJSONMigrateToUnix(qemuMonitorPtr mon,
         return -1;
     }
 
-    ret = qemuMonitorJSONMigrate(mon, background, dest);
+    ret = qemuMonitorJSONMigrate(mon, flags, dest);
 
     VIR_FREE(dest);
 
index c57821132e2b7cbac593a89e6a6f59021a829dae..6fa8d83549d2697b94a16ed53d24d31244cb858e 100644 (file)
@@ -97,22 +97,22 @@ int qemuMonitorJSONGetMigrationStatus(qemuMonitorPtr mon,
                                       unsigned long long *total);
 
 int qemuMonitorJSONMigrateToHost(qemuMonitorPtr mon,
-                                 int background,
+                                 unsigned int flags,
                                  const char *hostname,
                                  int port);
 
 int qemuMonitorJSONMigrateToCommand(qemuMonitorPtr mon,
-                                    int background,
+                                    unsigned int flags,
                                     const char * const *argv);
 
 int qemuMonitorJSONMigrateToFile(qemuMonitorPtr mon,
-                                 int background,
+                                 unsigned int flags,
                                  const char * const *argv,
                                  const char *target,
                                  unsigned long long offset);
 
 int qemuMonitorJSONMigrateToUnix(qemuMonitorPtr mon,
-                                 int background,
+                                 unsigned int flags,
                                  const char *unixfile);
 
 int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon);
index c08696244f951be88108c346d74d50555e00f81e..569742a42d145b0288703285d9e505aae7473136 100644 (file)
@@ -1136,7 +1136,7 @@ cleanup:
 
 
 static int qemuMonitorTextMigrate(qemuMonitorPtr mon,
-                                  unsigned int background,
+                                  unsigned int flags,
                                   const char *dest)
 {
     char *cmd = NULL;
@@ -1151,11 +1151,11 @@ static int qemuMonitorTextMigrate(qemuMonitorPtr mon,
         return -1;
     }
 
-    if (background & QEMU_MONITOR_MIGRATE_BACKGROUND)
+    if (flags & QEMU_MONITOR_MIGRATE_BACKGROUND)
         virBufferAddLit(&extra, " -d");
-    if (background & QEMU_MONITOR_MIGRATE_NON_SHARED_DISK)
+    if (flags & QEMU_MONITOR_MIGRATE_NON_SHARED_DISK)
         virBufferAddLit(&extra, " -b");
-    if (background & QEMU_MONITOR_MIGRATE_NON_SHARED_INC)
+    if (flags & QEMU_MONITOR_MIGRATE_NON_SHARED_INC)
         virBufferAddLit(&extra, " -i");
     if (virBufferError(&extra)) {
         virBufferFreeAndReset(&extra);
@@ -1202,7 +1202,7 @@ cleanup:
 }
 
 int qemuMonitorTextMigrateToHost(qemuMonitorPtr mon,
-                                 unsigned int background,
+                                 unsigned int flags,
                                  const char *hostname,
                                  int port)
 {
@@ -1214,7 +1214,7 @@ int qemuMonitorTextMigrateToHost(qemuMonitorPtr mon,
         return -1;
     }
 
-    ret = qemuMonitorTextMigrate(mon, background, uri);
+    ret = qemuMonitorTextMigrate(mon, flags, uri);
 
     VIR_FREE(uri);
 
@@ -1223,7 +1223,7 @@ int qemuMonitorTextMigrateToHost(qemuMonitorPtr mon,
 
 
 int qemuMonitorTextMigrateToCommand(qemuMonitorPtr mon,
-                                    unsigned int background,
+                                    unsigned int flags,
                                     const char * const *argv)
 {
     char *argstr;
@@ -1241,7 +1241,7 @@ int qemuMonitorTextMigrateToCommand(qemuMonitorPtr mon,
         goto cleanup;
     }
 
-    ret = qemuMonitorTextMigrate(mon, background, dest);
+    ret = qemuMonitorTextMigrate(mon, flags, dest);
 
 cleanup:
     VIR_FREE(argstr);
@@ -1250,7 +1250,7 @@ cleanup:
 }
 
 int qemuMonitorTextMigrateToFile(qemuMonitorPtr mon,
-                                 unsigned int background,
+                                 unsigned int flags,
                                  const char * const *argv,
                                  const char *target,
                                  unsigned long long offset)
@@ -1287,7 +1287,7 @@ int qemuMonitorTextMigrateToFile(qemuMonitorPtr mon,
         goto cleanup;
     }
 
-    ret = qemuMonitorTextMigrate(mon, background, dest);
+    ret = qemuMonitorTextMigrate(mon, flags, dest);
 
 cleanup:
     VIR_FREE(safe_target);
@@ -1297,7 +1297,7 @@ cleanup:
 }
 
 int qemuMonitorTextMigrateToUnix(qemuMonitorPtr mon,
-                                 unsigned int background,
+                                 unsigned int flags,
                                  const char *unixfile)
 {
     char *dest = NULL;
@@ -1308,7 +1308,7 @@ int qemuMonitorTextMigrateToUnix(qemuMonitorPtr mon,
         return -1;
     }
 
-    ret = qemuMonitorTextMigrate(mon, background, dest);
+    ret = qemuMonitorTextMigrate(mon, flags, dest);
 
     VIR_FREE(dest);
 
index 91eed84b0651d8ffff8caa2bfc99dba2996b82f8..9926d34723bde049dafcfb558d86a984a928b124 100644 (file)
@@ -95,22 +95,22 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
                                       unsigned long long *total);
 
 int qemuMonitorTextMigrateToHost(qemuMonitorPtr mon,
-                                 unsigned int background,
+                                 unsigned int flags,
                                  const char *hostname,
                                  int port);
 
 int qemuMonitorTextMigrateToCommand(qemuMonitorPtr mon,
-                                    unsigned int background,
+                                    unsigned int flags,
                                     const char * const *argv);
 
 int qemuMonitorTextMigrateToFile(qemuMonitorPtr mon,
-                                 unsigned int background,
+                                 unsigned int flags,
                                  const char * const *argv,
                                  const char *target,
                                  unsigned long long offset);
 
 int qemuMonitorTextMigrateToUnix(qemuMonitorPtr mon,
-                                 unsigned int background,
+                                 unsigned int flags,
                                  const char *unixfile);
 
 int qemuMonitorTextMigrateCancel(qemuMonitorPtr mon);