migrate: add log for guest fstrim

and make a failure noticable.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2022-04-25 14:31:11 +02:00 committed by Fabian Grünbichler
parent 73b8b0bc49
commit 0028391f95

View File

@ -1170,14 +1170,23 @@ sub phase3_cleanup {
$self->{errors} = 1;
}
}
}
if (
$self->{storage_migration}
&& PVE::QemuServer::parse_guest_agent($conf)->{fstrim_cloned_disks}
&& $self->{running}
) {
if (!$self->{vm_was_paused}) {
$self->log('info', "issuing guest fstrim");
my $cmd = [@{$self->{rem_ssh}}, 'qm', 'guest', 'cmd', $vmid, 'fstrim'];
eval { PVE::Tools::run_command($cmd, outfunc => sub {}, errfunc => sub {}) };
if (my $err = $@) {
$self->log('err', "fstrim failed - $err");
$self->{errors} = 1;
}
} else {
$self->log('info', "skipping guest fstrim, because VM is paused");
}
}
}