qmp: use migrate-set-parameters in favor of deprecated options

migrate_set_downtime, migrate_set_speed and migrate-set-cachesize have
all been deprecated since 2.8 or 2.11 [0]. They still work, but no
reason not to use the correct version.

Note that the downtime-limit parameter switched from seconds to
milliseconds, so convert to that. Slightly improve log output with units
while at it.

[0] https://qemu.weilnetz.de/doc/qemu-doc.html#Deprecated-features

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
This commit is contained in:
Stefan Reiter 2020-02-06 10:53:54 +01:00 committed by Thomas Lamprecht
parent 922869f223
commit 485449e37b

View File

@ -706,6 +706,14 @@ sub phase2 {
# load_defaults # load_defaults
my $defaults = PVE::QemuServer::load_defaults(); my $defaults = PVE::QemuServer::load_defaults();
$self->log('info', "set migration_caps");
eval {
PVE::QemuServer::set_migration_caps($vmid);
};
warn $@ if $@;
my $qemu_migrate_params = {};
# migrate speed can be set via bwlimit (datacenter.cfg and API) and via the # migrate speed can be set via bwlimit (datacenter.cfg and API) and via the
# migrate_speed parameter in qm.conf - take the lower of the two. # migrate_speed parameter in qm.conf - take the lower of the two.
my $bwlimit = PVE::Storage::get_bandwidth_limit('migrate', undef, $opt_bwlimit) // 0; my $bwlimit = PVE::Storage::get_bandwidth_limit('migrate', undef, $opt_bwlimit) // 0;
@ -721,38 +729,31 @@ sub phase2 {
# qmp takes migrate_speed in B/s. # qmp takes migrate_speed in B/s.
$migrate_speed *= 1024; $migrate_speed *= 1024;
$self->log('info', "migrate_set_speed: $migrate_speed"); $self->log('info', "migration speed limit: $migrate_speed B/s");
eval { $qemu_migrate_params->{'max-bandwidth'} = int($migrate_speed);
mon_cmd($vmid, "migrate_set_speed", value => int($migrate_speed));
};
$self->log('info', "migrate_set_speed error: $@") if $@;
my $migrate_downtime = $defaults->{migrate_downtime}; my $migrate_downtime = $defaults->{migrate_downtime};
$migrate_downtime = $conf->{migrate_downtime} if defined($conf->{migrate_downtime}); $migrate_downtime = $conf->{migrate_downtime} if defined($conf->{migrate_downtime});
if (defined($migrate_downtime)) { if (defined($migrate_downtime)) {
$self->log('info', "migrate_set_downtime: $migrate_downtime"); # migrate-set-parameters expects limit in ms
eval { $migrate_downtime *= 1000;
mon_cmd($vmid, "migrate_set_downtime", value => int($migrate_downtime*100)/100); $self->log('info', "migration downtime limit: $migrate_downtime ms");
}; $qemu_migrate_params->{'downtime-limit'} = int($migrate_downtime);
$self->log('info', "migrate_set_downtime error: $@") if $@;
} }
$self->log('info', "set migration_caps");
eval {
PVE::QemuServer::set_migration_caps($vmid);
};
warn $@ if $@;
# set cachesize to 10% of the total memory # set cachesize to 10% of the total memory
my $memory = $conf->{memory} || $defaults->{memory}; my $memory = $conf->{memory} || $defaults->{memory};
my $cachesize = int($memory * 1048576 / 10); my $cachesize = int($memory * 1048576 / 10);
$cachesize = round_powerof2($cachesize); $cachesize = round_powerof2($cachesize);
$self->log('info', "set cachesize: $cachesize"); $self->log('info', "migration cachesize: $cachesize B");
$qemu_migrate_params->{'xbzrle-cache-size'} = int($cachesize);
$self->log('info', "set migration parameters");
eval { eval {
mon_cmd($vmid, "migrate-set-cache-size", value => int($cachesize)); mon_cmd($vmid, "migrate-set-parameters", %{$qemu_migrate_params});
}; };
$self->log('info', "migrate-set-cache-size error: $@") if $@; $self->log('info', "migrate-set-parameters error: $@") if $@;
if (PVE::QemuServer::vga_conf_has_spice($conf->{vga})) { if (PVE::QemuServer::vga_conf_has_spice($conf->{vga})) {
my $rpcenv = PVE::RPCEnvironment::get(); my $rpcenv = PVE::RPCEnvironment::get();