]> git.proxmox.com Git - qemu-server.git/commitdiff
cleanup: more the new-disk regex deduplication
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 30 Jun 2017 07:31:29 +0000 (09:31 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 30 Jun 2017 07:31:29 +0000 (09:31 +0200)
PVE/API2/Qemu.pm

index efb3198f2d5c8e00bc24e999632ab4c946ec046d..aa7c83296d1e4184cc881cb203a3a3453e9c55db 100644 (file)
@@ -52,6 +52,7 @@ my $resolve_cdrom_alias = sub {
     }
 };
 
+my $NEW_DISK_RE = qr!^(([^/:\s]+):)?(\d+(\.\d+)?)$!;
 my $check_storage_access = sub {
    my ($rpcenv, $authuser, $storecfg, $vmid, $settings, $default_storage) = @_;
 
@@ -66,7 +67,7 @@ my $check_storage_access = sub {
            # nothing to check
        } elsif ($isCDROM && ($volid eq 'cdrom')) {
            $rpcenv->check($authuser, "/", ['Sys.Console']);
-       } elsif (!$isCDROM && ($volid =~ m/^(([^:\s]+):)?(\d+(\.\d+)?)$/)) {
+       } elsif (!$isCDROM && ($volid =~ $NEW_DISK_RE)) {
            my ($storeid, $size) = ($2 || $default_storage, $3);
            die "no storage ID specified (and no default storage)\n" if !$storeid;
            $rpcenv->check($authuser, "/storage/$storeid", ['Datastore.AllocateSpace']);
@@ -118,7 +119,6 @@ my $check_storage_access_clone = sub {
 
 # Note: $pool is only needed when creating a VM, because pool permissions
 # are automatically inherited if VM already exists inside a pool.
-my $NEW_DISK_RE = qr!^(([^/:\s]+):)?(\d+(\.\d+)?)$!;
 my $create_disks = sub {
     my ($rpcenv, $authuser, $conf, $storecfg, $vmid, $pool, $settings, $default_storage) = @_;