[pve-devel] [PATCH qemu-server] fix #2563: allow live migration with local cloud-init disk

Mira Limbeck m.limbeck at proxmox.com
Thu Jul 15 14:33:18 CEST 2021


The content of the ISO should be the same on both nodes, so offline
migrate the ISO, but don't regenerate it on VM start on the target node.

This way even with snippets the content will not change during live
migration.

Signed-off-by: Mira Limbeck <m.limbeck at proxmox.com>
---
 PVE/QemuMigrate.pm | 3 ++-
 PVE/QemuServer.pm  | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 0b41db7..5ecc2a7 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -579,7 +579,8 @@ sub scan_local_volumes {
 	    if ($self->{running} && $ref eq 'config') {
 		$local_volumes->{$volid}->{migration_mode} = 'online';
 	    } elsif ($self->{running} && $ref eq 'generated') {
-		die "can't live migrate VM with local cloudinit disk. use a shared storage instead\n";
+		# offline migrate the cloud-init ISO and don't regenerate on VM start
+		$local_volumes->{$volid}->{migration_mode} = 'offline';
 	    } else {
 		$local_volumes->{$volid}->{migration_mode} = 'offline';
 	    }
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index b0fe257..6f1862b 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5155,7 +5155,9 @@ sub vm_start_nolock {
 	$conf = PVE::QemuConfig->load_config($vmid); # update/reload
     }
 
-    PVE::QemuServer::Cloudinit::generate_cloudinitconfig($conf, $vmid);
+    # don't regenerate the ISO if the VM is started as part of a live migration
+    # this way we can reuse the old ISO with the correct config
+    PVE::QemuServer::Cloudinit::generate_cloudinitconfig($conf, $vmid) if !$migratedfrom;
 
     my $defaults = load_defaults();
 
-- 
2.30.2






More information about the pve-devel mailing list