Signed-off-by: Fabian Ebner <f.eb...@proxmox.com>
---
 PVE/QemuServer.pm | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 9ef3b71..59335c5 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -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);
                }
-- 
2.20.1


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to