[pve-devel] [PATCH v2 qemu-server 13/16] phase3_cleanup: add stop_local_vm

Alexandre Derumier aderumier at odiso.com
Mon Mar 9 16:24:36 CET 2020


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuMigrate.pm | 40 ++++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 3aaee51..6b14c25 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -639,22 +639,7 @@ sub phase3_cleanup {
 
     finish_spice_migration($self, $vmid);
 
-    # always stop local VM
-    eval { PVE::QemuServer::vm_stop($self->{storecfg}, $vmid, 1, 1); };
-    if (my $err = $@) {
-	$self->log('err', "stopping vm failed - $err");
-	$self->{errors} = 1;
-    }
-
-    # always deactivate volumes - avoid lvm LVs to be active on several nodes
-    eval {
-	my $vollist = PVE::QemuServer::get_vm_volumes($conf);
-	PVE::Storage::deactivate_volumes($self->{storecfg}, $vollist);
-    };
-    if (my $err = $@) {
-	$self->log('err', $err);
-	$self->{errors} = 1;
-    }
+    stop_local_vm($self, $vmid);
 
     if($self->{storage_migration}) {
 	# destroy local copies
@@ -1192,4 +1177,27 @@ sub finish_spice_migration {
     };
 }
 
+sub stop_local_vm {
+    my ($self, $vmid) = @_;
+
+    my $conf = $self->{vmconf};
+
+    # always stop local VM
+    eval { PVE::QemuServer::vm_stop($self->{storecfg}, $vmid, 1, 1); };
+    if (my $err = $@) {
+	$self->log('err', "stopping vm failed - $err");
+	$self->{errors} = 1;
+    }
+
+    # always deactivate volumes - avoid lvm LVs to be active on several nodes
+    eval {
+	my $vollist = PVE::QemuServer::get_vm_volumes($conf);
+	PVE::Storage::deactivate_volumes($self->{storecfg}, $vollist);
+    };
+    if (my $err = $@) {
+	$self->log('err', $err);
+	$self->{errors} = 1;
+    }
+}
+
 1;
-- 
2.20.1




More information about the pve-devel mailing list