[pve-devel] [PATCH] check if volume exist on volume update.

Alexandre Derumier aderumier at odiso.com
Sat Jun 23 09:07:32 CEST 2012


for the moment we check only if the real path exist on the host.
This doesn't work for "virtual" device that host doesn't see.(like rbd, virtio-scsi,...).

This add a check if the volid exist in the storage.

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Qemu.pm |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index c172fde..497c334 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -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};
 	}
     });
-- 
1.7.2.5




More information about the pve-devel mailing list