[PATCH qemu-server v4 03/18] drive: introduce drive_uses_qsd_fuse() helper

Fiona Ebner
2026-04-24T11:49:13Z

In preparation for supporting snapshot operations for drives which
are QSD FUSE exported. Having a central drive_uses_qsd_fuse() helper
makes it possible to consistently decide whether the QMP peer is the
QEMU storage daemon or the main QEMU instance.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Tested-by: Lukas Sichert <l.sichert@proxmox.com>
---
src/PVE/QemuServer.pm | 7 +++----
src/PVE/QemuServer/Drive.pm | 12 ++++++++++++
2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 2a469fff..476fef0b 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -2832,12 +2832,11 @@ sub start_swtpm {
my $tpm = parse_drive("tpmstate0", $tpmdrive);
my ($storeid) = PVE::Storage::parse_volume_id($tpm->{file}, 1);
if ($storeid) {
- my $format = checked_volume_format($storecfg, $tpm->{file});
- if ($format eq 'raw') {
- $state = PVE::Storage::map_volume($storecfg, $tpm->{file});
- } else {
+ if (PVE::QemuServer::Drive::drive_uses_qsd_fuse($storecfg, $tpm)) {
PVE::QemuServer::QSD::start($vmid);
$state = PVE::QemuServer::QSD::add_fuse_export($vmid, $tpm, 'tpmstate0');
+ } else {
+ $state = PVE::Storage::map_volume($storecfg, $tpm->{file});
}
} else {
$state = $tpm->{file};
diff --git a/src/PVE/QemuServer/Drive.pm b/src/PVE/QemuServer/Drive.pm
index 10106ebd..f88504b2 100644
--- a/src/PVE/QemuServer/Drive.pm
+++ b/src/PVE/QemuServer/Drive.pm
@@ -1152,4 +1152,16 @@ sub detect_zeroes_cmdline_option {
return 'on';
}

+sub drive_uses_qsd_fuse {
+ my ($storecfg, $drive) = @_;
+
+ if ($drive->{interface} eq 'tpmstate') {
+ my ($storeid) = PVE::Storage::parse_volume_id($drive->{file}, 1);
+ my $format = checked_volume_format($storecfg, $drive->{file});
+ return $storeid && $format ne 'raw';
+ }
+
+ return;
+}
+
1;
--
2.47.3