From c4ac8f713caa54ae94b3ca3d22d98ca2ef62e669 Mon Sep 17 00:00:00 2001 From: Mira Limbeck Date: Tue, 17 Mar 2020 20:56:11 +0100 Subject: [PATCH] parse nbd_protocol_version if available 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: '. 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 --- PVE/API2/Qemu.pm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 21a0eae1..fa8315e1 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -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 = )) { + while (defined(my $line = )) { 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; };