From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 7551D6B208 for ; Fri, 18 Mar 2022 08:51:59 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 642DD1AB9B for ; Fri, 18 Mar 2022 08:51:29 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 76FA81AB92 for ; Fri, 18 Mar 2022 08:51:28 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 4831742E19 for ; Fri, 18 Mar 2022 08:51:28 +0100 (CET) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Fri, 18 Mar 2022 08:51:23 +0100 Message-Id: <20220318075123.5445-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.120 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH qemu-server] migrate: keep VM paused after migration if it was before X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Mar 2022 07:51:59 -0000 Also cannot issue a guest agent command in that case. Reported in the community forum: https://forum.proxmox.com/threads/106618 Signed-off-by: Fabian Ebner --- Best viewed with -w. PVE/QemuMigrate.pm | 54 ++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm index 104e62ce..891edfb2 100644 --- a/PVE/QemuMigrate.pm +++ b/PVE/QemuMigrate.pm @@ -158,6 +158,8 @@ sub prepare { $self->{forcecpu} = PVE::QemuServer::CPUConfig::get_cpu_from_running_vm($pid); } } + + $self->{vm_was_paused} = 1 if PVE::QemuServer::vm_is_paused($vmid); } my $loc_res = PVE::QemuServer::check_local_resources($conf, 1); @@ -1146,31 +1148,37 @@ sub phase3_cleanup { } } - # config moved and nbd server stopped - now we can resume vm on target - if ($tunnel && $tunnel->{version} && $tunnel->{version} >= 1) { - eval { - PVE::Tunnel::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; + if (!$self->{vm_was_paused}) { + # config moved and nbd server stopped - now we can resume vm on target + if ($tunnel && $tunnel->{version} && $tunnel->{version} >= 1) { + eval { + PVE::Tunnel::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; + } } - } - if ($self->{storage_migration} && PVE::QemuServer::parse_guest_agent($conf)->{fstrim_cloned_disks} && $self->{running}) { - my $cmd = [@{$self->{rem_ssh}}, 'qm', 'guest', 'cmd', $vmid, 'fstrim']; - eval{ PVE::Tools::run_command($cmd, outfunc => sub {}, errfunc => sub {}) }; + if ( + $self->{storage_migration} + && PVE::QemuServer::parse_guest_agent($conf)->{fstrim_cloned_disks} + && $self->{running} + ) { + my $cmd = [@{$self->{rem_ssh}}, 'qm', 'guest', 'cmd', $vmid, 'fstrim']; + eval{ PVE::Tools::run_command($cmd, outfunc => sub {}, errfunc => sub {}) }; + } } } -- 2.30.2