]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_migration: set bandwidth in priv during migration
authorKristina Hanicova <khanicov@redhat.com>
Fri, 8 Oct 2021 08:19:04 +0000 (10:19 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 13 Oct 2021 10:19:13 +0000 (12:19 +0200)
We did not set priv->migMaxBandwidth if '--bandwidth' was
specified as an option in the 'migrate' virsh command. This
caused in printing the wrong value if virsh command
'migrate-getspeed' was called during the migration. This patch
first sets the value to the given bandwidth (if one was
specified) and restores the previous value after the migration.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1806856

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_migration.c

index dd226ea4bcb595ea1d02b767089980e6afa6551e..71edcd5c62002ef5f4e03d76423f54e6cbad506b 100644 (file)
@@ -4013,6 +4013,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
     qemuMigrationIOThread *iothread = NULL;
     VIR_AUTOCLOSE fd = -1;
     unsigned long migrate_speed = resource ? resource : priv->migMaxBandwidth;
+    unsigned long restore_max_bandwidth = priv->migMaxBandwidth;
     virErrorPtr orig_err = NULL;
     unsigned int cookieFlags = 0;
     bool abort_on_error = !!(flags & VIR_MIGRATE_ABORT_ON_ERROR);
@@ -4025,6 +4026,8 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
     g_autofree char *timestamp = NULL;
     int rc;
 
+    priv->migMaxBandwidth = migrate_speed;
+
     VIR_DEBUG("driver=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
               "cookieout=%p, cookieoutlen=%p, flags=0x%lx, resource=%lu, "
               "spec=%p (dest=%d, fwd=%d), dconn=%p, graphicsuri=%s, "
@@ -4351,6 +4354,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
     if (events)
         priv->signalIOError = false;
 
+    priv->migMaxBandwidth = restore_max_bandwidth;
     virErrorRestore(&orig_err);
 
     return ret;