On March 18, 2020 10:02 am, Stefan Reiter wrote: > On 17/03/2020 20:56, Mira Limbeck wrote: >> As the NBD server spawned by qemu can only listen on a single socket, >> we're dependent on a version being passed to vm_start that indicates >> which protocol can be used, TCP or Unix, by the source node. >> >> The change in socket type (TCP to Unix) comes with a different URI. For >> unix sockets it has the form: >> 'nbd:unix:<path/to/socket>:exportname=<device>'. >> >> Signed-off-by: Mira Limbeck <m.limb...@proxmox.com> >> --- >> v2: >> - added fallback to 0 if nbd_protocol_version is undefined >> - some cleanup regarding variables only used in one case >> >> PVE/QemuServer.pm | 34 ++++++++++++++++++++++++---------- >> 1 file changed, 24 insertions(+), 10 deletions(-) >> >> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm >> index 429ec05..2ef8bff 100644 >> --- a/PVE/QemuServer.pm >> +++ b/PVE/QemuServer.pm >> @@ -4707,7 +4707,8 @@ sub vmconfig_update_disk { >> >> sub vm_start { >> my ($storecfg, $vmid, $statefile, $skiplock, $migratedfrom, $paused, >> - $forcemachine, $spice_ticket, $migration_network, $migration_type, >> $targetstorage, $timeout) = @_; >> + $forcemachine, $spice_ticket, $migration_network, $migration_type, >> + $targetstorage, $timeout, $nbd_protocol_version) = @_; >> >> PVE::QemuConfig->lock_config($vmid, sub { >> my $conf = PVE::QemuConfig->load_config($vmid, $migratedfrom); >> @@ -4985,20 +4986,33 @@ sub vm_start { >> >> #start nbd server for storage migration >> if ($targetstorage) { >> - my $nodename = nodename(); >> - my $localip = $get_migration_ip->($migration_network, $nodename); >> - my $pfamily = PVE::Tools::get_host_address_family($nodename); >> - my $storage_migrate_port = PVE::Tools::next_migrate_port($pfamily); >> - >> - mon_cmd($vmid, "nbd-server-start", addr => { type => 'inet', data >> => { host => "${localip}", port => "${storage_migrate_port}" } } ); >> + $nbd_protocol_version //= 0; >> + >> + my $migrate_storage_uri; >> + # nbd_protocol_version > 0 for unix socket support >> + if ($nbd_protocol_version > 0 && $migration_type eq 'secure') { >> + my $socket_path = "/run/qemu-server/$vmid\_nbd.migrate"; >> + mon_cmd($vmid, "nbd-server-start", addr => { type => 'unix', >> data => { path => $socket_path } } ); >> + $migrate_storage_uri = "nbd:unix:$socket_path"; >> + } else { >> + my $nodename = nodename(); >> + my $localip = $get_migration_ip->($migration_network, >> $nodename); >> + my $pfamily = PVE::Tools::get_host_address_family($nodename); >> + my $storage_migrate_port = >> PVE::Tools::next_migrate_port($pfamily); >> >> - $localip = "[$localip]" if Net::IP::ip_is_ipv6($localip); >> + mon_cmd($vmid, "nbd-server-start", addr => { type => 'inet', >> data => { host => "${localip}", port => "${storage_migrate_port}" } } ); >> + $localip = "[$localip]" if Net::IP::ip_is_ipv6($localip); >> + $migrate_storage_uri = "nbd:${localip}:${storage_migrate_port}"; >> + } >> >> foreach my $opt (sort keys %$local_volumes) { >> my $drivestr = $local_volumes->{$opt}; >> mon_cmd($vmid, "nbd-server-add", device => "drive-$opt", >> writable => JSON::true ); >> - my $migrate_storage_uri = >> "nbd:${localip}:${storage_migrate_port}:exportname=drive-$opt"; >> - print "storage migration listens on $migrate_storage_uri >> volume:$drivestr\n"; >> + if ($nbd_protocol_version > 0 && $migration_type eq 'secure') { >> + print "storage migration listens on >> $migrate_storage_uri:exportname=drive-$opt volume:$drivestr\n"; >> + } else { >> + print "storage migration listens on >> $migrate_storage_uri:exportname=drive-$opt volume:$drivestr\n"; >> + } > > What's the idea of this if?
thanks for catching, this was obviously a remnant of v1 where these two branches built the printed $migrate_storage_uri. pushed a followup: diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 21fb1b1..e022141 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -5008,11 +5008,7 @@ sub vm_start { foreach my $opt (sort keys %$local_volumes) { my $drivestr = $local_volumes->{$opt}; mon_cmd($vmid, "nbd-server-add", device => "drive-$opt", writable => JSON::true ); - if ($nbd_protocol_version > 0 && $migration_type eq 'secure') { - print "storage migration listens on $migrate_storage_uri:exportname=drive-$opt volume:$drivestr\n"; - } else { - print "storage migration listens on $migrate_storage_uri:exportname=drive-$opt volume:$drivestr\n"; - } + print "storage migration listens on $migrate_storage_uri:exportname=drive-$opt volume:$drivestr\n"; } } > >> } >> } >> >> > _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel