[PATCH storage 1/1] storage/plugins: pass scfg to parse_volname
Roland Kammerer
roland.kammerer at linbit.com
Fri Feb 23 10:24:36 CET 2024
This passes the well known $scfg to parse_volname and bumps the API
versions accordingly. This allows plugins to access their configuration
if necessary.
Signed-off-by: Roland Kammerer <roland.kammerer at linbit.com>
---
ApiChangeLog | 7 +++++++
src/PVE/Storage.pm | 18 +++++++++---------
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/ApiChangeLog b/ApiChangeLog
index 98b5893..042e13b 100644
--- a/ApiChangeLog
+++ b/ApiChangeLog
@@ -6,6 +6,13 @@ without breaking anything unaware of it.)
Future changes should be documented in here.
+## Version 11:
+
+* `parse_volname` got additional `$scfg` parameter
+
+ This allows plugins to use information from their configuration.
+ As this is the last, additional parameter APIAGE is not reset.
+
## Version 10:
* a new `rename_volume` method has been added
diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm
index 0beabbc..3ac4f1e 100755
--- a/src/PVE/Storage.pm
+++ b/src/PVE/Storage.pm
@@ -41,11 +41,11 @@ use PVE::Storage::PBSPlugin;
use PVE::Storage::BTRFSPlugin;
# Storage API version. Increment it on changes in storage API interface.
-use constant APIVER => 10;
+use constant APIVER => 11;
# Age is the number of versions we're backward compatible with.
# This is like having 'current=APIVER' and age='APIAGE' in libtool,
# see https://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html
-use constant APIAGE => 1;
+use constant APIAGE => 2;
our $KNOWN_EXPORT_FORMATS = ['raw+size', 'tar+size', 'qcow2+size', 'vmdk+size', 'zfs', 'btrfs'];
@@ -253,7 +253,7 @@ sub update_volume_attribute {
my $scfg = storage_config($cfg, $storeid);
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
- my ($vtype, undef, $vmid) = $plugin->parse_volname($volname);
+ my ($vtype, undef, $vmid) = $plugin->parse_volname($volname, $scfg);
my $max_protected_backups = get_max_protected_backups($scfg, $storeid);
if (
@@ -500,7 +500,7 @@ sub parse_volname {
# returns ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format)
- return $plugin->parse_volname($volname);
+ return $plugin->parse_volname($volname, $scfg);
}
sub parse_volume_id {
@@ -556,7 +556,7 @@ sub volume_is_base_and_used {
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
my ($vtype, $name, $vmid, undef, undef, $isBase, undef) =
- $plugin->parse_volname($volname);
+ $plugin->parse_volname($volname, $scfg);
if ($isBase) {
my $vollist = $plugin->list_images($storeid, $scfg);
@@ -567,7 +567,7 @@ sub volume_is_base_and_used {
eval{
(undef, undef, undef, $basename, $basevmid) =
- $plugin->parse_volname($tmpvolname);
+ $plugin->parse_volname($tmpvolname, $scfg);
};
if ($basename && defined($basevmid) && $basevmid == $vmid && $basename eq $name) {
@@ -589,7 +589,7 @@ sub path_to_volume_id {
if (my $scfg = $ids->{$sid}) {
if ($scfg->{path}) {
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
- my ($vtype, $name, $vmid) = $plugin->parse_volname($volname);
+ my ($vtype, $name, $vmid) = $plugin->parse_volname($volname, $scfg);
return ($vtype, $path);
}
}
@@ -1017,7 +1017,7 @@ sub vdisk_free {
if volume_is_base_and_used($cfg, $volid);
my (undef, undef, undef, undef, undef, $isBase, $format) =
- $plugin->parse_volname($volname);
+ $plugin->parse_volname($volname, $scfg);
$cleanup_worker = $plugin->free_image($storeid, $scfg, $volname, $isBase, $format);
});
@@ -2058,7 +2058,7 @@ sub rename_volume {
my $scfg = storage_config($cfg, $storeid);
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
- $target_vmid = ($plugin->parse_volname($source_volname))[3] if !$target_vmid;
+ $target_vmid = ($plugin->parse_volname($source_volname, $scfg))[3] if !$target_vmid;
return $plugin->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
return $plugin->rename_volume($scfg, $storeid, $source_volname, $target_vmid, $target_volname);
--
2.42.0
More information about the pve-devel
mailing list