[pve-devel] [PATCH qemu-server 5/7] migrate : phase2 : migrate external
David Limbeck
d.limbeck at proxmox.com
Wed Nov 7 16:54:50 CET 2018
one more thing inline
On 11/7/18 4:29 PM, David Limbeck wrote:
> comments inline
>
> On 10/29/18 4:38 PM, Alexandre Derumier wrote:
>> ---
>> PVE/API2/Qemu.pm | 4 ++--
>> PVE/QemuMigrate.pm | 21 +++++++++++++--------
>> PVE/QemuServer.pm | 24 +++++++++++++++++++++---
>> 3 files changed, 36 insertions(+), 13 deletions(-)
>>
>> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
>> index ac8b907..509747c 100644
>> --- a/PVE/API2/Qemu.pm
>> +++ b/PVE/API2/Qemu.pm
>> @@ -1927,7 +1927,7 @@ __PACKAGE__->register_method({
>> migratedfrom => get_standard_option('pve-node',{ optional
>> => 1 }),
>> migration_type => {
>> type => 'string',
>> - enum => ['secure', 'insecure'],
>> + enum => ['secure', 'insecure', 'external'],
>> description => "Migration traffic is encrypted using an SSH
>> " .
>> "tunnel by default. On secure, completely private
>> networks " .
>> "this can be disabled to increase performance.",
>> @@ -1987,7 +1987,7 @@ __PACKAGE__->register_method({
>> if $targetstorage && $authuser ne 'root at pam';
>> raise_param_exc({ targetstorage => "targetstorage can only by
>> used with migratedfrom." })
>> - if $targetstorage && !$migratedfrom;
>> + if $targetstorage && !$migratedfrom && !($migration_type &&
>> $migration_type eq 'external');
>> # read spice ticket from STDIN
>> my $spice_ticket;
>> diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
>> index 3e50f07..6eb629b 100644
>> --- a/PVE/QemuMigrate.pm
>> +++ b/PVE/QemuMigrate.pm
>> @@ -591,7 +591,9 @@ sub phase2 {
>> my $conf = $self->{vmconf};
>> - $self->log('info', "starting VM $vmid on remote node
>> '$self->{node}'");
>> + my $targetvmid = $self->{opts}->{targetvmid} ?
>> $self->{opts}->{targetvmid} : $vmid;
>> +
>> + $self->log('info', "starting VM $targetvmid on remote node
>> '$self->{node}'");
>> my $raddr;
>> my $rport;
>> @@ -607,11 +609,13 @@ sub phase2 {
>> $spice_ticket = $res->{ticket};
>> }
>> - push @$cmd , 'qm', 'start', $vmid, '--skiplock',
>> '--migratedfrom', $nodename;
>> -
>> my $migration_type = $self->{opts}->{migration_type};
>> - push @$cmd, '--migration_type', $migration_type;
>> + push @$cmd , 'qm', 'start', $targetvmid, '--skiplock';
>> +
>> + push @$cmd, '--migratedfrom', $nodename if
>> !$self->{migration_external};
>> +
>> + push @$cmd, '--migration_type', $self->{opts}->{migration_type};
use $migration_type that's already defined instead of
$self->{opts}->{migration_type}
>> push @$cmd, '--migration_network',
>> $self->{opts}->{migration_network}
>> if $self->{opts}->{migration_network};
>> @@ -644,7 +648,7 @@ sub phase2 {
>> }
>> elsif ($line =~ m!^migration listens on
>> unix:(/run/qemu-server/(\d+)\.migrate)$!) {
>> $raddr = $1;
>> - die "Destination UNIX sockets VMID does not match source
>> VMID" if $vmid ne $2;
>> + die "Destination UNIX sockets VMID does not match source
>> VMID" if $targetvmid ne $2;
> missing '\n'
>> $ruri = "unix:$raddr";
>> }
>> elsif ($line =~ m/^migration listens on port (\d+)$/) {
>> @@ -674,7 +678,7 @@ sub phase2 {
>> $self->log('info', "start remote tunnel");
>> - if ($migration_type eq 'secure') {
>> + if ($migration_type eq 'secure' || $migration_type eq 'external') {
>> if ($ruri =~ /^unix:/) {
>> unlink $raddr;
>> @@ -714,13 +718,14 @@ sub phase2 {
>> my $start = time();
>> - if ($self->{opts}->{targetstorage} &&
>> defined($self->{online_local_volumes})) {
>> + if (($self->{opts}->{targetstorage} &&
>> defined($self->{online_local_volumes})) ||
>> $self->{migration_external}) {
>> $self->{storage_migration} = 1;
>> $self->{storage_migration_jobs} = {};
>> $self->log('info', "starting storage migration");
>> die "The number of local disks does not match between the
>> source and the destination.\n"
>> - if (scalar(keys %{$self->{target_drive}}) != scalar
>> @{$self->{online_local_volumes}});
>> + if !$self->{migration_external} && (scalar(keys
>> %{$self->{target_drive}}) != scalar @{$self->{online_local_volumes}});
>> +
>> foreach my $drive (keys %{$self->{target_drive}}){
>> my $nbd_uri = $self->{target_drive}->{$drive}->{nbd_uri};
>> $self->log('info', "$drive: start migration to $nbd_uri");
>> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
>> index 933f54f..37dcf5f 100644
>> --- a/PVE/QemuServer.pm
>> +++ b/PVE/QemuServer.pm
>> @@ -4820,8 +4820,26 @@ sub vm_start {
>> $ENV{PVE_MIGRATED_FROM} = $migratedfrom if $migratedfrom;
>> my $local_volumes = {};
>> + my $external_migration = undef;
>> - if ($targetstorage) {
>> + if ($migration_type && $migration_type eq 'external') {
>> + $migration_type = 'secure';
>> + $external_migration = 1;
>> + }
>> +
>> + 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) = @_;
>> @@ -5007,7 +5025,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);
>> @@ -5026,7 +5044,7 @@ sub vm_start {
>> }
>> }
>> - if ($migratedfrom) {
>> + if ($migratedfrom || $external_migration) {
>> eval {
>> set_migration_caps($vmid);
>> };
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list