public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server] api: create/modify: fix content type checks by re-allowing iso images
Date: Fri, 22 Apr 2022 13:03:06 +0200	[thread overview]
Message-ID: <20220422110306.53913-1-f.ebner@proxmox.com> (raw)

Fixes: f9be9137 ("api: create/modify: add content type checks"
Reported-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 PVE/API2/Qemu.pm | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 3af21325..71db264a 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -142,14 +142,12 @@ my $check_storage_access = sub {
 	    raise_param_exc({ storage => "storage '$storeid' does not support vm images"})
 		if !$scfg->{content}->{images};
 	} else {
-	    PVE::Storage::check_volume_access(
-		$rpcenv,
-		$authuser,
-		$storecfg,
-		$vmid,
-		$volid,
-		'images',
-	    );
+	    PVE::Storage::check_volume_access($rpcenv, $authuser, $storecfg, $vmid, $volid);
+	    if ($storeid) {
+		my ($vtype) = PVE::Storage::parse_volname($storecfg, $volid);
+		raise_param_exc({ $ds => "content type needs to be 'images' or 'iso'" })
+		    if $vtype ne 'images' && $vtype ne 'iso';
+	    }
 	}
 
 	if (my $src_image = $drive->{'import-from'}) {
@@ -421,14 +419,12 @@ my $create_disks = sub {
 
 	    print "$ds: successfully created disk '$res->{$ds}'\n";
 	} else {
-	    PVE::Storage::check_volume_access(
-		$rpcenv,
-		$authuser,
-		$storecfg,
-		$vmid,
-		$volid,
-		'images',
-	    );
+	    PVE::Storage::check_volume_access($rpcenv, $authuser, $storecfg, $vmid, $volid);
+	    if ($storeid) {
+		my ($vtype) = PVE::Storage::parse_volname($storecfg, $volid);
+		die "cannot use volume $volid - content type needs to be 'images' or 'iso'"
+		    if $vtype ne 'images' && $vtype ne 'iso';
+	    }
 
 	    PVE::Storage::activate_volumes($storecfg, [ $volid ]) if $storeid;
 
-- 
2.30.2





             reply	other threads:[~2022-04-22 11:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-22 11:03 Fabian Ebner [this message]
2022-04-22 12:42 ` [pve-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220422110306.53913-1-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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