From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <f.ebner@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 36964723B3
 for <pve-devel@lists.proxmox.com>; Tue, 25 May 2021 09:57:35 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 28D9129801
 for <pve-devel@lists.proxmox.com>; Tue, 25 May 2021 09:57:35 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id 8D880297F2
 for <pve-devel@lists.proxmox.com>; Tue, 25 May 2021 09:57:34 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 6371243ECF
 for <pve-devel@lists.proxmox.com>; Tue, 25 May 2021 09:57:28 +0200 (CEST)
To: pve-devel@lists.proxmox.com, l.stechauner@proxmox.com
References: <20210517090324.63391-1-l.stechauner@proxmox.com>
From: Fabian Ebner <f.ebner@proxmox.com>
Message-ID: <284af35b-70f3-ed07-2200-4e9002c2c976@proxmox.com>
Date: Tue, 25 May 2021 09:57:19 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.10.0
MIME-Version: 1.0
In-Reply-To: <20210517090324.63391-1-l.stechauner@proxmox.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.002 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 NICE_REPLY_A           -0.001 Looks like a legit reply (A)
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [lxc.pm]
Subject: Re: [pve-devel] [PATCH v2 container] fix #3421: allow custom
 storage plugins to support rootfs
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Tue, 25 May 2021 07:57:35 -0000

Am 17.05.21 um 11:03 schrieb Lorenz Stechauner:
> it is now necessary for storages to support the 'rootdir' content
> in order to create/start containers on them. all native storage
> plugins already report the rootdir content correctly.
> 

For creation, this was already required in the past. For startup, while 
such a change can be fine for 7.0, if we go for it, we should make the 
equivalent change for VMs too (requiring the 'image' content type to be 
configured for the relevant storages upon startup).

> Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
> ---
>   src/PVE/LXC.pm | 30 ++++++++++++------------------
>   1 file changed, 12 insertions(+), 18 deletions(-)
> 
> diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
> index 7e6f378..75e1c20 100644
> --- a/src/PVE/LXC.pm
> +++ b/src/PVE/LXC.pm
> @@ -1682,15 +1682,16 @@ sub __mountpoint_mount {
>   		}
>   	    };
>   	    my $use_loopdev = 0;
> -	    if ($scfg->{path}) {
> -		$mounted_dev = run_with_loopdev($domount, $path, $readonly);
> -		$use_loopdev = 1;
> -	    } elsif ($scfg->{type} eq 'drbd' || $scfg->{type} eq 'lvm' ||
> -		     $scfg->{type} eq 'rbd' || $scfg->{type} eq 'lvmthin') {
> -		$mounted_dev = $path;
> -		&$domount($path);
> +	    if ($scfg->{content}->{rootdir}) {
> +		if ($scfg->{path}) {
> +		    $mounted_dev = run_with_loopdev($domount, $path, $readonly);
> +		    $use_loopdev = 1;
> +		} else {
> +		    $mounted_dev = $path;
> +		    &$domount($path);
> +		}
>   	    } else {
> -		die "unsupported storage type '$scfg->{type}'\n";
> +		die "storage type '$scfg->{type}' does not support containers\n";

Note that it's not necessarily the storage type which does not support 
'rootdir', it could simply be that the concrete storage is not 
configured for 'rootdir' content type. So the error message should use 
the storage ID instead of the storage type.

>   	    }
>   	    return wantarray ? ($path, $use_loopdev, $mounted_dev) : $path;
>   	} else {
> @@ -1871,7 +1872,7 @@ sub alloc_disk {
>   
>       eval {
>   	my $do_format = 0;
> -	if ($scfg->{type} eq 'dir' || $scfg->{type} eq 'nfs' || $scfg->{type} eq 'cifs' ) {
> +	if ($scfg->{content}->{rootdir} && $scfg->{path}) {
>   	    if ($size_kb > 0) {
>   		$volid = PVE::Storage::vdisk_alloc($storecfg, $storage, $vmid, 'raw',
>   						   undef, $size_kb);
> @@ -1882,21 +1883,14 @@ sub alloc_disk {
>   		$needs_chown = 1;
>   	    }
>   	} elsif ($scfg->{type} eq 'zfspool') {
> -
>   	    $volid = PVE::Storage::vdisk_alloc($storecfg, $storage, $vmid, 'subvol',
>   					       undef, $size_kb);
>   	    $needs_chown = 1;
> -	} elsif ($scfg->{type} eq 'drbd' || $scfg->{type} eq 'lvm' || $scfg->{type} eq 'lvmthin') {
> -
> -	    $volid = PVE::Storage::vdisk_alloc($storecfg, $storage, $vmid, 'raw', undef, $size_kb);
> -	    $do_format = 1;
> -
> -	} elsif ($scfg->{type} eq 'rbd') {
> -
> +	} elsif ($scfg->{content}->{rootdir}) {
>   	    $volid = PVE::Storage::vdisk_alloc($storecfg, $storage, $vmid, 'raw', undef, $size_kb);
>   	    $do_format = 1;
>   	} else {
> -	    die "unable to create containers on storage type '$scfg->{type}'\n";
> +	    die "storage type '$scfg->{type}' does not supoort containers\n";

Same as above.

>   	}
>   	format_disk($storecfg, $volid, $rootuid, $rootgid) if $do_format;
>       };
>