[pve-devel] [PATCH qemu-server 1/7] bwlimit: honor bwlimit for migrate qmp call

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Mar 29 10:17:28 CET 2019


On 3/29/19 8:28 AM, Stoiko Ivanov wrote:
> The 'migrate_speed' can be set in the VM config. Additionally migrate should
> honor the 'migrate' bwlimit set in datacenter.cfg (storage-specific limits play
> no role for memory+state migration) or the parameter provided to the API call.
> 
> With this patch a set bwlimit overrides the 'migrate_speed' setting.
> 
> Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
> ---
>  PVE/QemuMigrate.pm | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
> index ee605d8..8f4ee5b 100644
> --- a/PVE/QemuMigrate.pm
> +++ b/PVE/QemuMigrate.pm
> @@ -663,9 +663,11 @@ sub phase2 {
>  
>      # always set migrate speed (overwrite kvm default of 32m)
>      # we set a very high default of 8192m which is basically unlimited
> -    my $migrate_speed = $defaults->{migrate_speed} || 8192;
> -    $migrate_speed = $conf->{migrate_speed} || $migrate_speed;
> -    $migrate_speed = $migrate_speed * 1048576;
> +    my $migrate_speed = $conf->{migrate_speed} // ($defaults->{migrate_speed} || 8192*1024);
> +    #optionally override with $opt_bwlimit - with undef as storagelist

space between # and start of comment

> +    my $bwlimit = PVE::Storage::get_bandwidth_limit('migrate', undef, $opt_bwlimit);
> +    $migrate_speed = $bwlimit // $migrate_speed;

you could set $migrate_speed to $bwlimit initially and then do here a:
$migrate_speed //= $conf->{migrate_speed};
$migrate_speed //= $defaults->{migrate_speed} || 8192*1024;


could be maybe a bit nicer to see the order of defaults applied

> +    $migrate_speed *= 1024;
>      $self->log('info', "migrate_set_speed: $migrate_speed");
>      eval {
>          PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate_set_speed", value => int($migrate_speed));
> 




More information about the pve-devel mailing list