[PATCH v2 44/73] qemu: Move qemuMigrationAnyCompression*

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

 



The code really belongs to qemu_migration_params.c.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_migration.c        | 140 -----------------------------
 src/qemu/qemu_migration.h        |  19 ----
 src/qemu/qemu_migration_params.c | 147 +++++++++++++++++++++++++++++++
 src/qemu/qemu_migration_params.h |  11 +++
 4 files changed, 158 insertions(+), 159 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index d4c5994f25..d0d0d97be4 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -77,11 +77,6 @@ VIR_ENUM_IMPL(qemuMigrationJobPhase, QEMU_MIGRATION_PHASE_LAST,
               "finish3",
 );
 
-VIR_ENUM_IMPL(qemuMigrationCompressMethod, QEMU_MIGRATION_COMPRESS_LAST,
-              "xbzrle",
-              "mt",
-);
-
 static int
 qemuMigrationJobStart(virQEMUDriverPtr driver,
                       virDomainObjPtr vm,
@@ -5439,141 +5434,6 @@ qemuMigrationDstErrorReport(virQEMUDriverPtr driver,
 }
 
 
-/* don't ever pass NULL params with non zero nparams */
-qemuMigrationCompressionPtr
-qemuMigrationAnyCompressionParse(virTypedParameterPtr params,
-                                 int nparams,
-                                 unsigned long flags)
-{
-    size_t i;
-    qemuMigrationCompressionPtr compression = NULL;
-
-    if (VIR_ALLOC(compression) < 0)
-        return NULL;
-
-    for (i = 0; i < nparams; i++) {
-        int method;
-
-        if (STRNEQ(params[i].field, VIR_MIGRATE_PARAM_COMPRESSION))
-            continue;
-
-        method = qemuMigrationCompressMethodTypeFromString(params[i].value.s);
-        if (method < 0) {
-            virReportError(VIR_ERR_INVALID_ARG,
-                           _("Unsupported compression method '%s'"),
-                           params[i].value.s);
-            goto error;
-        }
-
-        if (compression->methods & (1ULL << method)) {
-            virReportError(VIR_ERR_INVALID_ARG,
-                           _("Compression method '%s' is specified twice"),
-                           params[i].value.s);
-            goto error;
-        }
-
-        compression->methods |= 1ULL << method;
-    }
-
-#define GET_PARAM(PARAM, TYPE, VALUE) \
-    do { \
-        int rc; \
-        const char *par = VIR_MIGRATE_PARAM_COMPRESSION_ ## PARAM; \
- \
-        if ((rc = virTypedParamsGet ## TYPE(params, nparams, \
-                                            par, &compression->VALUE)) < 0) \
-            goto error; \
- \
-        if (rc == 1) \
-            compression->VALUE ## _set = true; \
-    } while (0)
-
-    if (params) {
-        GET_PARAM(MT_LEVEL, Int, level);
-        GET_PARAM(MT_THREADS, Int, threads);
-        GET_PARAM(MT_DTHREADS, Int, dthreads);
-        GET_PARAM(XBZRLE_CACHE, ULLong, xbzrle_cache);
-    }
-
-#undef GET_PARAM
-
-    if ((compression->level_set ||
-         compression->threads_set ||
-         compression->dthreads_set) &&
-        !(compression->methods & (1ULL << QEMU_MIGRATION_COMPRESS_MT))) {
-        virReportError(VIR_ERR_INVALID_ARG, "%s",
-                       _("Turn multithread compression on to tune it"));
-        goto error;
-    }
-
-    if (compression->xbzrle_cache_set &&
-        !(compression->methods & (1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE))) {
-        virReportError(VIR_ERR_INVALID_ARG, "%s",
-                       _("Turn xbzrle compression on to tune it"));
-        goto error;
-    }
-
-    if (!compression->methods && (flags & VIR_MIGRATE_COMPRESSED))
-        compression->methods = 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE;
-
-    return compression;
-
- error:
-    VIR_FREE(compression);
-    return NULL;
-}
-
-int
-qemuMigrationAnyCompressionDump(qemuMigrationCompressionPtr compression,
-                                virTypedParameterPtr *params,
-                                int *nparams,
-                                int *maxparams,
-                                unsigned long *flags)
-{
-    size_t i;
-
-    if (compression->methods == 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE &&
-        !compression->xbzrle_cache_set) {
-        *flags |= VIR_MIGRATE_COMPRESSED;
-        return 0;
-    }
-
-    for (i = 0; i < QEMU_MIGRATION_COMPRESS_LAST; ++i) {
-        if ((compression->methods & (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;
-
-    if (compression->threads_set &&
-        virTypedParamsAddInt(params, nparams, maxparams,
-                             VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS,
-                             compression->threads) < 0)
-        return -1;
-
-    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;
-
-    return 0;
-}
-
-
 int
 qemuMigrationSrcFetchMirrorStats(virQEMUDriverPtr driver,
                                  virDomainObjPtr vm,
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index 3cd456568a..53d8c529fc 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -98,25 +98,6 @@ typedef enum {
 } qemuMigrationJobPhase;
 VIR_ENUM_DECL(qemuMigrationJobPhase)
 
-typedef enum {
-    QEMU_MIGRATION_COMPRESS_XBZRLE = 0,
-    QEMU_MIGRATION_COMPRESS_MT,
-
-    QEMU_MIGRATION_COMPRESS_LAST
-} qemuMigrationCompressMethod;
-VIR_ENUM_DECL(qemuMigrationCompressMethod)
-
-qemuMigrationCompressionPtr
-qemuMigrationAnyCompressionParse(virTypedParameterPtr params,
-                                 int nparams,
-                                 unsigned long flags);
-int
-qemuMigrationAnyCompressionDump(qemuMigrationCompressionPtr compression,
-                                virTypedParameterPtr *params,
-                                int *nparams,
-                                int *maxparams,
-                                unsigned long *flags);
-
 int
 qemuMigrationSrcSetOffline(virQEMUDriverPtr driver,
                            virDomainObjPtr vm);
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index b532299a5f..94eb08a6bb 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -43,6 +43,19 @@ struct _qemuMigrationParams {
     qemuMonitorMigrationParams params;
 };
 
+typedef enum {
+    QEMU_MIGRATION_COMPRESS_XBZRLE = 0,
+    QEMU_MIGRATION_COMPRESS_MT,
+
+    QEMU_MIGRATION_COMPRESS_LAST
+} qemuMigrationCompressMethod;
+VIR_ENUM_DECL(qemuMigrationCompressMethod)
+VIR_ENUM_IMPL(qemuMigrationCompressMethod, QEMU_MIGRATION_COMPRESS_LAST,
+              "xbzrle",
+              "mt",
+);
+
+
 typedef struct _qemuMigrationParamsAlwaysOnItem qemuMigrationParamsAlwaysOnItem;
 struct _qemuMigrationParamsAlwaysOnItem {
     qemuMonitorMigrationCaps cap;
@@ -201,6 +214,140 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params,
 #undef GET
 
 
+qemuMigrationCompressionPtr
+qemuMigrationAnyCompressionParse(virTypedParameterPtr params,
+                                 int nparams,
+                                 unsigned long flags)
+{
+    size_t i;
+    qemuMigrationCompressionPtr compression = NULL;
+
+    if (VIR_ALLOC(compression) < 0)
+        return NULL;
+
+    for (i = 0; i < nparams; i++) {
+        int method;
+
+        if (STRNEQ(params[i].field, VIR_MIGRATE_PARAM_COMPRESSION))
+            continue;
+
+        method = qemuMigrationCompressMethodTypeFromString(params[i].value.s);
+        if (method < 0) {
+            virReportError(VIR_ERR_INVALID_ARG,
+                           _("Unsupported compression method '%s'"),
+                           params[i].value.s);
+            goto error;
+        }
+
+        if (compression->methods & (1ULL << method)) {
+            virReportError(VIR_ERR_INVALID_ARG,
+                           _("Compression method '%s' is specified twice"),
+                           params[i].value.s);
+            goto error;
+        }
+
+        compression->methods |= 1ULL << method;
+    }
+
+#define GET_PARAM(PARAM, TYPE, VALUE) \
+    do { \
+        int rc; \
+        const char *par = VIR_MIGRATE_PARAM_COMPRESSION_ ## PARAM; \
+ \
+        if ((rc = virTypedParamsGet ## TYPE(params, nparams, \
+                                            par, &compression->VALUE)) < 0) \
+            goto error; \
+ \
+        if (rc == 1) \
+            compression->VALUE ## _set = true; \
+    } while (0)
+
+    if (params) {
+        GET_PARAM(MT_LEVEL, Int, level);
+        GET_PARAM(MT_THREADS, Int, threads);
+        GET_PARAM(MT_DTHREADS, Int, dthreads);
+        GET_PARAM(XBZRLE_CACHE, ULLong, xbzrle_cache);
+    }
+
+#undef GET_PARAM
+
+    if ((compression->level_set ||
+         compression->threads_set ||
+         compression->dthreads_set) &&
+        !(compression->methods & (1ULL << QEMU_MIGRATION_COMPRESS_MT))) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("Turn multithread compression on to tune it"));
+        goto error;
+    }
+
+    if (compression->xbzrle_cache_set &&
+        !(compression->methods & (1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE))) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("Turn xbzrle compression on to tune it"));
+        goto error;
+    }
+
+    if (!compression->methods && (flags & VIR_MIGRATE_COMPRESSED))
+        compression->methods = 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE;
+
+    return compression;
+
+ error:
+    VIR_FREE(compression);
+    return NULL;
+}
+
+int
+qemuMigrationAnyCompressionDump(qemuMigrationCompressionPtr compression,
+                                virTypedParameterPtr *params,
+                                int *nparams,
+                                int *maxparams,
+                                unsigned long *flags)
+{
+    size_t i;
+
+    if (compression->methods == 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE &&
+        !compression->xbzrle_cache_set) {
+        *flags |= VIR_MIGRATE_COMPRESSED;
+        return 0;
+    }
+
+    for (i = 0; i < QEMU_MIGRATION_COMPRESS_LAST; ++i) {
+        if ((compression->methods & (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;
+
+    if (compression->threads_set &&
+        virTypedParamsAddInt(params, nparams, maxparams,
+                             VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS,
+                             compression->threads) < 0)
+        return -1;
+
+    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;
+
+    return 0;
+}
+
+
 /**
  * qemuMigrationParamsApply
  * @driver: qemu driver
diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h
index 494ac104ad..165e1267ab 100644
--- a/src/qemu/qemu_migration_params.h
+++ b/src/qemu/qemu_migration_params.h
@@ -62,6 +62,17 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params,
                              unsigned long flags,
                              qemuMigrationParty party);
 
+qemuMigrationCompressionPtr
+qemuMigrationAnyCompressionParse(virTypedParameterPtr params,
+                                 int nparams,
+                                 unsigned long flags);
+int
+qemuMigrationAnyCompressionDump(qemuMigrationCompressionPtr compression,
+                                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