[pve-devel] [PATCH qemu-server v2 15/16] fix #4693: drive: allow non-raw image formats for TPM state drive
Fiona Ebner
f.ebner at proxmox.com
Mon Oct 20 16:13:02 CEST 2025
Now that there is a mechanism to export non-raw images as FUSE for
swtpm, it's possible to align the possible formats with what other
disk types can use. This also reduces special-casing for TPM state
volumes.
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
Reviewed-by: Daniel Kral <d.kral at proxmox.com>
Tested-by: Daniel Kral <d.kral at proxmox.com>
---
Build-dependency bump and dependency bump for pve-storage needed!
src/PVE/API2/Qemu.pm | 7 ++-----
src/PVE/QemuServer.pm | 1 -
src/PVE/QemuServer/Drive.pm | 2 ++
3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
index 4243e4da..e77245a3 100644
--- a/src/PVE/API2/Qemu.pm
+++ b/src/PVE/API2/Qemu.pm
@@ -627,13 +627,13 @@ my sub create_disks : prototype($$$$$$$$$$$) {
$storecfg, $storeid, $vmid, $fmt, $arch, $disk, $smm, $amd_sev_type,
);
} elsif ($ds eq 'tpmstate0') {
- # swtpm can only use raw volumes, and uses a fixed size
+ # A fixed size is used for TPM state volumes
$size = PVE::Tools::convert_size(
PVE::QemuServer::Drive::TPMSTATE_DISK_SIZE,
'b' => 'kb',
);
$volid =
- PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid, "raw", undef, $size);
+ PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid, $fmt, undef, $size);
} else {
$volid =
PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid, $fmt, undef, $size);
@@ -675,9 +675,6 @@ my sub create_disks : prototype($$$$$$$$$$$) {
) {
die "$ds - cloud-init drive is already attached at '$ci_key'\n";
}
- } elsif ($ds eq 'tpmstate0' && $volume_format ne 'raw') {
- die
- "tpmstate0: volume format is '$volume_format', only 'raw' is supported!\n";
}
}
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 5791eee8..fcdfaf66 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -7827,7 +7827,6 @@ sub clone_disk {
} elsif ($dst_drivename eq 'efidisk0') {
$size = $efisize or die "internal error - need to specify EFI disk size\n";
} elsif ($dst_drivename eq 'tpmstate0') {
- $dst_format = 'raw';
$size = PVE::QemuServer::Drive::TPMSTATE_DISK_SIZE;
} else {
clone_disk_check_io_uring(
diff --git a/src/PVE/QemuServer/Drive.pm b/src/PVE/QemuServer/Drive.pm
index 79dd22e6..f54f9612 100644
--- a/src/PVE/QemuServer/Drive.pm
+++ b/src/PVE/QemuServer/Drive.pm
@@ -10,6 +10,7 @@ use List::Util qw(first);
use PVE::RESTEnvironment qw(log_warn);
use PVE::Storage;
+use PVE::Storage::Common;
use PVE::JSONSchema qw(get_standard_option);
use base qw(Exporter);
@@ -570,6 +571,7 @@ my $tpmstate_fmt = {
format_description => 'volume',
description => "The drive's backing volume.",
},
+ format => get_standard_option('pve-vm-image-format', { optional => 1 }),
size => {
type => 'string',
format => 'disk-size',
--
2.47.3
More information about the pve-devel
mailing list