[pve-devel] [PATCH qemu-server] Fix #1361: create disk: stricter parsing of storage:size

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Apr 24 11:12:29 CEST 2017


This fixes paths such as
/dev/disk/by-id/some-ID:0.5
being interpreted as a request to create a 0.5G-sized disk
in the storage named '/dev/disk/by-id/some-ID'.
---
For: master, stable-4

 PVE/API2/Qemu.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 19ba5be..4cf0a56 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -127,7 +127,7 @@ my $create_disks = sub {
 	if (!$volid || $volid eq 'none' || $volid eq 'cdrom') {
 	    delete $disk->{size};
 	    $res->{$ds} = PVE::QemuServer::print_drive($vmid, $disk);
-	} elsif ($volid =~ m/^(([^:\s]+):)?(\d+(\.\d+)?)$/) {
+	} 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);
-- 
2.11.0





More information about the pve-devel mailing list