From nobody Sat May 4 09:21:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1559816218; cv=none; d=zoho.com; s=zohoarc; b=jhlycidMlfQY8vKrvkEo1JqFOtBasiU9AKqi0+lhQ62nwSzLLig4a9XHgjVNYWj3bFvuGkxfKC5gYcdbRjaYaH+x6/ey+HiJDLUlbCpFeUGlyQXxKTUUFeigT2sdLuZHgYhtp6Av2lfU+s07b/iFo1Sub8BiDUmaeo8yUe58qNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559816218; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=sFcTyyT4ej156ZngLdZz+azIFaSdcoYuZDrOVzKZoGA=; b=EvxiXE9dmJjEaLxy4WPQvK2bfgDcJ+o5vWK7Ni/1mtJf8ims4h/LNJItl816qu1qbJKw9jt3aMLQLniB8XTWohvVp0Od9xxfiXJnRagEN+/5fxb/wwpVPF0drV9eNcHCu0eQTXwoatQuckeorec5oUXKc2ChYlefkXEA5fJ7IhQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail 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 1559816218530538.350446216849; Thu, 6 Jun 2019 03:16:58 -0700 (PDT) Received: from localhost ([127.0.0.1]:57751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYpS1-0002Qe-P6 for importer@patchew.org; Thu, 06 Jun 2019 06:16:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYpR4-0001u7-RU for qemu-devel@nongnu.org; Thu, 06 Jun 2019 06:15:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYpQz-0007OW-ND for qemu-devel@nongnu.org; Thu, 06 Jun 2019 06:15:51 -0400 Received: from relay.sw.ru ([185.231.240.75]:38212) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hYpQx-0006sf-86 for qemu-devel@nongnu.org; Thu, 06 Jun 2019 06:15:48 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hYpQj-0007Qy-Uc; Thu, 06 Jun 2019 13:15:34 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Date: Thu, 6 Jun 2019 13:15:33 +0300 Message-Id: <20190606101533.20228-1-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH] qapi: InitSocketAddress: add keepalive option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladimir Sementsov-Ogievskiy --- Hi all! This is a continuation of "[PATCH v2 0/2] nbd: enable keepalive", but it's a try from another side, so almost nothing common with v2. qapi/sockets.json | 5 ++++- util/qemu-sockets.c | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/qapi/sockets.json b/qapi/sockets.json index fc81d8d5e8..aefa024051 100644 --- a/qapi/sockets.json +++ b/qapi/sockets.json @@ -53,6 +53,8 @@ # # @ipv6: whether to accept IPv6 addresses, default try both IPv4 and IPv6 # +# @keepalive: enable keepalive when connecting to this socket (Since 4.1) +# # Since: 1.3 ## { 'struct': 'InetSocketAddress', @@ -61,7 +63,8 @@ '*numeric': 'bool', '*to': 'uint16', '*ipv4': 'bool', - '*ipv6': 'bool' } } + '*ipv6': 'bool', + '*keepalive': 'bool' } } =20 ## # @UnixSocketAddress: diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 8850a280a8..d2cd2a9d4f 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -457,6 +457,19 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error= **errp) } =20 freeaddrinfo(res); + + if (saddr->keepalive) { + 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; + } + } + return sock; } =20 --=20 2.18.0