[pve-devel] [PATCH qemu-server 07/10] qm mtunnel/migrate: add resume VMID command
Fabian Grünbichler
f.gruenbichler at proxmox.com
Fri Aug 4 10:55:06 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 | 34 ++++++++++++++++++++++++----------
2 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
index 1bfbc1e..1792cb0 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 1924754..4082122 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -903,6 +903,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}); };
@@ -948,17 +950,29 @@ 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.0) {
+ 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'];
+ eval {
+ my $logf = sub {
+ my $line = shift;
+ $self->log('err', $line);
+ };
+ 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