From nobody Thu May 2 16:56:52 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=1559751688; cv=none; d=zoho.com; s=zohoarc; b=oZH9iH/4tEQ1EXuPPX61WWZhpcbLs2qcSlPBVOcIcsOCU+ESJLErSmltHOskEqr6S6UGzhgrkfL7q14SDd0XtPwc+NV25pbhA7qiTiTVNnTO2ouddJ/Gkhn3PjwAqPW9OsqpOHodsvNYIaWLpN9RM/lXq0v0gavj9nNIU+aaJEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559751688; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zuqXmQOYCmq6L1d+GzSieUh+VN1fBEa/jbfFBYuawJ4=; b=CYQFs7QQSMT9DUZFpS5rfIx+Ry4e5ZSVQGDMHoyO+aB/wQ6uG4PSuTMMKAKZ56+9HBIsF1HCykE+4rwfVS5JuSh06V4Phm36Qc1kv4Pw9rJw79BkziHh5dBXItpWM75psBxzYjVPqSZkV43KwBJ5r37t4bXYAaWUM+FET1SQa4E= 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 1559751688725887.955465452461; Wed, 5 Jun 2019 09:21:28 -0700 (PDT) Received: from localhost ([127.0.0.1]:45879 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYYfE-0005pV-KS for importer@patchew.org; Wed, 05 Jun 2019 12:21:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYYc6-0003jO-HW for qemu-devel@nongnu.org; Wed, 05 Jun 2019 12:18:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYYc5-0000B4-4o for qemu-devel@nongnu.org; Wed, 05 Jun 2019 12:18:10 -0400 Received: from relay.sw.ru ([185.231.240.75]:33138) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hYYc4-00005n-TZ; Wed, 05 Jun 2019 12:18:09 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hYYc1-0003ZF-FG; Wed, 05 Jun 2019 19:18:05 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Wed, 5 Jun 2019 19:18:03 +0300 Message-Id: <20190605161804.118956-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190605161804.118956-1-vsementsov@virtuozzo.com> References: <20190605161804.118956-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v2 1/2] io/channel: add qio_channel_set_keepalive 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: kwolf@redhat.com, vsementsov@virtuozzo.com, berrange@redhat.com, mreitz@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 Acked-by: Daniel P. Berrang=C3=A9 --- include/io/channel.h | 15 +++++++++++++++ io/channel-socket.c | 20 ++++++++++++++++++++ io/channel.c | 14 ++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/include/io/channel.h b/include/io/channel.h index 59460cb1ec..b8789ea08a 100644 --- a/include/io/channel.h +++ b/include/io/channel.h @@ -124,6 +124,9 @@ struct QIOChannelClass { int (*io_set_blocking)(QIOChannel *ioc, bool enabled, Error **errp); + int (*io_set_keepalive)(QIOChannel *ioc, + bool enabled, + Error **errp); =20 /* Optional callbacks */ int (*io_shutdown)(QIOChannel *ioc, @@ -490,6 +493,18 @@ int qio_channel_set_blocking(QIOChannel *ioc, bool enabled, Error **errp); =20 +/* + * qio_channel_set_keepalive: + * @ioc: the channel object + * @enabled: the keepalive flag state + * @errp: pointer to a NULL-initialized error object + * + * Returns 0 on success, -1 on error. + */ +int qio_channel_set_keepalive(QIOChannel *ioc, + bool enabled, + Error **errp); + /** * qio_channel_close: * @ioc: the channel object diff --git a/io/channel-socket.c b/io/channel-socket.c index bc5f80e780..84b474851b 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -656,6 +656,25 @@ qio_channel_socket_set_blocking(QIOChannel *ioc, } =20 =20 +static int +qio_channel_socket_set_keepalive(QIOChannel *ioc, + bool enabled, + Error **errp) +{ + QIOChannelSocket *sioc =3D QIO_CHANNEL_SOCKET(ioc); + int val =3D enabled; + int ret =3D qemu_setsockopt(sioc->fd, SOL_SOCKET, SO_KEEPALIVE, + &val, sizeof(val)); + + if (ret < 0) { + error_setg_errno(errp, errno, "Unable to set KEEPALIVE"); + return -1; + } + + return 0; +} + + static void qio_channel_socket_set_delay(QIOChannel *ioc, bool enabled) @@ -762,6 +781,7 @@ static void qio_channel_socket_class_init(ObjectClass *= klass, ioc_klass->io_writev =3D qio_channel_socket_writev; ioc_klass->io_readv =3D qio_channel_socket_readv; ioc_klass->io_set_blocking =3D qio_channel_socket_set_blocking; + ioc_klass->io_set_keepalive =3D qio_channel_socket_set_keepalive; ioc_klass->io_close =3D qio_channel_socket_close; ioc_klass->io_shutdown =3D qio_channel_socket_shutdown; ioc_klass->io_set_cork =3D qio_channel_socket_set_cork; diff --git a/io/channel.c b/io/channel.c index 2a26c2a2c0..a9e62fdbdc 100644 --- a/io/channel.c +++ b/io/channel.c @@ -265,6 +265,20 @@ int qio_channel_set_blocking(QIOChannel *ioc, return klass->io_set_blocking(ioc, enabled, errp); } =20 +int qio_channel_set_keepalive(QIOChannel *ioc, + bool enabled, + Error **errp) +{ + QIOChannelClass *klass =3D QIO_CHANNEL_GET_CLASS(ioc); + + if (!klass->io_set_keepalive) { + error_setg(errp, "KEEPALIVE is not supported by IO channel"); + return -1; + } + + return klass->io_set_keepalive(ioc, enabled, errp); +} + =20 int qio_channel_close(QIOChannel *ioc, Error **errp) --=20 2.18.0 From nobody Thu May 2 16:56:52 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=1559751583; cv=none; d=zoho.com; s=zohoarc; b=ODv+rN3LhiyFejLI/Eb2+JDmPE7LAAAAGM2e2n5rbg4HBSWMXdpRLdq3D8oE73SKlsu5SahGs3x/pj0pZNcpcOb1TnjrQU8PZfMi/h9V1m2p6M1gLv7AeMK3ypoKYbL640qj2gLc/5bnSrqMrHmIJoUkphjZhbtI1OOC9UOBuVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559751583; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=qOVbG2nZaHrNtPMLXkZmMiU5JDQ7pPmGsDLVYPqWCLY=; b=dEwzNUSqWNh68rVMTR6DGE9UQduag8I4bP984qSY/DZMeWLuDWkVfwHnqLP7KD891hqrEauRY/4xkAOqsVaUPU0kk6VicDZVlJh6fxtuikoIb3vnk0aWMVXoj1v7acgCiIMJ+ZZr/tmfHWB8bvzAqAOdyY7Blyq18pn7ijeKZ8U= 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559751583502969.9750358886107; Wed, 5 Jun 2019 09:19:43 -0700 (PDT) Received: from localhost ([127.0.0.1]:45819 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYYdV-0004Qa-Gf for importer@patchew.org; Wed, 05 Jun 2019 12:19:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYYc6-0003jN-Ap for qemu-devel@nongnu.org; Wed, 05 Jun 2019 12:18:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYYc5-0000BQ-7z for qemu-devel@nongnu.org; Wed, 05 Jun 2019 12:18:10 -0400 Received: from relay.sw.ru ([185.231.240.75]:33136) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hYYc4-00005m-Vr; Wed, 05 Jun 2019 12:18:09 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hYYc1-0003ZF-IU; Wed, 05 Jun 2019 19:18:05 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Wed, 5 Jun 2019 19:18:04 +0300 Message-Id: <20190605161804.118956-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190605161804.118956-1-vsementsov@virtuozzo.com> References: <20190605161804.118956-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v2 2/2] nbd-client: enable TCP keepalive 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: kwolf@redhat.com, vsementsov@virtuozzo.com, berrange@redhat.com, mreitz@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" Enable keepalive option to track server availability. Requested-by: Denis V. Lunev Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/nbd-client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/nbd-client.c b/block/nbd-client.c index 790ecc1ee1..b57cea8482 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -1137,6 +1137,7 @@ static int nbd_client_connect(BlockDriverState *bs, =20 /* NBD handshake */ logout("session init %s\n", export); + qio_channel_set_keepalive(QIO_CHANNEL(sioc), true, NULL); qio_channel_set_blocking(QIO_CHANNEL(sioc), true, NULL); =20 client->info.request_sizes =3D true; --=20 2.18.0