From patchwork Mon Feb 18 16:18:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 10818439 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41A45922 for ; Mon, 18 Feb 2019 16:25:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DAFB29D70 for ; Mon, 18 Feb 2019 16:25:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E1FB2A169; Mon, 18 Feb 2019 16:25:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A129829D70 for ; Mon, 18 Feb 2019 16:25:08 +0000 (UTC) Received: from localhost ([127.0.0.1]:33107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvlj9-00010A-Kl for patchwork-qemu-devel@patchwork.kernel.org; Mon, 18 Feb 2019 11:25:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvldO-0006GI-Sn for qemu-devel@nongnu.org; Mon, 18 Feb 2019 11:19:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gvldL-0002NA-1Y for qemu-devel@nongnu.org; Mon, 18 Feb 2019 11:19:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47302) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gvldH-0002FE-JO; Mon, 18 Feb 2019 11:19:03 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CB563D77F2; Mon, 18 Feb 2019 16:18:54 +0000 (UTC) Received: from dhcp-200-176.str.redhat.com (dhcp-200-176.str.redhat.com [10.33.200.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id 387FC5D70E; Mon, 18 Feb 2019 16:18:53 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 18 Feb 2019 17:18:15 +0100 Message-Id: <20190218161822.3573-6-kwolf@redhat.com> In-Reply-To: <20190218161822.3573-1-kwolf@redhat.com> References: <20190218161822.3573-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 18 Feb 2019 16:18:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 05/12] nbd: Move nbd_read_eof() to nbd/client.c 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, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The only caller of nbd_read_eof() is nbd_receive_reply(), so it doesn't have to live in the header file, but can move next to its caller. Also add the missing coroutine_fn to the function and its caller. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- include/block/nbd.h | 3 ++- nbd/nbd-internal.h | 19 ------------------- nbd/client.c | 22 +++++++++++++++++++++- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/include/block/nbd.h b/include/block/nbd.h index 96cfb1d7d5..cad975e00c 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -300,7 +300,8 @@ int nbd_receive_export_list(QIOChannel *ioc, QCryptoTLSCreds *tlscreds, int nbd_init(int fd, QIOChannelSocket *sioc, NBDExportInfo *info, Error **errp); int nbd_send_request(QIOChannel *ioc, NBDRequest *request); -int nbd_receive_reply(QIOChannel *ioc, NBDReply *reply, Error **errp); +int coroutine_fn nbd_receive_reply(QIOChannel *ioc, NBDReply *reply, + Error **errp); int nbd_client(int fd); int nbd_disconnect(int fd); int nbd_errno_to_system_errno(int err); diff --git a/nbd/nbd-internal.h b/nbd/nbd-internal.h index 82aa221227..049f83df77 100644 --- a/nbd/nbd-internal.h +++ b/nbd/nbd-internal.h @@ -64,25 +64,6 @@ #define NBD_SET_TIMEOUT _IO(0xab, 9) #define NBD_SET_FLAGS _IO(0xab, 10) -/* nbd_read_eof - * Tries to read @size bytes from @ioc. - * Returns 1 on success - * 0 on eof, when no data was read (errp is not set) - * negative errno on failure (errp is set) - */ -static inline int nbd_read_eof(QIOChannel *ioc, void *buffer, size_t size, - Error **errp) -{ - int ret; - - assert(size); - ret = qio_channel_read_all_eof(ioc, buffer, size, errp); - if (ret < 0) { - ret = -EIO; - } - return ret; -} - /* nbd_write * Writes @size bytes to @ioc. Returns 0 on success. */ diff --git a/nbd/client.c b/nbd/client.c index 10a52ad7d0..28d174c0f3 100644 --- a/nbd/client.c +++ b/nbd/client.c @@ -1387,12 +1387,32 @@ static int nbd_receive_structured_reply_chunk(QIOChannel *ioc, return 0; } +/* nbd_read_eof + * Tries to read @size bytes from @ioc. + * Returns 1 on success + * 0 on eof, when no data was read (errp is not set) + * negative errno on failure (errp is set) + */ +static inline int coroutine_fn +nbd_read_eof(QIOChannel *ioc, void *buffer, size_t size, Error **errp) +{ + int ret; + + assert(size); + ret = qio_channel_read_all_eof(ioc, buffer, size, errp); + if (ret < 0) { + ret = -EIO; + } + return ret; +} + /* nbd_receive_reply * Returns 1 on success * 0 on eof, when no data was read (errp is not set) * negative errno on failure (errp is set) */ -int nbd_receive_reply(QIOChannel *ioc, NBDReply *reply, Error **errp) +int coroutine_fn nbd_receive_reply(QIOChannel *ioc, NBDReply *reply, + Error **errp) { int ret; const char *type;