Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2222710/?format=api
{ "id": 2222710, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2222710/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260413214549.926435-5-junjie.cao@intel.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/1.1/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": "" }, "msgid": "<20260413214549.926435-5-junjie.cao@intel.com>", "date": "2026-04-13T21:45:49", "name": "[v3,4/4] tests/unit: add pread/pwrite _all tests for io channel file", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "141797663369e7bb547cfec4bb4702d9514a143f", "submitter": { "id": 91537, "url": "http://patchwork.ozlabs.org/api/1.1/people/91537/?format=api", "name": "Junjie Cao", "email": "junjie.cao@intel.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260413214549.926435-5-junjie.cao@intel.com/mbox/", "series": [ { "id": 499708, "url": "http://patchwork.ozlabs.org/api/1.1/series/499708/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=499708", "date": "2026-04-13T21:45:46", "name": "io/channel: complete pread/pwrite_all API and fix multifd_file_recv_data", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/499708/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2222710/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2222710/checks/", "tags": {}, "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 (2048-bit key;\n unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256\n header.s=Intel header.b=PaRSvuvi;\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)" ], "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 4fvTGy2p1yz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 13 Apr 2026 23:47:06 +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 1wCHci-0005Qw-Mq; Mon, 13 Apr 2026 09:46:44 -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 <junjie.cao@intel.com>)\n id 1wCHcg-0005OI-Tb\n for qemu-devel@nongnu.org; Mon, 13 Apr 2026 09:46:42 -0400", "from mgamail.intel.com ([198.175.65.14])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <junjie.cao@intel.com>)\n id 1wCHce-0002Hd-Vl\n for qemu-devel@nongnu.org; Mon, 13 Apr 2026 09:46:42 -0400", "from orviesa005.jf.intel.com ([10.64.159.145])\n by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 13 Apr 2026 06:46:40 -0700", "from junjie-optiplex-micro-plus-7010.bj.intel.com ([10.238.152.98])\n by orviesa005-auth.jf.intel.com with\n ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2026 06:46:38 -0700" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1776088001; x=1807624001;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=ApqyZHZa9fhGJ2xZs56EjVo0twC5/V/7fNPCkKeWwQs=;\n b=PaRSvuviHw0X4pwDubkC0GkYmbE8eR0ywl4Np2Pt3mzY1DZz8AKhPTIB\n dNKx9w+G7AW8KSZTxkgdIwDYNX5rIOUVWfltJ0OhpN8IkzcVdAoKFA7uI\n wHlMT7f1G+9yK9lL/2DT3hfFz69opN2iFqKyW9Wa2nm8vK+6p/wdRO4Lw\n MzorLheRfnfhiZ0ZMlWNLJN/aWorq0RsmLHxNb0fSFtMTYeaemTDZeiJ6\n BM2ubyrsJSoj3zfIRXWC1Navo7EXS0gy/j8c2tC2ZW73bUcjkIHWMkCFc\n 8m02ekDSbbZZk3R0zrchPEzr3tybbk4Aw7n2B62VgDfVwBFlzcAYBdNWm g==;", "X-CSE-ConnectionGUID": [ "xf0GMaG+RhS7+7lKbvVNpg==", "bTHnEagBRkGVRw0IeTHWIA==" ], "X-CSE-MsgGUID": [ "jDYVNDPJRUuj4dl+b32flw==", "07XdndmdTya6AiJ2a+osWQ==" ], "X-IronPort-AV": [ "E=McAfee;i=\"6800,10657,11758\"; a=\"80885702\"", "E=Sophos;i=\"6.23,177,1770624000\"; d=\"scan'208\";a=\"80885702\"", "E=Sophos;i=\"6.23,177,1770624000\"; d=\"scan'208\";a=\"234770444\"" ], "X-ExtLoop1": "1", "From": "Junjie Cao <junjie.cao@intel.com>", "To": "qemu-devel@nongnu.org", "Cc": "berrange@redhat.com, peterx@redhat.com, farosas@suse.de,\n junjie.cao@intel.com", "Subject": "[PATCH v3 4/4] tests/unit: add pread/pwrite _all tests for io channel\n file", "Date": "Tue, 14 Apr 2026 05:45:49 +0800", "Message-ID": "<20260413214549.926435-5-junjie.cao@intel.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20260413214549.926435-1-junjie.cao@intel.com>", "References": "<20260413214549.926435-1-junjie.cao@intel.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=198.175.65.14;\n envelope-from=junjie.cao@intel.com;\n helo=mgamail.intel.com", "X-Spam_score_int": "-29", "X-Spam_score": "-3.0", "X-Spam_bar": "---", "X-Spam_report": "(-3.0 / 5.0 requ) BAYES_00=-1.9, DATE_IN_FUTURE_06_12=1.947,\n DKIMWL_WL_HIGH=-0.54, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\n DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,\n SPF_HELO_NONE=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.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": "Add unit tests for the new qio_channel_pread{v,}_all{,_eof}() and\nqio_channel_pwrite{v,}_all() APIs.\n\nThe basic tests write data to a file channel, then read it back at\nvarious offsets using both the single-buffer and iovec variants to\nmake sure the round-trip produces identical content. The _eof tests\nverify all three return cases -- full read (1), clean EOF (0), and\npartial-then-EOF (-1 with error set) -- and check that the strict\nwrappers (preadv_all / pread_all) treat a clean EOF as an error.\n\nAll tests are guarded by CONFIG_PREADV since the underlying channel\nmethods require preadv(2).\n\nSigned-off-by: Junjie Cao <junjie.cao@intel.com>\n---\n tests/unit/test-io-channel-file.c | 207 ++++++++++++++++++++++++++++++\n 1 file changed, 207 insertions(+)", "diff": "diff --git a/tests/unit/test-io-channel-file.c b/tests/unit/test-io-channel-file.c\nindex 1977006ce9..b597350dca 100644\n--- a/tests/unit/test-io-channel-file.c\n+++ b/tests/unit/test-io-channel-file.c\n@@ -102,6 +102,203 @@ static void test_io_channel_fd(void)\n }\n \n \n+#ifdef CONFIG_PREADV\n+static void test_io_channel_pread_all(void)\n+{\n+ QIOChannel *ioc;\n+ char write_buf[] = \"Hello World, pread_all\";\n+ char read_buf[sizeof(write_buf)] = {0};\n+ int ret;\n+\n+ unlink(TEST_FILE);\n+ ioc = QIO_CHANNEL(qio_channel_file_new_path(\n+ TEST_FILE,\n+ O_RDWR | O_CREAT | O_TRUNC | O_BINARY,\n+ TEST_MASK,\n+ &error_abort));\n+\n+ ret = qio_channel_pwrite_all(ioc, write_buf, sizeof(write_buf),\n+ 0, &error_abort);\n+ g_assert_cmpint(ret, ==, 0);\n+\n+ /* Read back at offset 0 */\n+ ret = qio_channel_pread_all(ioc, read_buf, sizeof(read_buf),\n+ 0, &error_abort);\n+ g_assert_cmpint(ret, ==, 0);\n+ g_assert_cmpmem(write_buf, sizeof(write_buf),\n+ read_buf, sizeof(read_buf));\n+\n+ /* Read at a non-zero offset */\n+ memset(read_buf, 0, sizeof(read_buf));\n+ ret = qio_channel_pread_all(ioc, read_buf, sizeof(write_buf) - 7,\n+ 7, &error_abort);\n+ g_assert_cmpint(ret, ==, 0);\n+ g_assert_cmpmem(write_buf + 7, sizeof(write_buf) - 7,\n+ read_buf, sizeof(write_buf) - 7);\n+\n+ unlink(TEST_FILE);\n+ object_unref(OBJECT(ioc));\n+}\n+\n+static void test_io_channel_preadv_all(void)\n+{\n+ QIOChannel *ioc;\n+ char write_buf[256];\n+ char read_buf[256] = {0};\n+ struct iovec write_iov[2];\n+ struct iovec read_iov[2];\n+ int ret;\n+ size_t i;\n+\n+ for (i = 0; i < sizeof(write_buf); i++) {\n+ write_buf[i] = i & 0xff;\n+ }\n+\n+ unlink(TEST_FILE);\n+ ioc = QIO_CHANNEL(qio_channel_file_new_path(\n+ TEST_FILE,\n+ O_RDWR | O_CREAT | O_TRUNC | O_BINARY,\n+ TEST_MASK,\n+ &error_abort));\n+\n+ /* Write using pwritev_all with 2 iovecs */\n+ write_iov[0].iov_base = write_buf;\n+ write_iov[0].iov_len = 128;\n+ write_iov[1].iov_base = write_buf + 128;\n+ write_iov[1].iov_len = 128;\n+ ret = qio_channel_pwritev_all(ioc, write_iov, 2, 0, &error_abort);\n+ g_assert_cmpint(ret, ==, 0);\n+\n+ /* Read back using preadv_all with 2 iovecs */\n+ read_iov[0].iov_base = read_buf;\n+ read_iov[0].iov_len = 128;\n+ read_iov[1].iov_base = read_buf + 128;\n+ read_iov[1].iov_len = 128;\n+ ret = qio_channel_preadv_all(ioc, read_iov, 2, 0, &error_abort);\n+ g_assert_cmpint(ret, ==, 0);\n+\n+ g_assert_cmpmem(write_buf, sizeof(write_buf),\n+ read_buf, sizeof(read_buf));\n+\n+ /* Read at non-zero offset with preadv_all */\n+ memset(read_buf, 0, sizeof(read_buf));\n+ read_iov[0].iov_base = read_buf;\n+ read_iov[0].iov_len = 64;\n+ read_iov[1].iov_base = read_buf + 64;\n+ read_iov[1].iov_len = 64;\n+ ret = qio_channel_preadv_all(ioc, read_iov, 2, 128, &error_abort);\n+ g_assert_cmpint(ret, ==, 0);\n+\n+ g_assert_cmpmem(write_buf + 128, 128,\n+ read_buf, 128);\n+\n+ unlink(TEST_FILE);\n+ object_unref(OBJECT(ioc));\n+}\n+\n+static void test_io_channel_preadv_all_eof(void)\n+{\n+ QIOChannel *ioc;\n+ char write_buf[] = \"Hello World, preadv_all_eof\";\n+ char read_buf[sizeof(write_buf)] = {0};\n+ struct iovec iov;\n+ int ret;\n+ Error *err = NULL;\n+\n+ unlink(TEST_FILE);\n+ ioc = QIO_CHANNEL(qio_channel_file_new_path(\n+ TEST_FILE,\n+ O_RDWR | O_CREAT | O_TRUNC | O_BINARY,\n+ TEST_MASK,\n+ &error_abort));\n+\n+ ret = qio_channel_pwrite_all(ioc, write_buf, sizeof(write_buf),\n+ 0, &error_abort);\n+ g_assert_cmpint(ret, ==, 0);\n+\n+ /* Full read succeeds: should return 1 */\n+ iov.iov_base = read_buf;\n+ iov.iov_len = sizeof(read_buf);\n+ ret = qio_channel_preadv_all_eof(ioc, &iov, 1, 0, &error_abort);\n+ g_assert_cmpint(ret, ==, 1);\n+ g_assert_cmpmem(write_buf, sizeof(write_buf),\n+ read_buf, sizeof(read_buf));\n+\n+ /* Clean EOF: offset at file end, should return 0 */\n+ iov.iov_base = read_buf;\n+ iov.iov_len = 1;\n+ ret = qio_channel_preadv_all_eof(ioc, &iov, 1,\n+ sizeof(write_buf), &err);\n+ g_assert_cmpint(ret, ==, 0);\n+ g_assert_null(err);\n+\n+ /* Partial EOF: start before end, request extends past */\n+ iov.iov_base = read_buf;\n+ iov.iov_len = 8;\n+ ret = qio_channel_preadv_all_eof(ioc, &iov, 1,\n+ sizeof(write_buf) - 4, &err);\n+ g_assert_cmpint(ret, ==, -1);\n+ g_assert_nonnull(err);\n+ error_free(err);\n+ err = NULL;\n+\n+ /* Strict wrapper (preadv_all) treats clean EOF as error */\n+ iov.iov_base = read_buf;\n+ iov.iov_len = 1;\n+ ret = qio_channel_preadv_all(ioc, &iov, 1,\n+ sizeof(write_buf), &err);\n+ g_assert_cmpint(ret, ==, -1);\n+ g_assert_nonnull(err);\n+ error_free(err);\n+\n+ unlink(TEST_FILE);\n+ object_unref(OBJECT(ioc));\n+}\n+\n+static void test_io_channel_pread_all_eof(void)\n+{\n+ QIOChannel *ioc;\n+ char write_buf[] = \"Hello World, pread_all_eof\";\n+ char read_buf[sizeof(write_buf)] = {0};\n+ int ret;\n+ Error *err = NULL;\n+\n+ unlink(TEST_FILE);\n+ ioc = QIO_CHANNEL(qio_channel_file_new_path(\n+ TEST_FILE,\n+ O_RDWR | O_CREAT | O_TRUNC | O_BINARY,\n+ TEST_MASK,\n+ &error_abort));\n+\n+ ret = qio_channel_pwrite_all(ioc, write_buf, sizeof(write_buf),\n+ 0, &error_abort);\n+ g_assert_cmpint(ret, ==, 0);\n+\n+ /* Full read succeeds: should return 1 */\n+ ret = qio_channel_pread_all_eof(ioc, read_buf, sizeof(read_buf),\n+ 0, &error_abort);\n+ g_assert_cmpint(ret, ==, 1);\n+ g_assert_cmpmem(write_buf, sizeof(write_buf),\n+ read_buf, sizeof(read_buf));\n+\n+ /* Clean EOF: should return 0 */\n+ ret = qio_channel_pread_all_eof(ioc, read_buf, 1,\n+ sizeof(write_buf), &err);\n+ g_assert_cmpint(ret, ==, 0);\n+ g_assert_null(err);\n+\n+ /* Partial EOF: should return -1 */\n+ ret = qio_channel_pread_all_eof(ioc, read_buf, 8,\n+ sizeof(write_buf) - 4, &err);\n+ g_assert_cmpint(ret, ==, -1);\n+ g_assert_nonnull(err);\n+ error_free(err);\n+\n+ unlink(TEST_FILE);\n+ object_unref(OBJECT(ioc));\n+}\n+#endif /* CONFIG_PREADV */\n+\n #ifndef _WIN32\n static void test_io_channel_pipe(bool async)\n {\n@@ -147,6 +344,16 @@ int main(int argc, char **argv)\n g_test_add_func(\"/io/channel/file\", test_io_channel_file);\n g_test_add_func(\"/io/channel/file/rdwr\", test_io_channel_file_rdwr);\n g_test_add_func(\"/io/channel/file/fd\", test_io_channel_fd);\n+#ifdef CONFIG_PREADV\n+ g_test_add_func(\"/io/channel/file/pread-all\",\n+ test_io_channel_pread_all);\n+ g_test_add_func(\"/io/channel/file/preadv-all\",\n+ test_io_channel_preadv_all);\n+ g_test_add_func(\"/io/channel/file/preadv-all-eof\",\n+ test_io_channel_preadv_all_eof);\n+ g_test_add_func(\"/io/channel/file/pread-all-eof\",\n+ test_io_channel_pread_all_eof);\n+#endif\n #ifndef _WIN32\n g_test_add_func(\"/io/channel/pipe/sync\", test_io_channel_pipe_sync);\n g_test_add_func(\"/io/channel/pipe/async\", test_io_channel_pipe_async);\n", "prefixes": [ "v3", "4/4" ] }