From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <m.limbeck@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 00376600A3
 for <pve-devel@lists.proxmox.com>; Fri,  5 Feb 2021 10:51:53 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id E27ED92EC
 for <pve-devel@lists.proxmox.com>; Fri,  5 Feb 2021 10:51:23 +0100 (CET)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [212.186.127.180])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id 5168592C2
 for <pve-devel@lists.proxmox.com>; Fri,  5 Feb 2021 10:51:23 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 0A22E461E8
 for <pve-devel@lists.proxmox.com>; Fri,  5 Feb 2021 10:51:23 +0100 (CET)
To: Fabian Ebner <f.ebner@proxmox.com>, pve-devel@lists.proxmox.com
References: <20210203142536.28480-1-m.limbeck@proxmox.com>
 <20210203142536.28480-6-m.limbeck@proxmox.com>
 <295d4f46-fbdb-bb8d-9be1-e9fa1fb6dce0@proxmox.com>
From: Mira Limbeck <m.limbeck@proxmox.com>
Message-ID: <b409b602-35d5-272c-15c0-d44135865d58@proxmox.com>
Date: Fri, 5 Feb 2021 10:51:22 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.7.0
MIME-Version: 1.0
In-Reply-To: <295d4f46-fbdb-bb8d-9be1-e9fa1fb6dce0@proxmox.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Content-Language: en-US
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.626 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 NICE_REPLY_A           -0.182 Looks like a legit reply (A)
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [qemu.pm, qemumigrate.pm]
Subject: Re: [pve-devel] [PATCH qemu-server v2] copy conntrack information
 on migration
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Fri, 05 Feb 2021 09:51:54 -0000

On 2/5/21 9:11 AM, Fabian Ebner wrote:
> Am 03.02.21 um 15:25 schrieb Mira Limbeck:
>> Requires the pve-conntrack-tool. On migration the conntrack information
>> from the source node is dumped and sent to the target node where it is
>> then inserted.
>> This helps with open connections during migration when the firewall 
>> is active.
>>
>> A new 'migrate-conntracks' option is added to the migrate_vm API call.
>>
>> Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
>> ---
>> v2:
>>   - added the migrate-conntracks option so that it only copies conntrack
>>     information when requested
>>
>>   PVE/API2/Qemu.pm   | 5 +++++
>>   PVE/QemuMigrate.pm | 5 +++++
>>   2 files changed, 10 insertions(+)
>>
>> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
>> index 3571f5e..8c4336b 100644
>> --- a/PVE/API2/Qemu.pm
>> +++ b/PVE/API2/Qemu.pm
>> @@ -3556,6 +3556,11 @@ __PACKAGE__->register_method({
>>           minimum => '0',
>>           default => 'migrate limit from datacenter or storage config',
>>           },
>> +        'migrate-conntracks' => {
>> +        description => "Migrate connection tracking info.",
>> +        type => 'boolean',
>> +        optional => 1,
>> +        }
>>       },
>>       },
>>       returns => {
>> diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
>> index 5c019fc..2ccef2a 100644
>> --- a/PVE/QemuMigrate.pm
>> +++ b/PVE/QemuMigrate.pm
>> @@ -1087,6 +1087,11 @@ sub phase2 {
>>           die "unable to parse migration status '$stat->{status}' - 
>> aborting\n";
>>       }
>>       }
>> +
>> +    if ($self->{opts}->{'migrate-conntracks'}) {
>> +    $self->log('info', 'copy conntrack information');
>> +    PVE::Tools::run_command([['/usr/bin/pve-conntrack-tool', 
>> 'dump'], [@{$self->{rem_ssh}}, '/usr/bin/pve-conntrack-tool', 
>> 'insert']]);
>
> Just wondering if having an eval here and still continue with the 
> migration if there's a problem would make sense? OTOH one can argue 
> that if the option is set and the connection information cannot be 
> copied, it's better to abort.
>
I'm in favor of aborting, but perhaps eval and die on error with a 
custom error message?
>> +    }
>>   }
>>     sub phase2_cleanup {
>>