From nobody Mon Feb 9 16:04:16 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1608270926; cv=none; d=zohomail.com; s=zohoarc; b=P+GOMuR6T+4Ep+0cXL7/fvufb+TmlbsjJIG5s6xAq5qmkJ5QbkUj4u0UhhxEUGmHkZvFBfab1iYvVEh4KUhWnAfFtFmxR+V0OLlB53SxGzFU1e3NCWj4+wYKBCqhj+pfws8pbUUtsAUd+6eOmDnjpXon30OQyqB1Usr5UD7zMzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608270926; h=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=SqYGPAgOeH6adh0daAxrfVrjvGUucL8eoyhQM4lsbII=; b=bcC08FDcf4TUCVoBoFGc7OvG4/jIHftiLiGGbuWOxVKzfN0QCUa/MRN2EJOmjAx1yjx7Pi7OMNlZdvB/UpyYRQPjqs+vNpQjmaowXJ5EzxTmw6XdwUXnww/wN1z4JOGALuj+qKxi72HJXX+SCgAV2MhGeoaR05CfhWtVIVbPK6M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; 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 1608270926331299.0721516995736; Thu, 17 Dec 2020 21:55:26 -0800 (PST) Received: from localhost ([::1]:56524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kq8jd-0006w2-BY for importer@patchew.org; Fri, 18 Dec 2020 00:55:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kq8Xm-0002jV-FN for qemu-devel@nongnu.org; Fri, 18 Dec 2020 00:43:10 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:59028) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kq8Xk-0004dn-IM for qemu-devel@nongnu.org; Fri, 18 Dec 2020 00:43:10 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0BI5Yw3R079598; Fri, 18 Dec 2020 05:43:02 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 35cntmgp27-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 18 Dec 2020 05:43:02 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0BI5ZKET043504; Fri, 18 Dec 2020 05:41:02 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 35e6eu9vrh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 18 Dec 2020 05:41:01 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0BI5f1wo003833; Fri, 18 Dec 2020 05:41:01 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 17 Dec 2020 21:41:00 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=SqYGPAgOeH6adh0daAxrfVrjvGUucL8eoyhQM4lsbII=; b=wO5Pe1B1gJX3FcgkhXJrcCi5oXrImSjvT95Bns4wTfIWCIwDSGKokTI7jsIohqin3hKX G3vyhV0s+u+KZrqFrRAqK9ZKXP5E/wgWnknbxY8BD/fIQaKU9bEKMWVeoR+XPy6JPKai TT92ThnSPjLC2crUXuXtDgB9hZ8C5m1BnQAOcng1/MN7zFqsWrevwPGEV05ACbyxjw21 CPE27GdAG1GWXThZG44qfNTqRS+p/01FBWJHnBZt5BBJsDc7QbpU9TatFaY2yVitvJnj DHWaroEdMqbL1y8n4zPMA6D6cvlfXTkJNNijEiYkL9JoUR3qhE257XtddGDm+VNWmtjO 8g== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v14 RESEND 08/21] multi-process: add qio channel write function Date: Thu, 17 Dec 2020 21:40:38 -0800 Message-Id: <5c5ef9d87f35255e626055af353fbc62517773ca.1608263018.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9838 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012180040 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9838 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 adultscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 impostorscore=0 priorityscore=1501 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012180040 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=141.146.126.78; envelope-from=elena.ufimtseva@oracle.com; helo=aserp2120.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: elena.ufimtseva@oracle.com, fam@euphon.net, swapnil.ingle@nutanix.com, john.g.johnson@oracle.com, kraxel@redhat.com, jag.raman@oracle.com, quintela@redhat.com, mst@redhat.com, armbru@redhat.com, kanth.ghatraju@oracle.com, felipe@nutanix.com, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, alex.williamson@redhat.com, stefanha@redhat.com, thanos.makatos@nutanix.com, kwolf@redhat.com, berrange@redhat.com, mreitz@redhat.com, ross.lagerwall@citrix.com, marcandre.lureau@gmail.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Adds qio_channel_writev_full_all() to transmit both data and FDs. Refactors existing code to use this function. Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Reviewed-by: Stefan Hajnoczi --- include/io/channel.h | 25 +++++++++++++++++++++++++ io/channel.c | 17 ++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/include/io/channel.h b/include/io/channel.h index 4d6fe45f63..2378567d4b 100644 --- a/include/io/channel.h +++ b/include/io/channel.h @@ -774,4 +774,29 @@ void qio_channel_set_aio_fd_handler(QIOChannel *ioc, IOHandler *io_write, void *opaque); =20 +/** + * 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 93d449dee2..bde1f6d0f4 100644 --- a/io/channel.c +++ b/io/channel.c @@ -156,11 +156,22 @@ 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 =3D -1; struct iovec *local_iov =3D g_new(struct iovec, niov); struct iovec *local_iov_head =3D local_iov; unsigned int nlocal_iov =3D niov; + int *local_fds =3D fds; + size_t local_nfds =3D nfds; =20 nlocal_iov =3D iov_copy(local_iov, nlocal_iov, iov, niov, @@ -168,7 +179,8 @@ int qio_channel_writev_all(QIOChannel *ioc, =20 while (nlocal_iov > 0) { ssize_t len; - len =3D qio_channel_writev(ioc, local_iov, nlocal_iov, errp); + len =3D qio_channel_writev_full(ioc, local_iov, nlocal_iov, local_= fds, + local_nfds, errp); if (len =3D=3D QIO_CHANNEL_ERR_BLOCK) { if (qemu_in_coroutine()) { qio_channel_yield(ioc, G_IO_OUT); @@ -182,6 +194,9 @@ int qio_channel_writev_all(QIOChannel *ioc, } =20 iov_discard_front(&local_iov, &nlocal_iov, len); + + local_fds =3D NULL; + local_nfds =3D 0; } =20 ret =3D 0; --=20 2.25.GIT