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

[libvirt] [PATCH 7/8] Set qemu migration speed unlimited when migrating to file



The qemu migration speed default is 32MiB/s as defined in migration.c

/* Migration speed throttling */
static int64_t max_throttle = (32 << 20);

The only reason to throttle migration when targeting a file is user
request.  If user has not changed the qemu default, set migration speed
to unlimited prior to migration, and restore to qemu default value after
migration.

Default units is MB for migrate_set_speed monitor command, so
(INT64_MAX / (1024 * 1024)) is used for unlimited migration speed.

Tested with both json and text monitors.
---
 src/qemu/qemu_migration.c |   22 ++++++++++++++++++++++
 src/qemu/qemu_migration.h |    3 +++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index a2dc97c..910cd8d 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2699,6 +2699,18 @@ qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
     bool restoreLabel = false;
     virCommandPtr cmd = NULL;
     int pipeFD[2] = { -1, -1 };
+    unsigned long initMigBandwidth = vm->def->migration_max_bandwidth;
+
+    /* If no user-defined migration speed is set, increase qemu default
+     * (32MiB/s) to unlimited since target is a file.
+     * Failure to change migration speed is not fatal. */
+    if (initMigBandwidth == 0) {
+        if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
+            qemuMonitorSetMigrationSpeed(priv->mon, QEMU_FILE_MIGRATION_SPEED_MAX);
+            vm->def->migration_max_bandwidth =  QEMU_FILE_MIGRATION_SPEED_MAX;
+            qemuDomainObjExitMonitorWithDriver(driver, vm);
+        }
+    }
 
     if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
         (!compressor || pipe(pipeFD) == 0)) {
@@ -2807,6 +2819,16 @@ qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
     ret = 0;
 
 cleanup:
+    /* If migration speed was changed from default, restore it. */
+    if (initMigBandwidth == 0) {
+        if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
+            qemuMonitorSetMigrationSpeed(priv->mon,
+                                         QEMU_DEFAULT_MIGRATION_SPEED_MAX);
+            vm->def->migration_max_bandwidth = 0;
+            qemuDomainObjExitMonitorWithDriver(driver, vm);
+        }
+    }
+
     VIR_FORCE_CLOSE(pipeFD[0]);
     VIR_FORCE_CLOSE(pipeFD[1]);
     virCommandFree(cmd);
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index 5c6921d..e49505e 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -53,6 +53,9 @@ enum qemuMigrationJobPhase {
 };
 VIR_ENUM_DECL(qemuMigrationJobPhase)
 
+# define QEMU_DEFAULT_MIGRATION_SPEED_MAX (32 << 20)
+# define QEMU_FILE_MIGRATION_SPEED_MAX    (INT64_MAX / (1024 * 1024))
+
 int qemuMigrationJobStart(struct qemud_driver *driver,
                           virDomainObjPtr vm,
                           enum qemuDomainAsyncJob job)
-- 
1.7.5.4


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