Re: [PATCH v3 1/7] qemu migration: factor out setting migration option

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

 



28.01.2016 10:04, Nikolay Shirokovskiy пишет:
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>

I'd be happy if you added a bit info into the commit message what functions you are removing
and to what function you are combining them.
Otherwise ACK.

---
  src/qemu/qemu_migration.c | 138 ++++++++++------------------------------------
  1 file changed, 28 insertions(+), 110 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 51e7125..a6412ce 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2364,97 +2364,10 @@ qemuMigrationSetOffline(virQEMUDriverPtr driver,
      return ret;
  }
-
-static int
-qemuMigrationSetCompression(virQEMUDriverPtr driver,
-                            virDomainObjPtr vm,
-                            bool state,
-                            qemuDomainAsyncJob job)
-{
-    qemuDomainObjPrivatePtr priv = vm->privateData;
-    int ret;
-
-    if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0)
-        return -1;
-
-    ret = qemuMonitorGetMigrationCapability(
-                priv->mon,
-                QEMU_MONITOR_MIGRATION_CAPS_XBZRLE);
-
-    if (ret < 0) {
-        goto cleanup;
-    } else if (ret == 0 && !state) {
-        /* Unsupported but we want it off anyway */
-        goto cleanup;
-    } else if (ret == 0) {
-        if (job == QEMU_ASYNC_JOB_MIGRATION_IN) {
-            virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
-                           _("Compressed migration is not supported by "
-                             "target QEMU binary"));
-        } else {
-            virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
-                           _("Compressed migration is not supported by "
-                             "source QEMU binary"));
-        }
-        ret = -1;
-        goto cleanup;
-    }
-
-    ret = qemuMonitorSetMigrationCapability(
-                priv->mon,
-                QEMU_MONITOR_MIGRATION_CAPS_XBZRLE,
-                state);
-
- cleanup:
-    if (qemuDomainObjExitMonitor(driver, vm) < 0)
-        ret = -1;
-    return ret;
-}
-
-static int
-qemuMigrationSetAutoConverge(virQEMUDriverPtr driver,
-                             virDomainObjPtr vm,
-                             bool state,
-                             qemuDomainAsyncJob job)
-{
-    qemuDomainObjPrivatePtr priv = vm->privateData;
-    int ret;
-
-    if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0)
-        return -1;
-
-    ret = qemuMonitorGetMigrationCapability(
-                priv->mon,
-                QEMU_MONITOR_MIGRATION_CAPS_AUTO_CONVERGE);
-
-    if (ret < 0) {
-        goto cleanup;
-    } else if (ret == 0 && !state) {
-        /* Unsupported but we want it off anyway */
-        goto cleanup;
-    } else if (ret == 0) {
-        virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
-                       _("Auto-Converge is not supported by "
-                         "QEMU binary"));
-        ret = -1;
-        goto cleanup;
-    }
-
-    ret = qemuMonitorSetMigrationCapability(
-                priv->mon,
-                QEMU_MONITOR_MIGRATION_CAPS_AUTO_CONVERGE,
-                state);
-
- cleanup:
-    if (qemuDomainObjExitMonitor(driver, vm) < 0)
-        ret = -1;
-    return ret;
-}
-
-
  static int
-qemuMigrationSetPinAll(virQEMUDriverPtr driver,
+qemuMigrationSetOption(virQEMUDriverPtr driver,
                         virDomainObjPtr vm,
+                       qemuMonitorMigrationCaps capability,
                         bool state,
                         qemuDomainAsyncJob job)
  {
@@ -2464,9 +2377,7 @@ qemuMigrationSetPinAll(virQEMUDriverPtr driver,
      if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0)
          return -1;
- ret = qemuMonitorGetMigrationCapability(
-                priv->mon,
-                QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL);
+    ret = qemuMonitorGetMigrationCapability(priv->mon, capability);
if (ret < 0) {
          goto cleanup;
@@ -2475,13 +2386,15 @@ qemuMigrationSetPinAll(virQEMUDriverPtr driver,
          goto cleanup;
      } else if (ret == 0) {
          if (job == QEMU_ASYNC_JOB_MIGRATION_IN) {
-            virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
-                           _("rdma pinning migration is not supported by "
-                             "target QEMU binary"));
+            virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
+                           _("Migration option '%s' is not supported by "
+                             "target QEMU binary"),
+                           qemuMonitorMigrationCapsTypeToString(capability));
          } else {
-            virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
-                           _("rdma pinning migration is not supported by "
-                             "source QEMU binary"));
+            virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
+                           _("Migration option '%s' is not supported by "
+                             "source QEMU binary"),
+                           qemuMonitorMigrationCapsTypeToString(capability));
          }
          ret = -1;
          goto cleanup;
@@ -2489,7 +2402,7 @@ qemuMigrationSetPinAll(virQEMUDriverPtr driver,
ret = qemuMonitorSetMigrationCapability(
                  priv->mon,
-                QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL,
+                capability,
                  state);
cleanup:
@@ -3582,9 +3495,10 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
          dataFD[1] = -1; /* 'st' owns the FD now & will close it */
      }
- if (qemuMigrationSetCompression(driver, vm,
-                                    flags & VIR_MIGRATE_COMPRESSED,
-                                    QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
+    if (qemuMigrationSetOption(driver, vm,
+                               QEMU_MONITOR_MIGRATION_CAPS_XBZRLE,
+                               flags & VIR_MIGRATE_COMPRESSED,
+                               QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
          goto stopjob;
if (STREQ_NULLABLE(protocol, "rdma") &&
@@ -3592,7 +3506,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
          goto stopjob;
      }
- if (qemuMigrationSetPinAll(driver, vm,
+    if (qemuMigrationSetOption(driver, vm,
+                               QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL,
                                 flags & VIR_MIGRATE_RDMA_PIN_ALL,
                                 QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
          goto stopjob;
@@ -4447,17 +4362,20 @@ qemuMigrationRun(virQEMUDriverPtr driver,
              goto cleanup;
      }
- if (qemuMigrationSetCompression(driver, vm,
-                                    flags & VIR_MIGRATE_COMPRESSED,
-                                    QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
+    if (qemuMigrationSetOption(driver, vm,
+                               QEMU_MONITOR_MIGRATION_CAPS_XBZRLE,
+                               flags & VIR_MIGRATE_COMPRESSED,
+                               QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
          goto cleanup;
- if (qemuMigrationSetAutoConverge(driver, vm,
-                                     flags & VIR_MIGRATE_AUTO_CONVERGE,
-                                     QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
+    if (qemuMigrationSetOption(driver, vm,
+                               QEMU_MONITOR_MIGRATION_CAPS_AUTO_CONVERGE,
+                               flags & VIR_MIGRATE_AUTO_CONVERGE,
+                               QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
          goto cleanup;
- if (qemuMigrationSetPinAll(driver, vm,
+    if (qemuMigrationSetOption(driver, vm,
+                               QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL,
                                 flags & VIR_MIGRATE_RDMA_PIN_ALL,
                                 QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
          goto cleanup;

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