From: Friedrich Weber <f.weber@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH storage 1/5] plugin: introduce hints for activating and mapping volumes
Date: Fri, 31 Oct 2025 11:36:08 +0100 [thread overview]
Message-ID: <20251031103709.60233-2-f.weber@proxmox.com> (raw)
In-Reply-To: <20251031103709.60233-1-f.weber@proxmox.com>
Currently, when a storage plugin activates or maps a guest volume, it
has no information about the respective guest. This is by design to
reduce coupling between the storage layer and the upper layers.
However, in some cases, storage plugins may need to activate volumes
differently based on certain features of the guest. An example is the
RBD plugin with KRBD enabled, where guest volumes of Windows VMs have
to be mapped with the rxbounce option.
Introduce "hints" as a mechanism that allows the upper layers to pass
down well-defined information to the storage plugins on volume
activation/mapping. The storage plugin can make adjustments to its
volume activation/mapping based on the hints. The supported hints are
specified by a JSON schema and may be extended in the future.
Add a subroutine that checks whether a particular hint is supported
(may be used by the storage plugin as well as upper layers). This
allows to add further hints without having to bump pve-storage, since
upper layers can just check whether the current pve-storage supports a
particular hint.
The Boolean 'guest-is-windows' hint denotes that the
to-be-activated/mapped volume belongs to a Windows VM.
It is not guaranteed that the volume is inactive when
{activate,map}_volume are called, and it is not guaranteed that hints
are passed on every storage activation. Hence, it can happen that a
volume is already active but applying the hint would require unmapping
the volume and mapping it again with the hint applied (this is the
case for rxbounce). To cover such cases, the Boolean hint
'plugin-may-deactivate-volume' denotes whether unmapping the volume is
currently safe. Only if this hint is true, the plugin may deactivate
the volume and map it again with the hint applied.
Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
---
src/PVE/Storage/Plugin.pm | 43 +++++++++++++++++++++++++++++++++++++--
1 file changed, 41 insertions(+), 2 deletions(-)
diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index 8acd214..4fe903f 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -59,6 +59,25 @@ cfs_register_file(
sub { __PACKAGE__->write_config(@_); },
);
+our $hints_properties = {
+ 'guest-is-windows' => {
+ type => 'boolean',
+ optional => 1,
+ description => "true if the volume belongs to a Windows VM guest",
+ },
+ 'plugin-may-deactivate-volume' => {
+ type => 'boolean',
+ optional => 1,
+ description => "true if the plugin may deactivate the volume in order to apply a hint",
+ },
+};
+
+our $hints_format = {
+ type => 'object',
+ additionalProperties => 0,
+ properties => $hints_properties,
+};
+
my %prune_option = (
optional => 1,
type => 'integer',
@@ -614,6 +633,26 @@ sub preallocation_cmd_opt {
return;
}
+sub is_hint_supported {
+ my ($hint) = @_;
+
+ return defined($hints_properties->{$hint});
+}
+
+sub verify_hints {
+ my ($hints, $noerr) = @_;
+
+ return if !defined($hints);
+
+ eval { PVE::JSONSchema::validate($hints, $hints_format); };
+ my $err = $@;
+
+ return $hints if !$err;
+ return if $noerr;
+
+ die "internal error - hints are not valid: $@";
+}
+
# Storage implementation
=head3 get_formats
@@ -1871,7 +1910,7 @@ sub deactivate_storage {
}
sub map_volume {
- my ($class, $storeid, $scfg, $volname, $snapname) = @_;
+ my ($class, $storeid, $scfg, $volname, $snapname, $hints) = @_;
my ($path) = $class->path($scfg, $volname, $storeid, $snapname);
return $path;
@@ -1884,7 +1923,7 @@ sub unmap_volume {
}
sub activate_volume {
- my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
+ my ($class, $storeid, $scfg, $volname, $snapname, $cache, $hints) = @_;
my $path = $class->filesystem_path($scfg, $volname, $snapname);
--
2.47.3
_______________________________________________
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-10-31 10:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-31 10:36 [pve-devel] [PATCH qemu-server/storage 0/6] fix #5779: introduce guest hints to pass rxbounce flag to KRBD Friedrich Weber
2025-10-31 10:36 ` Friedrich Weber [this message]
2025-10-31 10:36 ` [pve-devel] [PATCH storage 2/5] plugin api: bump api version and age Friedrich Weber
2025-10-31 10:36 ` [pve-devel] [PATCH storage 3/5] storage: activate/map volumes: verify and pass hints to plugin Friedrich Weber
2025-10-31 10:36 ` [pve-devel] [PATCH storage 4/5] plugin: rbd: factor out subroutine to obtain RBD ID Friedrich Weber
2025-10-31 10:36 ` [pve-devel] [PATCH storage 5/5] plugin: rbd: pass rxbounce when mapping Windows VM guest volumes Friedrich Weber
2025-10-31 10:36 ` [pve-devel] [PATCH qemu-server 1/1] fix #5779: vm start: pass storage hints when activating " Friedrich Weber
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=20251031103709.60233-2-f.weber@proxmox.com \
--to=f.weber@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