From 09d0ee6473b1325e11ee42a5951d6a9d8b9b14e9 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 3 Feb 2012 10:49:37 +0100 Subject: [PATCH] fix CD eject --- PVE/API2/Qemu.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index e709396d..b7ef2190 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -65,7 +65,9 @@ my $check_storage_access = sub { my $volid = $drive->{file}; - if (!$isCDROM && ($volid =~ m/^(([^:\s]+):)?(\d+(\.\d+)?)$/)) { + if (!$volid || $volid eq 'none') { + # nothing to check + } elsif (!$isCDROM && ($volid =~ m/^(([^:\s]+):)?(\d+(\.\d+)?)$/)) { my ($storeid, $size) = ($2 || $default_storage, $3); die "no storage ID specified (and no default storage)\n" if !$storeid; $rpcenv->check_storage_perm($authuser, $vmid, $pool, $storeid, [ 'Datastore.AllocateSpace' ]); @@ -89,7 +91,9 @@ my $create_disks = sub { my $volid = $disk->{file}; - if ($volid =~ m/^(([^:\s]+):)?(\d+(\.\d+)?)$/) { + if (!$volid || $volid eq 'none') { + $res->{$ds} = $settings->{$ds}; + } elsif ($volid =~ m/^(([^:\s]+):)?(\d+(\.\d+)?)$/) { my ($storeid, $size) = ($2 || $default_storage, $3); die "no storage ID specified (and no default storage)\n" if !$storeid; my $defformat = PVE::Storage::storage_default_format($storecfg, $storeid); @@ -103,7 +107,7 @@ my $create_disks = sub { } else { my $path = &$check_volume_access($rpcenv, $authuser, $storecfg, $vmid, $volid, $pool); die "image '$path' does not exists\n" if (!(-f $path || -b $path)); - $res->{$ds} = $settings->{ds}; + $res->{$ds} = $settings->{$ds}; } });