all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server 1/6] blockdev: helper to add common options
Date: Thu, 24 Jul 2025 15:59:40 +0200	[thread overview]
Message-ID: <20250724135956.112138-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250724135956.112138-1-f.ebner@proxmox.com>

Certain options like read-only need to be set on all nodes in the
throttle->fmt->file chain to apply correctly and consistently.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/QemuServer/Blockdev.pm | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/PVE/QemuServer/Blockdev.pm b/src/PVE/QemuServer/Blockdev.pm
index 28453b48..822543cd 100644
--- a/src/PVE/QemuServer/Blockdev.pm
+++ b/src/PVE/QemuServer/Blockdev.pm
@@ -186,6 +186,13 @@ my sub read_only_json_option {
     return json_bool($drive->{ro} || drive_is_cdrom($drive) || $options->{'read-only'});
 }
 
+# Common blockdev options that need to be set across the whole throttle->fmt->file chain.
+my sub add_common_options {
+    my ($blockdev, $drive, $options) = @_;
+
+    $blockdev->{'read-only'} = read_only_json_option($drive, $options);
+}
+
 my sub throttle_group_id {
     my ($drive_id) = @_;
 
@@ -314,7 +321,7 @@ my sub generate_file_blockdev {
 
     $blockdev->{'node-name'} = get_node_name('file', $drive_id, $drive->{file}, $options);
 
-    $blockdev->{'read-only'} = read_only_json_option($drive, $options);
+    add_common_options($blockdev, $drive, $options);
 
     return $blockdev;
 }
@@ -356,9 +363,10 @@ my sub generate_format_blockdev {
         driver => "$format",
         file => $child,
         cache => $child->{cache}, # define cache option on both format && file node like libvirt
-        'read-only' => read_only_json_option($drive, $options),
     };
 
+    add_common_options($blockdev, $drive, $options);
+
     if (defined($options->{size})) {
         die "blockdev: 'size' is only supported for 'raw' format" if $format ne 'raw';
         $blockdev->{size} = int($options->{size});
@@ -411,13 +419,16 @@ sub generate_throttle_blockdev {
 
     my $drive_id = PVE::QemuServer::Drive::get_drive_id($drive);
 
-    return {
+    my $blockdev = {
         driver => "throttle",
         'node-name' => top_node_name($drive_id),
         'throttle-group' => throttle_group_id($drive_id),
         file => $child,
-        'read-only' => read_only_json_option($drive, $options),
     };
+
+    add_common_options($blockdev, $drive, $options);
+
+    return $blockdev;
 }
 
 sub generate_drive_blockdev {
-- 
2.47.2



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


  reply	other threads:[~2025-07-24 13:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-24 13:59 [pve-devel] [PATCH-SERIES qemu-server 0/6] blockdev and snapshot-as-volume-chain on LVM fixes Fiona Ebner
2025-07-24 13:59 ` Fiona Ebner [this message]
2025-07-24 13:59 ` [pve-devel] [PATCH qemu-server 2/6] blockdev: fix discard Fiona Ebner
2025-07-24 13:59 ` [pve-devel] [PATCH qemu-server 3/6] tests: image convert: avoid hard-coded VM ID in result Fiona Ebner
2025-07-24 13:59 ` [pve-devel] [PATCH qemu-server 4/6] tests: image convert: properly set snapshot-as-volume-chain option Fiona Ebner
2025-07-24 13:59 ` [pve-devel] [PATCH qemu-server 5/6] tests: image convert: add tests where storages with 'snapshot-as-volume-chain' are the target Fiona Ebner
2025-07-24 13:59 ` [pve-devel] [PATCH qemu-server 6/6] fix #6543: use qcow2 'discard-no-unref' option when using snapshot-as-volume-chain Fiona Ebner
2025-07-24 18:01   ` DERUMIER, Alexandre via pve-devel
2025-07-25  7:38   ` Fabian Grünbichler
2025-07-25  8:24     ` Fiona Ebner
2025-07-25  7:40 ` [pve-devel] [PATCH-SERIES qemu-server 0/6] blockdev and snapshot-as-volume-chain on LVM fixes 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=20250724135956.112138-2-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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal