]> git.proxmox.com Git - qemu-server.git/commitdiff
Fix 2070: vm_start: for a migrating VM, use current format of disk if possible
authorFabian Ebner <f.ebner@proxmox.com>
Mon, 20 Jan 2020 13:00:43 +0000 (14:00 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 21 Jan 2020 06:45:31 +0000 (07:45 +0100)
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/QemuServer.pm

index 9ef3b71adf8a0157ab735e9a80755ddcd8193d76..59335c59217296e1e3ae0867a17766120323758d 100644 (file)
@@ -5376,13 +5376,16 @@ sub vm_start {
                my ($volid, $storeid, $volname) = @{$local_volumes->{$opt}};
                my $drive = parse_drive($opt, $conf->{$opt});
 
-               #if remote storage is specified, use default format
+               # If a remote storage is specified and the format of the original
+               # volume is not available there, fall back to the default format.
+               # Otherwise use the same format as the original.
                if ($targetstorage && $targetstorage ne "1") {
                    $storeid = $targetstorage;
                    my ($defFormat, $validFormats) = PVE::Storage::storage_default_format($storecfg, $storeid);
-                   $format = $defFormat;
+                   my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
+                   my $fileFormat = qemu_img_format($scfg, $volname);
+                   $format = (grep {$fileFormat eq $_} @{$validFormats}) ? $fileFormat : $defFormat;
                } else {
-                   #else we use same format than original
                    my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
                    $format = qemu_img_format($scfg, $volid);
                }