]> git.proxmox.com Git - qemu-server.git/commitdiff
parse nbd_protocol_version if available
authorMira Limbeck <m.limbeck@proxmox.com>
Tue, 17 Mar 2020 19:56:11 +0000 (20:56 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 18 Mar 2020 07:03:44 +0000 (08:03 +0100)
For secure live migration with local disks via NBD over a unix socket,
we have to somehow communicate from the source node to the target node
if it supports it. This is because there can only be one NBD server with
exactly one socket bound.

The source node passes that information via STDIN. Support for
'spice_ticket: (...)' is added in addition to 'nbd_protocol_version:
<version>'. As old source nodes send the spice ticket without a prefix,
we still have to have a fallback for this case. New information should
always be passed via a prefix that is matched, otherwise it will be
recognized as spice ticket.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
PVE/API2/Qemu.pm

index 21a0eae14b3e98177025f670ddabe82fec17b05e..fa8315e1d18f0572ba3cb6be381e6c5c541b2d6b 100644 (file)
@@ -2072,10 +2072,18 @@ __PACKAGE__->register_method({
 
        # read spice ticket from STDIN
        my $spice_ticket;
+       my $nbd_protocol_version = 0;
        if ($stateuri && ($stateuri eq 'tcp' || $stateuri eq 'unix') && $migratedfrom && ($rpcenv->{type} eq 'cli')) {
-           if (defined(my $line = <STDIN>)) {
+           while (defined(my $line = <STDIN>)) {
                chomp $line;
-               $spice_ticket = $line;
+               if ($line =~ m/^spice_ticket: (.+)$/) {
+                   $spice_ticket = $1;
+               } elsif ($line =~ m/^nbd_protocol_version: (\d+)$/) {
+                   $nbd_protocol_version = $1;
+               } else {
+                   # fallback for old source node
+                   $spice_ticket = $line;
+               }
            }
        }
 
@@ -2104,7 +2112,8 @@ __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, $timeout);
+                                         $spice_ticket, $migration_network, $migration_type, $targetstorage, $timeout,
+                                         $nbd_protocol_version);
                return;
            };