we currently only call deactivate_volumes, but we actually want to call the whole vm_stop_cleanup, since that is not invoked by the vm_stop above (we cannot parse the config anymore) and might do other cleanups we also want to do (like mdev cleanup).
For this to work properly we have to clone the original config at the beginning, since we might modify the volids. To get a better log output, add a `noerr` parameter to `vm_stop_cleanup` that is enabled by default and decides if we `die` or `warn` on an error. That way we can catch the error in the migrate code and log it properly. Signed-off-by: Dominik Csapak <d.csa...@proxmox.com> --- PVE/QemuMigrate.pm | 12 ++++++------ PVE/QemuServer.pm | 12 ++++++++++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm index b3570770..1be12bf1 100644 --- a/PVE/QemuMigrate.pm +++ b/PVE/QemuMigrate.pm @@ -5,6 +5,7 @@ use warnings; use IO::File; use IPC::Open2; +use Storable qw(dclone); use Time::HiRes qw( usleep ); use PVE::Cluster; @@ -1460,7 +1461,8 @@ sub phase3_cleanup { my $tunnel = $self->{tunnel}; - my $sourcevollist = PVE::QemuServer::get_vm_volumes($conf); + # we'll need an unmodified copy of the config later for the cleanup + my $oldconf = dclone($conf); if ($self->{volume_map} && !$self->{opts}->{remote}) { my $target_drives = $self->{target_drive}; @@ -1591,12 +1593,10 @@ sub phase3_cleanup { $self->{errors} = 1; } - # always deactivate volumes - avoid lvm LVs to be active on several nodes - eval { - PVE::Storage::deactivate_volumes($self->{storecfg}, $sourcevollist); - }; + # stop with nocheck does not do a cleanup, so do it here with the original config + eval { PVE::QemuServer::vm_stop_cleanup($self->{storecfg}, $vmid, $oldconf, 0) }; if (my $err = $@) { - $self->log('err', $err); + $self->log('err', "cleanup for vm failed - $err"); $self->{errors} = 1; } diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index d53e9693..54f73093 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -6160,7 +6160,9 @@ sub cleanup_pci_devices { } sub vm_stop_cleanup { - my ($storecfg, $vmid, $conf, $keepActive, $apply_pending_changes) = @_; + my ($storecfg, $vmid, $conf, $keepActive, $apply_pending_changes, $noerr) = @_; + + $noerr //= 1; # defaults to warning eval { @@ -6186,7 +6188,13 @@ sub vm_stop_cleanup { vmconfig_apply_pending($vmid, $conf, $storecfg) if $apply_pending_changes; }; - warn $@ if $@; # avoid errors - just warn + if (my $err = $@) { + if ($noerr) { + warn $err; + } else { + die $err; + } + } } # call only in locked context -- 2.39.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel