[pve-devel] [PATCH 47/48] storage : parse_volume_id : add bigregex to handle basename in path

Alexandre Derumier aderumier at odiso.com
Tue Jan 29 17:14:29 CET 2013


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/Storage.pm |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index 919c79b..41c31ab 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -307,8 +307,9 @@ sub parse_vmid {
 PVE::JSONSchema::register_format('pve-volume-id', \&parse_volume_id);
 sub parse_volume_id {
     my ($volid, $noerr) = @_;
-
-    if ($volid =~ m/^([a-z][a-z0-9\-\_\.]*[a-z0-9]):(.+)$/i) {
+    if ($volid =~ m/^([a-z][a-z0-9\-\_\.]*[a-z0-9]):(((\d+)\/)?((vm|base)-(\d+)-disk-(\d+)(.(raw|qcow2|vmdk))?)\/)?(((\d+)\/)?((vm|base)-(\d+)-disk-(\d+)(.(raw|qcow2|vmdk))?))$/i) {
+	return wantarray ? ($1, $11) : $1;
+    }elsif($volid =~ m/^([a-z][a-z0-9\-\_\.]*[a-z0-9]):(.+)$/i) {
 	return wantarray ? ($1, $2) : $1;
     }
     return undef if $noerr;
-- 
1.7.10.4




More information about the pve-devel mailing list