[pve-devel] [PATCH v2 qemu-server 2/3] fix #2100: ignore cloudinit drive on offline migration

Mira Limbeck m.limbeck at proxmox.com
Fri Mar 29 16:32:04 CET 2019


disk is not copied to the target node but still deleted on cleanup
(phase3_cleanup).

Signed-off-by: Mira Limbeck <m.limbeck at proxmox.com>
Tested-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/QemuMigrate.pm | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index ee605d8..6bb19db 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -246,6 +246,7 @@ sub prepare {
 		if !$plugin->check_connection($sid, $scfg);
 	} else {
 	    # only activate if not shared
+	    next if ($volid =~ m/vm-\d+-cloudinit/);
 	    push @$need_activate, $volid;
 	}
     }
@@ -353,7 +354,13 @@ sub sync_disks {
 
 	    $local_volumes->{$volid}->{ref} = $attr->{referenced_in_config} ? 'config' : 'snapshot';
 
-	    die "local cdrom image\n" if $attr->{cdrom};
+	    if ($attr->{cdrom}) {
+		if ($volid =~ /vm-\d+-cloudinit/) {
+		    $local_volumes->{$volid}->{ref} = 'generated';
+		    return;
+		}
+		die "local cdrom image\n";
+	    }
 
 	    my ($path, $owner) = PVE::Storage::path($self->{storecfg}, $volid);
 
@@ -394,6 +401,8 @@ sub sync_disks {
 		$self->log('info', "found local disk '$vol' (in current VM config)\n");
 	    } elsif ($ref eq 'snapshot') {
 		$self->log('info', "found local disk '$vol' (referenced by snapshot(s))\n");
+	    } elsif ($ref eq 'generated') {
+		$self->log('info', "found generated disk '$vol' (in current VM config)\n");
 	    } else {
 		$self->log('info', "found local disk '$vol'\n");
 	    }
@@ -445,8 +454,13 @@ sub sync_disks {
 	foreach my $volid (keys %$local_volumes) {
 	    my ($sid, $volname) = PVE::Storage::parse_volume_id($volid);
 	    my $targetsid = $override_targetsid // $sid;
-	    if ($self->{running} && $local_volumes->{$volid}->{ref} eq 'config') {
+	    my $ref = $local_volumes->{$volid}->{ref};
+	    if ($self->{running} && $ref eq 'config') {
 		push @{$self->{online_local_volumes}}, $volid;
+	    } elsif ($ref eq 'generated') {
+		# skip all generated volumes but queue them for deletion in phase3_cleanup
+		push @{$self->{volumes}}, $volid;
+		next;
 	    } else {
 		next if $rep_volumes->{$volid};
 		push @{$self->{volumes}}, $volid;
-- 
2.11.0




More information about the pve-devel mailing list