public inbox for pve-devel@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 v2 1/8] blockdev: helper to add common options
Date: Fri, 25 Jul 2025 12:50:48 +0200	[thread overview]
Message-ID: <20250725105109.54093-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250725105109.54093-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>
Reviewed-by: Fabian Grünbichler <f.gruenbichler@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-25 10:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-25 10:50 [pve-devel] [PATCH-SERIES qemu-server v2 0/8] blockdev and snapshot-as-volume-chain on LVM fixes Fiona Ebner
2025-07-25 10:50 ` Fiona Ebner [this message]
2025-07-25 10:50 ` [pve-devel] [PATCH qemu-server v2 2/8] blockdev: fix discard Fiona Ebner
2025-07-25 10:50 ` [pve-devel] [PATCH qemu-server v2 3/8] tests: image convert: avoid hard-coded VM ID in result Fiona Ebner
2025-07-25 10:50 ` [pve-devel] [PATCH qemu-server v2 4/8] tests: image convert: properly set snapshot-as-volume-chain option Fiona Ebner
2025-07-25 10:50 ` [pve-devel] [PATCH qemu-server v2 5/8] tests: image convert: add tests where storages with 'snapshot-as-volume-chain' are the target Fiona Ebner
2025-07-25 10:50 ` [pve-devel] [PATCH qemu-server v2 6/8] fix #6543: use qcow2 'discard-no-unref' option when using snapshot-as-volume-chain Fiona Ebner
2025-07-25 10:50 ` [pve-devel] [PATCH qemu-server v2 7/8] tests: cfg2cmd: improve mocking File::stat Fiona Ebner
2025-07-25 10:50 ` [pve-devel] [PATCH qemu-server v2 8/8] image convert: re-use generate_drive_blockdev() Fiona Ebner
2025-07-25 12:15 ` [pve-devel] applied-series: [PATCH-SERIES qemu-server v2 0/8] 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=20250725105109.54093-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal