From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH storage v4 11/49] plugin: qemu block device: add hints option and EFI disk hint
Date: Tue, 1 Jul 2025 17:40:31 +0200 [thread overview]
Message-ID: <20250701154117.434512-12-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250701154117.434512-1-f.ebner@proxmox.com>
For '-drive', qemu-server sets special cache options for EFI disk
using RBD. In preparation to seamlessly switch to the new '-blockdev'
interface, do the same here. Note that the issue from bug #3329, which
is solved by these cache options, still affects current versions.
With -blockdev, the cache options are split up. While cache.direct and
cache.no-flush can be set in the -blockdev options, cache.writeback is
a front-end property and was intentionally removed from the -blockdev
options by QEMU commit aaa436f998 ("block: Remove cache.writeback from
blockdev-add"). It needs to be configured as the 'write-cache'
property for the ide-hd/scsi-hd/virtio-blk device.
The default is already 'writeback' and no cache mode can be set for an
EFI drive configuration in Proxmox VE currently, so there will not be
a clash.
┌─────────────┬─────────────────┬──────────────┬────────────────┐
│ │ cache.writeback │ cache.direct │ cache.no-flush │
├─────────────┼─────────────────┼──────────────┼────────────────┤
│writeback │ on │ off │ off │
├─────────────┼─────────────────┼──────────────┼────────────────┤
│none │ on │ on │ off │
├─────────────┼─────────────────┼──────────────┼────────────────┤
│writethrough │ off │ off │ off │
├─────────────┼─────────────────┼──────────────┼────────────────┤
│directsync │ off │ on │ off │
├─────────────┼─────────────────┼──────────────┼────────────────┤
│unsafe │ on │ off │ on │
└─────────────┴─────────────────┴──────────────┴────────────────┘
Table from 'man kvm'.
Alternatively, the option could only be set once when allocating the
RBD volume. However, then we would need to detect all cases were a
volume could potentially be used as an EFI disk later. Having a custom
disk type would help a lot there. The approach here was chosen as it
is catch-all and should not be too costly either.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
Changes in v4:
* More compact POD.
src/PVE/Storage.pm | 4 ++--
src/PVE/Storage/ISCSIDirectPlugin.pm | 2 +-
src/PVE/Storage/Plugin.pm | 23 +++++++++++++++++++++--
src/PVE/Storage/RBDPlugin.pm | 20 +++++++++++++++++++-
src/PVE/Storage/ZFSPlugin.pm | 2 +-
src/PVE/Storage/ZFSPoolPlugin.pm | 2 +-
6 files changed, 45 insertions(+), 8 deletions(-)
diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm
index ec8b753..4920bd6 100755
--- a/src/PVE/Storage.pm
+++ b/src/PVE/Storage.pm
@@ -721,7 +721,7 @@ sub abs_filesystem_path {
# see the documentation for the plugin method
sub qemu_blockdev_options {
- my ($cfg, $volid) = @_;
+ my ($cfg, $volid, $options) = @_;
my ($storeid, $volname) = parse_volume_id($volid);
@@ -733,7 +733,7 @@ sub qemu_blockdev_options {
die "cannot use volume of type '$vtype' as a QEMU blockdevice\n"
if $vtype ne 'images' && $vtype ne 'iso' && $vtype ne 'import';
- return $plugin->qemu_blockdev_options($scfg, $storeid, $volname);
+ return $plugin->qemu_blockdev_options($scfg, $storeid, $volname, $options);
}
# used as last resort to adapt volnames when migrating
diff --git a/src/PVE/Storage/ISCSIDirectPlugin.pm b/src/PVE/Storage/ISCSIDirectPlugin.pm
index 8c6b4ab..12b894d 100644
--- a/src/PVE/Storage/ISCSIDirectPlugin.pm
+++ b/src/PVE/Storage/ISCSIDirectPlugin.pm
@@ -111,7 +111,7 @@ sub path {
}
sub qemu_blockdev_options {
- my ($class, $scfg, $storeid, $volname) = @_;
+ my ($class, $scfg, $storeid, $volname, $options) = @_;
my $lun = ($class->parse_volname($volname))[1];
diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index 680bb6b..4ec4a0d 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -1965,7 +1965,7 @@ sub rename_volume {
=head3 qemu_blockdev_options
- $blockdev = $plugin->qemu_blockdev_options($scfg, $storeid, $volname)
+ $blockdev = $plugin->qemu_blockdev_options($scfg, $storeid, $volname, $options)
Returns a hash reference with the basic options needed to open the volume via QEMU's C<-blockdev>
API. This at least requires a C<< $blockdev->{driver} >> and a reference to the image, e.g.
@@ -1992,12 +1992,31 @@ Arguments:
=item C<$volume>: The volume name.
+=item C<$options>: A hash reference with additional options.
+
+=over
+
+=item C<< $options->{hints} >>: A hash reference with hints indicating what the volume will be used
+for. This can be safely ignored if no concrete issues are known with your plugin. For certain use
+cases, setting additional (plugin-specific) options might be very beneficial however. An example is
+setting the correct cache options for an EFI disk on RBD. The list of hints might get expanded in
+the future.
+
+=over
+
+=item C<< $options->{hints}->{'efi-disk'} >>: (optional) If set, the volume will be used as the EFI
+disk of a VM, containing its OMVF variables.
+
+=back
+
+=back
+
=back
=cut
sub qemu_blockdev_options {
- my ($class, $scfg, $storeid, $volname) = @_;
+ my ($class, $scfg, $storeid, $volname, $options) = @_;
my $blockdev = {};
diff --git a/src/PVE/Storage/RBDPlugin.pm b/src/PVE/Storage/RBDPlugin.pm
index 6e70a19..c40c845 100644
--- a/src/PVE/Storage/RBDPlugin.pm
+++ b/src/PVE/Storage/RBDPlugin.pm
@@ -374,6 +374,16 @@ my sub rbd_volume_exists {
return 0;
}
+# Needs to be public, so qemu-server can mock it for cfg2cmd.
+sub rbd_volume_config_set {
+ my ($scfg, $storeid, $volname, $key, $value) = @_;
+
+ my $cmd = $rbd_cmd->($scfg, $storeid, 'config', 'image', 'set', $volname, $key, $value);
+ run_rbd_command($cmd, errmsg => "rbd config image set $volname $key $value error");
+
+ return;
+}
+
# Configuration
sub type {
@@ -514,7 +524,7 @@ sub path {
}
sub qemu_blockdev_options {
- my ($class, $scfg, $storeid, $volname) = @_;
+ my ($class, $scfg, $storeid, $volname, $options) = @_;
my $cmd_option = PVE::CephConfig::ceph_connect_option($scfg, $storeid);
my ($name) = ($class->parse_volname($volname))[1];
@@ -547,6 +557,14 @@ sub qemu_blockdev_options {
$blockdev->{user} = "$cmd_option->{userid}" if $cmd_option->{keyring};
+ # SPI flash does lots of read-modify-write OPs, without writeback this gets really slow #3329
+ if ($options->{hints}->{'efi-disk'}) {
+ # Querying the value would just cost more and the 'rbd image config get' command will just
+ # fail if the config has not been set yet, so it's not even straight-forward to do so.
+ # Simply set the value (possibly again).
+ rbd_volume_config_set($scfg, $storeid, $name, 'rbd_cache_policy', 'writeback');
+ }
+
return $blockdev;
}
diff --git a/src/PVE/Storage/ZFSPlugin.pm b/src/PVE/Storage/ZFSPlugin.pm
index c03fcca..0f64898 100644
--- a/src/PVE/Storage/ZFSPlugin.pm
+++ b/src/PVE/Storage/ZFSPlugin.pm
@@ -248,7 +248,7 @@ sub path {
}
sub qemu_blockdev_options {
- my ($class, $scfg, $storeid, $volname) = @_;
+ my ($class, $scfg, $storeid, $volname, $options) = @_;
my $name = ($class->parse_volname($volname))[1];
my $guid = $class->zfs_get_lu_name($scfg, $name);
diff --git a/src/PVE/Storage/ZFSPoolPlugin.pm b/src/PVE/Storage/ZFSPoolPlugin.pm
index 86c52ea..e775dae 100644
--- a/src/PVE/Storage/ZFSPoolPlugin.pm
+++ b/src/PVE/Storage/ZFSPoolPlugin.pm
@@ -163,7 +163,7 @@ sub path {
}
sub qemu_blockdev_options {
- my ($class, $scfg, $storeid, $volname) = @_;
+ my ($class, $scfg, $storeid, $volname, $options) = @_;
my $format = ($class->parse_volname($volname))[6];
--
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-07-01 15:43 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-01 15:40 [pve-devel] [PATCH-SERIES qemu/storage/qemu-server v2 00/49] let's switch to blockdev, blockdev, blockdev, part four (final) Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu v2 01/49] PVE backup: prepare for the switch to using blockdev rather than drive Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu v2 02/49] block/zeroinit: support using as blockdev driver Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu v2 03/49] block/alloc-track: " Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu v2 04/49] block: include child references in block device info Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH storage v4 05/49] plugin: add method to get qemu blockdevice options for volume Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH storage v4 06/49] iscsi direct plugin: implement method to get qemu blockdevice options Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH storage v4 07/49] zfs iscsi plugin: implement new " Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH storage v4 08/49] zfs pool plugin: implement " Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH storage v4 09/49] ceph/rbd: set 'keyring' in ceph configuration for externally managed RBD storages Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH storage v4 10/49] rbd plugin: implement new method to get qemu blockdevice options Fiona Ebner
2025-07-01 15:40 ` Fiona Ebner [this message]
2025-07-01 15:40 ` [pve-devel] [PATCH storage v4 12/49] plugin: qemu block device: add support for snapshot option Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH storage v4 13/49] plugin: add machine version to qemu_blockdev_options() interface Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH storage v4 14/49] plugin api: bump api version and age Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 15/49] mirror: code style: avoid masking earlier declaration of $op Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 16/49] test: collect mocked functions for QemuServer module Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 17/49] drive: add helper to parse drive interface Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 18/49] drive: drop invalid export of get_scsi_devicetype Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 19/49] blockdev: add and use throttle_group_id() helper Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 20/49] blockdev: introduce top_node_name() and parse_top_node_name() helpers Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 21/49] blockdev: add helpers for attaching and detaching block devices Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 22/49] blockdev: add missing include for JSON module Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 23/49] backup: use blockdev for fleecing images Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 24/49] backup: use blockdev for TPM state file Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 25/49] blockdev: introduce qdev_id_to_drive_id() helper Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 26/49] blockdev: introduce and use get_block_info() helper Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 27/49] blockdev: move helper for resize into module Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 28/49] blockdev: add helper to get node below throttle node Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 29/49] blockdev: resize: query and use node name for resize operation Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 30/49] blockdev: support using zeroinit filter Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 31/49] blockdev: make some functions private Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 32/49] blockdev: add 'no-throttle' option to skip generationg throttle top node Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 33/49] block job: allow specifying a block node that should be detached upon completion Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 34/49] block job: add blockdev mirror Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 35/49] blockdev: add change_medium() helper Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 36/49] blockdev: add blockdev_change_medium() helper Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 37/49] blockdev: move helper for configuring throttle limits to module Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 38/49] clone disk: skip check for aio=default (io_uring) compatibility starting with machine version 10.0 Fiona Ebner
2025-07-01 15:40 ` [pve-devel] [PATCH qemu-server v2 39/49] print drive device: don't reference any drive for 'none' " Fiona Ebner
2025-07-01 15:41 ` [pve-devel] [PATCH qemu-server v2 40/49] blockdev: add support for NBD paths Fiona Ebner
2025-07-01 15:41 ` [pve-devel] [PATCH qemu-server v2 41/49] blockdev: add helper to generate PBS block device for live restore Fiona Ebner
2025-07-01 15:41 ` [pve-devel] [PATCH qemu-server v2 42/49] blockdev: support alloc-track driver for live-{import, restore} Fiona Ebner
2025-07-01 15:41 ` [pve-devel] [PATCH qemu-server v2 43/49] live import: also record volid information Fiona Ebner
2025-07-01 15:41 ` [pve-devel] [PATCH qemu-server v2 44/49] live import/restore: query which node to use for operation Fiona Ebner
2025-07-01 15:41 ` [pve-devel] [PATCH qemu-server v2 45/49] live import/restore: use Blockdev::detach helper Fiona Ebner
2025-07-01 15:41 ` [pve-devel] [PATCH qemu-server v2 46/49] command line: switch to blockdev starting with machine version 10.0 Fiona Ebner
2025-07-01 15:41 ` [pve-devel] [PATCH qemu-server v2 47/49] test: migration: update running machine to 10.0 Fiona Ebner
2025-07-01 15:41 ` [pve-devel] [PATCH qemu-server v2 48/49] partially fix #3227: ensure that target image for mirror has the same size for EFI disks Fiona Ebner
2025-07-01 15:41 ` [pve-devel] [PATCH qemu-server v2 49/49] blockdev: pass along machine version to storage layer Fiona Ebner
2025-07-02 8:20 ` [pve-devel] [PATCH-SERIES qemu/storage/qemu-server v2 00/49] let's switch to blockdev, blockdev, blockdev, part four (final) DERUMIER, Alexandre via pve-devel
2025-07-02 8:36 ` Fiona Ebner
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=20250701154117.434512-12-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