]> git.proxmox.com Git - qemu-server.git/commitdiff
fix bug #391 - restore: test if requested format is supported
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 21 May 2013 10:02:41 +0000 (12:02 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 21 May 2013 10:02:41 +0000 (12:02 +0200)
PVE/QemuServer.pm

index ae817f754fee0f609b2503d0b1b7a879a547e484..5cf8b89831302444c2b5f64942a7b52785b65cf1 100644 (file)
@@ -3584,6 +3584,7 @@ sub restore_update_config_line {
            print $outfd "#$line";
        } elsif ($virtdev && $map->{$virtdev}) {
            my $di = parse_drive($virtdev, $value);
+           delete $di->{format}; # format can change on restore
            $di->{file} = $map->{$virtdev};
            $value = print_drive($vmid, $di);
            print $outfd "$virtdev: $value\n";
@@ -3810,6 +3811,12 @@ sub restore_vma_archive {
            my $d = $virtdev_hash->{$virtdev};
            my $alloc_size = int(($d->{size} + 1024 - 1)/1024);
            my $scfg = PVE::Storage::storage_config($cfg, $d->{storeid});
+
+           # test if requested format is supported
+           my ($defFormat, $validFormats) = PVE::Storage::storage_default_format($cfg, $d->{storeid});
+           my $supported = grep { $_ eq $d->{format} } @$validFormats;
+           $d->{format} = $defFormat if !$supported;
+
            my $volid = PVE::Storage::vdisk_alloc($cfg, $d->{storeid}, $vmid,
                                                  $d->{format}, undef, $alloc_size);
            print STDERR "new volume ID is '$volid'\n";