public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH v2 container] fix #3421: allow custom storage plugins to support rootfs
@ 2021-05-17  9:03 Lorenz Stechauner
  2021-05-17 13:41 ` Thomas Lamprecht
  2021-05-25  7:57 ` Fabian Ebner
  0 siblings, 2 replies; 4+ messages in thread
From: Lorenz Stechauner @ 2021-05-17  9:03 UTC (permalink / raw)
  To: pve-devel

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.

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";
 	    }
 	    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";
 	}
 	format_disk($storecfg, $volid, $rootuid, $rootgid) if $do_format;
     };
-- 
2.20.1





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] [PATCH v2 container] fix #3421: allow custom storage plugins to support rootfs
  2021-05-17  9:03 [pve-devel] [PATCH v2 container] fix #3421: allow custom storage plugins to support rootfs Lorenz Stechauner
@ 2021-05-17 13:41 ` Thomas Lamprecht
  2021-05-17 14:21   ` Lorenz Stechauner
  2021-05-25  7:57 ` Fabian Ebner
  1 sibling, 1 reply; 4+ messages in thread
From: Thomas Lamprecht @ 2021-05-17 13:41 UTC (permalink / raw)
  To: Proxmox VE development discussion, Lorenz Stechauner

On 17.05.21 11:03, Lorenz Stechauner wrote:
> 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.
> 
> Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
> ---

I'm missing the description of changes from v1 -> v2 here...

>  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";
>  	    }
>  	    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";
>  	}
>  	format_disk($storecfg, $volid, $rootuid, $rootgid) if $do_format;
>      };
> 





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] [PATCH v2 container] fix #3421: allow custom storage plugins to support rootfs
  2021-05-17 13:41 ` Thomas Lamprecht
@ 2021-05-17 14:21   ` Lorenz Stechauner
  0 siblings, 0 replies; 4+ messages in thread
From: Lorenz Stechauner @ 2021-05-17 14:21 UTC (permalink / raw)
  To: Thomas Lamprecht, Proxmox VE development discussion

On 5/17/21 3:41 PM, Thomas Lamprecht wrote:

> On 17.05.21 11:03, Lorenz Stechauner wrote:
>> 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.
>>
>> Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
>> ---
> I'm missing the description of changes from v1 -> v2 here...

Sorry, forgot to include. Changes v1 -> v2:

- Added a commit message which explains the need of content type 'rootdir'
- code style
- new behavior should now be the same as old behavior (regarding native 
storage plugins)
- updated error messages

>>   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";
>>   	    }
>>   	    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";
>>   	}
>>   	format_disk($storecfg, $volid, $rootuid, $rootgid) if $do_format;
>>       };
>>




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] [PATCH v2 container] fix #3421: allow custom storage plugins to support rootfs
  2021-05-17  9:03 [pve-devel] [PATCH v2 container] fix #3421: allow custom storage plugins to support rootfs Lorenz Stechauner
  2021-05-17 13:41 ` Thomas Lamprecht
@ 2021-05-25  7:57 ` Fabian Ebner
  1 sibling, 0 replies; 4+ messages in thread
From: Fabian Ebner @ 2021-05-25  7:57 UTC (permalink / raw)
  To: pve-devel, l.stechauner

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;
>       };
> 




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-25  7:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17  9:03 [pve-devel] [PATCH v2 container] fix #3421: allow custom storage plugins to support rootfs Lorenz Stechauner
2021-05-17 13:41 ` Thomas Lamprecht
2021-05-17 14:21   ` Lorenz Stechauner
2021-05-25  7:57 ` Fabian Ebner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal