Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2227489/?format=api
{ "id": 2227489, "url": "http://patchwork.ozlabs.org/api/patches/2227489/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260423191958.1440-37-farosas@suse.de/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260423191958.1440-37-farosas@suse.de>", "list_archive_url": null, "date": "2026-04-23T19:19:50", "name": "[PULL,36/43] io/channel: introduce qio_channel_pread{v, }_all{, _eof}()", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "fb5b04646b05449c9ac847806d10758563950a1e", "submitter": { "id": 85343, "url": "http://patchwork.ozlabs.org/api/people/85343/?format=api", "name": "Fabiano Rosas", "email": "farosas@suse.de" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260423191958.1440-37-farosas@suse.de/mbox/", "series": [ { "id": 501236, "url": "http://patchwork.ozlabs.org/api/series/501236/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=501236", "date": "2026-04-23T19:19:14", "name": "[PULL,01/43] checkpatch: Allow spaces after all coroutine annotations", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/501236/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2227489/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2227489/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256\n header.s=susede2_rsa header.b=XQEfy1ju;\n\tdkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=EMut86uE;\n\tdkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de\n header.a=rsa-sha256 header.s=susede2_rsa header.b=XQEfy1ju;\n\tdkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=EMut86uE;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)", "smtp-out1.suse.de;\n dkim=pass header.d=suse.de header.s=susede2_rsa header.b=XQEfy1ju;\n dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=EMut86uE" ], "Received": [ "from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g1mJx4wxGz1yDD\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 24 Apr 2026 05:25:37 +1000 (AEST)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wFzdO-0006vr-Us; Thu, 23 Apr 2026 15:22:47 -0400", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <farosas@suse.de>) id 1wFzdE-0005uc-7C\n for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:36 -0400", "from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <farosas@suse.de>) id 1wFzdB-0002VM-Qo\n for qemu-devel@nongnu.org; Thu, 23 Apr 2026 15:22:35 -0400", "from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org\n [IPv6:2a07:de40:b281:104:10:150:64:97])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by smtp-out1.suse.de (Postfix) with ESMTPS id 012C56A8B4;\n Thu, 23 Apr 2026 19:20:57 +0000 (UTC)", "from imap1.dmz-prg2.suse.org (localhost [127.0.0.1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B71A1593A3;\n Thu, 23 Apr 2026 19:20:55 +0000 (UTC)", "from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167])\n by imap1.dmz-prg2.suse.org with ESMTPSA id 8OF2IBdx6mlJCwAAD6G6ig\n (envelope-from <farosas@suse.de>); Thu, 23 Apr 2026 19:20:55 +0000" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1776972057;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=ktgHlFwzBqtWrN3Ixqg4emDXyY8jOSXsuMWGz1RSYMI=;\n b=XQEfy1juH85LgKZZv6iSuBE8F1xm1+l659RfLkVe0OIc2hxwcQL8qEoYj8BeJj6K/OGhfm\n RyyImYIKYd6xH+P26TprReDhdjJsGLBWrEH0RKaidYiBQrv7aS2Bf0huYETAa3K9QGb/Pu\n fz4tBuAPh80Du5mnOdbwongJkO505OU=", "v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1776972057;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=ktgHlFwzBqtWrN3Ixqg4emDXyY8jOSXsuMWGz1RSYMI=;\n b=EMut86uE2uFJ6aHGMIi42qR+myN554jrTlS/XZR5YNX7NjANWv726+3sj7rxvyqtTW6tQu\n 0V3vjyqQvTJZAACA==", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1776972057;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=ktgHlFwzBqtWrN3Ixqg4emDXyY8jOSXsuMWGz1RSYMI=;\n b=XQEfy1juH85LgKZZv6iSuBE8F1xm1+l659RfLkVe0OIc2hxwcQL8qEoYj8BeJj6K/OGhfm\n RyyImYIKYd6xH+P26TprReDhdjJsGLBWrEH0RKaidYiBQrv7aS2Bf0huYETAa3K9QGb/Pu\n fz4tBuAPh80Du5mnOdbwongJkO505OU=", "v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1776972057;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=ktgHlFwzBqtWrN3Ixqg4emDXyY8jOSXsuMWGz1RSYMI=;\n b=EMut86uE2uFJ6aHGMIi42qR+myN554jrTlS/XZR5YNX7NjANWv726+3sj7rxvyqtTW6tQu\n 0V3vjyqQvTJZAACA==" ], "From": "Fabiano Rosas <farosas@suse.de>", "To": "qemu-devel@nongnu.org", "Cc": "Peter Xu <peterx@redhat.com>, Junjie Cao <junjie.cao@intel.com>,\n\t=?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= <berrange@redhat.com>", "Subject": "[PULL 36/43] io/channel: introduce qio_channel_pread{v, }_all{,\n _eof}()", "Date": "Thu, 23 Apr 2026 16:19:50 -0300", "Message-ID": "<20260423191958.1440-37-farosas@suse.de>", "X-Mailer": "git-send-email 2.51.0", "In-Reply-To": "<20260423191958.1440-1-farosas@suse.de>", "References": "<20260423191958.1440-1-farosas@suse.de>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "X-Spamd-Result": "default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[100.00%];\n MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000];\n R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519];\n NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain];\n MX_GOOD(-0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[];\n RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from];\n TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+];\n SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from];\n FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[];\n RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[];\n FROM_HAS_DN(0.00)[];\n RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received];\n RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[];\n DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:dkim,suse.de:email,intel.com:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns];\n DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519];\n DKIM_TRACE(0.00)[suse.de:+]", "X-Rspamd-Action": "no action", "X-Spam-Score": "-3.51", "X-Rspamd-Server": "rspamd1.dmz-prg2.suse.org", "X-Rspamd-Queue-Id": "012C56A8B4", "Received-SPF": "pass client-ip=2a07:de40:b251:101:10:150:64:1;\n envelope-from=farosas@suse.de; helo=smtp-out1.suse.de", "X-Spam_score_int": "-20", "X-Spam_score": "-2.1", "X-Spam_bar": "--", "X-Spam_report": "(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,\n 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.29", "Precedence": "list", "List-Id": "qemu development <qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org" }, "content": "From: Junjie Cao <junjie.cao@intel.com>\n\nqio_channel_pread() and qio_channel_preadv() perform a single\npositioned read and may return a short result. Callers that need all\nbytes currently have to open-code a retry loop or simply treat a short\nread as an error.\n\nIntroduce four new helpers following the existing read_all / readv_all\npattern:\n\n qio_channel_preadv_all_eof() -- retry loop; returns 1 on success,\n 0 on clean EOF, -1 on error.\n qio_channel_preadv_all() -- wraps _eof; treats early EOF as\n error; returns 0 / -1.\n qio_channel_pread_all_eof() -- single-buffer convenience wrapper\n around preadv_all_eof().\n qio_channel_pread_all() -- single-buffer convenience wrapper\n around preadv_all().\n\nThese advance the file offset internally after each partial read.\nAll four are marked coroutine_mixed_fn, consistent with the existing\n_all helpers.\n\nSuggested-by: Peter Xu <peterx@redhat.com>\nSigned-off-by: Junjie Cao <junjie.cao@intel.com>\nReviewed-by: Fabiano Rosas <farosas@suse.de>\nReviewed-by: Daniel P. Berrangé <berrange@redhat.com>\nAcked-by: Daniel P. Berrangé <berrange@redhat.com>\nLink: https://lore.kernel.org/qemu-devel/20260413214549.926435-2-junjie.cao@intel.com\nSigned-off-by: Fabiano Rosas <farosas@suse.de>\n---\n include/io/channel.h | 92 ++++++++++++++++++++++++++++++++++++++++++++\n io/channel.c | 91 +++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 183 insertions(+)", "diff": "diff --git a/include/io/channel.h b/include/io/channel.h\nindex 1b02350437..47af409ede 100644\n--- a/include/io/channel.h\n+++ b/include/io/channel.h\n@@ -634,6 +634,98 @@ ssize_t qio_channel_preadv(QIOChannel *ioc, const struct iovec *iov,\n ssize_t qio_channel_pread(QIOChannel *ioc, void *buf, size_t buflen,\n off_t offset, Error **errp);\n \n+/**\n+ * qio_channel_preadv_all_eof:\n+ * @ioc: the channel object\n+ * @iov: the array of memory regions to read data into\n+ * @niov: the length of the @iov array\n+ * @offset: the starting offset in the channel to read from\n+ * @errp: pointer to a NULL-initialized error object\n+ *\n+ * Reads @iov, possibly blocking or (if the channel is non-blocking)\n+ * yielding from the current coroutine multiple times until the entire\n+ * content is read. If end-of-file occurs immediately it is not an\n+ * error, but if it occurs after data has been read it will return\n+ * an error rather than a short-read. Otherwise behaves as\n+ * qio_channel_preadv().\n+ *\n+ * Returns: 1 if all bytes were read, 0 if end-of-file occurs\n+ * without data, or -1 on error\n+ */\n+int coroutine_mixed_fn qio_channel_preadv_all_eof(QIOChannel *ioc,\n+ const struct iovec *iov,\n+ size_t niov,\n+ off_t offset,\n+ Error **errp);\n+\n+/**\n+ * qio_channel_preadv_all:\n+ * @ioc: the channel object\n+ * @iov: the array of memory regions to read data into\n+ * @niov: the length of the @iov array\n+ * @offset: the starting offset in the channel to read from\n+ * @errp: pointer to a NULL-initialized error object\n+ *\n+ * Reads @iov, possibly blocking or (if the channel is non-blocking)\n+ * yielding from the current coroutine multiple times until the entire\n+ * content is read. If end-of-file occurs before all requested data\n+ * has been read, an error will be reported. Otherwise behaves as\n+ * qio_channel_preadv().\n+ *\n+ * Returns: 0 if all bytes were read, or -1 on error\n+ */\n+int coroutine_mixed_fn qio_channel_preadv_all(QIOChannel *ioc,\n+ const struct iovec *iov,\n+ size_t niov,\n+ off_t offset,\n+ Error **errp);\n+\n+/**\n+ * qio_channel_pread_all_eof:\n+ * @ioc: the channel object\n+ * @buf: the memory region to read data into\n+ * @buflen: the number of bytes to read into @buf\n+ * @offset: the starting offset in the channel to read from\n+ * @errp: pointer to a NULL-initialized error object\n+ *\n+ * Reads @buflen bytes, possibly blocking or (if the channel is\n+ * non-blocking) yielding from the current coroutine multiple times\n+ * until the entire content is read. If end-of-file occurs\n+ * immediately it is not an error, but if it occurs after data has\n+ * been read it will return an error rather than a short-read.\n+ * Otherwise behaves as qio_channel_pread().\n+ *\n+ * Returns: 1 if all bytes were read, 0 if end-of-file occurs\n+ * without data, or -1 on error\n+ */\n+int coroutine_mixed_fn qio_channel_pread_all_eof(QIOChannel *ioc,\n+ void *buf,\n+ size_t buflen,\n+ off_t offset,\n+ Error **errp);\n+\n+/**\n+ * qio_channel_pread_all:\n+ * @ioc: the channel object\n+ * @buf: the memory region to read data into\n+ * @buflen: the number of bytes to read into @buf\n+ * @offset: the starting offset in the channel to read from\n+ * @errp: pointer to a NULL-initialized error object\n+ *\n+ * Reads @buflen bytes, possibly blocking or (if the channel is\n+ * non-blocking) yielding from the current coroutine multiple times\n+ * until the entire content is read. If end-of-file occurs before\n+ * all requested data has been read, an error will be reported.\n+ * Otherwise behaves as qio_channel_pread().\n+ *\n+ * Returns: 0 if all bytes were read, or -1 on error\n+ */\n+int coroutine_mixed_fn qio_channel_pread_all(QIOChannel *ioc,\n+ void *buf,\n+ size_t buflen,\n+ off_t offset,\n+ Error **errp);\n+\n /**\n * qio_channel_shutdown:\n * @ioc: the channel object\ndiff --git a/io/channel.c b/io/channel.c\nindex cc02d997a4..52c1abfcbc 100644\n--- a/io/channel.c\n+++ b/io/channel.c\n@@ -507,6 +507,97 @@ ssize_t qio_channel_pread(QIOChannel *ioc, void *buf, size_t buflen,\n return qio_channel_preadv(ioc, &iov, 1, offset, errp);\n }\n \n+int coroutine_mixed_fn qio_channel_preadv_all_eof(QIOChannel *ioc,\n+ const struct iovec *iov,\n+ size_t niov,\n+ off_t offset,\n+ Error **errp)\n+{\n+ int ret = -1;\n+ struct iovec *local_iov = g_new(struct iovec, niov);\n+ struct iovec *local_iov_head = local_iov;\n+ unsigned int nlocal_iov = niov;\n+ bool partial = false;\n+\n+ nlocal_iov = iov_copy(local_iov, nlocal_iov,\n+ iov, niov,\n+ 0, iov_size(iov, niov));\n+\n+ while (nlocal_iov > 0) {\n+ ssize_t len;\n+ len = qio_channel_preadv(ioc, local_iov, nlocal_iov, offset, errp);\n+\n+ if (len == QIO_CHANNEL_ERR_BLOCK) {\n+ qio_channel_wait_cond(ioc, G_IO_IN);\n+ continue;\n+ }\n+\n+ if (len == 0) {\n+ if (!partial) {\n+ ret = 0;\n+ goto cleanup;\n+ }\n+ error_setg(errp,\n+ \"Unexpected end-of-file before all data were read\");\n+ goto cleanup;\n+ }\n+\n+ if (len < 0) {\n+ goto cleanup;\n+ }\n+\n+ partial = true;\n+ offset += len;\n+ iov_discard_front(&local_iov, &nlocal_iov, len);\n+ }\n+\n+ ret = 1;\n+\n+ cleanup:\n+ g_free(local_iov_head);\n+ return ret;\n+}\n+\n+int coroutine_mixed_fn qio_channel_preadv_all(QIOChannel *ioc,\n+ const struct iovec *iov,\n+ size_t niov,\n+ off_t offset,\n+ Error **errp)\n+{\n+ int ret = qio_channel_preadv_all_eof(ioc, iov, niov, offset, errp);\n+\n+ if (ret == 0) {\n+ error_setg(errp,\n+ \"Unexpected end-of-file before all data were read\");\n+ return -1;\n+ }\n+ if (ret == 1) {\n+ return 0;\n+ }\n+\n+ return ret;\n+}\n+\n+int coroutine_mixed_fn qio_channel_pread_all_eof(QIOChannel *ioc,\n+ void *buf,\n+ size_t buflen,\n+ off_t offset,\n+ Error **errp)\n+{\n+ struct iovec iov = { .iov_base = buf, .iov_len = buflen };\n+ return qio_channel_preadv_all_eof(ioc, &iov, 1, offset, errp);\n+}\n+\n+int coroutine_mixed_fn qio_channel_pread_all(QIOChannel *ioc,\n+ void *buf,\n+ size_t buflen,\n+ off_t offset,\n+ Error **errp)\n+{\n+ struct iovec iov = { .iov_base = buf, .iov_len = buflen };\n+ return qio_channel_preadv_all(ioc, &iov, 1, offset, errp);\n+}\n+\n int qio_channel_shutdown(QIOChannel *ioc,\n QIOChannelShutdown how,\n Error **errp)\n", "prefixes": [ "PULL", "36/43" ] }