]> git.proxmox.com Git - qemu-server.git/commitdiff
migrate: add log for guest fstrim
authorFabian Ebner <f.ebner@proxmox.com>
Mon, 25 Apr 2022 12:31:11 +0000 (14:31 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 26 Apr 2022 09:42:25 +0000 (11:42 +0200)
and make a failure noticable.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/QemuMigrate.pm

index 891edfb2e0c1c35e0e2667dd39de0557abfc0652..c293e2948bc1f8ab23ad0dc1636169fafd3f2d12 100644 (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->{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 {}) };
+               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");
            }
        }
     }