[pve-devel] [PATCH v2 qemu-server 1/2] Always set 'snapshots' for qcow2 and vmdk volumes

Fabian Ebner f.ebner at proxmox.com
Mon Mar 9 13:24:50 CET 2020


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 <f.ebner at proxmox.com>
---

Changes from v1:
    * squash renaming volname->volinfo into this patch
    * explain reason for setting snapshots in comment

 PVE/QemuMigrate.pm | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index a88b82f..aa8ee6e 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)
 
-- 
2.20.1





More information about the pve-devel mailing list