]> git.proxmox.com Git - qemu-server.git/commitdiff
Fix #1242 : clone_disk : call qga fstrim after clone
authorStoiko Ivanov <s.ivanov@proxmox.com>
Wed, 1 Aug 2018 18:29:05 +0000 (20:29 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 2 Aug 2018 09:35:50 +0000 (11:35 +0200)
Some storage like rbd or lvm can't keep thin-provising after a qemu-mirror.

Call qga guest-fstrim if qga is available and fstrim_cloned_disks is enabled
after move_disk and migrate.

Co-Authored-By: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
PVE/API2/Qemu.pm
PVE/QemuMigrate.pm

index 464ba7f8d2edc4fa6f778a18e1fd47238cc8deb8..b0af9d902bbdb4cf5681dcedf01dd3d5b4868887 100644 (file)
@@ -2969,6 +2969,10 @@ __PACKAGE__->register_method({
 
                    PVE::QemuConfig->write_config($vmid, $conf);
 
+                   if ($running && PVE::QemuServer::parse_guest_agent($conf)->{fstrim_cloned_disks} && PVE::QemuServer::qga_check_running($vmid)) {
+                       eval { PVE::QemuServer::vm_mon_cmd($vmid, "guest-fstrim"); };
+                   }
+
                    eval {
                        # try to deactivate volumes - avoid lvm LVs to be active on several nodes
                        PVE::Storage::deactivate_volumes($storecfg, [ $newdrive->{file} ])
index 27cf7e36eb3706d3cc73cadad0f0ea436a7fa4dc..e9e9075ab4e3373cfa8505e08d6d1d1b494b8274 100644 (file)
@@ -966,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