[pve-devel] [PATCH qemu-server 13/15] phase3_cleanup: add stop_local_vm
Alexandre Derumier
aderumier at odiso.com
Mon Apr 29 12:01:28 CEST 2019
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/QemuMigrate.pm | 43 ++++++++++++++++++++++++++-----------------
1 file changed, 26 insertions(+), 17 deletions(-)
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 7529502..4b521fd 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -618,24 +618,9 @@ sub phase3_cleanup {
finish_livemigration($self, $vmid);
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
my $volids = $self->{online_local_volumes};
@@ -1168,4 +1153,28 @@ 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.11.0
More information about the pve-devel
mailing list