]> git.proxmox.com Git - qemu-server.git/blobdiff - PVE/API2/Qemu.pm
check if volume exist on volume update.
[qemu-server.git] / PVE / API2 / Qemu.pm
index 3895b189a677ccf0d9fa6b1444a8a286441a5b09..497c3343107916988c52a14b551bbcdd36a7c6dd 100644 (file)
@@ -88,7 +88,20 @@ my $create_disks = sub {
            my $path = $rpcenv->check_volume_access($authuser, $storecfg, $vmid, $volid);
            PVE::Storage::activate_volumes($storecfg, [ $volid ])
                if PVE::Storage::parse_volume_id ($volid, 1);
-           die "image '$path' does not exists\n" if (!(-f $path || -b $path));
+
+           my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid);
+           my $dl = PVE::Storage::vdisk_list($storecfg, $storeid, undef);
+           my $foundvolid = undef;
+
+           PVE::Storage::foreach_volid($dl, sub {
+               my ($volumeid) = @_;
+               if($volumeid eq $volid) {
+                   $foundvolid = 1;
+                   return;
+               }
+           });
+       
+           die "image '$path' does not exists\n" if (!(-f $path || -b $path || $foundvolid));
            $res->{$ds} = $settings->{$ds};
        }
     });
@@ -269,7 +282,6 @@ __PACKAGE__->register_method({
 
        if (defined($pool)) {
            $rpcenv->check_pool_exist($pool);
-           $rpcenv->check_perm_modify($authuser, "/pool/$pool");
        } 
 
        $rpcenv->check($authuser, "/storage/$storage", ['Datastore.AllocateSpace'])
@@ -599,7 +611,7 @@ my $delete_drive = sub {
        if (&$vm_is_volid_owner($storecfg, $vmid, $volid)) {
            if ($force || $key =~ m/^unused/) {
                eval { PVE::Storage::vdisk_free($storecfg, $volid); };
-               warn $@ if $@;
+               die $@ if $@;
            } else {
                PVE::QemuServer::add_unused_volume($conf, $volid, $vmid);
            }