[pve-devel] [v2 qemu-server 07/10] qm mtunnel/migrate: add resume VMID command
Fabian Grünbichler
f.gruenbichler at proxmox.com
Fri Aug 4 14:54:04 CEST 2017
and reformat the legacy SSH variant for readability.
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
PVE/CLI/qm.pm | 12 ++++++++++++
PVE/QemuMigrate.pm | 32 ++++++++++++++++++++++----------
2 files changed, 34 insertions(+), 10 deletions(-)
diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
index b70bb20..5dce10f 100755
--- a/PVE/CLI/qm.pm
+++ b/PVE/CLI/qm.pm
@@ -280,6 +280,18 @@ __PACKAGE__->register_method ({
if ($line =~ /^quit$/) {
$tunnel_write->("OK");
last;
+ } elsif ($line =~ /^resume (\d+)$/) {
+ my $vmid = $1;
+ if (PVE::QemuServer::check_running($vmid, 1)) {
+ eval { PVE::QemuServer::vm_resume($vmid, 1, 1); };
+ if ($@) {
+ $tunnel_write->("ERR: resume failed - $@");
+ } else {
+ $tunnel_write->("OK");
+ }
+ } else {
+ $tunnel_write->("ERR: resume failed - VM $vmid not running");
+ }
}
}
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 43a3911..75935e0 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -906,6 +906,8 @@ sub phase3_cleanup {
my $conf = $self->{vmconf};
return if $self->{phase2errors};
+ my $tunnel = $self->{tunnel};
+
if ($self->{storage_migration}) {
# finish block-job
eval { PVE::QemuServer::qemu_drive_mirror_monitor($vmid, undef, $self->{storage_migration_jobs}); };
@@ -951,17 +953,27 @@ sub phase3_cleanup {
$self->{errors} = 1;
}
}
+
# config moved and nbd server stopped - now we can resume vm on target
- my $cmd = [@{$self->{rem_ssh}}, 'qm', 'resume', $vmid, '--skiplock', '--nocheck'];
- eval{ PVE::Tools::run_command($cmd, outfunc => sub {},
- errfunc => sub {
- my $line = shift;
- $self->log('err', $line);
- });
- };
- if (my $err = $@) {
- $self->log('err', $err);
- $self->{errors} = 1;
+ if ($tunnel && $tunnel->{version} && $tunnel->{version} >= 1) {
+ eval {
+ $self->write_tunnel($tunnel, 30, "resume $vmid");
+ };
+ if (my $err = $@) {
+ $self->log('err', $err);
+ $self->{errors} = 1;
+ }
+ } else {
+ my $cmd = [@{$self->{rem_ssh}}, 'qm', 'resume', $vmid, '--skiplock', '--nocheck'];
+ my $logf = sub {
+ my $line = shift;
+ $self->log('err', $line);
+ };
+ eval { PVE::Tools::run_command($cmd, outfunc => sub {}, errfunc => $logf); };
+ if (my $err = $@) {
+ $self->log('err', $err);
+ $self->{errors} = 1;
+ }
}
}
--
2.11.0
More information about the pve-devel
mailing list