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 012D01FF137 for ; Tue, 03 Mar 2026 11:48:53 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A3A9012381; Tue, 3 Mar 2026 11:49:54 +0100 (CET) From: Manuel Federanko To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v3] fix #5578: smbios: set serial number Date: Tue, 3 Mar 2026 11:49:19 +0100 Message-ID: <20260303104919.33634-1-m.federanko@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 1 AWL -1.378 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 HEADER_FROM_DIFFERENT_DOMAINS 0.25 From and EnvelopeFrom 2nd level mail domains are different KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.66 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.968 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.495 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: N25VTEWILF6FTCSPTEZFJFDHXS2QOZUM X-Message-ID-Hash: N25VTEWILF6FTCSPTEZFJFDHXS2QOZUM X-MailFrom: mfederanko@pve.localdomain X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: If no smbios options are given on creation, default to generate a serial number. This is required for Windows Autopilot to identify a user device. Use the already generated smbios uuid as serial number, it should be unique enough for our purposes. The base64 here is needed since all configuration options are stored as a base64 encoded string, which is ensured by the format. This ensures that the values are properly decoded in the gui, for example. Since all fields are forced to be stored in base64 format it might make sense for a future patch to a) remove the flag or b) allow values different than base64 encoded data in the other fields. Tested by creating a new vm via the gui and command line. Signed-off-by: Manuel Federanko --- Changes since v2: * add "PVE-" prefix to serial * move logic back into a helper subroutine Changes since v1: * switch serial to be the same uuid * use print_smbios1 over manually constructing strings * remove the dedicated generate_smbios1_uuid subroutine src/PVE/API2/Qemu.pm | 2 +- src/PVE/CLI/qm.pm | 2 +- src/PVE/QemuServer.pm | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm index c2e185a6..a68b1906 100644 --- a/src/PVE/API2/Qemu.pm +++ b/src/PVE/API2/Qemu.pm @@ -1471,7 +1471,7 @@ __PACKAGE__->register_method({ # auto generate uuid if user did not specify smbios1 option if (!$conf->{smbios1}) { - $conf->{smbios1} = PVE::QemuServer::generate_smbios1_uuid(); + $conf->{smbios1} = PVE::QemuServer::generate_smbios1(); } if ( diff --git a/src/PVE/CLI/qm.pm b/src/PVE/CLI/qm.pm index bdae9641..975ec3f5 100755 --- a/src/PVE/CLI/qm.pm +++ b/src/PVE/CLI/qm.pm @@ -912,7 +912,7 @@ __PACKAGE__->register_method({ eval { # order matters, as do_import() will load_config() internally $conf->{vmgenid} = PVE::QemuServer::generate_uuid(); - $conf->{smbios1} = PVE::QemuServer::generate_smbios1_uuid(); + $conf->{smbios1} = PVE::QemuServer::generate_smbios1(); PVE::QemuConfig->write_config($vmid, $conf); foreach my $disk (@{ $parsed->{disks} }) { diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm index 545758dc..77dd7cca 100644 --- a/src/PVE/QemuServer.pm +++ b/src/PVE/QemuServer.pm @@ -8082,8 +8082,14 @@ sub generate_uuid { return $uuid_str; } -sub generate_smbios1_uuid { - return "uuid=" . generate_uuid(); +sub generate_smbios1 { + my $smbios1_uuid = PVE::QemuServer::generate_uuid(); + my $smbios1 = { + uuid => $smbios1_uuid, + serial => encode_base64("PVE-" . $smbios1_uuid, ""), + base64 => 1, + }; + return PVE::QemuServer::print_smbios1($smbios1); } sub create_reboot_request { -- 2.47.3