From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C39F7C4361B for ; Tue, 15 Dec 2020 21:24:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3570822D06 for ; Tue, 15 Dec 2020 21:24:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3570822D06 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpHnr-0000qT-H0 for qemu-devel@archiver.kernel.org; Tue, 15 Dec 2020 16:24:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpHmR-0007bQ-Bv for qemu-devel@nongnu.org; Tue, 15 Dec 2020 16:22:47 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:44098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpHmM-00040P-Qn for qemu-devel@nongnu.org; Tue, 15 Dec 2020 16:22:46 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0BFLDeaC045819; Tue, 15 Dec 2020 21:22:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : content-transfer-encoding : in-reply-to; s=corp-2020-01-29; bh=uq8nctSy4jAVB+sbq7H7ehXdASVKzKRl/a8HSRRP9vo=; b=npD9BgATLIfTRG484TiDE2kkgAiGsb3JWMLmCFG3tFpa1z5tgLEWyf/OEVFjTHDS8vgl Z+BRuFuw+2tQDzBpDLx1Xv/lwCaR5sD9GBw/2v2y5tTjR2GO59wPJlvfncOGePsbnp0q yPvyXSMBZMv73hk+/E+/5I/Tvej5iCMrxqxz2X6hfdgOZIX0TxAyHTnlwyGCQJ4ewI08 vbHyIz+r1hr6MOyuqH/5ZEssRwgIdHMokiWm2MDO3FvsU0LNoB9XsU4Y167udAH/h432 Af2vTbTaeWHXfr5FtRoVixkJf+XVm3oEytYUhLnJuoukljFRkmUQuL+jtcd3dcRJb2+n uQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 35ckcbd2fs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 15 Dec 2020 21:22:32 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0BFLLCtW062705; Tue, 15 Dec 2020 21:22:32 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 35d7enkg2r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Dec 2020 21:22:32 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0BFLMTsp022539; Tue, 15 Dec 2020 21:22:29 GMT Received: from heatpipe (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 15 Dec 2020 13:22:28 -0800 Date: Tue, 15 Dec 2020 13:22:25 -0800 From: Elena Ufimtseva To: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , stefanha@redhat.com Subject: Re: [PATCH v13 07/19] multi-process: add qio channel function to transmit data and fds Message-ID: <20201215212225.GB17643@heatpipe> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9836 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012150144 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9836 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 mlxscore=0 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012150143 Received-SPF: pass client-ip=141.146.126.79; envelope-from=elena.ufimtseva@oracle.com; helo=aserp2130.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=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: Fam Zheng , John G Johnson , Swapnil Ingle , "Michael S. Tsirkin" , QEMU , Gerd Hoffmann , Jagannathan Raman , Juan Quintela , Markus Armbruster , Kanth Ghatraju , Felipe Franciosi , Thomas Huth , Eduardo Habkost , Konrad Rzeszutek Wilk , "Dr. David Alan Gilbert" , Alex Williamson , Stefan Hajnoczi , Thanos Makatos , Kevin Wolf , "Daniel P. Berrange" , Max Reitz , Ross Lagerwall , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Tue, Dec 15, 2020 at 02:49:22PM +0400, Marc-André Lureau wrote: > Hi > > On Mon, Dec 14, 2020 at 9:15 AM Jagannathan Raman > wrote: > > > From: Elena Ufimtseva > > > > Adds QIO channel functions that transmit and receive iovs along with fds. > > > > Signed-off-by: Elena Ufimtseva > > Signed-off-by: John G Johnson > > Signed-off-by: Jagannathan Raman > > Reviewed-by: Stefan Hajnoczi > > --- > > include/io/channel.h | 50 +++++++++++++++++++++++++++++++++++++++++ > > io/channel.c | 63 > > +++++++++++++++++++++++++++++++++++++++++++++++++++- > > 2 files changed, 112 insertions(+), 1 deletion(-) > > > > diff --git a/include/io/channel.h b/include/io/channel.h > > index 4d6fe45..c2d9836 100644 > > --- a/include/io/channel.h > > +++ b/include/io/channel.h > > @@ -774,4 +774,54 @@ void qio_channel_set_aio_fd_handler(QIOChannel *ioc, > > IOHandler *io_write, > > void *opaque); > > > > +/** > > + * qio_channel_readv_full_all: > > + * @ioc: the channel object > > + * @iov: the array of memory regions to read data to > > + * @niov: the length of the @iov array > > + * @fds: an array of file handles to read > > + * @nfds: number of file handles in @fds > > + * @errp: pointer to a NULL-initialized error object > > + * > > + * > > + * Behaves like qio_channel_readvv_full but will attempt > > + * to read all data specified (file handles and memory regions). > > + * The function will wait for all requested data > > + * to be read, yielding from the current coroutine > > + * if required. > > + * > > + * Returns: 0 if all bytes were read, or -1 on error > > + */ > > + > > +int qio_channel_readv_full_all(QIOChannel *ioc, > > + const struct iovec *iov, > > + size_t niov, > > + int **fds, size_t *nfds, > > + Error **errp); > > + > > +/** > > + * qio_channel_writev_full_all: > > + * @ioc: the channel object > > + * @iov: the array of memory regions to write data from > > + * @niov: the length of the @iov array > > + * @fds: an array of file handles to send > > + * @nfds: number of file handles in @fds > > + * @errp: pointer to a NULL-initialized error object > > + * > > + * > > + * Behaves like qio_channel_writev_full but will attempt > > + * to send all data passed (file handles and memory regions). > > + * The function will wait for all requested data > > + * to be written, yielding from the current coroutine > > + * if required. > > + * > > + * Returns: 0 if all bytes were written, or -1 on error > > + */ > > + > > +int qio_channel_writev_full_all(QIOChannel *ioc, > > + const struct iovec *iov, > > + size_t niov, > > + int *fds, size_t nfds, > > + Error **errp); > > + > > #endif /* QIO_CHANNEL_H */ > > diff --git a/io/channel.c b/io/channel.c > > index 93d449d..13b0e7a 100644 > > --- a/io/channel.c > > +++ b/io/channel.c > > @@ -152,15 +152,72 @@ int qio_channel_readv_all(QIOChannel *ioc, > > return ret; > > } > > > > +int qio_channel_readv_full_all(QIOChannel *ioc, > > + const struct iovec *iov, > > + size_t niov, > > + int **fds, size_t *nfds, > > + Error **errp) > > +{ > > + int ret = -1; > > + struct iovec *local_iov = g_new(struct iovec, niov); > > + struct iovec *local_iov_head = local_iov; > > + unsigned int nlocal_iov = niov; > > + int **local_fds = fds; > > + size_t *local_nfds = nfds; > > + > > + nlocal_iov = iov_copy(local_iov, nlocal_iov, > > + iov, niov, > > + 0, iov_size(iov, niov)); > > + > > + while (nlocal_iov > 0) { > > + ssize_t len; > > + len = qio_channel_readv_full(ioc, local_iov, nlocal_iov, > > local_fds, > > + local_nfds, errp); > > + if (len == QIO_CHANNEL_ERR_BLOCK) { > > + if (qemu_in_coroutine()) { > > + qio_channel_yield(ioc, G_IO_OUT); > > + } else { > > + qio_channel_wait(ioc, G_IO_OUT); > > + } > > + continue; > > + } > > + if (len <= 0) { > > + ret = len; > > + goto cleanup; > > + } > > + > > + iov_discard_front(&local_iov, &nlocal_iov, len); > > + > > + local_fds = NULL; > > + local_nfds = 0; > > + } > > + > > + ret = 1; > > + cleanup: > > + g_free(local_iov_head); > > + return ret; > > +} > > + > > > > I suggest to adapt the code so qio_channel_readv_all_eof() calls > qio_channel_readv_full_all(). > > You may want to split this patch in 2 parts: the read and write parts. > And should we drop the Reviewed-by: Stefan Hajnoczi then? Thanks! Elena > > > int qio_channel_writev_all(QIOChannel *ioc, > > const struct iovec *iov, > > size_t niov, > > Error **errp) > > { > > + return qio_channel_writev_full_all(ioc, iov, niov, NULL, 0, errp); > > +} > > + > > +int qio_channel_writev_full_all(QIOChannel *ioc, > > + const struct iovec *iov, > > + size_t niov, > > + int *fds, size_t nfds, > > + Error **errp) > > +{ > > int ret = -1; > > struct iovec *local_iov = g_new(struct iovec, niov); > > struct iovec *local_iov_head = local_iov; > > unsigned int nlocal_iov = niov; > > + int *local_fds = fds; > > + size_t local_nfds = nfds; > > > > nlocal_iov = iov_copy(local_iov, nlocal_iov, > > iov, niov, > > @@ -168,7 +225,8 @@ int qio_channel_writev_all(QIOChannel *ioc, > > > > while (nlocal_iov > 0) { > > ssize_t len; > > - len = qio_channel_writev(ioc, local_iov, nlocal_iov, errp); > > + len = qio_channel_writev_full(ioc, local_iov, nlocal_iov, > > local_fds, > > + local_nfds, errp); > > if (len == QIO_CHANNEL_ERR_BLOCK) { > > if (qemu_in_coroutine()) { > > qio_channel_yield(ioc, G_IO_OUT); > > @@ -182,6 +240,9 @@ int qio_channel_writev_all(QIOChannel *ioc, > > } > > > > iov_discard_front(&local_iov, &nlocal_iov, len); > > + > > + local_fds = NULL; > > + local_nfds = 0; > > } > > > > ret = 0; > > -- > > 1.8.3.1 > > > > > > -- > Marc-André Lureau