[libvirt] [PATCH V2] Set qemu migration speed unlimited when migrating to file

Jim Fehlig jfehlig at novell.com
Thu Aug 4 17:35:08 UTC 2011


Discussed previously:

https://www.redhat.com/archives/libvir-list/2011-August/msg00166.html

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

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

There is no reason to throttle migration when targeting a file.  For
dump and save operations, set migration speed to unlimited prior to
migration and restore to 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.

V2:
 - Use qemuDomainObjEnterMonitorAsync() instead of qemuDomainObjEnterMonitor()
 - Check return status of qemuDomainObjEnterMonitorAsync()
---
 src/qemu/qemu_migration.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 7aeea69..fa05ccf 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2676,6 +2676,14 @@ qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
     virCommandPtr cmd = NULL;
     int pipeFD[2] = { -1, -1 };
 
+    /* No need for qemu default of 32MiB/s when migrating to a file.
+       Default speed unit is MB, so set to unlimited with INT64_MAX / 1M.
+       Failure to change migration speed is not fatal. */
+    if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
+        qemuMonitorSetMigrationSpeed(priv->mon, INT64_MAX / (1024 * 1024));
+        qemuDomainObjExitMonitorWithDriver(driver, vm);
+    }
+
     if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
         (!compressor || pipe(pipeFD) == 0)) {
         /* All right! We can use fd migration, which means that qemu
@@ -2783,6 +2791,12 @@ qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
     ret = 0;
 
 cleanup:
+    /* Restore migration speed to 32MiB/s default */
+    if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
+        qemuMonitorSetMigrationSpeed(priv->mon, (32 << 20));
+        qemuDomainObjExitMonitorWithDriver(driver, vm);
+    }
+
     VIR_FORCE_CLOSE(pipeFD[0]);
     VIR_FORCE_CLOSE(pipeFD[1]);
     virCommandFree(cmd);
-- 
1.7.5.4




More information about the libvir-list mailing list