From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server v2 4/5] code cleanup: drive: get rid of outdated drive_is_read_only() helper
Date: Tue, 12 Aug 2025 16:37:42 +0200 [thread overview]
Message-ID: <20250812143900.138723-5-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250812143900.138723-1-f.ebner@proxmox.com>
The drive_is_read_only() helper only applies to '-drive', but not
'-blockdev' and is only used in a single place. Inline it to avoid
accidental usages popping up in the future.
This also gets rid of a hidden dependency from Drive to QemuConfig.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
src/PVE/QemuServer.pm | 7 ++++---
src/PVE/QemuServer/Drive.pm | 10 ----------
2 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index d3f0c589..aacdadad 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -67,7 +67,6 @@ use PVE::QemuServer::Drive qw(
checked_volume_format
drive_is_cloudinit
drive_is_cdrom
- drive_is_read_only
parse_drive
print_drive
storage_allows_io_uring_default
@@ -3778,8 +3777,10 @@ sub config_to_command {
my $drive_cmd =
print_drive_commandline_full($storecfg, $vmid, $drive, $live_blockdev_name);
- # extra protection for templates, but SATA and IDE don't support it..
- $drive_cmd .= ',readonly=on' if drive_is_read_only($conf, $drive);
+ if ($is_template) {
+ my $interface = $drive->{interface};
+ $drive_cmd .= ',readonly=on' if $interface ne 'ide' && $interface ne 'sata';
+ }
push @$devices, '-drive', $drive_cmd;
}
diff --git a/src/PVE/QemuServer/Drive.pm b/src/PVE/QemuServer/Drive.pm
index 9dc4e674..79dd22e6 100644
--- a/src/PVE/QemuServer/Drive.pm
+++ b/src/PVE/QemuServer/Drive.pm
@@ -20,7 +20,6 @@ our @EXPORT_OK = qw(
checked_volume_format
drive_is_cloudinit
drive_is_cdrom
- drive_is_read_only
parse_drive
print_drive
storage_allows_io_uring_default
@@ -751,15 +750,6 @@ sub drive_is_cdrom {
return $drive && $drive->{media} && ($drive->{media} eq 'cdrom');
}
-sub drive_is_read_only {
- my ($conf, $drive) = @_;
-
- return 0 if !PVE::QemuConfig->is_template($conf);
-
- # don't support being marked read-only
- return $drive->{interface} ne 'sata' && $drive->{interface} ne 'ide';
-}
-
sub parse_drive_interface {
my ($key) = @_;
--
2.47.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-08-12 14:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 14:37 [pve-devel] [PATCH-SERIES qemu-server v2 0/5] fix #6675: template backup: fix regression with IDE/SATA and blockdev Fiona Ebner
2025-08-12 14:37 ` [pve-devel] [PATCH qemu-server v2 1/5] ovmf: pass along whether the VM is a template Fiona Ebner
2025-08-13 7:37 ` Fabian Grünbichler
2025-08-12 14:37 ` [pve-devel] [PATCH qemu-server v2 2/5] code cleanup: cfg2cmd: check if configuration is for template centrally Fiona Ebner
2025-08-12 14:37 ` [pve-devel] [PATCH qemu-server v2 3/5] fix #6675: template backup: fix regression with IDE/SATA and blockdev Fiona Ebner
2025-08-12 14:37 ` Fiona Ebner [this message]
2025-08-12 14:37 ` [pve-devel] [PATCH qemu-server v2 5/5] cfg2cmd: add reminder comments to remove template handling for -drive Fiona Ebner
2025-08-13 7:34 ` [pve-devel] applied-series: [PATCH-SERIES qemu-server v2 0/5] fix #6675: template backup: fix regression with IDE/SATA and blockdev Fabian Grünbichler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250812143900.138723-5-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.