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.eb...@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