]>
Commit | Line | Data |
---|---|---|
3ea94c60 | 1 | package PVE::QemuMigrate; |
1ef75254 | 2 | |
1e3baf05 | 3 | use strict; |
3ea94c60 | 4 | use warnings; |
16e903f2 | 5 | use PVE::AbstractMigrate; |
3ea94c60 | 6 | use IO::File; |
1e3baf05 | 7 | use IPC::Open2; |
3ea94c60 DM |
8 | use PVE::INotify; |
9 | use PVE::Cluster; | |
1e3baf05 | 10 | use PVE::Storage; |
3ea94c60 | 11 | use PVE::QemuServer; |
e52bd94c | 12 | use Time::HiRes qw( usleep ); |
1e3baf05 | 13 | |
16e903f2 | 14 | use base qw(PVE::AbstractMigrate); |
1e3baf05 | 15 | |
1ef75254 | 16 | sub fork_command_pipe { |
46a84fd4 | 17 | my ($self, $cmd) = @_; |
19672434 | 18 | |
1ef75254 DM |
19 | my $reader = IO::File->new(); |
20 | my $writer = IO::File->new(); | |
21 | ||
22 | my $orig_pid = $$; | |
23 | ||
24 | my $cpid; | |
25 | ||
26 | eval { $cpid = open2($reader, $writer, @$cmd); }; | |
27 | ||
28 | my $err = $@; | |
29 | ||
30 | # catch exec errors | |
31 | if ($orig_pid != $$) { | |
46a84fd4 | 32 | $self->log('err', "can't fork command pipe\n"); |
19672434 DM |
33 | POSIX::_exit(1); |
34 | kill('KILL', $$); | |
1ef75254 DM |
35 | } |
36 | ||
37 | die $err if $err; | |
38 | ||
39 | return { writer => $writer, reader => $reader, pid => $cpid }; | |
40 | } | |
41 | ||
19672434 | 42 | sub finish_command_pipe { |
97439670 | 43 | my ($self, $cmdpipe, $timeout) = @_; |
1ef75254 DM |
44 | |
45 | my $writer = $cmdpipe->{writer}; | |
46 | my $reader = $cmdpipe->{reader}; | |
47 | ||
48 | $writer->close(); | |
49 | $reader->close(); | |
50 | ||
51 | my $cpid = $cmdpipe->{pid}; | |
52 | ||
97439670 DM |
53 | if ($timeout) { |
54 | for (my $i = 0; $i < $timeout; $i++) { | |
55 | return if !PVE::ProcFSTools::check_process_running($cpid); | |
56 | sleep(1); | |
57 | } | |
58 | } | |
59 | ||
60 | $self->log('info', "ssh tunnel still running - terminating now with SIGTERM\n"); | |
61 | kill(15, $cpid); | |
1ef75254 | 62 | |
97439670 DM |
63 | # wait again |
64 | for (my $i = 0; $i < 10; $i++) { | |
65 | return if !PVE::ProcFSTools::check_process_running($cpid); | |
66 | sleep(1); | |
67 | } | |
68 | ||
69 | $self->log('info', "ssh tunnel still running - terminating now with SIGKILL\n"); | |
70 | kill 9, $cpid; | |
71 | sleep 1; | |
1ef75254 DM |
72 | } |
73 | ||
1e3baf05 | 74 | sub fork_tunnel { |
16e903f2 | 75 | my ($self, $nodeip, $lport, $rport) = @_; |
1e3baf05 | 76 | |
16e903f2 | 77 | my $cmd = [@{$self->{rem_ssh}}, '-L', "$lport:localhost:$rport", |
1e3baf05 | 78 | 'qm', 'mtunnel' ]; |
19672434 | 79 | |
46a84fd4 | 80 | my $tunnel = $self->fork_command_pipe($cmd); |
1e3baf05 DM |
81 | |
82 | my $reader = $tunnel->{reader}; | |
83 | ||
84 | my $helo; | |
19672434 | 85 | eval { |
17eed025 | 86 | PVE::Tools::run_with_timeout(60, sub { $helo = <$reader>; }); |
1e3baf05 | 87 | die "no reply\n" if !$helo; |
1ef75254 | 88 | die "no quorum on target node\n" if $helo =~ m/^no quorum$/; |
19672434 | 89 | die "got strange reply from mtunnel ('$helo')\n" |
1e3baf05 DM |
90 | if $helo !~ m/^tunnel online$/; |
91 | }; | |
92 | my $err = $@; | |
93 | ||
94 | if ($err) { | |
46a84fd4 | 95 | $self->finish_command_pipe($tunnel); |
1e3baf05 DM |
96 | die "can't open migration tunnel - $err"; |
97 | } | |
98 | return $tunnel; | |
99 | } | |
100 | ||
19672434 | 101 | sub finish_tunnel { |
16e903f2 | 102 | my ($self, $tunnel) = @_; |
1e3baf05 DM |
103 | |
104 | my $writer = $tunnel->{writer}; | |
105 | ||
19672434 | 106 | eval { |
17eed025 | 107 | PVE::Tools::run_with_timeout(30, sub { |
1e3baf05 DM |
108 | print $writer "quit\n"; |
109 | $writer->flush(); | |
19672434 | 110 | }); |
1e3baf05 DM |
111 | }; |
112 | my $err = $@; | |
19672434 | 113 | |
97439670 | 114 | $self->finish_command_pipe($tunnel, 30); |
19672434 | 115 | |
1e3baf05 DM |
116 | die $err if $err; |
117 | } | |
118 | ||
16e903f2 DM |
119 | sub lock_vm { |
120 | my ($self, $vmid, $code, @param) = @_; | |
f5eb281a | 121 | |
16e903f2 DM |
122 | return PVE::QemuServer::lock_config($vmid, $code, @param); |
123 | } | |
ff1a2432 | 124 | |
16e903f2 DM |
125 | sub prepare { |
126 | my ($self, $vmid) = @_; | |
ff1a2432 | 127 | |
16e903f2 | 128 | my $online = $self->{opts}->{online}; |
3ea94c60 | 129 | |
16e903f2 | 130 | $self->{storecfg} = PVE::Storage::config(); |
3ea94c60 | 131 | |
16e903f2 DM |
132 | # test is VM exist |
133 | my $conf = $self->{vmconf} = PVE::QemuServer::load_config($vmid); | |
3ea94c60 | 134 | |
16e903f2 | 135 | PVE::QemuServer::check_lock($conf); |
3ea94c60 | 136 | |
16e903f2 DM |
137 | my $running = 0; |
138 | if (my $pid = PVE::QemuServer::check_running($vmid)) { | |
139 | die "cant migrate running VM without --online\n" if !$online; | |
140 | $running = $pid; | |
3ea94c60 DM |
141 | } |
142 | ||
16e903f2 DM |
143 | if (my $loc_res = PVE::QemuServer::check_local_resources($conf, 1)) { |
144 | if ($self->{running} || !$self->{opts}->{force}) { | |
145 | die "can't migrate VM which uses local devices\n"; | |
146 | } else { | |
147 | $self->log('info', "migrating VM which uses local devices"); | |
148 | } | |
3ea94c60 DM |
149 | } |
150 | ||
ff1a2432 DM |
151 | # activate volumes |
152 | my $vollist = PVE::QemuServer::get_vm_volumes($conf); | |
16e903f2 DM |
153 | PVE::Storage::activate_volumes($self->{storecfg}, $vollist); |
154 | ||
155 | # fixme: check if storage is available on both nodes | |
3ea94c60 DM |
156 | |
157 | # test ssh connection | |
16e903f2 DM |
158 | my $cmd = [ @{$self->{rem_ssh}}, '/bin/true' ]; |
159 | eval { $self->cmd_quiet($cmd); }; | |
3ea94c60 | 160 | die "Can't connect to destination address using public key\n" if $@; |
ff1a2432 | 161 | |
16e903f2 | 162 | return $running; |
3ea94c60 DM |
163 | } |
164 | ||
165 | sub sync_disks { | |
16e903f2 DM |
166 | my ($self, $vmid) = @_; |
167 | ||
168 | $self->log('info', "copying disk images"); | |
3ea94c60 | 169 | |
16e903f2 DM |
170 | my $conf = $self->{vmconf}; |
171 | ||
172 | $self->{volumes} = []; | |
3ea94c60 DM |
173 | |
174 | my $res = []; | |
175 | ||
176 | eval { | |
177 | ||
178 | my $volhash = {}; | |
179 | my $cdromhash = {}; | |
180 | ||
522c8f97 DM |
181 | my @sids = PVE::Storage::storage_ids($self->{storecfg}); |
182 | foreach my $storeid (@sids) { | |
183 | my $scfg = PVE::Storage::storage_config($self->{storecfg}, $storeid); | |
184 | next if $scfg->{shared}; | |
373ea579 DM |
185 | next if !PVE::Storage::storage_check_enabled($self->{storecfg}, $storeid, undef, 1); |
186 | ||
80b2cbd1 AD |
187 | # get list from PVE::Storage (for unused volumes) |
188 | my $dl = PVE::Storage::vdisk_list($self->{storecfg}, $storeid, $vmid); | |
189 | PVE::Storage::foreach_volid($dl, sub { | |
190 | my ($volid, $sid, $volname) = @_; | |
191 | ||
373ea579 | 192 | # check if storage is available on target node |
80b2cbd1 AD |
193 | PVE::Storage::storage_check_node($self->{storecfg}, $sid, $self->{node}); |
194 | ||
195 | $volhash->{$volid} = 1; | |
196 | }); | |
197 | } | |
3ea94c60 DM |
198 | |
199 | # and add used,owned/non-shared disks (just to be sure we have all) | |
200 | ||
201 | my $sharedvm = 1; | |
202 | PVE::QemuServer::foreach_drive($conf, sub { | |
203 | my ($ds, $drive) = @_; | |
204 | ||
205 | my $volid = $drive->{file}; | |
206 | return if !$volid; | |
207 | ||
208 | die "cant migrate local file/device '$volid'\n" if $volid =~ m|^/|; | |
209 | ||
210 | if (PVE::QemuServer::drive_is_cdrom($drive)) { | |
211 | die "cant migrate local cdrom drive\n" if $volid eq 'cdrom'; | |
212 | return if $volid eq 'none'; | |
213 | $cdromhash->{$volid} = 1; | |
214 | } | |
215 | ||
216 | my ($sid, $volname) = PVE::Storage::parse_volume_id($volid); | |
217 | ||
16e903f2 DM |
218 | # check if storage is available on both nodes |
219 | my $scfg = PVE::Storage::storage_check_node($self->{storecfg}, $sid); | |
220 | PVE::Storage::storage_check_node($self->{storecfg}, $sid, $self->{node}); | |
3ea94c60 DM |
221 | |
222 | return if $scfg->{shared}; | |
223 | ||
224 | die "can't migrate local cdrom '$volid'\n" if $cdromhash->{$volid}; | |
225 | ||
226 | $sharedvm = 0; | |
227 | ||
16e903f2 | 228 | my ($path, $owner) = PVE::Storage::path($self->{storecfg}, $volid); |
3ea94c60 DM |
229 | |
230 | die "can't migrate volume '$volid' - owned by other VM (owner = VM $owner)\n" | |
16e903f2 | 231 | if !$owner || ($owner != $self->{vmid}); |
3ea94c60 DM |
232 | |
233 | $volhash->{$volid} = 1; | |
234 | }); | |
235 | ||
16e903f2 | 236 | if ($self->{running} && !$sharedvm) { |
3ea94c60 DM |
237 | die "can't do online migration - VM uses local disks\n"; |
238 | } | |
239 | ||
240 | # do some checks first | |
241 | foreach my $volid (keys %$volhash) { | |
242 | my ($sid, $volname) = PVE::Storage::parse_volume_id($volid); | |
16e903f2 | 243 | my $scfg = PVE::Storage::storage_config($self->{storecfg}, $sid); |
3ea94c60 DM |
244 | |
245 | die "can't migrate '$volid' - storagy type '$scfg->{type}' not supported\n" | |
246 | if $scfg->{type} ne 'dir'; | |
247 | } | |
248 | ||
249 | foreach my $volid (keys %$volhash) { | |
250 | my ($sid, $volname) = PVE::Storage::parse_volume_id($volid); | |
16e903f2 DM |
251 | push @{$self->{volumes}}, $volid; |
252 | PVE::Storage::storage_migrate($self->{storecfg}, $volid, $self->{nodeip}, $sid); | |
3ea94c60 DM |
253 | } |
254 | }; | |
255 | die "Failed to sync data - $@" if $@; | |
256 | } | |
257 | ||
1e3baf05 | 258 | sub phase1 { |
16e903f2 | 259 | my ($self, $vmid) = @_; |
1e3baf05 | 260 | |
16e903f2 | 261 | $self->log('info', "starting migration of VM $vmid to node '$self->{node}' ($self->{nodeip})"); |
1e3baf05 | 262 | |
16e903f2 | 263 | my $conf = $self->{vmconf}; |
1e3baf05 DM |
264 | |
265 | # set migrate lock in config file | |
1858638f DM |
266 | $conf->{lock} = 'migrate'; |
267 | PVE::QemuServer::update_config_nolock($vmid, $conf, 1); | |
1e3baf05 | 268 | |
16e903f2 | 269 | sync_disks($self, $vmid); |
1ef75254 | 270 | |
1e3baf05 DM |
271 | }; |
272 | ||
16e903f2 DM |
273 | sub phase1_cleanup { |
274 | my ($self, $vmid, $err) = @_; | |
275 | ||
276 | $self->log('info', "aborting phase 1 - cleanup resources"); | |
277 | ||
1858638f DM |
278 | my $conf = $self->{vmconf}; |
279 | delete $conf->{lock}; | |
280 | eval { PVE::QemuServer::update_config_nolock($vmid, $conf, 1) }; | |
16e903f2 DM |
281 | if (my $err = $@) { |
282 | $self->log('err', $err); | |
283 | } | |
f5eb281a | 284 | |
16e903f2 DM |
285 | if ($self->{volumes}) { |
286 | foreach my $volid (@{$self->{volumes}}) { | |
287 | $self->log('err', "found stale volume copy '$volid' on node '$self->{node}'"); | |
288 | # fixme: try to remove ? | |
289 | } | |
290 | } | |
291 | } | |
292 | ||
1e3baf05 | 293 | sub phase2 { |
16e903f2 | 294 | my ($self, $vmid) = @_; |
1e3baf05 | 295 | |
16e903f2 DM |
296 | my $conf = $self->{vmconf}; |
297 | ||
46a84fd4 | 298 | $self->log('info', "starting VM $vmid on remote node '$self->{node}'"); |
1e3baf05 DM |
299 | |
300 | my $rport; | |
301 | ||
7e8dcf2c AD |
302 | my $nodename = PVE::INotify::nodename(); |
303 | ||
19672434 | 304 | ## start on remote node |
7e8dcf2c AD |
305 | my $cmd = [@{$self->{rem_ssh}}, 'qm', 'start', |
306 | $vmid, '--stateuri', 'tcp', '--skiplock', '--migratedfrom', $nodename]; | |
1e3baf05 | 307 | |
72afda82 | 308 | PVE::Tools::run_command($cmd, outfunc => sub { |
1e3baf05 DM |
309 | my $line = shift; |
310 | ||
311 | if ($line =~ m/^migration listens on port (\d+)$/) { | |
312 | $rport = $1; | |
313 | } | |
72afda82 | 314 | }, errfunc => sub {}); |
1e3baf05 DM |
315 | |
316 | die "unable to detect remote migration port\n" if !$rport; | |
317 | ||
16e903f2 | 318 | $self->log('info', "starting migration tunnel"); |
1ef75254 | 319 | |
1e3baf05 | 320 | ## create tunnel to remote port |
1ef75254 | 321 | my $lport = PVE::QemuServer::next_migrate_port(); |
16e903f2 | 322 | $self->{tunnel} = $self->fork_tunnel($self->{nodeip}, $lport, $rport); |
1e3baf05 | 323 | |
d68afb26 | 324 | $self->log('info', "starting online/live migration on port $lport"); |
1e3baf05 DM |
325 | # start migration |
326 | ||
327 | my $start = time(); | |
e18b0b99 AD |
328 | |
329 | my $capabilities = {}; | |
330 | $capabilities->{capability} = "xbzrle"; | |
331 | $capabilities->{state} = JSON::true; | |
332 | ||
333 | eval { | |
334 | PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate-set-capabilities", capabilities => [$capabilities]); | |
335 | }; | |
336 | ||
337 | #set cachesize 10% of the total memory | |
338 | my $cachesize = int($conf->{memory}*1048576/10); | |
339 | eval { | |
340 | PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate-set-cache-size", value => $cachesize); | |
341 | }; | |
342 | ||
5a7835f5 AD |
343 | eval { |
344 | PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate", uri => "tcp:localhost:$lport"); | |
345 | }; | |
346 | my $merr = $@; | |
1e3baf05 | 347 | |
a05b47a8 | 348 | my $lstat = 0; |
e52bd94c AD |
349 | my $usleep = 2000000; |
350 | my $i = 0; | |
b0b756c1 | 351 | my $err_count = 0; |
1e3baf05 | 352 | while (1) { |
e52bd94c AD |
353 | $i++; |
354 | my $avglstat = $lstat/$i if $lstat; | |
355 | ||
b0b756c1 DM |
356 | usleep($usleep); |
357 | my $stat; | |
358 | eval { | |
359 | $stat = PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "query-migrate"); | |
360 | }; | |
361 | if (my $err = $@) { | |
362 | $err_count++; | |
363 | warn "query migrate failed: $err\n"; | |
364 | if ($err_count <= 5) { | |
365 | usleep(1000000); | |
366 | next; | |
367 | } | |
368 | die "too many query migrate failures - aborting\n"; | |
369 | } | |
5a7835f5 | 370 | if ($stat->{status} =~ m/^(active|completed|failed|cancelled)$/im) { |
d68afb26 | 371 | $merr = undef; |
b0b756c1 | 372 | $err_count = 0; |
5a7835f5 | 373 | if ($stat->{status} eq 'completed') { |
1e3baf05 DM |
374 | my $delay = time() - $start; |
375 | if ($delay > 0) { | |
376 | my $mbps = sprintf "%.2f", $conf->{memory}/$delay; | |
16e903f2 | 377 | $self->log('info', "migration speed: $mbps MB/s"); |
1e3baf05 DM |
378 | } |
379 | } | |
f5eb281a | 380 | |
5a7835f5 | 381 | if ($stat->{status} eq 'failed' || $stat->{status} eq 'cancelled') { |
1e3baf05 DM |
382 | die "aborting\n" |
383 | } | |
384 | ||
a05b47a8 DM |
385 | if ($stat->{status} ne 'active') { |
386 | $self->log('info', "migration status: $stat->{status}"); | |
387 | last; | |
388 | } | |
389 | ||
390 | if ($stat->{ram}->{transferred} ne $lstat) { | |
391 | my $trans = $stat->{ram}->{transferred} || 0; | |
392 | my $rem = $stat->{ram}->{remaining} || 0; | |
393 | my $total = $stat->{ram}->{total} || 0; | |
e18b0b99 AD |
394 | my $xbzrlecachesize = $stat->{"xbzrle-cache"}->{"cache-size"} || 0; |
395 | my $xbzrlebytes = $stat->{"xbzrle-cache"}->{"bytes"} || 0; | |
396 | my $xbzrlepages = $stat->{"xbzrle-cache"}->{"pages"} || 0; | |
397 | my $xbzrlecachemiss = $stat->{"xbzrle-cache"}->{"cache-miss"} || 0; | |
398 | my $xbzrleoverflow = $stat->{"xbzrle-cache"}->{"overflow"} || 0; | |
e52bd94c AD |
399 | #reduce sleep if remainig memory if lower than the everage transfert |
400 | $usleep = 300000 if $rem < $avglstat; | |
a05b47a8 DM |
401 | |
402 | $self->log('info', "migration status: $stat->{status} (transferred ${trans}, " . | |
403 | "remaining ${rem}), total ${total})"); | |
e18b0b99 AD |
404 | |
405 | $self->log('info', "migration xbzrle cachesize: ${xbzrlecachesize} transferred ${xbzrlebytes} pages ${xbzrlepages} cachemiss ${xbzrlecachemiss} overflow ${xbzrleoverflow}"); | |
a05b47a8 DM |
406 | } |
407 | ||
408 | $lstat = $stat->{ram}->{transferred}; | |
e52bd94c | 409 | |
1e3baf05 | 410 | } else { |
d68afb26 | 411 | die $merr if $merr; |
5a7835f5 | 412 | die "unable to parse migration status '$stat->{status}' - aborting\n"; |
1e3baf05 | 413 | } |
a05b47a8 | 414 | } |
1e3baf05 | 415 | } |
16e903f2 | 416 | |
c04b5b04 AD |
417 | sub phase2_cleanup { |
418 | my ($self, $vmid, $err) = @_; | |
419 | ||
af30308f DM |
420 | return if !$self->{errors}; |
421 | $self->{phase2errors} = 1; | |
422 | ||
c04b5b04 AD |
423 | $self->log('info', "aborting phase 2 - cleanup resources"); |
424 | ||
425 | my $conf = $self->{vmconf}; | |
426 | delete $conf->{lock}; | |
427 | eval { PVE::QemuServer::update_config_nolock($vmid, $conf, 1) }; | |
428 | if (my $err = $@) { | |
429 | $self->log('err', $err); | |
430 | } | |
431 | ||
af30308f DM |
432 | # cleanup ressources on target host |
433 | my $nodename = PVE::INotify::nodename(); | |
434 | ||
435 | my $cmd = [@{$self->{rem_ssh}}, 'qm', 'stop', $vmid, '--skiplock', '--migratedfrom', $nodename]; | |
436 | eval{ PVE::Tools::run_command($cmd, outfunc => sub {}, errfunc => sub {}) }; | |
437 | if (my $err = $@) { | |
438 | $self->log('err', $err); | |
439 | $self->{errors} = 1; | |
440 | } | |
c04b5b04 AD |
441 | } |
442 | ||
16e903f2 DM |
443 | sub phase3 { |
444 | my ($self, $vmid) = @_; | |
f5eb281a | 445 | |
16e903f2 | 446 | my $volids = $self->{volumes}; |
af30308f | 447 | return if $self->{phase2errors}; |
16e903f2 DM |
448 | |
449 | # destroy local copies | |
450 | foreach my $volid (@$volids) { | |
451 | eval { PVE::Storage::vdisk_free($self->{storecfg}, $volid); }; | |
452 | if (my $err = $@) { | |
453 | $self->log('err', "removing local copy of '$volid' failed - $err"); | |
454 | $self->{errors} = 1; | |
455 | last if $err =~ /^interrupted by signal$/; | |
456 | } | |
457 | } | |
16e903f2 DM |
458 | } |
459 | ||
460 | sub phase3_cleanup { | |
461 | my ($self, $vmid, $err) = @_; | |
462 | ||
463 | my $conf = $self->{vmconf}; | |
af30308f | 464 | return if $self->{phase2errors}; |
16e903f2 | 465 | |
b8d20802 AD |
466 | # move config to remote node |
467 | my $conffile = PVE::QemuServer::config_file($vmid); | |
468 | my $newconffile = PVE::QemuServer::config_file($vmid, $self->{node}); | |
469 | ||
470 | die "Failed to move config to node '$self->{node}' - rename failed: $!\n" | |
471 | if !rename($conffile, $newconffile); | |
472 | ||
f5eb281a | 473 | # now that config file is move, we can resume vm on target if livemigrate |
b67900f1 | 474 | if ($self->{tunnel}) { |
b67900f1 AD |
475 | my $cmd = [@{$self->{rem_ssh}}, 'qm', 'resume', $vmid, '--skiplock']; |
476 | eval{ PVE::Tools::run_command($cmd, outfunc => sub {}, errfunc => sub {}) }; | |
f5eb281a | 477 | if (my $err = $@) { |
b67900f1 AD |
478 | $self->log('err', $err); |
479 | $self->{errors} = 1; | |
480 | } | |
481 | } | |
482 | ||
16e903f2 DM |
483 | # always stop local VM |
484 | eval { PVE::QemuServer::vm_stop($self->{storecfg}, $vmid, 1, 1); }; | |
485 | if (my $err = $@) { | |
486 | $self->log('err', "stopping vm failed - $err"); | |
487 | $self->{errors} = 1; | |
488 | } | |
489 | ||
97439670 DM |
490 | if ($self->{tunnel}) { |
491 | eval { finish_tunnel($self, $self->{tunnel}); }; | |
492 | if (my $err = $@) { | |
493 | $self->log('err', $err); | |
494 | $self->{errors} = 1; | |
495 | } | |
496 | } | |
497 | ||
16e903f2 DM |
498 | # always deactivate volumes - avoid lvm LVs to be active on several nodes |
499 | eval { | |
500 | my $vollist = PVE::QemuServer::get_vm_volumes($conf); | |
501 | PVE::Storage::deactivate_volumes($self->{storecfg}, $vollist); | |
502 | }; | |
503 | if (my $err = $@) { | |
504 | $self->log('err', $err); | |
505 | $self->{errors} = 1; | |
506 | } | |
507 | ||
508 | # clear migrate lock | |
509 | my $cmd = [ @{$self->{rem_ssh}}, 'qm', 'unlock', $vmid ]; | |
510 | $self->cmd_logerr($cmd, errmsg => "failed to clear migrate lock"); | |
511 | } | |
512 | ||
513 | sub final_cleanup { | |
514 | my ($self, $vmid) = @_; | |
515 | ||
516 | # nothing to do | |
517 | } | |
518 | ||
519 | 1; |