render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
a1c947
From 4c906acec14efe3893491d749465ed7e285a825c Mon Sep 17 00:00:00 2001
a1c947
Message-Id: <4c906acec14efe3893491d749465ed7e285a825c@dist-git>
a1c947
From: Jiri Denemark <jdenemar@redhat.com>
a1c947
Date: Wed, 29 Jun 2022 12:00:03 +0200
a1c947
Subject: [PATCH] qemu: Pass migration flags to qemuMigrationParamsApply
a1c947
a1c947
The flags will later be used to determine which parameters should
a1c947
actually be applied.
a1c947
a1c947
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a1c947
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
a1c947
(cherry picked from commit 0eae541257cd4f01c9d90db62056ad8d03c5af23)
a1c947
a1c947
https://bugzilla.redhat.com/show_bug.cgi?id=2111070
a1c947
a1c947
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a1c947
---
a1c947
 src/qemu/qemu_driver.c           |  6 +++---
a1c947
 src/qemu/qemu_migration.c        |  8 ++++----
a1c947
 src/qemu/qemu_migration_params.c | 11 ++++++++---
a1c947
 src/qemu/qemu_migration_params.h |  3 ++-
a1c947
 4 files changed, 17 insertions(+), 11 deletions(-)
a1c947
a1c947
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
a1c947
index 847c96639d..17e4c23199 100644
a1c947
--- a/src/qemu/qemu_driver.c
a1c947
+++ b/src/qemu/qemu_driver.c
a1c947
@@ -13091,7 +13091,7 @@ qemuDomainMigrateSetMaxDowntime(virDomainPtr dom,
a1c947
             goto endjob;
a1c947
 
a1c947
         if (qemuMigrationParamsApply(driver, vm, VIR_ASYNC_JOB_NONE,
a1c947
-                                     migParams) < 0)
a1c947
+                                     migParams, 0) < 0)
a1c947
             goto endjob;
a1c947
     } else {
a1c947
         qemuDomainObjEnterMonitor(driver, vm);
a1c947
@@ -13273,7 +13273,7 @@ qemuDomainMigrateSetCompressionCache(virDomainPtr dom,
a1c947
             goto endjob;
a1c947
 
a1c947
         if (qemuMigrationParamsApply(driver, vm, VIR_ASYNC_JOB_NONE,
a1c947
-                                     migParams) < 0)
a1c947
+                                     migParams, 0) < 0)
a1c947
             goto endjob;
a1c947
     } else {
a1c947
         qemuDomainObjEnterMonitor(driver, vm);
a1c947
@@ -13360,7 +13360,7 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom,
a1c947
             goto endjob;
a1c947
 
a1c947
         if (qemuMigrationParamsApply(driver, vm, VIR_ASYNC_JOB_NONE,
a1c947
-                                     migParams) < 0)
a1c947
+                                     migParams, 0) < 0)
a1c947
             goto endjob;
a1c947
     } else {
a1c947
         int rc;
a1c947
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
a1c947
index 76903d612b..8cbd73a809 100644
a1c947
--- a/src/qemu/qemu_migration.c
a1c947
+++ b/src/qemu/qemu_migration.c
a1c947
@@ -3259,7 +3259,7 @@ qemuMigrationDstPrepareActive(virQEMUDriver *driver,
a1c947
     }
a1c947
 
a1c947
     if (qemuMigrationParamsApply(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN,
a1c947
-                                 migParams) < 0)
a1c947
+                                 migParams, flags) < 0)
a1c947
         goto error;
a1c947
 
a1c947
     if (mig->nbd &&
a1c947
@@ -4847,7 +4847,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
a1c947
         goto error;
a1c947
 
a1c947
     if (qemuMigrationParamsApply(driver, vm, VIR_ASYNC_JOB_MIGRATION_OUT,
a1c947
-                                 migParams) < 0)
a1c947
+                                 migParams, flags) < 0)
a1c947
         goto error;
a1c947
 
a1c947
     if (flags & VIR_MIGRATE_ZEROCOPY) {
a1c947
@@ -6941,7 +6941,7 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm,
a1c947
                                       QEMU_DOMAIN_MIG_BANDWIDTH_MAX * 1024 * 1024) < 0)
a1c947
             return -1;
a1c947
 
a1c947
-        if (qemuMigrationParamsApply(driver, vm, asyncJob, migParams) < 0)
a1c947
+        if (qemuMigrationParamsApply(driver, vm, asyncJob, migParams, 0) < 0)
a1c947
             return -1;
a1c947
 
a1c947
         priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX;
a1c947
@@ -7037,7 +7037,7 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm,
a1c947
                                           QEMU_MIGRATION_PARAM_MAX_BANDWIDTH,
a1c947
                                           saveMigBandwidth * 1024 * 1024) == 0)
a1c947
                 ignore_value(qemuMigrationParamsApply(driver, vm, asyncJob,
a1c947
-                                                      migParams));
a1c947
+                                                      migParams, 0));
a1c947
         } else {
a1c947
             if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
a1c947
                 qemuMonitorSetMigrationSpeed(priv->mon, saveMigBandwidth);
a1c947
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
a1c947
index cc66ed8229..398c07efd0 100644
a1c947
--- a/src/qemu/qemu_migration_params.c
a1c947
+++ b/src/qemu/qemu_migration_params.c
a1c947
@@ -833,8 +833,10 @@ qemuMigrationCapsToJSON(virBitmap *caps,
a1c947
  * @vm: domain object
a1c947
  * @asyncJob: migration job
a1c947
  * @migParams: migration parameters to send to QEMU
a1c947
+ * @apiFlags: migration flags, some of them may affect which parameters are applied
a1c947
  *
a1c947
- * Send all parameters stored in @migParams to QEMU.
a1c947
+ * Send parameters stored in @migParams to QEMU. If @apiFlags is non-zero, some
a1c947
+ * parameters that do not make sense for the enabled flags will be ignored.
a1c947
  *
a1c947
  * Returns 0 on success, -1 on failure.
a1c947
  */
a1c947
@@ -842,7 +844,8 @@ int
a1c947
 qemuMigrationParamsApply(virQEMUDriver *driver,
a1c947
                          virDomainObj *vm,
a1c947
                          int asyncJob,
a1c947
-                         qemuMigrationParams *migParams)
a1c947
+                         qemuMigrationParams *migParams,
a1c947
+                         unsigned long apiFlags G_GNUC_UNUSED)
a1c947
 {
a1c947
     qemuDomainObjPrivate *priv = vm->privateData;
a1c947
     bool xbzrleCacheSize_old = false;
a1c947
@@ -1245,7 +1248,9 @@ qemuMigrationParamsReset(virQEMUDriver *driver,
a1c947
     if (!virDomainObjIsActive(vm) || !origParams)
a1c947
         goto cleanup;
a1c947
 
a1c947
-    if (qemuMigrationParamsApply(driver, vm, asyncJob, origParams) < 0)
a1c947
+    /* Do not pass apiFlags to qemuMigrationParamsApply here to make sure all
a1c947
+     * parameters and capabilities are reset. */
a1c947
+    if (qemuMigrationParamsApply(driver, vm, asyncJob, origParams, 0) < 0)
a1c947
         goto cleanup;
a1c947
 
a1c947
     qemuMigrationParamsResetTLS(driver, vm, asyncJob, origParams, apiFlags);
a1c947
diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h
a1c947
index d1184acded..9e990e09bd 100644
a1c947
--- a/src/qemu/qemu_migration_params.h
a1c947
+++ b/src/qemu/qemu_migration_params.h
a1c947
@@ -98,7 +98,8 @@ int
a1c947
 qemuMigrationParamsApply(virQEMUDriver *driver,
a1c947
                          virDomainObj *vm,
a1c947
                          int asyncJob,
a1c947
-                         qemuMigrationParams *migParams);
a1c947
+                         qemuMigrationParams *migParams,
a1c947
+                         unsigned long apiFlags);
a1c947
 
a1c947
 int
a1c947
 qemuMigrationParamsEnableTLS(virQEMUDriver *driver,
a1c947
-- 
a1c947
2.35.1
a1c947