[pve-devel] [PATCH v3 qemu-server 5/7] migrate : phase2_cleanup : migrate_external
Alexandre Derumier
aderumier at odiso.com
Tue Nov 27 16:38:07 CET 2018
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 b4dc8f7..9e963d3 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -915,6 +915,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");
@@ -948,13 +951,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
More information about the pve-devel
mailing list