[pve-devel] [PATCH storage] Do not include a volume more than once in list_volumes
Fabian Ebner
f.ebner at proxmox.com
Wed Nov 20 08:41:09 CET 2019
On 11/19/19 10:13 AM, Fabian Ebner wrote:
> When 'content_types' included both 'images' and 'rootdir', a single volume
> could appear twice in the volume list. This also fixes the same kind of
> duplication in 'pvesm list'.
>
> Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
> ---
> PVE/Storage/Plugin.pm | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
> index 88da231..5ce3ef8 100644
> --- a/PVE/Storage/Plugin.pm
> +++ b/PVE/Storage/Plugin.pm
> @@ -937,6 +937,7 @@ sub list_volumes {
> my ($class, $storeid, $scfg, $vmid, $content_types) = @_;
>
> my $res = [];
> + my $seen = {};
>
> foreach my $ct (@$content_types) {
> my $data;
> @@ -960,8 +961,11 @@ sub list_volumes {
> next if !$data;
>
> foreach my $item (@$data) {
> - $item->{content} = $ct;
> - push @$res, $item;
> + if (!$seen->{$item->{volid}}) {
> + $seen->{$item->{volid}} = 1;
> + $item->{content} = $ct;
> + push @$res, $item;
> + }
> }
> }
>
>
Please just ignore this. Tim already sent a patch which also sets
$item->{content} to the correct value, while mine doesn't.
More information about the pve-devel
mailing list