[pve-devel] applied: [PATCH storage] don't (accidentally) modify PVE::Cluster::vmlist

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Jan 8 12:05:15 CET 2020


On 1/7/20 12:24 PM, Fabian Grünbichler wrote:
> when listing volumes, otherwise an empty hash can be persisted into the
> current worker's $vmlist, which could cause issues at various other API
> endpoints.
> 
> Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
> ---
> 
> Notes:
>     likely cause of https://forum.proxmox.com/threads/proxmox-api-unable-to-create-vm-already-exists-on-node.62868/
> 
>  PVE/Storage/Plugin.pm | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
> index e826d36..0c39cbd 100644
> --- a/PVE/Storage/Plugin.pm
> +++ b/PVE/Storage/Plugin.pm
> @@ -958,8 +958,11 @@ sub list_volumes {
>  
>  	foreach my $item (@$data) {
>  	    if ($type eq 'images' || $type eq 'rootdir') {
> -
> -		my $vmtype = $vmlist->{ids}->{$item->{vmid}}->{type};
> +		my $vminfo = $vmlist->{ids}->{$item->{vmid}};
> +		my $vmtype;
> +		if (defined($vminfo)) {
> +		    $vmtype = $vminfo->{type};
> +		}
>  		if (defined($vmtype) && $vmtype eq 'lxc') {
>  		    $item->{content} = 'rootdir';
>  		} else {
> 

applied, thanks! Could have been slightly shorter with:

my $vminfo = $vmlist->{ids}->{$item->{vmid}} // {};
my $vmtype = $vminfo->{type};

but OK as is. nice catch!





More information about the pve-devel mailing list