From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id 2AC871FF165
	for <inbox@lore.proxmox.com>; Wed, 15 Jan 2025 14:58:23 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id CBB79CEBA;
	Wed, 15 Jan 2025 14:58:19 +0100 (CET)
From: Hannes Duerr <h.duerr@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Wed, 15 Jan 2025 14:58:06 +0100
Message-Id: <20250115135806.169660-1-h.duerr@proxmox.com>
X-Mailer: git-send-email 2.39.5
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.037 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
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [proxmox.com, qemuserver.pm, qemu.org]
Subject: [pve-devel] [PATCH qemu-server] cfg2cmd: use tpm-tis and
 tpm-tis-device depending on the arch
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

When using arch aarch64 for a VM in combination with new enough Windows
OS type the VM start fails:

> qemu-system-aarch64: -device tpm-tis,tpmdev=tpmdev: 'tpm-tis' is not a valid device model name

QEMU uses the `tpm-tis-device` device model for ARM[0] and RISCV[1]
instead of the `tmp-tis` which is used for x86_64.

This patch is a follow-up to [2].

[0] https://www.qemu.org/docs/master/specs/tpm.html#the-qemu-tpm-emulator-device
[1] https://www.qemu.org/docs/master/system/riscv/virt.html#enabling-tpm
[2] https://lore.proxmox.com/pve-devel/20250113135638.88099-1-f.ebner@proxmox.com/

Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
---
 PVE/QemuServer.pm | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 43008f3f..f7cb5fcb 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3203,7 +3203,7 @@ sub get_tpm_paths {
 }
 
 sub add_tpm_device {
-    my ($vmid, $devices, $conf) = @_;
+    my ($vmid, $devices, $conf, $arch) = @_;
 
     return if !$conf->{tpmstate0};
 
@@ -3211,7 +3211,11 @@ sub add_tpm_device {
 
     push @$devices, "-chardev", "socket,id=tpmchar,path=$paths->{socket}";
     push @$devices, "-tpmdev", "emulator,id=tpmdev,chardev=tpmchar";
-    push @$devices, "-device", "tpm-tis,tpmdev=tpmdev";
+    if ($arch eq 'x86_64') {
+	push @$devices, "-device", "tpm-tis,tpmdev=tpmdev";
+    } else {
+	push @$devices, "-device", "tpm-tis-device,tpmdev=tpmdev";
+    }
 }
 
 sub start_swtpm {
@@ -3838,7 +3842,7 @@ sub config_to_command {
 
     # Add a TPM only if the VM is not a template,
     # to support backing up template VMs even if the TPM disk is write-protected.
-    add_tpm_device($vmid, $devices, $conf) if (!PVE::QemuConfig->is_template($conf));
+    add_tpm_device($vmid, $devices, $conf, $arch) if (!PVE::QemuConfig->is_template($conf));
 
     my $sockets = 1;
     $sockets = $conf->{smp} if $conf->{smp}; # old style - no longer iused
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel