[PATCH 10/68] qemu: Introduce qemuMigrationParams struct

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

 



Currently migration parameters are stored in a structure which mimics
the QEMU migration parameters handled by query-migrate-parameters and
migrate-set-parameters. The new structure will become a libvirt's
abstraction on top of QEMU migration parameters, capabilities, and
related stuff.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c           |  6 ++--
 src/qemu/qemu_migration.c        | 26 +++++++-------
 src/qemu/qemu_migration.h        |  2 +-
 src/qemu/qemu_migration_params.c | 62 ++++++++++++++++----------------
 src/qemu/qemu_migration_params.h | 21 +++++++----
 5 files changed, 62 insertions(+), 55 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c157ff9bb0..6e6fc130c5 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12241,7 +12241,7 @@ qemuDomainMigratePerform(virDomainPtr dom,
     int ret = -1;
     const char *dconnuri = NULL;
     qemuMigrationCompressionPtr compression = NULL;
-    qemuMonitorMigrationParamsPtr migParams = NULL;
+    qemuMigrationParamsPtr migParams = NULL;
 
     virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
 
@@ -12669,7 +12669,7 @@ qemuDomainMigratePerform3(virDomainPtr dom,
     virQEMUDriverPtr driver = dom->conn->privateData;
     virDomainObjPtr vm;
     qemuMigrationCompressionPtr compression = NULL;
-    qemuMonitorMigrationParamsPtr migParams = NULL;
+    qemuMigrationParamsPtr migParams = NULL;
     int ret = -1;
 
     virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
@@ -12725,7 +12725,7 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
     unsigned long long bandwidth = 0;
     int nbdPort = 0;
     qemuMigrationCompressionPtr compression = NULL;
-    qemuMonitorMigrationParamsPtr migParams = NULL;
+    qemuMigrationParamsPtr migParams = NULL;
     int ret = -1;
 
     virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index ffdf0ba2e5..a6f8e66891 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2254,7 +2254,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
     int rv;
     char *tlsAlias = NULL;
     char *secAlias = NULL;
-    qemuMonitorMigrationParamsPtr migParams = NULL;
+    qemuMigrationParamsPtr migParams = NULL;
 
     virNWFilterReadLockFilterUpdates();
 
@@ -2468,7 +2468,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
             goto stopjob;
 
         /* Force reset of 'tls-hostname', it's a source only parameter */
-        if (VIR_STRDUP(migParams->tlsHostname, "") < 0)
+        if (VIR_STRDUP(migParams->params.tlsHostname, "") < 0)
             goto stopjob;
 
     } else {
@@ -3340,7 +3340,7 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
                     size_t nmigrate_disks,
                     const char **migrate_disks,
                     qemuMigrationCompressionPtr compression,
-                    qemuMonitorMigrationParamsPtr migParams)
+                    qemuMigrationParamsPtr migParams)
 {
     int ret = -1;
     unsigned int migrate_flags = QEMU_MONITOR_MIGRATE_BACKGROUND;
@@ -3429,11 +3429,11 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
          * connect directly to the destination. */
         if (spec->destType == MIGRATION_DEST_CONNECT_HOST ||
             spec->destType == MIGRATION_DEST_FD) {
-            if (VIR_STRDUP(migParams->tlsHostname, spec->dest.host.name) < 0)
+            if (VIR_STRDUP(migParams->params.tlsHostname, spec->dest.host.name) < 0)
                 goto error;
         } else {
             /* Be sure there's nothing from a previous migration */
-            if (VIR_STRDUP(migParams->tlsHostname, "") < 0)
+            if (VIR_STRDUP(migParams->params.tlsHostname, "") < 0)
                 goto error;
         }
     } else {
@@ -3736,7 +3736,7 @@ qemuMigrationSrcPerformNative(virQEMUDriverPtr driver,
                               size_t nmigrate_disks,
                               const char **migrate_disks,
                               qemuMigrationCompressionPtr compression,
-                              qemuMonitorMigrationParamsPtr migParams)
+                              qemuMigrationParamsPtr migParams)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
     virURIPtr uribits = NULL;
@@ -3815,7 +3815,7 @@ qemuMigrationSrcPerformTunnel(virQEMUDriverPtr driver,
                               size_t nmigrate_disks,
                               const char **migrate_disks,
                               qemuMigrationCompressionPtr compression,
-                              qemuMonitorMigrationParamsPtr migParams)
+                              qemuMigrationParamsPtr migParams)
 {
     int ret = -1;
     qemuMigrationSpec spec;
@@ -3887,7 +3887,7 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriverPtr driver,
     virStreamPtr st = NULL;
     unsigned long destflags;
     qemuMigrationCompressionPtr compression = NULL;
-    qemuMonitorMigrationParamsPtr migParams = NULL;
+    qemuMigrationParamsPtr migParams = NULL;
 
     VIR_DEBUG("driver=%p, sconn=%p, dconn=%p, vm=%p, dconnuri=%s, "
               "flags=0x%lx, dname=%s, resource=%lu",
@@ -4042,7 +4042,7 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr driver,
                                   const char **migrate_disks,
                                   int nbdPort,
                                   qemuMigrationCompressionPtr compression,
-                                  qemuMonitorMigrationParamsPtr migParams,
+                                  qemuMigrationParamsPtr migParams,
                                   unsigned long long bandwidth,
                                   bool useParams,
                                   unsigned long flags)
@@ -4401,7 +4401,7 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriverPtr driver,
                                  const char **migrate_disks,
                                  int nbdPort,
                                  qemuMigrationCompressionPtr compression,
-                                 qemuMonitorMigrationParamsPtr migParams,
+                                 qemuMigrationParamsPtr migParams,
                                  unsigned long flags,
                                  const char *dname,
                                  unsigned long resource,
@@ -4566,7 +4566,7 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver,
                            const char **migrate_disks,
                            int nbdPort,
                            qemuMigrationCompressionPtr compression,
-                           qemuMonitorMigrationParamsPtr migParams,
+                           qemuMigrationParamsPtr migParams,
                            const char *cookiein,
                            int cookieinlen,
                            char **cookieout,
@@ -4679,7 +4679,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriverPtr driver,
                              size_t nmigrate_disks,
                              const char **migrate_disks,
                              qemuMigrationCompressionPtr compression,
-                             qemuMonitorMigrationParamsPtr migParams,
+                             qemuMigrationParamsPtr migParams,
                              const char *cookiein,
                              int cookieinlen,
                              char **cookieout,
@@ -4753,7 +4753,7 @@ qemuMigrationSrcPerform(virQEMUDriverPtr driver,
                         const char **migrate_disks,
                         int nbdPort,
                         qemuMigrationCompressionPtr compression,
-                        qemuMonitorMigrationParamsPtr migParams,
+                        qemuMigrationParamsPtr migParams,
                         const char *cookiein,
                         int cookieinlen,
                         char **cookieout,
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index 32028845a7..b15eca9e51 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -183,7 +183,7 @@ qemuMigrationSrcPerform(virQEMUDriverPtr driver,
                         const char **migrate_disks,
                         int nbdPort,
                         qemuMigrationCompressionPtr compression,
-                        qemuMonitorMigrationParamsPtr migParams,
+                        qemuMigrationParamsPtr migParams,
                         const char *cookiein,
                         int cookieinlen,
                         char **cookieout,
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index c91216a2a4..187c0c2258 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -38,10 +38,10 @@ VIR_LOG_INIT("qemu.qemu_migration_params");
 #define QEMU_MIGRATION_TLS_ALIAS_BASE "libvirt_migrate"
 
 
-qemuMonitorMigrationParamsPtr
+qemuMigrationParamsPtr
 qemuMigrationParamsNew(void)
 {
-    qemuMonitorMigrationParamsPtr params;
+    qemuMigrationParamsPtr params;
 
     if (VIR_ALLOC(params) < 0)
         return NULL;
@@ -51,23 +51,23 @@ qemuMigrationParamsNew(void)
 
 
 void
-qemuMigrationParamsFree(qemuMonitorMigrationParamsPtr migParams)
+qemuMigrationParamsFree(qemuMigrationParamsPtr migParams)
 {
     if (!migParams)
         return;
 
-    VIR_FREE(migParams->tlsCreds);
-    VIR_FREE(migParams->tlsHostname);
+    VIR_FREE(migParams->params.tlsCreds);
+    VIR_FREE(migParams->params.tlsHostname);
     VIR_FREE(migParams);
 }
 
 
-qemuMonitorMigrationParamsPtr
+qemuMigrationParamsPtr
 qemuMigrationParamsFromFlags(virTypedParameterPtr params,
                              int nparams,
                              unsigned long flags)
 {
-    qemuMonitorMigrationParamsPtr migParams;
+    qemuMigrationParamsPtr migParams;
 
     if (!(migParams = qemuMigrationParamsNew()))
         return NULL;
@@ -80,11 +80,11 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params,
         int rc; \
         if ((rc = virTypedParamsGetInt(params, nparams, \
                                        VIR_MIGRATE_PARAM_ ## PARAM, \
-                                       &migParams->VAR)) < 0) \
+                                       &migParams->params.VAR)) < 0) \
             goto error; \
  \
         if (rc == 1) \
-            migParams->VAR ## _set = true; \
+            migParams->params.VAR ## _set = true; \
     } while (0)
 
     GET(AUTO_CONVERGE_INITIAL, cpuThrottleInitial);
@@ -92,8 +92,8 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params,
 
 #undef GET
 
-    if ((migParams->cpuThrottleInitial_set ||
-         migParams->cpuThrottleIncrement_set) &&
+    if ((migParams->params.cpuThrottleInitial_set ||
+         migParams->params.cpuThrottleIncrement_set) &&
         !(flags & VIR_MIGRATE_AUTO_CONVERGE)) {
         virReportError(VIR_ERR_INVALID_ARG, "%s",
                        _("Turn auto convergence on to tune it"));
@@ -112,7 +112,7 @@ int
 qemuMigrationParamsSet(virQEMUDriverPtr driver,
                        virDomainObjPtr vm,
                        int asyncJob,
-                       qemuMonitorMigrationParamsPtr migParams)
+                       qemuMigrationParamsPtr migParams)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
     int ret = -1;
@@ -120,7 +120,7 @@ qemuMigrationParamsSet(virQEMUDriverPtr driver,
     if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
         return -1;
 
-    if (qemuMonitorSetMigrationParams(priv->mon, migParams) < 0)
+    if (qemuMonitorSetMigrationParams(priv->mon, &migParams->params) < 0)
         goto cleanup;
 
     ret = 0;
@@ -153,7 +153,7 @@ qemuMigrationParamsCheckTLSCreds(virQEMUDriverPtr driver,
 {
     int ret = -1;
     qemuDomainObjPrivatePtr priv = vm->privateData;
-    qemuMonitorMigrationParamsPtr migParams = NULL;
+    qemuMigrationParamsPtr migParams = NULL;
 
     if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
         return -1;
@@ -161,11 +161,11 @@ qemuMigrationParamsCheckTLSCreds(virQEMUDriverPtr driver,
     if (!(migParams = qemuMigrationParamsNew()))
         goto cleanup;
 
-    if (qemuMonitorGetMigrationParams(priv->mon, migParams) < 0)
+    if (qemuMonitorGetMigrationParams(priv->mon, &migParams->params) < 0)
         goto cleanup;
 
     /* NB: Could steal NULL pointer too! Let caller decide what to do. */
-    VIR_STEAL_PTR(priv->migTLSAlias, migParams->tlsCreds);
+    VIR_STEAL_PTR(priv->migTLSAlias, migParams->params.tlsCreds);
 
     ret = 0;
 
@@ -251,7 +251,7 @@ qemuMigrationParamsAddTLSObjects(virQEMUDriverPtr driver,
                                  int asyncJob,
                                  char **tlsAlias,
                                  char **secAlias,
-                                 qemuMonitorMigrationParamsPtr migParams)
+                                 qemuMigrationParamsPtr migParams)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
     virJSONValuePtr tlsProps = NULL;
@@ -274,7 +274,7 @@ qemuMigrationParamsAddTLSObjects(virQEMUDriverPtr driver,
                                 *tlsAlias, &tlsProps) < 0)
         goto error;
 
-    if (VIR_STRDUP(migParams->tlsCreds, *tlsAlias) < 0)
+    if (VIR_STRDUP(migParams->params.tlsCreds, *tlsAlias) < 0)
         goto error;
 
     return 0;
@@ -302,7 +302,7 @@ int
 qemuMigrationParamsSetEmptyTLS(virQEMUDriverPtr driver,
                                virDomainObjPtr vm,
                                int asyncJob,
-                               qemuMonitorMigrationParamsPtr migParams)
+                               qemuMigrationParamsPtr migParams)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
 
@@ -312,8 +312,8 @@ qemuMigrationParamsSetEmptyTLS(virQEMUDriverPtr driver,
     if (!priv->migTLSAlias)
         return 0;
 
-    if (VIR_STRDUP(migParams->tlsCreds, "") < 0 ||
-        VIR_STRDUP(migParams->tlsHostname, "") < 0)
+    if (VIR_STRDUP(migParams->params.tlsCreds, "") < 0 ||
+        VIR_STRDUP(migParams->params.tlsHostname, "") < 0)
         return -1;
 
     return 0;
@@ -325,7 +325,7 @@ qemuMigrationParamsSetCompression(virQEMUDriverPtr driver,
                                   virDomainObjPtr vm,
                                   int asyncJob,
                                   qemuMigrationCompressionPtr compression,
-                                  qemuMonitorMigrationParamsPtr migParams)
+                                  qemuMigrationParamsPtr migParams)
 {
     int ret = -1;
     qemuDomainObjPrivatePtr priv = vm->privateData;
@@ -347,14 +347,14 @@ qemuMigrationParamsSetCompression(virQEMUDriverPtr driver,
     if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
         return -1;
 
-    migParams->compressLevel_set = compression->level_set;
-    migParams->compressLevel = compression->level;
+    migParams->params.compressLevel_set = compression->level_set;
+    migParams->params.compressLevel = compression->level;
 
-    migParams->compressThreads_set = compression->threads_set;
-    migParams->compressThreads = compression->threads;
+    migParams->params.compressThreads_set = compression->threads_set;
+    migParams->params.compressThreads = compression->threads;
 
-    migParams->decompressThreads_set = compression->dthreads_set;
-    migParams->decompressThreads = compression->dthreads;
+    migParams->params.decompressThreads_set = compression->dthreads_set;
+    migParams->params.decompressThreads = compression->dthreads;
 
     if (compression->xbzrle_cache_set &&
         qemuMonitorSetMigrationCacheSize(priv->mon,
@@ -389,7 +389,7 @@ qemuMigrationParamsResetTLS(virQEMUDriverPtr driver,
     qemuDomainObjPrivatePtr priv = vm->privateData;
     char *tlsAlias = NULL;
     char *secAlias = NULL;
-    qemuMonitorMigrationParamsPtr migParams = NULL;
+    qemuMigrationParamsPtr migParams = NULL;
     int ret = -1;
 
     if (qemuMigrationParamsCheckTLSCreds(driver, vm, asyncJob) < 0)
@@ -412,8 +412,8 @@ qemuMigrationParamsResetTLS(virQEMUDriverPtr driver,
     qemuDomainDelTLSObjects(driver, vm, asyncJob, secAlias, tlsAlias);
     qemuDomainSecretInfoFree(&priv->migSecinfo);
 
-    if (VIR_STRDUP(migParams->tlsCreds, "") < 0 ||
-        VIR_STRDUP(migParams->tlsHostname, "") < 0 ||
+    if (VIR_STRDUP(migParams->params.tlsCreds, "") < 0 ||
+        VIR_STRDUP(migParams->params.tlsHostname, "") < 0 ||
         qemuMigrationParamsSet(driver, vm, asyncJob, migParams) < 0)
         goto cleanup;
 
diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h
index 247455b1cd..f5e64dcc1d 100644
--- a/src/qemu/qemu_migration_params.h
+++ b/src/qemu/qemu_migration_params.h
@@ -47,22 +47,29 @@ struct _qemuMigrationCompression {
 };
 
 
-qemuMonitorMigrationParamsPtr
+typedef struct _qemuMigrationParams qemuMigrationParams;
+typedef qemuMigrationParams *qemuMigrationParamsPtr;
+struct _qemuMigrationParams {
+    qemuMonitorMigrationParams params;
+};
+
+
+qemuMigrationParamsPtr
 qemuMigrationParamsNew(void);
 
-qemuMonitorMigrationParamsPtr
+qemuMigrationParamsPtr
 qemuMigrationParamsFromFlags(virTypedParameterPtr params,
                              int nparams,
                              unsigned long flags);
 
 void
-qemuMigrationParamsFree(qemuMonitorMigrationParamsPtr migParams);
+qemuMigrationParamsFree(qemuMigrationParamsPtr migParams);
 
 int
 qemuMigrationParamsSet(virQEMUDriverPtr driver,
                        virDomainObjPtr vm,
                        int asyncJob,
-                       qemuMonitorMigrationParamsPtr migParams);
+                       qemuMigrationParamsPtr migParams);
 
 int
 qemuMigrationParamsCheckSetupTLS(virQEMUDriverPtr driver,
@@ -78,20 +85,20 @@ qemuMigrationParamsAddTLSObjects(virQEMUDriverPtr driver,
                                  int asyncJob,
                                  char **tlsAlias,
                                  char **secAlias,
-                                 qemuMonitorMigrationParamsPtr migParams);
+                                 qemuMigrationParamsPtr migParams);
 
 int
 qemuMigrationParamsSetEmptyTLS(virQEMUDriverPtr driver,
                                virDomainObjPtr vm,
                                int asyncJob,
-                               qemuMonitorMigrationParamsPtr migParams);
+                               qemuMigrationParamsPtr migParams);
 
 int
 qemuMigrationParamsSetCompression(virQEMUDriverPtr driver,
                                   virDomainObjPtr vm,
                                   int asyncJob,
                                   qemuMigrationCompressionPtr compression,
-                                  qemuMonitorMigrationParamsPtr migParams);
+                                  qemuMigrationParamsPtr migParams);
 
 void
 qemuMigrationParamsReset(virQEMUDriverPtr driver,
-- 
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