From 5eca0c3643bd22d01557e10062e685a905ef9583 Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Mon, 9 Mar 2020 13:24:50 +0100 Subject: [PATCH] sync_disks: Always set 'snapshots' for qcow2 and vmdk volumes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes an issue when migrating a VM with an unused volume with format qcow2 or vmdk. Since 'snapshots' wasn't set, storage_migrate wanted to export/import with format raw+size instead. Therefore it used (instead of just 'dd') 'qemu-img convert', which fails when its output leaves through a pipe. Upon importing, a second error is present, because the format from the volume ID doesn't match the format of the stream and there is no conversion yet. Signed-off-by: Fabian Ebner LGTM-by: Fabian Grünbichler --- PVE/QemuMigrate.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm index a88b82f8..aa8ee6e4 100644 --- a/PVE/QemuMigrate.pm +++ b/PVE/QemuMigrate.pm @@ -311,9 +311,14 @@ sub sync_disks { PVE::Storage::storage_check_node($self->{storecfg}, $targetsid, $self->{node}); PVE::Storage::foreach_volid($dl, sub { - my ($volid, $sid, $volname) = @_; + my ($volid, $sid, $volinfo) = @_; $local_volumes->{$volid}->{ref} = 'storage'; + + # If with_snapshots is not set for storage migrate, it tries to use + # a raw+size stream, but on-the-fly conversion from qcow2 to raw+size + # back to qcow2 is currently not possible. + $local_volumes->{$volid}->{snapshots} = ($volinfo->{format} =~ /^(?:qcow2|vmdk)$/); }); } @@ -366,8 +371,9 @@ sub sync_disks { if !$owner || ($owner != $self->{vmid}); my $format = PVE::QemuServer::qemu_img_format($scfg, $volname); - $local_volumes->{$volid}->{snapshots} = defined($snaprefs) || ($format =~ /^(?:qcow2|vmdk)$/); if (defined($snaprefs)) { + $local_volumes->{$volid}->{snapshots} = 1; + # we cannot migrate shapshots on local storage # exceptions: 'zfspool' or 'qcow2' files (on directory storage)