]> git.proxmox.com Git - qemu-server.git/commitdiff
clone_disk: test if requested format is supported - else use default
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 29 May 2013 10:59:21 +0000 (12:59 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 29 May 2013 10:59:21 +0000 (12:59 +0200)
PVE/QemuServer.pm

index b541205ea9bc8b092becbdb33cd0b26512aa125b..50fbf69b1eef58a8f60411e09f4b323405165c0b 100644 (file)
@@ -4718,11 +4718,15 @@ sub clone_disk {
        my ($storeid, $volname) = PVE::Storage::parse_volume_id($drive->{file});
        $storeid = $storage if $storage;
 
-       if (!$format)  {
-           my $defformat = PVE::Storage::storage_default_format($storecfg, $storeid);
-           $format = $drive->{format} || $defformat;
+       my ($defFormat, $validFormats) = PVE::Storage::storage_default_format($storecfg, $storeid);
+       if (!$format) {
+           $format = $drive->{format} || $defFormat;
        }
 
+       # test if requested format is supported - else use default
+       my $supported = grep { $_ eq $format } @$validFormats;
+       $format = $defFormat if !$supported;
+
        my ($size) = PVE::Storage::volume_size_info($storecfg, $drive->{file}, 3);
 
        print "create full clone of drive $drivename ($drive->{file})\n";