[pve-devel] [PATCH] move migration speed/downtime from QemuServer vm_start to QemuMigrate phase2

Stefan Priebe s.priebe at profihost.ag
Wed Dec 26 21:44:21 CET 2012


Hello list,

this patch fixes my migration problems.

The strange thing is that there must be another bug too - NOT related to 
this patch.

My output looks like this:
Dec 26 21:42:24 migrate_set_speed: 8589934592
Dec 26 21:42:24 migrate_set_speed error: VM 105 qmp command 
'migrate_set_speed' failed - Invalid parameter type for 'value', 
expected: int
Dec 26 21:42:24 migrate_set_downtime: 1
Dec 26 21:42:24 migrate_set_downtime error: VM 105 qmp command 
'migrate_set_downtime' failed - Invalid parameter type for 'value', 
expected: number

To me these values and expected format seems to be OK.

Greets,
Stefan

Am 26.12.2012 21:41, schrieb Stefan Priebe:
> Signed-off-by: Stefan Priebe <s.priebe at profihost.ag>
> ---
>   PVE/QemuMigrate.pm |   28 ++++++++++++++++++++++++----
>   PVE/QemuServer.pm  |   15 ---------------
>   2 files changed, 24 insertions(+), 19 deletions(-)
>
> diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
> index 0711681..de84fed 100644
> --- a/PVE/QemuMigrate.pm
> +++ b/PVE/QemuMigrate.pm
> @@ -323,24 +323,44 @@ 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;
> +    $self->log('info', "migrate_set_speed: $migrate_speed");
> +    eval {
> +        PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate_set_speed", value => $migrate_speed);
> +    };
> +    $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 {
> +        PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate_set_downtime", value => $migrate_downtime);
> +    };
> +    $self->log('info', "migrate_set_downtime error: $@") if $@;
>
>       my $capabilities = {};
>       $capabilities->{capability} =  "xbzrle";
>       $capabilities->{state} = JSON::false;
> -
>       eval {
>   	PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate-set-capabilities", capabilities => [$capabilities]);
>       };
>
> -    #set cachesize 10% of the total memory
> +    # set cachesize 10% of the total memory
>       my $cachesize = int($conf->{memory}*1048576/10);
>       eval {
>   	PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate-set-cache-size", value => $cachesize);
>       };
>
> +    # start migration
> +    my $start = time();
>       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..d56fe65 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -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";
>



More information about the pve-devel mailing list