[PATCH 45/68] qemu: Replace qemuMigrationAnyCompressionDump

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

 



Since every parameter or capability set in qemuMigrationCompression
structure is now reflected in qemuMigrationParams structure, we can
replace qemuMigrationAnyCompressionDump with a new API which will work
on qemuMigrationParams.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c           |  6 ++--
 src/qemu/qemu_migration.c        | 16 ++++------
 src/qemu/qemu_migration.h        |  1 -
 src/qemu/qemu_migration_params.c | 52 ++++++++++++++------------------
 src/qemu/qemu_migration_params.h | 10 +++---
 5 files changed, 37 insertions(+), 48 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3b0c3a3ffb..5e79e90609 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12297,7 +12297,7 @@ qemuDomainMigratePerform(virDomainPtr dom,
      */
     ret = qemuMigrationSrcPerform(driver, dom->conn, vm, NULL,
                                   NULL, dconnuri, uri, NULL, NULL, 0, NULL, 0,
-                                  compression, migParams, cookie, cookielen,
+                                  migParams, cookie, cookielen,
                                   NULL, NULL, /* No output cookies in v2 */
                                   flags, dname, resource, false);
 
@@ -12743,7 +12743,7 @@ qemuDomainMigratePerform3(virDomainPtr dom,
 
     ret = qemuMigrationSrcPerform(driver, dom->conn, vm, xmlin, NULL,
                                   dconnuri, uri, NULL, NULL, 0, NULL, 0,
-                                  compression, migParams,
+                                  migParams,
                                   cookiein, cookieinlen,
                                   cookieout, cookieoutlen,
                                   flags, dname, resource, true);
@@ -12836,7 +12836,7 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
     ret = qemuMigrationSrcPerform(driver, dom->conn, vm, dom_xml, persist_xml,
                                   dconnuri, uri, graphicsuri, listenAddress,
                                   nmigrate_disks, migrate_disks, nbdPort,
-                                  compression, migParams,
+                                  migParams,
                                   cookiein, cookieinlen, cookieout, cookieoutlen,
                                   flags, dname, bandwidth, true);
  cleanup:
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 304eaf52c5..2a0431ea6f 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3894,7 +3894,6 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr driver,
                                   size_t nmigrate_disks,
                                   const char **migrate_disks,
                                   int nbdPort,
-                                  qemuMigrationCompressionPtr compression,
                                   qemuMigrationParamsPtr migParams,
                                   unsigned long long bandwidth,
                                   bool useParams,
@@ -3979,8 +3978,8 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr driver,
                                  nbdPort) < 0)
             goto cleanup;
 
-        if (qemuMigrationAnyCompressionDump(compression, &params, &nparams,
-                                            &maxparams, &flags) < 0)
+        if (qemuMigrationParamsDump(migParams, &params, &nparams,
+                                    &maxparams, &flags) < 0)
             goto cleanup;
     }
 
@@ -4253,7 +4252,6 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriverPtr driver,
                                  size_t nmigrate_disks,
                                  const char **migrate_disks,
                                  int nbdPort,
-                                 qemuMigrationCompressionPtr compression,
                                  qemuMigrationParamsPtr migParams,
                                  unsigned long flags,
                                  const char *dname,
@@ -4378,7 +4376,7 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriverPtr driver,
         ret = qemuMigrationSrcPerformPeer2Peer3(driver, sconn, dconn, dconnuri, vm, xmlin,
                                                 persist_xml, dname, uri, graphicsuri,
                                                 listenAddress, nmigrate_disks, migrate_disks,
-                                                nbdPort, compression, migParams, resource,
+                                                nbdPort, migParams, resource,
                                                 useParams, flags);
     } else {
         ret = qemuMigrationSrcPerformPeer2Peer2(driver, sconn, dconn, vm,
@@ -4419,7 +4417,6 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver,
                            size_t nmigrate_disks,
                            const char **migrate_disks,
                            int nbdPort,
-                           qemuMigrationCompressionPtr compression,
                            qemuMigrationParamsPtr migParams,
                            const char *cookiein,
                            int cookieinlen,
@@ -4458,7 +4455,7 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver,
         ret = qemuMigrationSrcPerformPeer2Peer(driver, conn, vm, xmlin, persist_xml,
                                                dconnuri, uri, graphicsuri, listenAddress,
                                                nmigrate_disks, migrate_disks, nbdPort,
-                                               compression, migParams, flags, dname, resource,
+                                               migParams, flags, dname, resource,
                                                &v3proto);
     } else {
         qemuMigrationJobSetPhase(driver, vm, QEMU_MIGRATION_PHASE_PERFORM2);
@@ -4609,7 +4606,6 @@ qemuMigrationSrcPerform(virQEMUDriverPtr driver,
                         size_t nmigrate_disks,
                         const char **migrate_disks,
                         int nbdPort,
-                        qemuMigrationCompressionPtr compression,
                         qemuMigrationParamsPtr migParams,
                         const char *cookiein,
                         int cookieinlen,
@@ -4641,7 +4637,7 @@ qemuMigrationSrcPerform(virQEMUDriverPtr driver,
         return qemuMigrationSrcPerformJob(driver, conn, vm, xmlin, persist_xml, dconnuri, uri,
                                           graphicsuri, listenAddress,
                                           nmigrate_disks, migrate_disks, nbdPort,
-                                          compression, migParams,
+                                          migParams,
                                           cookiein, cookieinlen,
                                           cookieout, cookieoutlen,
                                           flags, dname, resource, v3proto);
@@ -4664,7 +4660,7 @@ qemuMigrationSrcPerform(virQEMUDriverPtr driver,
             return qemuMigrationSrcPerformJob(driver, conn, vm, xmlin, persist_xml, NULL,
                                               uri, graphicsuri, listenAddress,
                                               nmigrate_disks, migrate_disks, nbdPort,
-                                              compression, migParams,
+                                              migParams,
                                               cookiein, cookieinlen,
                                               cookieout, cookieoutlen, flags,
                                               dname, resource, v3proto);
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index b67184874b..096c449bcc 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -164,7 +164,6 @@ qemuMigrationSrcPerform(virQEMUDriverPtr driver,
                         size_t nmigrate_disks,
                         const char **migrate_disks,
                         int nbdPort,
-                        qemuMigrationCompressionPtr compression,
                         qemuMigrationParamsPtr migParams,
                         const char *cookiein,
                         int cookieinlen,
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index 4f76cc6683..299920fc1a 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -39,6 +39,7 @@ VIR_LOG_INIT("qemu.qemu_migration_params");
 #define QEMU_MIGRATION_TLS_ALIAS_BASE "libvirt_migrate"
 
 struct _qemuMigrationParams {
+    unsigned long long compMethods; /* bit-wise OR of qemuMigrationCompressMethod */
     virBitmapPtr caps;
     qemuMonitorMigrationParams params;
 };
@@ -149,6 +150,8 @@ qemuMigrationParamsSetCompression(qemuMigrationCompressionPtr compression,
         ignore_value(virBitmapSetBit(migParams->caps,
                                      QEMU_MONITOR_MIGRATION_CAPS_COMPRESS));
 
+    migParams->compMethods = compression->methods;
+
     migParams->params.compressLevel_set = compression->level_set;
     migParams->params.compressLevel = compression->level;
 
@@ -298,51 +301,42 @@ qemuMigrationAnyCompressionParse(virTypedParameterPtr params,
 }
 
 int
-qemuMigrationAnyCompressionDump(qemuMigrationCompressionPtr compression,
-                                virTypedParameterPtr *params,
-                                int *nparams,
-                                int *maxparams,
-                                unsigned long *flags)
+qemuMigrationParamsDump(qemuMigrationParamsPtr migParams,
+                        virTypedParameterPtr *params,
+                        int *nparams,
+                        int *maxparams,
+                        unsigned long *flags)
 {
     size_t i;
 
-    if (compression->methods == 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE &&
-        !compression->xbzrle_cache_set) {
+    if (migParams->compMethods == 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE &&
+        !migParams->params.xbzrleCacheSize_set) {
         *flags |= VIR_MIGRATE_COMPRESSED;
         return 0;
     }
 
     for (i = 0; i < QEMU_MIGRATION_COMPRESS_LAST; ++i) {
-        if ((compression->methods & (1ULL << i)) &&
+        if ((migParams->compMethods & (1ULL << i)) &&
             virTypedParamsAddString(params, nparams, maxparams,
                                     VIR_MIGRATE_PARAM_COMPRESSION,
                                     qemuMigrationCompressMethodTypeToString(i)) < 0)
             return -1;
     }
 
-    if (compression->level_set &&
-        virTypedParamsAddInt(params, nparams, maxparams,
-                             VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL,
-                             compression->level) < 0)
-        return -1;
+#define SET(API, PARAM, VAR) \
+    do { \
+        if (migParams->params.VAR ## _set && \
+            API(params, nparams, maxparams, VIR_MIGRATE_PARAM_ ## PARAM, \
+                migParams->params.VAR) < 0) \
+            return -1; \
+    } while (0)
 
-    if (compression->threads_set &&
-        virTypedParamsAddInt(params, nparams, maxparams,
-                             VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS,
-                             compression->threads) < 0)
-        return -1;
+    SET(virTypedParamsAddInt, COMPRESSION_MT_LEVEL, compressLevel);
+    SET(virTypedParamsAddInt, COMPRESSION_MT_THREADS, compressThreads);
+    SET(virTypedParamsAddInt, COMPRESSION_MT_DTHREADS, decompressThreads);
+    SET(virTypedParamsAddULLong, COMPRESSION_XBZRLE_CACHE, xbzrleCacheSize);
 
-    if (compression->dthreads_set &&
-        virTypedParamsAddInt(params, nparams, maxparams,
-                             VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS,
-                             compression->dthreads) < 0)
-        return -1;
-
-    if (compression->xbzrle_cache_set &&
-        virTypedParamsAddULLong(params, nparams, maxparams,
-                                VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE,
-                                compression->xbzrle_cache) < 0)
-        return -1;
+#undef SET
 
     return 0;
 }
diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h
index 399b5cde77..3793b3bd17 100644
--- a/src/qemu/qemu_migration_params.h
+++ b/src/qemu/qemu_migration_params.h
@@ -68,11 +68,11 @@ qemuMigrationAnyCompressionParse(virTypedParameterPtr params,
                                  int nparams,
                                  unsigned long flags);
 int
-qemuMigrationAnyCompressionDump(qemuMigrationCompressionPtr compression,
-                                virTypedParameterPtr *params,
-                                int *nparams,
-                                int *maxparams,
-                                unsigned long *flags);
+qemuMigrationParamsDump(qemuMigrationParamsPtr migParams,
+                        virTypedParameterPtr *params,
+                        int *nparams,
+                        int *maxparams,
+                        unsigned long *flags);
 
 void
 qemuMigrationParamsFree(qemuMigrationParamsPtr migParams);
-- 
2.17.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]

  Powered by Linux