From nobody Sun Feb 8 14:12:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1676483294; cv=none; d=zohomail.com; s=zohoarc; b=fwGfv6qIwe2HOfEoEFswWGC0AYesMCCJqCaZMzNIuyl4+brUE0iPtt5W/pEu5QqIDiORXsNChmzdcRYKOz8eZK0yL97oyPGNM/+2Z6uTt/4+K42zJR0UGBFJIWoI7pPDomczUbV0Q0L9xvLsdlvjtaB2i6mtiZXH2LwjatcfdjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676483294; 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=drAf2ZqbcEMpmG5RYs9TvH1b9uvNGa+eyhPOGwfB6JQ=; b=RGsbXbEw0Y/r9czKVRFKHAGFhqci/UD4U9dghfJ505MxdvamfpwiCV0UvJkTusMxTFt3EaFIw/ZiW3T61xTgO506p1E0pamLHti+Pa3sSzJ1z5yQxpvFbM5J/2DSY5hrjPWQMKBeWv8890o2hA41EGOxsnxzrnxDptIKnAuH1hM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1676483294412344.4599474367135; Wed, 15 Feb 2023 09:48:14 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-652-pEd683skPQyzC9QgRqq43w-1; Wed, 15 Feb 2023 12:48:08 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BE9633811F35; Wed, 15 Feb 2023 17:47:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACB70492B15; Wed, 15 Feb 2023 17:47:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 937431946589; Wed, 15 Feb 2023 17:47:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D43B919465B6 for ; Wed, 15 Feb 2023 17:47:20 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C72EF4014D03; Wed, 15 Feb 2023 17:47:20 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.254]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C4FD408573E; Wed, 15 Feb 2023 17:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676483293; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=drAf2ZqbcEMpmG5RYs9TvH1b9uvNGa+eyhPOGwfB6JQ=; b=VQBHr3lmhnIk0qu6TVZr0EX0ljTYm9moUN03J+iYCrdWypES8oPsAPbaZ+WzN6tDD7znKk RL9gX8PznL5GtAo/ZQvWK1gQPPxHRg+cn4IKJawWR9f7UhImCoggCv3kTQ+541U6jabeQp RFYW93NxEbkQS1FmIGAlqrxTivhllho= X-MC-Unique: pEd683skPQyzC9QgRqq43w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 2/5] io/channel-tls: fix handling of bigger read buffers Date: Wed, 15 Feb 2023 17:47:09 +0000 Message-Id: <20230215174712.1894516-3-berrange@redhat.com> In-Reply-To: <20230215174712.1894516-1-berrange@redhat.com> References: <20230215174712.1894516-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, libvir-list@redhat.com, Peter Lieven , Hanna Reitz , Gerd Hoffmann , Ronnie Sahlberg , Paolo Bonzini , Antoine Damhet , Charles Frey Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1676483296006100001 From: Antoine Damhet Since the TLS backend can read more data from the underlying QIOChannel we introduce a minimal child GSource to notify if we still have more data available to be read. Signed-off-by: Antoine Damhet Signed-off-by: Charles Frey Signed-off-by: Daniel P. Berrang=C3=A9 --- io/channel-tls.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/io/channel-tls.c b/io/channel-tls.c index c730cb8ec5..8052945ba0 100644 --- a/io/channel-tls.c +++ b/io/channel-tls.c @@ -389,12 +389,76 @@ static void qio_channel_tls_set_aio_fd_handler(QIOCha= nnel *ioc, qio_channel_set_aio_fd_handler(tioc->master, ctx, io_read, io_write, o= paque); } =20 +typedef struct QIOChannelTLSSource QIOChannelTLSSource; +struct QIOChannelTLSSource { + GSource parent; + QIOChannelTLS *tioc; +}; + +static gboolean +qio_channel_tls_source_check(GSource *source) +{ + QIOChannelTLSSource *tsource =3D (QIOChannelTLSSource *)source; + + return qcrypto_tls_session_check_pending(tsource->tioc->session) > 0; +} + +static gboolean +qio_channel_tls_source_prepare(GSource *source, gint *timeout) +{ + *timeout =3D -1; + return qio_channel_tls_source_check(source); +} + +static gboolean +qio_channel_tls_source_dispatch(GSource *source, GSourceFunc callback, + gpointer user_data) +{ + return G_SOURCE_CONTINUE; +} + +static void +qio_channel_tls_source_finalize(GSource *source) +{ + QIOChannelTLSSource *tsource =3D (QIOChannelTLSSource *)source; + + object_unref(OBJECT(tsource->tioc)); +} + +static GSourceFuncs qio_channel_tls_source_funcs =3D { + qio_channel_tls_source_prepare, + qio_channel_tls_source_check, + qio_channel_tls_source_dispatch, + qio_channel_tls_source_finalize +}; + +static void +qio_channel_tls_read_watch(QIOChannelTLS *tioc, GSource *source) +{ + GSource *child; + QIOChannelTLSSource *tlssource; + + child =3D g_source_new(&qio_channel_tls_source_funcs, + sizeof(QIOChannelTLSSource)); + tlssource =3D (QIOChannelTLSSource *)child; + + tlssource->tioc =3D tioc; + object_ref(OBJECT(tioc)); + + g_source_add_child_source(source, child); +} + static GSource *qio_channel_tls_create_watch(QIOChannel *ioc, GIOCondition condition) { QIOChannelTLS *tioc =3D QIO_CHANNEL_TLS(ioc); + GSource *source =3D qio_channel_create_watch(tioc->master, condition); + + if (condition & G_IO_IN) { + qio_channel_tls_read_watch(tioc, source); + } =20 - return qio_channel_create_watch(tioc->master, condition); + return source; } =20 QCryptoTLSSession * --=20 2.39.1