]> git.proxmox.com Git - pve-storage.git/commitdiff
fix #2216: Allow .img files in 'iso' type storages
authorStefan Reiter <s.reiter@proxmox.com>
Thu, 22 Aug 2019 12:39:53 +0000 (14:39 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 3 Sep 2019 05:09:28 +0000 (07:09 +0200)
To maintain full (backwards) compatibility, leave the type name as
'iso' - this makes this patch work without changing every consumer of
storage APIs.

Note that currently these files can only be attached as a CDROM/DVD
drive, so USB-only images can be uploaded but might not work in VMs.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
PVE/API2/Storage/Status.pm
PVE/Storage.pm
PVE/Storage/Plugin.pm

index ce7e040b27fe62fefa94857ac91da76e8977867c..91946acf1473fb4a1507ace982e978338342a69a 100644 (file)
@@ -408,8 +408,8 @@ __PACKAGE__->register_method ({
        my $path;
 
        if ($content eq 'iso') {
-           if ($filename !~ m![^/]+\.[Ii][Ss][Oo]$!) {
-               raise_param_exc({ filename => "missing '.iso' extension" });
+           if ($filename !~ m![^/]+$PVE::Storage::iso_extension_re$!) {
+               raise_param_exc({ filename => "missing '.iso' or '.img' extension" });
            }
            $path = PVE::Storage::get_iso_dir($cfg, $param->{storage});
        } elsif ($content eq 'vztmpl') {
index 755eca83d4e3a5b1979813c8e5fd960be27c20e4..08b6e142e343d4f40eb5b0fd33e8f6f3f12ac24c 100755 (executable)
@@ -99,6 +99,8 @@ PVE::Storage::Plugin->init();
 
 my $UDEVADM = '/sbin/udevadm';
 
+my $iso_extension_re = qr/\.(?:[Ii][Ss][Oo]|[Ii][Mm][Gg])/;
+
 #  PVE::Storage utility functions
 
 sub config {
@@ -501,7 +503,7 @@ sub path_to_volume_id {
                    return ('images', $info->{volid});
                }
            }
-       } elsif ($path =~ m!^$isodir/([^/]+\.[Ii][Ss][Oo])$!) {
+       } elsif ($path =~ m!^$isodir/([^/]+$iso_extension_re)$!) {
            my $name = $1;
            return ('iso', "$sid:iso/$name");
        } elsif ($path =~ m!^$tmpldir/([^/]+\.tar\.gz)$!) {
index 27f832fc161a8da761fe2741fdf0d5280b6c6084..9a419f177b5489645f68cfafdb535a7b54dc3679 100644 (file)
@@ -415,7 +415,7 @@ sub parse_volname {
        my ($vmid, $name) = ($1, $2);
        my (undef, $format, $isBase) = parse_name_dir($name);
        return ('images', $name, $vmid, undef, undef, $isBase, $format);
-    } elsif ($volname =~ m!^iso/([^/]+\.[Ii][Ss][Oo])$!) {
+    } elsif ($volname =~ m!^iso/([^/]+$PVE::Storage::iso_extension_re)$!) {
        return ('iso', $1);
     } elsif ($volname =~ m!^vztmpl/([^/]+\.tar\.[gx]z)$!) {
        return ('vztmpl', $1);
@@ -915,7 +915,7 @@ my $get_subdir_files = sub {
        my $info;
 
        if ($tt eq 'iso') {
-           next if $fn !~ m!/([^/]+\.iso)$!i;
+           next if $fn !~ m!/([^/]+$PVE::Storage::iso_extension_re)$!i;
 
            $info = { volid => "$sid:iso/$1", format => 'iso' };