From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH storage 10/26] plugins: update volname parsing for new naming convention
Date: Tue, 29 Jul 2025 13:15:23 +0200 [thread overview]
Message-ID: <20250729111557.136012-11-w.bumiller@proxmox.com> (raw)
In-Reply-To: <20250729111557.136012-1-w.bumiller@proxmox.com>
- ESXi, ISCSIDirect, ISCSI:
Volumes are always vm volumes.
- LVM:
New volumes use a `vol-vm-` or `vol-ct-` prefix.
- Dir based, LvmThin, RBD:
Like LVM, but for base images a `base-` prefix is added
*additionally*, instead of *replacing* the `vm-` portion like we
used to.
- ZFS:
VMs: `vol-vm-` prefix.
Containers: `subvol-ct-` prefix.
Both also get an optional additional `base-` prefix for base
volumes.
Note: all new base- prefix come in front of the `(sub)vol-*` prefixes.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
---
src/PVE/Storage/ESXiPlugin.pm | 2 +-
src/PVE/Storage/ISCSIDirectPlugin.pm | 2 +-
src/PVE/Storage/ISCSIPlugin.pm | 2 +-
src/PVE/Storage/LVMPlugin.pm | 19 ++++++++---
src/PVE/Storage/LvmThinPlugin.pm | 13 ++++++++
src/PVE/Storage/Plugin.pm | 48 +++++++++++++++++++++-------
src/PVE/Storage/RBDPlugin.pm | 45 ++++++++++++++++++++++++--
src/PVE/Storage/ZFSPoolPlugin.pm | 34 ++++++++++++++++----
8 files changed, 138 insertions(+), 27 deletions(-)
diff --git a/src/PVE/Storage/ESXiPlugin.pm b/src/PVE/Storage/ESXiPlugin.pm
index eeb6a48..ea2f8f9 100644
--- a/src/PVE/Storage/ESXiPlugin.pm
+++ b/src/PVE/Storage/ESXiPlugin.pm
@@ -421,7 +421,7 @@ sub parse_volname {
my $format = 'raw';
$format = 'vmdk' if $volname =~ /\.vmdk$/;
- return ('images', $volname, 0, undef, undef, undef, $format);
+ return ('vm-vol', $volname, 0, undef, undef, undef, $format);
}
sub list_images {
diff --git a/src/PVE/Storage/ISCSIDirectPlugin.pm b/src/PVE/Storage/ISCSIDirectPlugin.pm
index 069a41f..f5b466e 100644
--- a/src/PVE/Storage/ISCSIDirectPlugin.pm
+++ b/src/PVE/Storage/ISCSIDirectPlugin.pm
@@ -87,7 +87,7 @@ sub parse_volname {
my ($class, $volname) = @_;
if ($volname =~ m/^lun(\d+)$/) {
- return ('images', $1, undef, undef, undef, undef, 'raw');
+ return ('vm-vol', $1, undef, undef, undef, undef, 'raw');
}
die "unable to parse iscsi volume name '$volname'\n";
diff --git a/src/PVE/Storage/ISCSIPlugin.pm b/src/PVE/Storage/ISCSIPlugin.pm
index 7b30955..4875a1f 100644
--- a/src/PVE/Storage/ISCSIPlugin.pm
+++ b/src/PVE/Storage/ISCSIPlugin.pm
@@ -371,7 +371,7 @@ sub parse_volname {
my ($class, $volname) = @_;
if ($volname =~ m!^\d+\.\d+\.\d+\.([^/\s]+)$!) {
- return ('images', $1, undef, undef, undef, undef, 'raw');
+ return ('vm-vol', $1, undef, undef, undef, undef, 'raw');
}
die "unable to parse iscsi volume name '$volname'\n";
diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index 6694cf2..9b88c6a 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -452,11 +452,22 @@ sub parse_volname {
PVE::Storage::Plugin::parse_lvm_name($volname);
- if ($volname =~ m/^(vm-(\d+)-\S+)$/) {
- my $name = $1;
- my $vmid = $2;
+ if (
+ $volname =~ m!^(?<name>
+ (
+ # New style volumes have a vtype:
+ vol-(?<vtype>vm|ct)
+
+ # Old style:
+ | vm
+ )
+ -(?<vmid>\d+)-\S+
+ )$!xn
+ ) {
+ my ($name, $vmid, $vtype) = @+{qw(name vmid vtype)};
+ $vtype = $vtype ? "$vtype-vol" : 'images';
my $format = $volname =~ m/\.qcow2$/ ? 'qcow2' : 'raw';
- return ('images', $name, $vmid, undef, undef, undef, $format);
+ return ($vtype, $name, $vmid, undef, undef, undef, $format);
}
die "unable to parse lvm volume name '$volname'\n";
diff --git a/src/PVE/Storage/LvmThinPlugin.pm b/src/PVE/Storage/LvmThinPlugin.pm
index cdf0fd0..751bd7b 100644
--- a/src/PVE/Storage/LvmThinPlugin.pm
+++ b/src/PVE/Storage/LvmThinPlugin.pm
@@ -77,6 +77,19 @@ sub parse_volname {
PVE::Storage::Plugin::parse_lvm_name($volname);
+ # New naming convention:
+ if (
+ $volname =~ m/^(?<name>
+ (?<isbase>base-)?
+ (?:vol-(?<vtype> vm|ct))-
+ (?<vmid>\d+)-
+ \S+)$/xn
+ ) {
+ my ($name, $vmid, $vtype, $isbase) = @+{qw(name vmid vtype isbase)};
+ return ($vtype . '-vol', $name, $vmid, undef, undef, !!$isbase, 'raw');
+ }
+
+ # Old naming convention:
if ($volname =~ m/^((vm|base)-(\d+)-\S+)$/) {
return ('images', $1, $3, undef, undef, $2 eq 'base', 'raw');
}
diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index ae9d673..77bcfc7 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -711,19 +711,46 @@ sub cluster_lock_storage {
my sub parse_snap_name {
my ($name) = @_;
+ if ($name =~ m/^snap-(.*)-vol-(?:vm|ct)(.*)$/) {
+ return $1;
+ }
+
if ($name =~ m/^snap-(.*)-vm(.*)$/) {
return $1;
}
+
+ return;
}
+our $DISK_NAME_REGEX = qr!
+ (?<name>
+ (
+ # New convention: 'base-' prefix, 'vol-vm' and 'subvol-ct'.
+ (?<israw> (?<isbase>base-)? vol- (?<vtype> vm|ct))
+ | (?<issub> (?<isbase>base-)? subvol- (?<vtype> ct))
+
+ # Old convention: "vm" vs "base" and "subvol" vs "basevol"
+ | (?<israw> vm)
+ | (?<issub> subvol)
+ | (?<israw> (?<isbase>base))
+ | (?<issub> (?<isbase>basevol))
+ )
+ -
+ (?<vmid>\d+)
+ -
+ (?<label>[^/\s]+)
+ )
+!xn;
+
sub parse_name_dir {
- my $name = shift;
+ my ($name) = @_;
- if ($name =~ m!^((vm-|base-|subvol-)(\d+)-[^/\s]+\.(raw|qcow2|vmdk|subvol))$!) {
- my $isbase = $2 eq 'base-' ? $2 : undef;
- return ($1, $4, $isbase); # (name, format, isBase)
+ if ($name =~ m!^$DISK_NAME_REGEX\.(?<format>raw|qcow2|vmdk|subvol)$!xn) {
+ my ($name, $israw, $issub, $isbase, $vmid, $vtype, $label, $format) =
+ @+{qw(name israw issub isbase vmid vtype label format)};
+ return ($name, $format, !!$isbase, $vtype ? "$vtype-vol" : "images");
} elsif ($name =~ m!^((base-)?[^/\s]+\.(raw|qcow2|vmdk|subvol))$!) {
- warn "this volume name `$name` is not supported anymore\n" if !parse_snap_name($name);
+ die "this volume name `$name` is not supported anymore\n";
}
die "unable to parse volume filename '$name'\n";
@@ -733,15 +760,14 @@ sub parse_volname {
my ($class, $volname) = @_;
if ($volname =~ m!^(\d+)/(\S+)/(\d+)/(\S+)$!) {
- my ($basedvmid, $basename) = ($1, $2);
+ my ($basedvmid, $basename, $vmid, $name) = ($1, $2, $3, $4);
parse_name_dir($basename);
- my ($vmid, $name) = ($3, $4);
- my (undef, $format, $isBase) = parse_name_dir($name);
- return ('images', $name, $vmid, $basename, $basedvmid, $isBase, $format);
+ my (undef, $format, $isBase, $vtype) = parse_name_dir($name);
+ return ($vtype, $name, $vmid, $basename, $basedvmid, $isBase, $format);
} elsif ($volname =~ m!^(\d+)/(\S+)$!) {
my ($vmid, $name) = ($1, $2);
- my (undef, $format, $isBase) = parse_name_dir($name);
- return ('images', $name, $vmid, undef, undef, $isBase, $format);
+ my (undef, $format, $isBase, $vtype) = parse_name_dir($name);
+ return ($vtype, $name, $vmid, undef, undef, $isBase, $format);
} elsif ($volname =~ m!^iso/([^/]+$PVE::Storage::ISO_EXT_RE_0)$!) {
return ('iso', $1, undef, undef, undef, undef, 'raw');
} elsif ($volname =~ m!^vztmpl/([^/]+$PVE::Storage::VZTMPL_EXT_RE_1)$!) {
diff --git a/src/PVE/Storage/RBDPlugin.pm b/src/PVE/Storage/RBDPlugin.pm
index 9f95c73..4400aeb 100644
--- a/src/PVE/Storage/RBDPlugin.pm
+++ b/src/PVE/Storage/RBDPlugin.pm
@@ -224,15 +224,26 @@ sub rbd_ls {
my $image = $el->{image};
- my ($owner) = $image =~ m/^(?:vm|base)-(\d+)-/;
- next if !defined($owner);
+ my ($owner, $vtype);
+ if ($image =~ /^(?:base-)?vol-(vm|ct)-(\d+)-/) {
+ $vtype = $1;
+ $owner = $2;
+ } elsif ($image =~ /^(?:vm|base)-(\d+)-/) {
+ $owner = $1;
+ } else {
+ next;
+ }
- $list->{$image} = {
+ my $info = {
name => $image,
size => $el->{size},
parent => $get_parent_image_name->($el->{parent}),
vmid => $owner,
};
+
+ $info->{vtype} = $vtype if defined($vtype);
+
+ $list->{$image} = $info;
}
return $list;
@@ -498,6 +509,34 @@ sub on_delete_hook {
sub parse_volname {
my ($class, $volname) = @_;
+ # New naming scheme:
+ if (
+ $volname =~ m!^(?<name>
+ (?<hasbase>
+ base-
+ (?<basevmid> \d+ )-
+ (?<basename> \S+ )
+ /
+ )?
+ (?<isbase> base- )?
+ vol-(?<vtype> vm | ct )-
+ (?<vmid> \d+ )-
+ (?<name> \S+ )
+ )$
+ !x
+ ) {
+ return (
+ $+{vtype} . '-vol',
+ $+{name},
+ $+{vmid},
+ $+{basename},
+ $+{basevmid},
+ !!$+{isbase},
+ 'raw',
+ );
+ }
+
+ # Old naming scheme:
if ($volname =~ m/^((base-(\d+)-\S+)\/)?((base)?(vm)?-(\d+)-\S+)$/) {
return ('images', $4, $7, $2, $3, $5, 'raw');
}
diff --git a/src/PVE/Storage/ZFSPoolPlugin.pm b/src/PVE/Storage/ZFSPoolPlugin.pm
index 0152c89..8e917b4 100644
--- a/src/PVE/Storage/ZFSPoolPlugin.pm
+++ b/src/PVE/Storage/ZFSPoolPlugin.pm
@@ -91,8 +91,15 @@ sub zfs_parse_zvol_list {
my $parsed_pool = join('/', @parts);
next if $parsed_pool ne $pool;
- next unless $name =~ m!^(vm|base|subvol|basevol)-(\d+)-(\S+)$!;
- $zvol->{owner} = $2;
+ if ($name =~ m!^((base-)?vol-vm)-(?<owner>\d+)-\S+$!n) {
+ $zvol->{owner} = $+{owner};
+ } elsif ($name =~ m!^((base-)?subvol-ct)-(?<owner>\d+)-\S+$!n) {
+ $zvol->{owner} = $+{owner};
+ } elsif ($name =~ m!^(vm|base|subvol|basevol)-(?<owner>\d+)-(\S+)$!n) {
+ $zvol->{owner} = $+{owner};
+ } else {
+ next;
+ }
$zvol->{name} = $name;
if ($type eq 'filesystem') {
@@ -118,10 +125,25 @@ sub zfs_parse_zvol_list {
sub parse_volname {
my ($class, $volname) = @_;
- if ($volname =~ m/^(((base|basevol)-(\d+)-\S+)\/)?((base|basevol|vm|subvol)-(\d+)-\S+)$/) {
- my $format = ($6 eq 'subvol' || $6 eq 'basevol') ? 'subvol' : 'raw';
- my $isBase = ($6 eq 'base' || $6 eq 'basevol');
- return ('images', $5, $7, $2, $4, $isBase, $format);
+ if (
+ $volname =~ m!^
+ ((?<basename>
+ (base-vol-vm | base-subvol-ct | base | basevol)
+ - (?<basevmid>\d+)
+ - \S+)
+ /)?
+ ${PVE::Storage::Plugin::DISK_NAME_REGEX}
+ $!xn
+ ) {
+ my ($basename, $basevmid, $name, $israw, $issub, $isbase, $vmid, $vtype) =
+ @+{qw(basename basevmid name israw issub isbase vmid vtype)};
+ my $format = $issub ? 'subvol' : 'raw';
+ if ($vtype) {
+ $vtype = "${vtype}-vol";
+ } else {
+ $vtype = $issub ? 'ct-vol' : 'vm-vol';
+ }
+ return ($vtype, $name, $vmid, $basename, $basevmid, $isbase, $format);
}
die "unable to parse zfs volume name '$volname'\n";
--
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-29 11:16 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 11:15 [pve-devel] [RFC storage 00/26+10+3] unify vtype and content-type and Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH storage 01/26] btrfs: remove unnecessary mkpath call Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH storage 02/26] parse_volname: remove openvz 'rootdir' case Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH storage 03/26] drop rootdir case in path_to_volume_id Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH storage 04/26] escape dirs in path_to_volume_id regexes Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH storage 05/26] tests: drop rootdir/ tests Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH storage 06/26] common: use v5.36 Wolfgang Bumiller
2025-07-29 13:59 ` Fiona Ebner
2025-07-29 14:42 ` Thomas Lamprecht
2025-07-29 11:15 ` [pve-devel] [PATCH storage 07/26] common: add pve-storage-vtype standard option with new types Wolfgang Bumiller
2025-07-29 13:50 ` Fiona Ebner
2025-07-29 11:15 ` [pve-devel] [PATCH storage 08/26] prepare for vm-vol and ct-vol content and vtypes Wolfgang Bumiller
2025-07-30 8:38 ` Fabian Grünbichler
2025-08-08 12:01 ` Wolfgang Bumiller
2025-07-30 9:14 ` Fabian Grünbichler
2025-08-08 12:05 ` Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH storage 09/26] plugins: add new content types to all plugindata Wolfgang Bumiller
2025-07-30 8:38 ` Fabian Grünbichler
2025-08-08 12:10 ` Wolfgang Bumiller
2025-07-29 11:15 ` Wolfgang Bumiller [this message]
2025-07-30 8:37 ` [pve-devel] [PATCH storage 10/26] plugins: update volname parsing for new naming convention Fabian Grünbichler
2025-07-30 8:53 ` Wolfgang Bumiller
2025-07-30 8:58 ` Fabian Grünbichler
2025-07-29 11:15 ` [pve-devel] [PATCH storage 11/26] plugin: add vm/ct-vol to 'local' storage default content types Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH storage 12/26] plugin: support new vtypes in activate_storage checks Wolfgang Bumiller
2025-07-30 8:36 ` Fabian Grünbichler
2025-08-08 13:16 ` Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH storage 13/26] plugin, btrfs: update list_images and list_volumes Wolfgang Bumiller
2025-07-30 8:36 ` Fabian Grünbichler
2025-07-30 8:41 ` Fiona Ebner
2025-07-29 11:15 ` [pve-devel] [PATCH storage 14/26] plugins: update image/volume listing to support new types Wolfgang Bumiller
2025-07-30 8:36 ` Fabian Grünbichler
2025-07-29 11:15 ` [pve-devel] [PATCH storage 15/26] common: add is_volume_type and is_type_change_allowed helpers Wolfgang Bumiller
2025-07-30 9:01 ` Fabian Grünbichler
2025-07-29 11:15 ` [pve-devel] [PATCH storage 16/26] common: add volume_type_from_name convenience helper Wolfgang Bumiller
2025-07-30 8:36 ` Fabian Grünbichler
2025-07-30 9:09 ` Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH storage 17/26] plugins: add vtype parameter to alloc_image Wolfgang Bumiller
2025-07-30 9:24 ` Fabian Grünbichler
2025-07-30 14:00 ` Max R. Carrara
2025-07-30 14:05 ` Max R. Carrara
2025-07-30 14:26 ` Fabian Grünbichler
2025-07-30 14:49 ` Max R. Carrara
2025-07-30 15:01 ` Fabian Grünbichler
2025-07-29 11:15 ` [pve-devel] [PATCH storage 18/26] plugins: update create_base methods Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH storage 19/26] plugins: update clone_image methods Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH storage 20/26] plugins: update rename_volumes methods Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH storage 21/26] plugins: update volume_import methods Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH storage 22/26] zfs: update 'path' method for new naming scheme Wolfgang Bumiller
2025-07-30 9:31 ` Fabian Grünbichler
2025-07-29 11:15 ` [pve-devel] [PATCH storage 23/26] pvesm: add vtype parameter to import command Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH storage 24/26] api: add vtype parameter to create call Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH storage 25/26] update tests Wolfgang Bumiller
2025-07-29 16:33 ` Max R. Carrara
2025-07-29 11:15 ` [pve-devel] [PATCH storage 26/26] update ApiChangeLog Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH container 1/3] add vtype to vdisk_alloc and vdisk_clone calls Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH container 2/3] expect 'vm-vol' vtype in get_replicatable_volumes Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH container 3/3] add vtype to rename_volume call Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH qemu-server 01/10] add vtype to vdisk_alloc and vdisk_clone calls Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH qemu-server 02/10] add vtype parameter to rename_volume call Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH qemu-server 03/10] expect 'vm-vol' vtype in get_replicatable_volumes Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH qemu-server 04/10] expect 'vm-vol' vtype wherever 'images' was expected Wolfgang Bumiller
2025-07-30 8:40 ` Fabian Grünbichler
2025-07-30 9:17 ` Fiona Ebner
2025-07-30 9:33 ` Fiona Ebner
2025-07-29 11:15 ` [pve-devel] [PATCH qemu-server 05/10] tests: update QmMock to support vtypes Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH qemu-server 06/10] tests: scripted: update tests to new vtypes and paths Wolfgang Bumiller
2025-07-29 14:13 ` Max R. Carrara
2025-07-29 11:15 ` [pve-devel] [PATCH qemu-server 07/10] make tidy Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH qemu-server 08/10] tests: fixup restore test to use new volume naming scheme Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH qemu-server 09/10] tests: update remaining tests to new snapshot paths Wolfgang Bumiller
2025-07-29 11:15 ` [pve-devel] [PATCH qemu-server 10/10] tests: regenerate cfg2cmd files Wolfgang Bumiller
2025-07-29 14:19 ` Max R. Carrara
2025-07-29 15:34 ` [pve-devel] partially-applied: [RFC storage 00/26+10+3] unify vtype and content-type and 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=20250729111557.136012-11-w.bumiller@proxmox.com \
--to=w.bumiller@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