[pve-devel] [PATCH V2] - fix setting migration parameters

Stefan Priebe - Profihost AG s.priebe at profihost.ag
Thu Dec 27 07:22:13 CET 2012


Hi,

Am 27.12.2012 um 06:55 schrieb Dietmar Maurer <dietmar at proxmox.com>:

>> - move migration speed/downtime from QemuServer vm_start to
>>   QemuMigrate phase2
> 
> what is the advantage?

Cleaner code. Nobody expects that those values were set at vm start.


>> - lower default migration downtime value to 0
> 
> We do not want that, because this is known to cause long wait times on busy VMs.

 A value of 1 does not work for me. Whole vm stalls immediately and socket is unavailable. Migration than takes 5-10 minutes of an idle vm.




> 
>> ---
>> PVE/QemuMigrate.pm |   30 ++++++++++++++++++++++++++----
>> PVE/QemuServer.pm  |   17 +----------------
>> 2 files changed, 27 insertions(+), 20 deletions(-)
>> 
>> diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm index
>> 0711681..af8813c 100644
>> --- a/PVE/QemuMigrate.pm
>> +++ b/PVE/QemuMigrate.pm
>> @@ -323,24 +323,46 @@ sub phase2 {
>>     $self->{tunnel} = $self->fork_tunnel($self->{nodeip}, $lport, $rport);
>> 
>>     $self->log('info', "starting online/live migration on port $lport");
>> -    # start migration
>> 
>> -    my $start = time();
>> +    # load_defaults
>> +    my $defaults = PVE::QemuServer::load_defaults();
>> +
>> +    # always set migrate speed (overwrite kvm default of 32m)
>> +    # we set a very hight 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;
> 
> This makes sure that $migrate_speed is an integer.
> 
>> +    $self->log('info', "migrate_set_speed: $migrate_speed");
>> +    eval {
>> +        # *1 ensures that JSON module convert the value to number
>> +        PVE::QemuServer::vm_mon_cmd_nocheck($vmid,
>> "migrate_set_speed", value => $migrate_speed*1);
> 
> so $migrate_speed*1 is not needed here.
> 
>> +    };
>> +    $self->log('info', "migrate_set_speed error: $@") if $@;
>> +
>> +    my $migrate_downtime = $defaults->{migrate_downtime};
>> +    $migrate_downtime = $conf->{migrate_downtime} if defined($conf-
>>> {migrate_downtime});
>> +    $self->log('info', "migrate_set_downtime: $migrate_downtime");
>> +    eval {
>> +        # *1 ensures that JSON module convert the value to number
>> +        PVE::QemuServer::vm_mon_cmd_nocheck($vmid,
>> "migrate_set_downtime", value => $migrate_downtime*1);
> 
> Please use:
> 
> value => int($migrate_downtime)
> 
> Or what is the advantage of '*1'?
> 
> 
>> +    # start migration
>> +    my $start = time();
> 
> what is this?
> 
>>     eval {
>>         PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate", uri =>
>> "tcp:localhost:$lport");
>>     };
>> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index
>> 1d4c275..bb7fd16 100644
>> --- a/PVE/QemuServer.pm
>> +++ b/PVE/QemuServer.pm
>> @@ -385,7 +385,7 @@ EODESCR
>>    type => 'integer',
>>    description => "Set maximum tolerated downtime (in seconds) for
>> migrations.",
>>    minimum => 0,
>> -    default => 1,
>> +    default => 0,
>>     },
>>     cdrom => {
>>    optional => 1,
>> @@ -2979,21 +2979,6 @@ sub vm_start {
>>        warn $@ if $@;
>>    }
>> 
>> -    # always set migrate speed (overwrite kvm default of 32m)
>> -    # we set a very hight 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;
>> -    eval {
>> -        vm_mon_cmd_nocheck($vmid, "migrate_set_speed", value =>
>> $migrate_speed);
>> -    };
>> -
>> -    my $migrate_downtime = $defaults->{migrate_downtime};
>> -    $migrate_downtime = $conf->{migrate_downtime} if defined($conf-
>>> {migrate_downtime});
>> -    if (defined($migrate_downtime)) {
>> -        eval { vm_mon_cmd_nocheck($vmid, "migrate_set_downtime",
>> value => $migrate_downtime); };
>> -    }
>> -
>>    if($migratedfrom) {
>>        my $capabilities = {};
>>        $capabilities->{capability} =  "xbzrle";
>> --
>> 1.7.10.4
>> 
>> _______________________________________________
>> pve-devel mailing list
>> pve-devel at pve.proxmox.com
>> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 



More information about the pve-devel mailing list