]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/Plugin.pm
allow templates using .xz compression
[pve-storage.git] / PVE / Storage / Plugin.pm
index 3eb99f2b454c2b2cb0885c1985dc831b8c401079..310a6589adcb54227dd51983136b04a30593e62a 100644 (file)
@@ -105,9 +105,9 @@ PVE::JSONSchema::register_format('pve-storage-server', \&verify_server);
 sub verify_server {
     my ($server, $noerr) = @_;
 
-    # fixme: use better regex ?
-    # IP or DNS name
-    if ($server !~ m/^[[:alnum:]\-\.]+$/) {
+    if (!(PVE::JSONSchema::pve_verify_ip($server, 1) ||
+          PVE::JSONSchema::pve_verify_dns_name($server, 1)))
+    {
        return undef if $noerr;
        die "value does not look like a valid server name or IP address\n";
     }
@@ -312,7 +312,7 @@ sub parse_config {
            $d->{content} = $def->{content}->[1] if !$d->{content};
        }
 
-       if ($type eq 'iscsi' || $type eq 'nfs' || $type eq 'rbd' || $type eq 'sheepdog' || $type eq 'iscsidirect' || $type eq 'glusterfs' || $type eq 'zfs') {
+       if ($type eq 'iscsi' || $type eq 'nfs' || $type eq 'rbd' || $type eq 'sheepdog' || $type eq 'iscsidirect' || $type eq 'glusterfs' || $type eq 'zfs' || $type eq 'drbd') {
            $d->{shared} = 1;
        }
     }
@@ -364,13 +364,13 @@ sub parse_volname {
        return ('images', $name, $vmid, undef, undef, $isBase);
     } elsif ($volname =~ m!^iso/([^/]+\.[Ii][Ss][Oo])$!) {
        return ('iso', $1);
-    } elsif ($volname =~ m!^vztmpl/([^/]+\.tar\.gz)$!) {
+    } elsif ($volname =~ m!^vztmpl/([^/]+\.tar\.[gx]z)$!) {
        return ('vztmpl', $1);
     } elsif ($volname =~ m!^rootdir/(\d+)$!) {
        return ('rootdir', $1, $1);
     } elsif ($volname =~ m!^backup/([^/]+(\.(tar|tar\.gz|tar\.lzo|tgz|vma|vma\.gz|vma\.lzo)))$!) {
        my $fn = $1;
-       if ($fn =~ m/^vzdump-(openvz|qemu)-(\d+)-.+/) {
+       if ($fn =~ m/^vzdump-(openvz|lxc|qemu)-(\d+)-.+/) {
            return ('backup', $fn, $2);
        }
        return ('backup', $fn);
@@ -627,7 +627,7 @@ sub volume_size_info {
 sub volume_resize {
     my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
 
-    die "can't resize this image format" if $volname !~ m/\.(raw|qcow2)$/;
+    die "can't resize this image format\n" if $volname !~ m/\.(raw|qcow2)$/;
 
     return 1 if $running;
 
@@ -641,11 +641,9 @@ sub volume_resize {
 }
 
 sub volume_snapshot {
-    my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
-
-    die "can't snapshot this image format" if $volname !~ m/\.(qcow2|qed)$/;
+    my ($class, $scfg, $storeid, $volname, $snap) = @_;
 
-    return 1 if $running;
+    die "can't snapshot this image format\n" if $volname !~ m/\.(qcow2|qed)$/;
 
     my $path = $class->filesystem_path($scfg, $volname);
 
@@ -665,7 +663,7 @@ sub volume_rollback_is_possible {
 sub volume_snapshot_rollback {
     my ($class, $scfg, $storeid, $volname, $snap) = @_;
 
-    die "can't rollback snapshot this image format" if $volname !~ m/\.(qcow2|qed)$/;
+    die "can't rollback snapshot this image format\n" if $volname !~ m/\.(qcow2|qed)$/;
 
     my $path = $class->filesystem_path($scfg, $volname);
 
@@ -679,7 +677,7 @@ sub volume_snapshot_rollback {
 sub volume_snapshot_delete {
     my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
 
-    die "can't delete snapshot for this image format" if $volname !~ m/\.(qcow2|qed)$/;
+    die "can't delete snapshot for this image format\n" if $volname !~ m/\.(qcow2|qed)$/;
 
     return 1 if $running;