On March 11, 2020 11:44 am, Mira Limbeck wrote: > As the NBD server spawned by qemu can only listen on a single socket, > we're dependant 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> > --- > PVE/QemuServer.pm | 19 +++++++++++++++---- > 1 file changed, 15 insertions(+), 4 deletions(-) > > diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm > index 24f2e16..7d2e0d4 100644 > --- a/PVE/QemuServer.pm > +++ b/PVE/QemuServer.pm > @@ -4696,7 +4696,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); > @@ -4979,15 +4980,25 @@ sub vm_start { > 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 for unix socket support > + # this is communicated by the source node via STDIN
actually, this is a regular parameter in this part of the code, so this comment does not really belong here ;) > + if ($nbd_protocol_version > 0 && $migration_type eq 'secure') { > + mon_cmd($vmid, "nbd-server-start", addr => { type => 'unix', > data => { path => "/run/qemu-server/$vmid\_nbd.migrate" } } ); > + } else { > + 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); $localip is only used for the TCP migration, so we could actually put all that handling into the else branch above > > 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 > nbd:unix:/run/qemu-server/$vmid\_nbd.migrate:exportname=drive-$opt > volume:$drivestr\n"; > + } else { > + my $migrate_storage_uri = > "nbd:${localip}:${storage_migrate_port}:exportname=drive-$opt"; > + print "storage migration listens on $migrate_storage_uri > volume:$drivestr\n"; > + } and if we also generate the migrate_storage_uri prefix in the if/else branches where we call nbd-server-start, we can drop this if/else differentiation here and have all the UNIX vs TCP logic in one conditional > } > } > > -- > 2.20.1 > > > _______________________________________________ > pve-devel mailing list > pve-devel@pve.proxmox.com > https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel > > _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel