--- PVE/API2/Qemu.pm | 16 ++++++++++++++-- PVE/QemuServer.pm | 20 ++++++++++++++++---- 2 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index b74f111..2f79a2b 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -1951,7 +1951,12 @@ __PACKAGE__->register_method({ description => "Target storage for the migration. (Can be '1' to use the same storage id as on the source node.)", type => 'string', optional => 1 - } + }, + external_migration => { + description => "Enable external migration.", + type => 'boolean', + optional => 1, + }, }, }, returns => { @@ -1997,6 +2002,13 @@ __PACKAGE__->register_method({ raise_param_exc({ targetstorage => "targetstorage can only by used with migratedfrom." }) if $targetstorage && !$migratedfrom; + my $external_migration = extract_param($param, 'external_migration'); + raise_param_exc({ external_migration => "Only root may use this option." }) + if $external_migration && $authuser ne 'root@pam'; + + raise_param_exc({ external_migration => "targetstorage can't be used with external_migration." }) + if ($targetstorage && $external_migration); + # read spice ticket from STDIN my $spice_ticket; if ($stateuri && ($stateuri eq 'tcp') && $migratedfrom && ($rpcenv->{type} eq 'cli')) { @@ -2037,7 +2049,7 @@ __PACKAGE__->register_method({ syslog('info', "start VM $vmid: $upid\n"); PVE::QemuServer::vm_start($storecfg, $vmid, $stateuri, $skiplock, $migratedfrom, undef, - $machine, $spice_ticket, $migration_network, $migration_type, $targetstorage); + $machine, $spice_ticket, $migration_network, $migration_type, $targetstorage, $external_migration); return; }; diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 1ccdccf..8bc326c 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -5034,7 +5034,7 @@ sub vmconfig_update_disk { sub vm_start { my ($storecfg, $vmid, $statefile, $skiplock, $migratedfrom, $paused, - $forcemachine, $spice_ticket, $migration_network, $migration_type, $targetstorage) = @_; + $forcemachine, $spice_ticket, $migration_network, $migration_type, $targetstorage, $external_migration) = @_; PVE::QemuConfig->lock_config($vmid, sub { my $conf = PVE::QemuConfig->load_config($vmid, $migratedfrom); @@ -5059,7 +5059,19 @@ sub vm_start { my $local_volumes = {}; - if ($targetstorage) { + if ($external_migration) { + foreach_drive($conf, sub { + my ($ds, $drive) = @_; + + return if drive_is_cdrom($drive); + + my $volid = $drive->{file}; + + return if !$volid; + + $local_volumes->{$ds} = $volid; + }); + } elsif ($targetstorage) { foreach_drive($conf, sub { my ($ds, $drive) = @_; @@ -5253,7 +5265,7 @@ sub vm_start { } #start nbd server for storage migration - if ($targetstorage) { + if ($targetstorage || $external_migration) { my $nodename = PVE::INotify::nodename(); my $migrate_network_addr = PVE::Cluster::get_local_migration_ip($migration_network); my $localip = $migrate_network_addr ? $migrate_network_addr : PVE::Cluster::remote_node_ip($nodename, 1); @@ -5272,7 +5284,7 @@ sub vm_start { } } - if ($migratedfrom) { + if ($migratedfrom || $external_migration) { eval { set_migration_caps($vmid); }; -- 2.11.0 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel