public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH qemu-server v2] fix 3886: QEMU restore: verify storage allows images before writing
@ 2022-02-23 11:15 Matthias Heiserer
  2022-02-24  7:52 ` Fabian Ebner
  0 siblings, 1 reply; 2+ messages in thread
From: Matthias Heiserer @ 2022-02-23 11:15 UTC (permalink / raw)
  To: pve-devel

When restoring a backup and the storage the disks would be created on
doesn't allow 'images', the process errors without cleanup.
This is the same behaviour we currently have when the storage is
disabled.

Signed-off-by: Matthias Heiserer <m.heiserer@proxmox.com>
---
 PVE/QemuServer.pm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index a99f1a5..aaada7a 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6243,6 +6243,9 @@ my $parse_backup_hints = sub {
 	    } elsif (!$storeid) {
 		$storeid = 'local';
 	    }
+	    my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
+	    die "Content type 'images' is not available on storage '$storeid'\n"
+		if !$scfg->{content}->{images};
 	    $format = 'raw' if !$format;
 	    $devinfo->{$devname}->{devname} = $devname;
 	    $devinfo->{$devname}->{virtdev} = $virtdev;
@@ -6264,6 +6267,8 @@ my $parse_backup_hints = sub {
 		$storeid = $options->{storage} if defined ($options->{storage});
 		my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
 		my $format = qemu_img_format($scfg, $volname); # has 'raw' fallback
+		die "Content type 'images' is not available on storage '$storeid'\n"
+		    if !$scfg->{content}->{images};
 
 		$virtdev_hash->{$virtdev} = {
 		    format => $format,
-- 
2.30.2





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

* Re: [pve-devel] [PATCH qemu-server v2] fix 3886: QEMU restore: verify storage allows images before writing
  2022-02-23 11:15 [pve-devel] [PATCH qemu-server v2] fix 3886: QEMU restore: verify storage allows images before writing Matthias Heiserer
@ 2022-02-24  7:52 ` Fabian Ebner
  0 siblings, 0 replies; 2+ messages in thread
From: Fabian Ebner @ 2022-02-24  7:52 UTC (permalink / raw)
  To: pve-devel, m.heiserer

Am 23.02.22 um 12:15 schrieb Matthias Heiserer:
> When restoring a backup and the storage the disks would be created on
> doesn't allow 'images', the process errors without cleanup.
> This is the same behaviour we currently have when the storage is
> disabled.
> 
> Signed-off-by: Matthias Heiserer <m.heiserer@proxmox.com>
> ---
>  PVE/QemuServer.pm | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index a99f1a5..aaada7a 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -6243,6 +6243,9 @@ my $parse_backup_hints = sub {
>  	    } elsif (!$storeid) {
>  		$storeid = 'local';
>  	    }
> +	    my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
> +	    die "Content type 'images' is not available on storage '$storeid'\n"
> +		if !$scfg->{content}->{images};

Style nit: could be placed closer to the permission check for
Datastore.AllocateSpace that follows below.

>  	    $format = 'raw' if !$format;
>  	    $devinfo->{$devname}->{devname} = $devname;
>  	    $devinfo->{$devname}->{virtdev} = $virtdev;
> @@ -6264,6 +6267,8 @@ my $parse_backup_hints = sub {
>  		$storeid = $options->{storage} if defined ($options->{storage});
>  		my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
>  		my $format = qemu_img_format($scfg, $volname); # has 'raw' fallback
> +		die "Content type 'images' is not available on storage '$storeid'\n"
> +		    if !$scfg->{content}->{images};

Here, the permission check for Datastore.AllocateSpace is missing, which
is the other existing bug. Maybe it's even worth having a small closure
doing both checks to re-use in both cases, but not really sure.

>  
>  		$virtdev_hash->{$virtdev} = {
>  		    format => $format,




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

end of thread, other threads:[~2022-02-24  7:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-23 11:15 [pve-devel] [PATCH qemu-server v2] fix 3886: QEMU restore: verify storage allows images before writing Matthias Heiserer
2022-02-24  7:52 ` 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