we destroy target vm in case of failure in phase2 --- PVE/QemuMigrate.pm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm index 87afde6..6059a10 100644 --- a/PVE/QemuMigrate.pm +++ b/PVE/QemuMigrate.pm @@ -913,6 +913,9 @@ sub phase2_cleanup { my ($self, $vmid, $err) = @_; return if !$self->{errors}; + + my $targetvmid = $self->{opts}->{targetvmid} ? $self->{opts}->{targetvmid} : $vmid; + $self->{phase2errors} = 1; $self->log('info', "aborting phase 2 - cleanup resources"); @@ -946,13 +949,26 @@ sub phase2_cleanup { my $nodename = PVE::INotify::nodename(); - my $cmd = [@{$self->{rem_ssh}}, 'qm', 'stop', $vmid, '--skiplock', '--migratedfrom', $nodename]; + my $cmd = [@{$self->{rem_ssh}}, 'qm', 'stop', $targetvmid, '--skiplock']; + push @$cmd, '--migratedfrom', $nodename if !$self->{opts}->{migration_external}; + eval{ PVE::Tools::run_command($cmd, outfunc => sub {}, errfunc => sub {}) }; if (my $err = $@) { $self->log('err', $err); $self->{errors} = 1; } + if ($self->{opts}->{migration_external}) { + my $cmd = [@{$self->{rem_ssh}}, 'qm', 'destroy', $targetvmid, '--skiplock']; + + eval{ PVE::Tools::run_command($cmd, outfunc => sub {}, errfunc => sub {}) }; + if (my $err = $@) { + $self->log('err', $err); + $self->{errors} = 1; + } + + } + if ($self->{tunnel}) { eval { finish_tunnel($self, $self->{tunnel}); }; if (my $err = $@) { -- 2.11.0 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel