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 736DBAB29 for ; Mon, 21 Nov 2022 13:16:50 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 510C82C450 for ; Mon, 21 Nov 2022 13:16:20 +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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 21 Nov 2022 13:16:19 +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 F1BE644BE5 for ; Mon, 21 Nov 2022 13:16:18 +0100 (CET) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pve-devel@lists.proxmox.com Date: Mon, 21 Nov 2022 13:16:05 +0100 Message-Id: <20221121121605.1217-2-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221121121605.1217-1-f.gruenbichler@proxmox.com> References: <20221121121605.1217-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.136 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 Subject: [pve-devel] [PATCH qemu-server 2/2] explain 'nocheck' in more places 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: Mon, 21 Nov 2022 12:16:50 -0000 was only explained in git history and vm_stop, add comments in other relevant places to avoid future breakage. Signed-off-by: Fabian Grünbichler --- PVE/API2/Qemu.pm | 2 ++ PVE/CLI/qm.pm | 2 ++ PVE/QemuMigrate.pm | 3 ++- PVE/QemuServer.pm | 9 +++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 6bdcce21..badfc37b 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -3200,6 +3200,8 @@ __PACKAGE__->register_method({ raise_param_exc({ skiplock => "Only root may use this option." }) if $skiplock && $authuser ne 'root@pam'; + # nocheck is used as part of migration when config file might be still + # be on source node my $nocheck = extract_param($param, 'nocheck'); raise_param_exc({ nocheck => "Only root may use this option." }) if $nocheck && $authuser ne 'root@pam'; diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm index 66feecce..3e0f1289 100755 --- a/PVE/CLI/qm.pm +++ b/PVE/CLI/qm.pm @@ -426,6 +426,8 @@ __PACKAGE__->register_method ({ last; } elsif ($line =~ /^resume (\d+)$/) { my $vmid = $1; + # check_running and vm_resume with nocheck, since local node + # might not have processed config move/rename yet if (PVE::QemuServer::check_running($vmid, 1)) { eval { PVE::QemuServer::vm_resume($vmid, 1, 1); }; if ($@) { diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm index 5941cce6..5e466d95 100644 --- a/PVE/QemuMigrate.pm +++ b/PVE/QemuMigrate.pm @@ -1500,6 +1500,7 @@ sub phase3_cleanup { $self->{errors} = 1; } } else { + # nocheck in case target node hasn't processed the config move/rename yet my $cmd = [@{$self->{rem_ssh}}, 'qm', 'resume', $vmid, '--skiplock', '--nocheck']; my $logf = sub { my $line = shift; @@ -1561,7 +1562,7 @@ sub phase3_cleanup { } }; - # always stop local VM + # always stop local VM with nocheck, since config is moved already eval { PVE::QemuServer::vm_stop($self->{storecfg}, $vmid, 1, 1); }; if (my $err = $@) { $self->log('err', "stopping vm failed - $err"); diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 29110c0f..e1ece548 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -2788,6 +2788,12 @@ sub check_local_storage_availability { sub check_running { my ($vmid, $nocheck, $node) = @_; + # $nocheck is set when called during a migration, in which case the config + # file might still or already reside on the *other* node + # - because rename has already happened, and current node is source + # - because rename hasn't happened yet, and current node is target + # - because rename has happened, current node is target, but hasn't yet + # processed it yet PVE::QemuConfig::assert_config_exists_on_node($vmid, $node) if !$nocheck; return PVE::QemuServer::Helpers::vm_running_locally($vmid); } @@ -6359,6 +6365,9 @@ sub vm_suspend { } } +# $nocheck is set when called as part of a migration - in this context the +# location of the config file (source or target node) is not deterministic, +# since migration cannot wait for pmxcfs to process the rename sub vm_resume { my ($vmid, $skiplock, $nocheck) = @_; -- 2.30.2