[pve-devel] [PATCH qemu-server v3] fix 3886: QEMU restore: verify storage allows images before writing

Matthias Heiserer m.heiserer at proxmox.com
Thu Feb 24 10:42:53 CET 2022


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.

Adds the Datastore.AllocateSpace check to cloudinit drives.

Signed-off-by: Matthias Heiserer <m.heiserer at proxmox.com>
---
Thanks to Fabian!
Changes from v2:
 + Also check Datastore.AllocateSpace permissions for cloudinit device
 + Move content type check closer to allocate permission check

Changes from v1:
 + Check content type for cloud init drives

 PVE/QemuServer.pm | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index a99f1a5..a808a0f 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6243,12 +6243,17 @@ my $parse_backup_hints = sub {
 	    } elsif (!$storeid) {
 	    }
 		$storeid = 'local';
 	    $format = 'raw' if !$format;
 	    $devinfo->{$devname}->{devname} = $devname;
 	    $devinfo->{$devname}->{virtdev} = $virtdev;
 	    $devinfo->{$devname}->{format} = $format;
 	    $devinfo->{$devname}->{storeid} = $storeid;
 
+	    my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
+	    die "Content type 'images' is not available on storage '$storeid'\n"
+		if !$scfg->{content}->{images};
+
 	    # check permission on storage
 	    my $pool = $options->{pool}; # todo: do we need that?
 	    if ($user ne 'root at pam') {
@@ -6265,6 +6270,12 @@ my $parse_backup_hints = sub {
 		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};
+		if ($user ne 'root at pam') {
+		    $rpcenv->check($user, "/storage/$storeid", ['Datastore.AllocateSpace']);
+		}
+
 		$virtdev_hash->{$virtdev} = {
 		    format => $format,
 		    storeid => $storeid,
-- 
2.30.2






More information about the pve-devel mailing list