X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=PVE%2FQemuMigrate.pm;h=e9e9075ab4e3373cfa8505e08d6d1d1b494b8274;hb=b4496b9ed5994cb624806db4edf5dbc24576bd9e;hp=937a85529049b4073227fe6f1c6fa796f0f4a21c;hpb=d296ed08d3bd85d9ccd730e12f7b7243bf2e08c0;p=qemu-server.git diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm index 937a855..e9e9075 100644 --- a/PVE/QemuMigrate.pm +++ b/PVE/QemuMigrate.pm @@ -318,6 +318,7 @@ sub sync_disks { my ($volid, $attr) = @_; if ($volid =~ m|^/|) { + return if $attr->{shared}; $local_volumes->{$volid}->{ref} = 'config'; die "local file/device\n"; } @@ -650,7 +651,7 @@ sub phase2 { if (scalar(keys %{$self->{target_drive}}) != scalar @{$self->{online_local_volumes}}); foreach my $drive (keys %{$self->{target_drive}}){ my $nbd_uri = $self->{target_drive}->{$drive}->{nbd_uri}; - $self->log('info', "$drive: start migration to to $nbd_uri"); + $self->log('info', "$drive: start migration to $nbd_uri"); PVE::QemuServer::qemu_drive_mirror($vmid, $drive, $nbd_uri, $vmid, undef, $self->{storage_migration_jobs}, 1); } } @@ -691,6 +692,8 @@ sub phase2 { # set cachesize to 10% of the total memory my $memory = $conf->{memory} || $defaults->{memory}; my $cachesize = int($memory * 1048576 / 10); + $cachesize = round_powerof2($cachesize); + $self->log('info', "set cachesize: $cachesize"); eval { PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate-set-cache-size", value => int($cachesize)); @@ -963,6 +966,11 @@ sub phase3_cleanup { $self->{errors} = 1; } } + + if ($self->{storage_migration} && PVE::QemuServer::parse_guest_agent($conf)->{fstrim_cloned_disks} && $self->{running}) { + my $cmd = [@{$self->{rem_ssh}}, 'qm', 'guest', 'cmd', $vmid, 'fstrim']; + eval{ PVE::Tools::run_command($cmd, outfunc => sub {}, errfunc => sub {}) }; + } } # close tunnel on successful migration, on error phase2_cleanup closed it @@ -1031,4 +1039,9 @@ sub final_cleanup { # nothing to do } +sub round_powerof2 { + return 1 if $_[0] < 2; + return 2 << int(log($_[0]-1)/log(2)); +} + 1;