From nobody Tue May 7 00:33:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1594235939; cv=pass; d=zohomail.com; s=zohoarc; b=JAhdtmfy+KxtT43gganNq6S9H/wXyFGiOBUSb4hzNoKpsWctU/y2ZtIShexwbSGCBdbhXn0TvUXZ/s9WXC2TGdwDoe/hhx5/ytUXrkAZ9AAsv+Xg//n3ZPDZ/PdAEl90Exhy9/ed0M60m/Q16VXDf4+MXMFcXAowaLwIY4AQxzQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594235939; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GRnYapanj2hvIF536VTHpHcFXNca4qFgv1jGKv0/7bY=; b=YvLenc+DizBNtTjWVrX6oQ13qHvo82OAPs254f5w2/v/StXK2cVq7fDWyXZNiaXUkMx3/9C7P+sXh1R0DdmrEf7OkJWj4+W1ndXc3vyc3rB/APhQmLPZm0gulNnRfrhPEdfdeawBiQHZ+h47dV5zidqrRuHfCrVL31xkdpONxxA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594235939801626.2853636374759; Wed, 8 Jul 2020 12:18:59 -0700 (PDT) Received: from localhost ([::1]:50998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jtFas-0003bI-BU for importer@patchew.org; Wed, 08 Jul 2020 15:18:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtFYf-0002Iv-QA for qemu-devel@nongnu.org; Wed, 08 Jul 2020 15:16:41 -0400 Received: from mail-eopbgr50098.outbound.protection.outlook.com ([40.107.5.98]:19714 helo=EUR03-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtFYe-0001hk-1b for qemu-devel@nongnu.org; Wed, 08 Jul 2020 15:16:41 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4070.eurprd08.prod.outlook.com (2603:10a6:20b:a3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20; Wed, 8 Jul 2020 19:16:02 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::a408:2f0f:bc6c:d312]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::a408:2f0f:bc6c:d312%3]) with mapi id 15.20.3174.021; Wed, 8 Jul 2020 19:16:02 +0000 Received: from localhost.localdomain (185.215.60.17) by AM0PR04CA0123.eurprd04.prod.outlook.com (2603:10a6:208:55::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 19:15:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dK7H2R4Un5JQQc5BCd9w2B7w535EvKoY3xA4Dw6QI0TNxqyvkJUN8uFuDAlIjk+DkDRK84lwOxhzTXZbwx0PKN0zWACeTCMbR6g7r5Jls8iJHRAzsXh/7BKhAhOPyyW0NoBhuNb4QY6iAtC+rUPu7qlW+tXQQ5bkov5xB2oXAfRKs7ehpHdTEVWlgeKh1Vv0EmNwfg3vOlCDS/7Sb+wGpas1FDCdQeEYXlC96364wAuujE8YgZ3Lx289JPIZGuLlfaoyXnEX1Reu/3bqnQee/y544BAWZDZz9xTLzOWmMkvnhW9xpRDRCwzKAhrVDiZCSoX9gX+fM8HeqZ06hn0l6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GRnYapanj2hvIF536VTHpHcFXNca4qFgv1jGKv0/7bY=; b=nu+TgXxW+9A1pRuuio1Yvkn6Ux91MhMWEgitg3v2gAJ7vQ09bVQykkqtGBwVlrL3xyZHsEnstke6Y1JFAFyIfZEFz7j0xOVhkG6Ul6tK1G6YhR0onFhXIclFveB+L8S+Yk55VTrbYmTmzztCzZNy0wroZP109toIHcW4CQddMmsPaMUUql+6nrSml0Aw1k6VcdCaT/lgHTEeQroGLVErsP96Rfs8mXeKsj1flU+Z7wK4ywd9V2S2D1Sv9P8fPwsxvFHRdXZnERn1dnSUFx/9QO7BXwVVTeub2AFJmkSyJq0JLKtavGu5L67fipsjvKoZ+i6Fsi3mpapaYUgnN1kqdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GRnYapanj2hvIF536VTHpHcFXNca4qFgv1jGKv0/7bY=; b=iCC1BGKa9nQKU/7ji4qao8j0klcurKAPcvO4l71isitpVfqGPRbJcsDvCkGwjE801pvXUpqraIhBfvbq2LG+aZ1jHbPL/SvdkmSsXXtmmEQq2Vx0EVi2P0fJ0WGqmt/fJnJenj+wW/vCd/2ICDv8MtVFrOF+jTFhMoeNQOb+F+U= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Subject: [PATCH 1/2] sockets: keep-alive settings Date: Wed, 8 Jul 2020 22:15:38 +0300 Message-Id: <20200708191540.28455-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200708191540.28455-1-vsementsov@virtuozzo.com> References: <20200708191540.28455-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM0PR04CA0123.eurprd04.prod.outlook.com (2603:10a6:208:55::28) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.21.0 X-Originating-IP: [185.215.60.17] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c43810b1-62a2-4844-41a8-08d823735705 X-MS-TrafficTypeDiagnostic: AM6PR08MB4070: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iv4UZVI5r92eixjZllFpvt4+aDiVE0KSK1PSSd08jCvdKHHg6xnyC0/GMTROcNz5vNZCWKoVMtTvbjzc5SbQIDYKqszGeFl+H+lLdFPiHYZJVtgKde32P0H6n5aULKKn02QtutxM1gQ3jqsqVllgd+3scGDslsCj2c35t4mfZRXkEDYXQKxkeNCuvuTb3PCw1cqXZX8a9/xy4hUIoak1HvLpsSCABxzybzn/n7EAgw3urcUTfWKM1HgB+cIFCqf8dcK6fiZjM6I4honbkjArrFZpEgsueTuuOlK78AdNsKhOFXPURQ3dW/xKtv+E0viwwVYiIqeBigk8Ny+Hs97OQ2SVSSnNZMeKiscfe9fZToFG4FAJvprQXDwZlLR1wCT7 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(136003)(396003)(39850400004)(366004)(376002)(346002)(186003)(16526019)(86362001)(1076003)(6506007)(956004)(69590400007)(26005)(6666004)(6486002)(5660300002)(316002)(52116002)(66476007)(66556008)(478600001)(4326008)(66946007)(8676002)(36756003)(8936002)(6512007)(2616005)(83380400001)(2906002)(6916009)(107886003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: dV+FuJE8QMHluEiuvN+cTEtHNX05kV3F8oVG2zjmI0GG77SLKFGrZ31UwGrDwWqhOc3Qr+nETzxuZhEpC7YWIojPkiYEpqX9E5Ab0hcsvR2p2B/ni+cHnx+ArDBDJGDK/NDqfQlumbFp10lPaGM5XS4Mn83fDDev7BElKw59bFi2Vg/LdR5L3kdrIxK87AvpzbkgIUvN+cv1arH2CX0EoWR4hMeRVpC2CwPJ520tlAtdheWnIkxakGCEW9QgCHyNI1S9Sf2CGVqEOzuHtPrCp9lhhJvkBelSFkQKZK1ZnqFWg5ZgwdrhgiscaCRTGXKk96tkYtY7XOAAClVase5d5Ph0OVVOGpfYF4J6MJthFDo4UqAgqjBP3Gq2zgyK0ePxfxei4+CyW1UwecJ0gqIo4H7I0lcdTr0MJSnqtc6X9q/G+SMyaBEx754B8FlLritTcMhv8lKqYKtPB8PKBLMdOGePYFbdy7OCpeDq9Qks21I= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c43810b1-62a2-4844-41a8-08d823735705 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 19:15:56.2860 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BMEdCZwRgHCanOJQcrt62UqdRs8GhtJiXbUQePQfDi/KlNTV2Rw0NZDTmmVJlF+jveHxVKerNUme9YzSBYStz8ko6gwdVjH1fujS0wCf70Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4070 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.5.98; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-VE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/08 15:16:36 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vsementsov@virtuozzo.com, berrange@redhat.com, armbru@redhat.com, kraxel@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" Introduce keep-alive settings (TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL) and chose some defaults. The linux default of 2 hours for /proc/tcp_keepalive_time (corresponding to TCP_KEEPIDLE) makes keep-alive option almost superfluous. Let's add a possibility to set the options by hand and specify some defaults resulting in smaller total time to terminate idle connection. Do not document the default values in QAPI as they may be altered in future (careful user will use explicit values). Signed-off-by: Vladimir Sementsov-Ogievskiy --- Suggested default numbers are RFC, any better suggestion is welcome. I just looked at /etc/libvirt/qemu.conf in my system and take values of keepalive_interval and keepalive_count. The only thing I'm sure in is that 2 hours is too long. qapi/sockets.json | 33 +++++++++++++++++++- util/qemu-sockets.c | 76 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 97 insertions(+), 12 deletions(-) diff --git a/qapi/sockets.json b/qapi/sockets.json index cbd6ef35d0..73ff66a5d5 100644 --- a/qapi/sockets.json +++ b/qapi/sockets.json @@ -37,6 +37,37 @@ 'host': 'str', 'port': 'str' } } =20 +## +# @KeepAliveSettings: +# +# @idle: The time (in seconds) the connection needs to remain idle +# before TCP starts sending keepalive probes (sets TCP_KEEPIDLE). +# @interval: The time (in seconds) between individual keepalive probes +# (sets TCP_KEEPINTVL). +# @count: The maximum number of keepalive probes TCP should send before +# dropping the connection (sets TCP_KEEPCNT). +# +# Since: 5.2 +## +{ 'struct': 'KeepAliveSettings', + 'data': { + 'idle': 'int', + 'interval': 'int', + 'count': 'int' } } + +## +# @KeepAliveField: +# +# @enabled: If true, enable keep-alive with some default settings +# @settings: Enable keep-alive and use explicit settings +# +# Since: 5.2 +## +{ 'alternate': 'KeepAliveField', + 'data': { + 'enabled': 'bool', + 'settings': 'KeepAliveSettings' } } + ## # @InetSocketAddress: # @@ -65,7 +96,7 @@ '*to': 'uint16', '*ipv4': 'bool', '*ipv6': 'bool', - '*keep-alive': 'bool' } } + '*keep-alive': 'KeepAliveField' } } =20 ## # @UnixSocketAddress: diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index b37d288866..b961963472 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -433,6 +433,57 @@ static struct addrinfo *inet_parse_connect_saddr(InetS= ocketAddress *saddr, return res; } =20 +/* + * inet_set_keepalive + * + * Handle keep_alive settings. If user specified settings explicitly, fail= if + * can't set the settings. If user just enabled keep-alive, not specifying= the + * settings, try to set defaults but ignore failures. + */ +static int inet_set_keepalive(int sock, bool has_keep_alive, + KeepAliveField *keep_alive, Error **errp) +{ + int ret; + int val; + bool has_settings =3D has_keep_alive && keep_alive->type =3D=3D QTYPE= _QDICT; + + if (!has_keep_alive || (keep_alive->type =3D=3D QTYPE_QBOOL && + !keep_alive->u.enabled)) + { + return 0; + } + + val =3D 1; + ret =3D qemu_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(v= al)); + if (ret < 0) { + error_setg_errno(errp, errno, "Unable to set KEEPALIVE"); + return -1; + } + + val =3D has_settings ? keep_alive->u.settings.idle : 30; + ret =3D qemu_setsockopt(sock, IPPROTO_TCP, TCP_KEEPIDLE, &val, sizeof(= val)); + if (has_settings && ret < 0) { + error_setg_errno(errp, errno, "Unable to set TCP_KEEPIDLE"); + return -1; + } + + val =3D has_settings ? keep_alive->u.settings.interval : 30; + ret =3D qemu_setsockopt(sock, IPPROTO_TCP, TCP_KEEPINTVL, &val, sizeof= (val)); + if (has_settings && ret < 0) { + error_setg_errno(errp, errno, "Unable to set TCP_KEEPINTVL"); + return -1; + } + + val =3D has_settings ? keep_alive->u.settings.count : 20; + ret =3D qemu_setsockopt(sock, IPPROTO_TCP, TCP_KEEPCNT, &val, sizeof(v= al)); + if (has_settings && ret < 0) { + error_setg_errno(errp, errno, "Unable to set TCP_KEEPCNT"); + return -1; + } + + return 0; +} + /** * Create a socket and connect it to an address. * @@ -468,16 +519,11 @@ int inet_connect_saddr(InetSocketAddress *saddr, Erro= r **errp) return sock; } =20 - if (saddr->keep_alive) { - int val =3D 1; - int ret =3D qemu_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, - &val, sizeof(val)); - - if (ret < 0) { - error_setg_errno(errp, errno, "Unable to set KEEPALIVE"); - close(sock); - return -1; - } + if (inet_set_keepalive(sock, saddr->has_keep_alive, saddr->keep_alive, + errp) < 0) + { + close(sock); + return -1; } =20 return sock; @@ -677,12 +723,20 @@ int inet_parse(InetSocketAddress *addr, const char *s= tr, Error **errp) } begin =3D strstr(optstr, ",keep-alive"); if (begin) { + bool val; + if (inet_parse_flag("keep-alive", begin + strlen(",keep-alive"), - &addr->keep_alive, errp) < 0) + &val, errp) < 0) { return -1; } + addr->has_keep_alive =3D true; + addr->keep_alive =3D g_new(KeepAliveField, 1); + *addr->keep_alive =3D (KeepAliveField) { + .type =3D QTYPE_QBOOL, + .u.enabled =3D val + }; } return 0; } --=20 2.21.0 From nobody Tue May 7 00:33:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1594235845; cv=pass; d=zohomail.com; s=zohoarc; b=GqPVl6+rlRpa4w5KiyYvqObIKHzX/TKELW+mB2Jq1TvszKClGAmKRA5ry4nS8IyodTohLwMyuq2cCrph0cpR84OhmeDeQ5xNn909szdrgn8PyqGxZPdShTyojxOqIWIbiAhoQMCRBaOSm5J2PcphVqPVpUWyZy/Qj+5kvkrV64U= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594235845; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X6xPYxQNI4IMCN522QoEIVGvxzwM0GNlL0IeNi1Q8Fc=; b=cjwMiWiW5HrqJkokzzL8iyw67Iazlrcm0rgxLQwUyxloJzhUrAgahETATQhu1oaCUEKsr8J1SaGQDw68okuiXQzLhfzESrxSjRLVqk22UCYnSXYt6zC1oaIFTYShm5jVxJ/CttmdvvKCBXK6XaQJSPw/MEY8E9Ms5qPLKAdqwa4= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594235844995438.3269497881596; Wed, 8 Jul 2020 12:17:24 -0700 (PDT) Received: from localhost ([::1]:48894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jtFZL-0002jW-QB for importer@patchew.org; Wed, 08 Jul 2020 15:17:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtFYd-0002Hk-Os for qemu-devel@nongnu.org; Wed, 08 Jul 2020 15:16:39 -0400 Received: from mail-eopbgr50098.outbound.protection.outlook.com ([40.107.5.98]:19714 helo=EUR03-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtFYc-0001hk-3U for qemu-devel@nongnu.org; Wed, 08 Jul 2020 15:16:39 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4070.eurprd08.prod.outlook.com (2603:10a6:20b:a3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20; Wed, 8 Jul 2020 19:16:02 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::a408:2f0f:bc6c:d312]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::a408:2f0f:bc6c:d312%3]) with mapi id 15.20.3174.021; Wed, 8 Jul 2020 19:16:02 +0000 Received: from localhost.localdomain (185.215.60.17) by AM0PR04CA0123.eurprd04.prod.outlook.com (2603:10a6:208:55::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 19:15:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LzWw3yqNoMfhaGplz+dWFFDgLmt3QEhk26qhv6L4TBNLIDWLTluZuPmVncz3QPuN8WH3trc6RpgvK874gvU7OrlOdPoUxQS1w4BaK+v0/HT73E529iX5VEcpeyYr5+/1nQJdy/qocfqHUhbRMGOPxZ8vwjeA8tn5GIRJIaH8oZiItPBhxAmsgQwJFtIrf4bDUQ0oHjB3rqkEASEZLnKKIfjOD0D4MmVaczijjx+r3eVmvv3r06UqQamxWoFJwd0m7G6Ni8swxT4+GYpCZLQa9tpjSYGs4gk7KN2CaYbqLy97zf2yEMgpkOKNiP+fVG6lfE59R/8lKTsF+Lnd4hOvnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=X6xPYxQNI4IMCN522QoEIVGvxzwM0GNlL0IeNi1Q8Fc=; b=Dd2hGoKRwe9qF029Q2tRt1Jv+gb7oVx3ROiAGbhKtwP2hzABe4k23gbWdvF7w/uPPKmNpcmBXFQD8leb2zODpJ0tfCMw7lBeJkM3y6eymWfS6zfsQ2IELKyXV/rwNe9AMKLwTe/4EFsgNT0xJ7iSrB30fKp/nTXuAlcNVi7eixrD9TBKLwEw5ZIVVbjUnGGu0q0Aa0yU6aMzrz3oZYOM3+VWbrrUAkMSfej3EyqMCQqiZxr8aB7EfaQXZOFPrJbQMMt3mOr1OJB0OZRMJo9db9fFagAbyfSmbFNDmq2r7tNlpbyxwxt37LFR81Iv4SILP8aNZIctJYZx2VcEsH8jLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=X6xPYxQNI4IMCN522QoEIVGvxzwM0GNlL0IeNi1Q8Fc=; b=c+VLPdlRxSRv34dyl6LrtVVs401G51SCNk+Gkv+FlGIByyesGMBwIIRTIuU5mEey7GbLbxRaCtamJcXnSsyXobrctg194Qo26masFGM+pZXwY/LVWBXGD+RtAp9G6N/alIay0ftSQHPNik2lkn7R6ExvDZRH12vHB7DGK0pDm/8= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Subject: [PATCH 2/2] util/qemu-sockets: make keep-alive enabled by default Date: Wed, 8 Jul 2020 22:15:39 +0300 Message-Id: <20200708191540.28455-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200708191540.28455-1-vsementsov@virtuozzo.com> References: <20200708191540.28455-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM0PR04CA0123.eurprd04.prod.outlook.com (2603:10a6:208:55::28) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.21.0 X-Originating-IP: [185.215.60.17] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4af41638-b39f-484b-2603-08d82373576f X-MS-TrafficTypeDiagnostic: AM6PR08MB4070: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1728; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yAECPv5FkgfMnjTevj92Ca6MrwrQxWo+GqOSJ05k+1Vx0noyuJjHoWClGRP5EuyPQ1Agki9oNsbycIv75TgavTzt8buuiRXeIj/qZ9DQjtHAE2xVUACt9ZXunac2fMkPb9LcArhkbIUBA0P99pd7YmNdK/z3doWxVgg03qhIJshxkDqfqaaqwmOqUAvoDttt+BJaxQsqHMxFouMrVua8R3li3wjFVSGyizqfBAK4Gaqea5W9qlYAbBE6layNHOgyTbvX4KhPUJ423RFAdZRttDUmvERKlSMsmaWEqjC64eNDMYhUCwMRSeGRAdlJaSebQwcnC0m708F7wg8GtyEV0jaFBaeckcdR3v6zzqjFFUCcxZUmd3zvQUG73MQSXG0U X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(136003)(396003)(39850400004)(366004)(376002)(346002)(186003)(16526019)(86362001)(1076003)(6506007)(956004)(69590400007)(26005)(6666004)(6486002)(5660300002)(316002)(52116002)(66476007)(66556008)(478600001)(4326008)(66946007)(8676002)(36756003)(8936002)(6512007)(2616005)(83380400001)(2906002)(6916009)(107886003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 4X3xGpOfQWwpKvrRzazDzbAGgCWSWyUDR2opsBFkprDeEPTu5kTBhBTZ9XFCV2cUXtVOZO+bQy21YvB4hikCeHfGNvgEYM5TPbeHPlSNTQAT+RxVrHbv/zpguX+7NkHuAZlzNuKAW11t/ToYsg1iJwPMS6VTGnQmuWTxUNF/kxaFdm5yPKssa+ZR0jUy1LFDJAqVQsiPVZvZ6tKiSBWe19/l0dbo+E1d8o6ok9wbSdLIdYow3nKM7tuyl1OtZxSZLIrYkdyaXv6DdYFklyjHIuURBuZZMqHb18XQ0576/Xj/Hf4Zyi2N60igV7iIlHTRoJzZwXkXb3hZL+5Iewyxme745qm+N83CNXzHN2vRwX9p3afOknz3b/e//jN5qm9OfEK7XCmDnWdHmtN3J1BVe/EhSjnZm6KLdbi5Gj8+HMptVjEgRWjfuUW73vsXJbiLThY70wSWTVf7rOfjcquz1S4Cp25RnMBM2ZIsF1jyz2g= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4af41638-b39f-484b-2603-08d82373576f X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 19:15:56.9820 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OInkp7pUmocH/xsaILuUyK8qub3RCkZlOitBlaemT2iNrLxVCZDY5MrDjRssYux9jzb14/2zELkCt2B/AeY5GP8t49rgqVcMjVX65Pji6wQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4070 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.5.98; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-VE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/08 15:16:36 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vsementsov@virtuozzo.com, berrange@redhat.com, armbru@redhat.com, kraxel@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" Keep-alive won't hurt, let's try to enable it even if not requested by user. Signed-off-by: Vladimir Sementsov-Ogievskiy --- util/qemu-sockets.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index b961963472..f6851376f5 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -438,7 +438,8 @@ static struct addrinfo *inet_parse_connect_saddr(InetSo= cketAddress *saddr, * * Handle keep_alive settings. If user specified settings explicitly, fail= if * can't set the settings. If user just enabled keep-alive, not specifying= the - * settings, try to set defaults but ignore failures. + * settings, try to set defaults but ignore failures. If keep-alive option= is + * not specified, try to set it but ignore failures. */ static int inet_set_keepalive(int sock, bool has_keep_alive, KeepAliveField *keep_alive, Error **errp) @@ -447,8 +448,8 @@ static int inet_set_keepalive(int sock, bool has_keep_a= live, int val; bool has_settings =3D has_keep_alive && keep_alive->type =3D=3D QTYPE= _QDICT; =20 - if (!has_keep_alive || (keep_alive->type =3D=3D QTYPE_QBOOL && - !keep_alive->u.enabled)) + if (has_keep_alive && + keep_alive->type =3D=3D QTYPE_QBOOL && !keep_alive->u.enabled) { return 0; } @@ -456,8 +457,12 @@ static int inet_set_keepalive(int sock, bool has_keep_= alive, val =3D 1; ret =3D qemu_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(v= al)); if (ret < 0) { - error_setg_errno(errp, errno, "Unable to set KEEPALIVE"); - return -1; + if (has_keep_alive) { + error_setg_errno(errp, errno, "Unable to set KEEPALIVE"); + return -1; + } else { + return 0; + } } =20 val =3D has_settings ? keep_alive->u.settings.idle : 30; --=20 2.21.0