From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id DFC2B1FF16E for ; Mon, 20 Jan 2025 14:28:28 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0AF9F1B6FD; Mon, 20 Jan 2025 14:28:26 +0100 (CET) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Mon, 20 Jan 2025 14:27:20 +0100 Message-Id: <20250120132720.95116-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.049 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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] api: create/update vm: avoid printing empty machine string 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: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" While no problem is known with having an empty machine string in the configuration and it was already possible setting an empty machine manually via 'qm set', the behavior changed because of commit 919e69d0 ("machine: add check_and_pin_machine_string() helper") and there is potential for problematic edge cases. Restore the previous behavior. Pinning is also required when there is no given machine type, so the call to check_and_pin_machine_string() should stay unconditional. For update, pinning was recently added by commit 7a9570f3 ("api: update vm config: pin machine version when switching to windows os type"), so bring that in-line with the behavior for create too. Another idea would've been to just return the default machine in check_and_pin_machine_string(), but that would also be a change in behavior. In particular, the default depends on the arch, so an empty machine type will pick the default machine for the currently configured arch even when the arch is later changed. Reported-by: Daniel Herzig Fixes: 919e69d0 ("machine: add check_and_pin_machine_string() helper") Signed-off-by: Fiona Ebner --- PVE/API2/Qemu.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 8acd8d9f..45fe6ea6 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -1243,8 +1243,9 @@ __PACKAGE__->register_method({ } # always pin Windows' machine version on create, they get confused too easily - $conf->{machine} = PVE::QemuServer::Machine::check_and_pin_machine_string( + my $machine_string = PVE::QemuServer::Machine::check_and_pin_machine_string( $conf->{machine}, $conf->{ostype}); + $conf->{machine} = $machine_string if $machine_string; $conf->{lock} = 'import' if $live_import_mapping; @@ -2120,9 +2121,10 @@ my $update_vm_api = sub { && !$modified->{machine} # detects deletion ) { eval { - $conf->{pending}->{machine} = + my $machine_string = PVE::QemuServer::Machine::check_and_pin_machine_string( $conf->{machine}, $param->{ostype}); + $conf->{pending}->{machine} = $machine_string if $machine_string; }; print "automatic pinning of machine version failed - $@" if $@; } -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel