From patchwork Tue Jan 19 20:28:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jag Raman X-Patchwork-Id: 12030823 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT 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 CD162C433E0 for ; Tue, 19 Jan 2021 21:08:49 +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 2106522D08 for ; Tue, 19 Jan 2021 21:08:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2106522D08 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]:47298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l1yF4-00087Z-Gn for qemu-devel@archiver.kernel.org; Tue, 19 Jan 2021 16:08:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1xcr-00016R-Pt for qemu-devel@nongnu.org; Tue, 19 Jan 2021 15:29:17 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:37668) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1xcp-0000FX-RM for qemu-devel@nongnu.org; Tue, 19 Jan 2021 15:29:17 -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 10JKOoFS146175; Tue, 19 Jan 2021 20:29:07 GMT 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 : content-type : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=tITNisM76d2ptiLo4WZ9Z0oHxop9K3Kuk+IOTcDyeg0=; b=RBPL1WeYf8CU2yEPWnUZqVGHB+C+1qoWDXD2U2RxqLlPh+wL5oz3qd2GaFbTyjYkdwmI nbCtJYsSOZzjDWhHTlEU+edvFgABVsctFVSl45tN7lbbaSMyT78T0X/jRiVga+THGRvV zEoNUB+M9dD/VusKoQGQpA9XUayW/PJNgqY4FFW9Yia3zjoM99Ml/q+hzpQwIQeGaJg/ JN6U9Oe8LUEAuy5V8IhTivEheUjlH9Y3OJ9o7ccTatavfe7PkLEO6OeCNK3pZiwh7y4w YJQ3mYQIwgexkX2XqJX26hpFkJxgHsd8nR7IOR1eNff+jOOHjDQGJmAAx3bAwwgRRt8a 7Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 363nnak4v7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Jan 2021 20:29:07 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10JKPdR2128405; Tue, 19 Jan 2021 20:29:06 GMT Received: from nam02-cy1-obe.outbound.protection.outlook.com (mail-cys01nam02lp2056.outbound.protection.outlook.com [104.47.37.56]) by userp3030.oracle.com with ESMTP id 3661njtaer-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Jan 2021 20:29:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aJaqONV53O9/ICXc+2ezyY7p24CEBzwL8F9Liu2hjbONebhVhN3m8zLbzLLP3dNqlOaMHI25qbb+T6V2rd68JdEzpoUyBDi8MxHMbUMf/w4Yoe3D8WNiMl9+tEQAHHh0FgJsZAXZ+NqcMsFgzn7eJPRqBSWdolkEkDz+5fEPqTNE99kPWh39Oxx3GZ8SF9rJ1nNNbXatTVxUilWyGyA05zGWve4gBGiZwqL/j+JyYzHQHF1wp+QK20P8FL4VsKXcpq5d34Bu2mxETtaLI1G++98AmvubuH+J400tWK0RsPHOZRczWFcm+ZOvTXgaxUF0vt0O1Y3+d5nte2ebp+tuQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tITNisM76d2ptiLo4WZ9Z0oHxop9K3Kuk+IOTcDyeg0=; b=inQe13LTUDqaJzBVHOfWmd7LZ0kPq38UbFROorSaryoOIDuhpX9/iwLR12/BKdBh2sTSdPDepeW1mPFLrtmD/wi752lxatZKBlvgquCtFAwc/j/HuOmnloj09CEOJ4DXwUsmTCaFc6ypxiXXbjKeyiEzmJTesbBUl1WWcCrq+OIk55pmgyTCEsEGn69lvIJh1ANDezNtkp09enkPmTspCixpaikih3b3TtnwiaTQj13aNRNRC0RDGueYfx/eBTjP5oIxdWq5SUddjznolDKIOQ+UoFZs80nydCSzmhlWk1T3Qt9kCT1dxe2NJZbMDbDbeT7yf8cT3SRup1DrNTDm3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tITNisM76d2ptiLo4WZ9Z0oHxop9K3Kuk+IOTcDyeg0=; b=ew6l7VBwWAXaTAvU/1qdRoI6MFkEdEKm0xXZEbP1WCcGKx44nMh4WjOLFFiyc4WF4Lr25xsEPnJxTKJha16K9ehrzaY93fd7HmsFdXs6YNT3vJzucp++lzphOLyr1IIc6qDaU81iGWahVP6s86nPCJqO6DdmiogI5CiCojZPw88= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB2744.namprd10.prod.outlook.com (2603:10b6:a02:ae::18) by BYAPR10MB3349.namprd10.prod.outlook.com (2603:10b6:a03:155::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9; Tue, 19 Jan 2021 20:29:04 +0000 Received: from BYAPR10MB2744.namprd10.prod.outlook.com ([fe80::5cf0:3e26:c005:341b]) by BYAPR10MB2744.namprd10.prod.outlook.com ([fe80::5cf0:3e26:c005:341b%7]) with mapi id 15.20.3763.014; Tue, 19 Jan 2021 20:29:04 +0000 From: Jagannathan Raman To: qemu-devel@nongnu.org Subject: [PATCH v20 07/20] io: add qio_channel_writev_full_all helper Date: Tue, 19 Jan 2021 15:28:24 -0500 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: X-Originating-IP: [209.17.40.38] X-ClientProxiedBy: DM6PR01CA0007.prod.exchangelabs.com (2603:10b6:5:296::12) To BYAPR10MB2744.namprd10.prod.outlook.com (2603:10b6:a02:ae::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from jaraman-bur-1.us.oracle.com (209.17.40.38) by DM6PR01CA0007.prod.exchangelabs.com (2603:10b6:5:296::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Tue, 19 Jan 2021 20:29:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 91371649-b44b-4526-4208-08d8bcb8dd00 X-MS-TrafficTypeDiagnostic: BYAPR10MB3349: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: okD2umQcyXEup6iLSd7sj44opLyC0KdSOBNQkEYy3zjLfShfL4sh5sAPaGYTGKnRghqEAx+nVROvnjqzXCowY1NkK9Yf1V/roUPSgG/tUoiHXHpB28qgmQsjYvp9U+FnU63P/xiZCP/ZVUPGlR4u/LneWzV5MDtItIN7eontt80wESqQu5IF6NmQh6HUoskkLdH6qCDjhi0Q7t8FDBVhBDYpik3NUi9HrsmfYNs7bU6n3uhSKsVZUzOP8h/qnSQl/H6OigZ+fK1su4H3C8bIa4K4VrtYkXpZKPUnAqY7359oXWL/UjlmPPEM8diOzhqDSXeTYXloSQhsyIAhj16Lhn+xuizgmBH6f4TAoAd12j7MB0ep/6OTyXF/Y9wxi3nZPkaK37MAmMzsUdv9y0YtSg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB2744.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(366004)(136003)(346002)(376002)(7696005)(52116002)(2906002)(6486002)(5660300002)(7416002)(36756003)(66476007)(66556008)(478600001)(6916009)(956004)(2616005)(4326008)(66946007)(26005)(186003)(16526019)(8676002)(86362001)(8936002)(107886003)(316002)(6666004)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?T7F0yJ1SuhAEeK6vResk3jH4Kv+lrQ?= =?utf-8?q?krQqwET+N1ick676dUTCXQN8IE8pv9A1T6tcBtlEy8lWojGUShssZwpYcUT4LyNZF?= =?utf-8?q?XVdbMyiC/GK33srNTptUkkAGcWOk+k720GVZxI5tVCXykkzX4xidJwcP4xDroDFKp?= =?utf-8?q?XVqzT3ORupH/NemOtn/XvBoJYk+GqbBgewR/oLXblNw0T1wPLZ1z1niZ+4wHdePOr?= =?utf-8?q?VtAehLAsX+PXLbX2aDSUvazrx9jiuIdWxR8gckq5px6r/b+uyFtzGS3pJeRdgf+ER?= =?utf-8?q?S0z8HEHOJryGrHBEUtFE2Aa7hAyqLX0AZ6j6t59eUtYIOXxcn9r82wTHUzbskumBd?= =?utf-8?q?IsHczP+H5IDnktrjdg8TWjfB6Mo/V267IudvP/21WYesPGbBRjB+yJI5rajrPV88J?= =?utf-8?q?PLDyxYAEIs5jkjhtqkZkFnqBet9HD7D7FIOFPAuR8yfmH31VM3DW56S2/li1lfzSL?= =?utf-8?q?QTQznvn6HVyLkN899R2OK37BJA5KDlhbE+rjdUfK5a9Bsf82tpaY/khAr8bKfzBN3?= =?utf-8?q?iumrOs95nWAzdB+TvKgGb1MmA9NXb0HgSkLYXL46APYWUyyFlskxURu7ajoXwwLYA?= =?utf-8?q?mj+ohzUtgKhIIhrILfzrW5KsMUTLFJ3bwWwisKr9RsA3EXTOEMO1AqqGsWJw8TW09?= =?utf-8?q?HLTsTGhXzEpRWr8rPH1zlKHXRwQPDuAqtTlVcVcyPApjbXkn7h8f8UbkCTKKJlHCl?= =?utf-8?q?q6b4a1LviCp7JbIWmCe8gb8U/Brf6gaFzv2c91eUQr75ShnV3vUUzPI3EL3DGxXxM?= =?utf-8?q?t/YTMTbaDR7ehl6H4yjwdhtaPVwjO9l7MqnYCEUk4zXZh4umoJxhvFc1cYXeVMYra?= =?utf-8?q?I+Z7b3/K9aqB8icBbvbL1QGxR2tzwnsb5C6cf9Ds+tVpjBGyIhY5aNH+x4tAfunPZ?= =?utf-8?q?7BWZn7NiWz2bYqbNZ0aAPEFfuHr4FoJMKbhDHvTz6lUhlYnJa3Wg8/W1X5iGHrI?= =?utf-8?q?=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 91371649-b44b-4526-4208-08d8bcb8dd00 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2744.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2021 20:29:04.2969 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: McquHyhaz2uADogOJY0wobJZsgVn1w+4q7vdDhcAFpbBcX6WM8UOVmJeHFBw8QDdNiuhBQEpxCtnYt4y99e77A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3349 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9869 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101190113 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9869 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 spamscore=0 mlxlogscore=999 clxscore=1015 bulkscore=0 adultscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 mlxscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101190113 Received-SPF: pass client-ip=141.146.126.79; envelope-from=jag.raman@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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Elena Ufimtseva Adds qio_channel_writev_full_all() to transmit both data and FDs. Refactors existing code to use this helper. Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Reviewed-by: Stefan Hajnoczi Acked-by: Daniel P. Berrangé --- include/io/channel.h | 25 +++++++++++++++++++++++++ io/channel.c | 15 ++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/include/io/channel.h b/include/io/channel.h index ab9ea77..19e76fc 100644 --- a/include/io/channel.h +++ b/include/io/channel.h @@ -777,4 +777,29 @@ void qio_channel_set_aio_fd_handler(QIOChannel *ioc, IOHandler *io_write, void *opaque); +/** + * 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..0d4b8b5 100644 --- a/io/channel.c +++ b/io/channel.c @@ -157,6 +157,15 @@ int qio_channel_writev_all(QIOChannel *ioc, 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; @@ -168,7 +177,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, fds, nfds, + errp); if (len == QIO_CHANNEL_ERR_BLOCK) { if (qemu_in_coroutine()) { qio_channel_yield(ioc, G_IO_OUT); @@ -182,6 +192,9 @@ int qio_channel_writev_all(QIOChannel *ioc, } iov_discard_front(&local_iov, &nlocal_iov, len); + + fds = NULL; + nfds = 0; } ret = 0;