From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH storage 14/26] plugins: update image/volume listing to support new types
Date: Wed, 30 Jul 2025 10:36:52 +0200 [thread overview]
Message-ID: <1753862619.nlcvtibp88.astroid@yuna.none> (raw)
In-Reply-To: <20250729111557.136012-15-w.bumiller@proxmox.com>
On July 29, 2025 1:15 pm, Wolfgang Bumiller wrote:
> Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
> ---
> src/PVE/Storage/Common.pm | 31 ++++++++++++++++++++++++++
> src/PVE/Storage/ISCSIDirectPlugin.pm | 5 ++++-
> src/PVE/Storage/ISCSIPlugin.pm | 7 ++++--
> src/PVE/Storage/LVMPlugin.pm | 28 +++++++++++++----------
> src/PVE/Storage/LvmThinPlugin.pm | 33 ++++++++++++++++++----------
> src/PVE/Storage/PBSPlugin.pm | 2 +-
> src/PVE/Storage/RBDPlugin.pm | 9 ++++++--
> src/PVE/Storage/ZFSPoolPlugin.pm | 16 +++++++++++++-
> 8 files changed, 102 insertions(+), 29 deletions(-)
>
> diff --git a/src/PVE/Storage/Common.pm b/src/PVE/Storage/Common.pm
> index b2ebd50..bab1260 100644
> --- a/src/PVE/Storage/Common.pm
> +++ b/src/PVE/Storage/Common.pm
> @@ -282,4 +282,35 @@ sub qemu_img_resize {
> run_command($cmd, timeout => $timeout);
> }
>
> +=head3 should_list_images($expected_content_type, $volume_type)
> +
> +Returns whether a volume of type C<$volume_type> should be listed in C<list_images> if the expected
> +content type is C<$expcted_content_type>.
> +
> +This effectively checks if C<$expected_content_type> is a "supertype" of C<$volume_type>.
> +
> +=cut
> +
> +sub should_list_images : prototype($$) ($expected_content_type, $volume_type) {
> + # If we have no expected type, everything should be listed.
> + return 1 if !defined($expected_content_type);
> +
> + if (!$volume_type) {
> + # For 'images' and 'rootdir', an unknown volume type should also be listed.
> + return 1
> + if $expected_content_type eq 'images' || $expected_content_type eq 'rootdir';
> + # Otherwise unknown volume types are unexpected.
> + return 0;
> + }
> +
> + # Images should also include vm-vol.
> + return 1 if $expected_content_type eq 'images' && $volume_type eq 'vm-vol';
> +
> + # Rootdir should also include ct-vol.
> + return 1 if $expected_content_type eq 'rootdir' && $volume_type eq 'ct-vol';
could we drop this if we made pve-container and qemu-server list twice,
once with the legacy and once with the new type? AFAICT the only user of
this is `PVE::Storage::vdisk_list` and list_volumes?
it seems like a potential footgun to have the legacy types refer to just
the legacy types sometimes, but both legacy and new types in other
places..
> +
> + # Otherwise they must be equal.
> + return $expected_content_type eq $volume_type;
> +}
> +
> 1;
> diff --git a/src/PVE/Storage/ISCSIDirectPlugin.pm b/src/PVE/Storage/ISCSIDirectPlugin.pm
> index f5b466e..98a3391 100644
> --- a/src/PVE/Storage/ISCSIDirectPlugin.pm
> +++ b/src/PVE/Storage/ISCSIDirectPlugin.pm
> @@ -152,10 +152,12 @@ sub free_image {
> }
>
> sub list_images {
> - my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
> + my ($class, $storeid, $scfg, $vmid, $vollist, $cache, $content_type) = @_;
>
> my $res = [];
>
> + return $res if $content_type && $content_type ne 'images' && $content_type ne 'vm-vol';
> +
> # we have no owner for iscsi devices
>
> my $dat = iscsi_ls($scfg);
> @@ -172,6 +174,7 @@ sub list_images {
>
> my $info = $dat->{$volname};
> $info->{volid} = $volid;
> + $info->{vtype} = 'vm-vol';
>
> push @$res, $info;
> }
> diff --git a/src/PVE/Storage/ISCSIPlugin.pm b/src/PVE/Storage/ISCSIPlugin.pm
> index 4875a1f..77a9173 100644
> --- a/src/PVE/Storage/ISCSIPlugin.pm
> +++ b/src/PVE/Storage/ISCSIPlugin.pm
> @@ -421,17 +421,19 @@ sub list_volumes {
> my $res = $class->list_images($storeid, $scfg, $vmid);
>
> for my $item (@$res) {
> - $item->{content} = 'images'; # we only have images
> + $item->{content} = 'vm-vol'; # we only have VM images
> }
>
> return $res;
> }
>
> sub list_images {
> - my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
> + my ($class, $storeid, $scfg, $vmid, $vollist, $cache, $content_type) = @_;
>
> my $res = [];
>
> + return $res if $content_type && $content_type ne 'images' && $content_type ne 'vm-vol';
> +
> $cache->{iscsi_devices} = iscsi_device_list() if !$cache->{iscsi_devices};
>
> # we have no owner for iscsi devices
> @@ -454,6 +456,7 @@ sub list_images {
>
> my $info = $dat->{$volname};
> $info->{volid} = $volid;
> + $info->{vtype} = 'vm-vol';
>
> push @$res, $info;
> }
> diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
> index 9b88c6a..55c4578 100644
> --- a/src/PVE/Storage/LVMPlugin.pm
> +++ b/src/PVE/Storage/LVMPlugin.pm
> @@ -750,7 +750,7 @@ my $check_tags = sub {
> };
>
> sub list_images {
> - my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
> + my ($class, $storeid, $scfg, $vmid, $vollist, $cache, $content_type) = @_;
>
> my $vgname = $scfg->{vgname};
>
> @@ -762,8 +762,11 @@ sub list_images {
>
> foreach my $volname (keys %$dat) {
>
> - next if $volname !~ m/^vm-(\d+)-/;
> - my $owner = $1;
> + next if $volname !~ m/^(?:vol-(?<vtype>vm|ct)-|vm)-(?<owner>\d+)-/xn;
> + my $owner = $+{owner};
> + my $vtype = $+{vtype} ? $+{vtype} . '-vol' : undef;
> +
> + next if !PVE::Storage::Common::should_list_images($content_type, $vtype);
>
> my $info = $dat->{$volname};
>
> @@ -787,14 +790,17 @@ sub list_images {
> ? $class->volume_size_info($scfg, $storeid, $volname)
> : $info->{lv_size};
>
> - push @$res,
> - {
> - volid => $volid,
> - format => $format,
> - size => $size,
> - vmid => $owner,
> - ctime => $info->{ctime},
> - };
> + my $entry = {
> + volid => $volid,
> + format => $format,
> + size => $size,
> + vmid => $owner,
> + ctime => $info->{ctime},
> + };
> +
> + $entry->{vtype} = $vtype if defined($vtype);
> +
> + push @$res, $entry;
> }
> }
>
> diff --git a/src/PVE/Storage/LvmThinPlugin.pm b/src/PVE/Storage/LvmThinPlugin.pm
> index 751bd7b..f6615d9 100644
> --- a/src/PVE/Storage/LvmThinPlugin.pm
> +++ b/src/PVE/Storage/LvmThinPlugin.pm
> @@ -182,7 +182,7 @@ sub free_image {
> }
>
> sub list_images {
> - my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
> + my ($class, $storeid, $scfg, $vmid, $vollist, $cache, $content_type) = @_;
>
> my $vgname = $scfg->{vgname};
>
> @@ -193,9 +193,17 @@ sub list_images {
> if (my $dat = $cache->{lvs}->{$vgname}) {
>
> foreach my $volname (keys %$dat) {
> + my ($owner, $vtype);
> + if ($volname =~ m/^(?:base-)?vol-(ct|vm)-(\d+)-/) {
> + $vtype = "$1-vol";
> + $owner = $2;
> + } elsif ($volname =~ m/^(?:vm|base)-(\d+)-/) {
> + $owner = $1;
> + } else {
> + next;
> + }
>
> - next if $volname !~ m/^(vm|base)-(\d+)-/;
> - my $owner = $2;
> + next if !PVE::Storage::Common::should_list_images($content_type, $vtype);
>
> my $info = $dat->{$volname};
>
> @@ -212,14 +220,17 @@ sub list_images {
> next if defined($vmid) && ($owner ne $vmid);
> }
>
> - push @$res,
> - {
> - volid => $volid,
> - format => 'raw',
> - size => $info->{lv_size},
> - vmid => $owner,
> - ctime => $info->{ctime},
> - };
> + my $entry = {
> + volid => $volid,
> + format => 'raw',
> + size => $info->{lv_size},
> + vmid => $owner,
> + ctime => $info->{ctime},
> + };
> +
> + $entry->{vtype} = $vtype if defined($vtype);
> +
> + push @$res, $entry;
> }
> }
>
> diff --git a/src/PVE/Storage/PBSPlugin.pm b/src/PVE/Storage/PBSPlugin.pm
> index 00170f5..bab026b 100644
> --- a/src/PVE/Storage/PBSPlugin.pm
> +++ b/src/PVE/Storage/PBSPlugin.pm
> @@ -674,7 +674,7 @@ sub free_image {
> }
>
> sub list_images {
> - my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
> + my ($class, $storeid, $scfg, $vmid, $vollist, $cache, $content_type) = @_;
>
> my $res = [];
>
> diff --git a/src/PVE/Storage/RBDPlugin.pm b/src/PVE/Storage/RBDPlugin.pm
> index 4400aeb..2ef1280 100644
> --- a/src/PVE/Storage/RBDPlugin.pm
> +++ b/src/PVE/Storage/RBDPlugin.pm
> @@ -773,7 +773,7 @@ sub free_image {
> }
>
> sub list_images {
> - my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
> + my ($class, $storeid, $scfg, $vmid, $vollist, $cache, $content_type) = @_;
>
> my $dat = rbd_ls($scfg, $storeid);
> return [] if !$dat; # nothing found
> @@ -783,12 +783,17 @@ sub list_images {
> my $info = $dat->{$image};
> my ($volname, $parent, $owner) = $info->@{ 'name', 'parent', 'vmid' };
>
> - if ($parent && $parent =~ m/^(base-\d+-\S+)\@__base__$/) {
> + my $vtype;
> +
> + if ($parent && $parent =~ m/^(base(?:-vol-(?<vtype>vm|ct))?-\d+-\S+)\@__base__$/xn) {
> + $vtype = $+{vtype} ? $+{vtype} . '-vol' : undef;
> $info->{volid} = "$storeid:$1/$volname";
> } else {
> $info->{volid} = "$storeid:$volname";
> }
>
> + next if !PVE::Storage::Common::should_list_images($content_type, $vtype);
> +
> if ($vollist) {
> my $found = grep { $_ eq $info->{volid} } @$vollist;
> next if !$found;
> diff --git a/src/PVE/Storage/ZFSPoolPlugin.pm b/src/PVE/Storage/ZFSPoolPlugin.pm
> index 8e917b4..d65af69 100644
> --- a/src/PVE/Storage/ZFSPoolPlugin.pm
> +++ b/src/PVE/Storage/ZFSPoolPlugin.pm
> @@ -122,6 +122,16 @@ sub zfs_parse_zvol_list {
> return $list;
> }
>
> +my sub image_vtype_from_name : prototype($) {
> + my ($name) = @_;
> +
> + return 'ct-vol' if $name =~ /^(base-)?subvol(-ct)?-/;
> + return 'ct-vol' if $name =~ /^basevol-/;
> + return 'vm-vol' if $name =~ /^(base-)?vol(-vm)?-/;
> + return 'vm-vol' if $name =~ /^base-/;
> + return 'images';
> +}
> +
> sub parse_volname {
> my ($class, $volname) = @_;
>
> @@ -305,7 +315,7 @@ sub free_image {
> }
>
> sub list_images {
> - my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
> + my ($class, $storeid, $scfg, $vmid, $vollist, $cache, $content_type) = @_;
>
> my $zfs_list = $class->zfs_list_zvol($scfg);
>
> @@ -330,6 +340,10 @@ sub list_images {
> next if defined($vmid) && ($owner ne $vmid);
> }
>
> + my $vtype = volume_type_from_name($volname);
> + next if !PVE::Storage::Common::should_list_images($content_type, $vtype);
> + $info->{vtype} = $vtype if $vtype ne 'images' && $vtype ne 'rootdir';
> +
> push @$res, $info;
> }
> return $res;
> --
> 2.47.2
>
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
>
>
_______________________________________________
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-30 8:35 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 ` [pve-devel] [PATCH storage 10/26] plugins: update volname parsing for new naming convention Wolfgang Bumiller
2025-07-30 8:37 ` 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 [this message]
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=1753862619.nlcvtibp88.astroid@yuna.none \
--to=f.gruenbichler@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.