Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/812527/?format=api
{ "id": 812527, "url": "http://patchwork.ozlabs.org/api/patches/812527/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170911172022.4738-38-eblake@redhat.com/", "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": "<20170911172022.4738-38-eblake@redhat.com>", "list_archive_url": null, "date": "2017-09-11T17:20:21", "name": "[v7,37/38] libqtest: Separate qmp_discard_response() from command", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "d60de92063ec1b115372028573ac67e9fd727227", "submitter": { "id": 6591, "url": "http://patchwork.ozlabs.org/api/people/6591/?format=api", "name": "Eric Blake", "email": "eblake@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170911172022.4738-38-eblake@redhat.com/mbox/", "series": [ { "id": 2534, "url": "http://patchwork.ozlabs.org/api/series/2534/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2534", "date": "2017-09-11T17:19:47", "name": "Preliminary libqtest cleanups", "version": 7, "mbox": "http://patchwork.ozlabs.org/series/2534/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/812527/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/812527/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@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)", "ext-mx08.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com", "ext-mx08.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=eblake@redhat.com" ], "Received": [ "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrbMg6LWQz9s7F\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 04:01:19 +1000 (AEST)", "from localhost ([::1]:59564 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1drT1J-0002cu-R5\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 14:01:17 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:39378)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1drSPk-0000C4-OC\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:22:30 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1drSPf-0001qN-UZ\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:22:28 -0400", "from mx1.redhat.com ([209.132.183.28]:52938)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eblake@redhat.com>)\n\tid 1drSPb-0001nE-FA; Mon, 11 Sep 2017 13:22:19 -0400", "from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 8F02AC057FA7;\n\tMon, 11 Sep 2017 17:22:18 +0000 (UTC)", "from red.redhat.com (ovpn-120-44.rdu2.redhat.com [10.10.120.44])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 22EED5D9CA;\n\tMon, 11 Sep 2017 17:22:15 +0000 (UTC)" ], "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com 8F02AC057FA7", "From": "Eric Blake <eblake@redhat.com>", "To": "qemu-devel@nongnu.org", "Date": "Mon, 11 Sep 2017 12:20:21 -0500", "Message-Id": "<20170911172022.4738-38-eblake@redhat.com>", "In-Reply-To": "<20170911172022.4738-1-eblake@redhat.com>", "References": "<20170911172022.4738-1-eblake@redhat.com>", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.14", "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.32]);\n\tMon, 11 Sep 2017 17:22:18 +0000 (UTC)", "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]", "X-Received-From": "209.132.183.28", "Subject": "[Qemu-devel] [PATCH v7 37/38] libqtest: Separate\n\tqmp_discard_response() from command", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.21", "Precedence": "list", "List-Id": "<qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<http://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\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Cc": "thuth@redhat.com, \"open list:IDE\" <qemu-block@nongnu.org>,\n\tarmbru@redhat.com, Stefan Hajnoczi <stefanha@redhat.com>,\n\tpbonzini@redhat.com, John Snow <jsnow@redhat.com>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>" }, "content": "Upcoming patches will be adding new convenience methods for\nconstructing QMP commands. But making every variation of sending\nsupport every variation of response handling becomes unwieldy;\nit's easier to specify that discarding a JSON response is\nunassociated with sending the command, where qmp_async() already\nfits the bill for sending a command without tying up a reference\nto the response.\n\nDoing this renders qtest_qmpv_discard_response() unused.\n\nBonus: gets rid of a non-literal format string in ide-test, which\nis a step towards compile-time format string checking without\ntriggering -Wformat-nonliteral.\n\nSigned-off-by: Eric Blake <eblake@redhat.com>\n---\n tests/libqtest.h | 20 ++++----------------\n tests/libqtest.c | 27 ++++++++-------------------\n tests/ahci-test.c | 26 +++++++++++++-------------\n tests/boot-order-test.c | 2 +-\n tests/drive_del-test.c | 5 +++--\n tests/fdc-test.c | 11 ++++++-----\n tests/ide-test.c | 5 ++---\n tests/postcopy-test.c | 3 ++-\n tests/test-filter-mirror.c | 3 ++-\n tests/test-filter-redirector.c | 6 ++++--\n tests/virtio-blk-test.c | 21 ++++++++++++---------\n 11 files changed, 57 insertions(+), 72 deletions(-)", "diff": "diff --git a/tests/libqtest.h b/tests/libqtest.h\nindex 8f2946ff5e..b811394d4d 100644\n--- a/tests/libqtest.h\n+++ b/tests/libqtest.h\n@@ -69,11 +69,10 @@ void qtest_quit(QTestState *s);\n /**\n * qtest_qmp_discard_response:\n * @s: #QTestState instance to operate on.\n- * @fmt...: QMP message to send to qemu\n *\n- * Sends a QMP message to QEMU and consumes the response.\n+ * Read and discard a QMP response, typically after qtest_async_qmp().\n */\n-void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...);\n+void qtest_qmp_discard_response(QTestState *s);\n\n /**\n * qtest_qmp:\n@@ -94,16 +93,6 @@ QDict *qtest_qmp(QTestState *s, const char *fmt, ...);\n void qtest_async_qmp(QTestState *s, const char *fmt, ...);\n\n /**\n- * qtest_qmpv_discard_response:\n- * @s: #QTestState instance to operate on.\n- * @fmt: QMP message to send to QEMU\n- * @ap: QMP message arguments\n- *\n- * Sends a QMP message to QEMU and consumes the response.\n- */\n-void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list ap);\n-\n-/**\n * qtest_qmpv:\n * @s: #QTestState instance to operate on.\n * @fmt: QMP message to send to QEMU\n@@ -543,11 +532,10 @@ void qmp_async(const char *fmt, ...);\n\n /**\n * qmp_discard_response:\n- * @fmt...: QMP message to send to qemu\n *\n- * Sends a QMP message to QEMU and consumes the response.\n+ * Read and discard a QMP response, typically after qmp_async().\n */\n-void qmp_discard_response(const char *fmt, ...);\n+void qmp_discard_response(void);\n\n /**\n * qmp_receive:\ndiff --git a/tests/libqtest.c b/tests/libqtest.c\nindex ac38f6d4bb..747411b5b5 100644\n--- a/tests/libqtest.c\n+++ b/tests/libqtest.c\n@@ -238,8 +238,9 @@ QTestState *qtest_start(const char *extra_args)\n QTestState *s = qtest_start_without_qmp_handshake(extra_args);\n\n /* Read the QMP greeting and then do the handshake */\n- qtest_qmp_discard_response(s, \"\");\n- qtest_qmp_discard_response(s, \"{ 'execute': 'qmp_capabilities' }\");\n+ qtest_qmp_discard_response(s);\n+ qtest_async_qmp(s, \"{ 'execute': 'qmp_capabilities' }\");\n+ qtest_qmp_discard_response(s);\n\n assert(!global_qtest);\n return s;\n@@ -566,20 +567,10 @@ void qtest_async_qmp(QTestState *s, const char *fmt, ...)\n va_end(ap);\n }\n\n-void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list ap)\n+void qtest_qmp_discard_response(QTestState *s)\n {\n- QDict *response = qtest_qmpv(s, fmt, ap);\n- QDECREF(response);\n-}\n+ QDict *response = qtest_qmp_receive(s);\n\n-void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...)\n-{\n- va_list ap;\n- QDict *response;\n-\n- va_start(ap, fmt);\n- response = qtest_qmpv(s, fmt, ap);\n- va_end(ap);\n QDECREF(response);\n }\n\n@@ -955,13 +946,11 @@ void qmp_async(const char *fmt, ...)\n va_end(ap);\n }\n\n-void qmp_discard_response(const char *fmt, ...)\n+void qmp_discard_response(void)\n {\n- va_list ap;\n+ QDict *response = qmp_receive();\n\n- va_start(ap, fmt);\n- qtest_qmpv_discard_response(global_qtest, fmt, ap);\n- va_end(ap);\n+ QDECREF(response);\n }\n char *hmp(const char *fmt, ...)\n {\ndiff --git a/tests/ahci-test.c b/tests/ahci-test.c\nindex 18af01501f..a0ed334604 100644\n--- a/tests/ahci-test.c\n+++ b/tests/ahci-test.c\n@@ -1589,9 +1589,10 @@ static void test_atapi_tray(void)\n rsp = qtest_qmp_receive(ahci->parent->qts);\n QDECREF(rsp);\n\n- qtest_qmp_discard_response(ahci->parent->qts,\n- \"{'execute': 'x-blockdev-remove-medium', \"\n- \"'arguments': {'device': 'drive0'}}\");\n+ qtest_async_qmp(ahci->parent->qts,\n+ \"{'execute': 'x-blockdev-remove-medium', \"\n+ \"'arguments': {'device': 'drive0'}}\");\n+ qtest_qmp_discard_response(ahci->parent->qts);\n\n /* Test the tray without a medium */\n ahci_atapi_load(ahci, port);\n@@ -1601,16 +1602,15 @@ static void test_atapi_tray(void)\n atapi_wait_tray(ahci, true);\n\n /* Re-insert media */\n- qtest_qmp_discard_response(ahci->parent->qts,\n- \"{'execute': 'blockdev-add', \"\n- \"'arguments': {'node-name': 'node0', \"\n- \"'driver': 'raw', \"\n- \"'file': { 'driver': 'file', \"\n- \"'filename': %s }}}\", iso);\n- qtest_qmp_discard_response(ahci->parent->qts,\n- \"{'execute': 'x-blockdev-insert-medium',\"\n- \"'arguments': { 'device': 'drive0', \"\n- \"'node-name': 'node0' }}\");\n+ qtest_async_qmp(ahci->parent->qts,\n+ \"{'execute': 'blockdev-add', 'arguments': {\"\n+ \" 'node-name': 'node0', 'driver': 'raw', \"\n+ \" 'file': { 'driver': 'file', 'filename': %s }}}\", iso);\n+ qtest_qmp_discard_response(ahci->parent->qts);\n+ qtest_async_qmp(ahci->parent->qts,\n+ \"{'execute': 'x-blockdev-insert-medium',\"\n+ \"'arguments': {'device': 'drive0', 'node-name': 'node0'}}\");\n+ qtest_qmp_discard_response(ahci->parent->qts);\n\n /* Again, the event shows up first */\n qtest_async_qmp(ahci->parent->qts, \"{'execute': 'blockdev-close-tray', \"\ndiff --git a/tests/boot-order-test.c b/tests/boot-order-test.c\nindex 048c8721c6..5cd793e075 100644\n--- a/tests/boot-order-test.c\n+++ b/tests/boot-order-test.c\n@@ -36,7 +36,7 @@ static void test_a_boot_order(const char *machine,\n test_args);\n actual = read_boot_order();\n g_assert_cmphex(actual, ==, expected_boot);\n- qmp_discard_response(\"{ 'execute': 'system_reset' }\");\n+ qmp_async(\"{ 'execute': 'system_reset' }\");\n /*\n * system_reset only requests reset. We get a RESET event after\n * the actual reset completes. Need to wait for that.\ndiff --git a/tests/drive_del-test.c b/tests/drive_del-test.c\nindex f68c4bc176..0fde0c2040 100644\n--- a/tests/drive_del-test.c\n+++ b/tests/drive_del-test.c\n@@ -34,8 +34,9 @@ static void device_del(void)\n QDict *response;\n\n /* Complication: ignore DEVICE_DELETED event */\n- qmp_discard_response(\"{'execute': 'device_del',\"\n- \" 'arguments': { 'id': 'dev0' } }\");\n+ qmp_async(\"{'execute': 'device_del',\"\n+ \" 'arguments': { 'id': 'dev0' } }\");\n+ qmp_discard_response();\n response = qmp_receive();\n g_assert(response);\n g_assert(qdict_haskey(response, \"return\"));\ndiff --git a/tests/fdc-test.c b/tests/fdc-test.c\nindex 7803ff2789..241b13e4de 100644\n--- a/tests/fdc-test.c\n+++ b/tests/fdc-test.c\n@@ -298,9 +298,10 @@ static void test_media_insert(void)\n\n /* Insert media in drive. DSKCHK should not be reset until a step pulse\n * is sent. */\n- qmp_discard_response(\"{'execute':'blockdev-change-medium', 'arguments':{\"\n- \" 'id':'floppy0', 'filename': %s, 'format': 'raw' }}\",\n- test_image);\n+ qmp_async(\"{'execute':'blockdev-change-medium', 'arguments':{\"\n+ \" 'id':'floppy0', 'filename': %s, 'format': 'raw' }}\",\n+ test_image);\n+ qmp_discard_response();\n\n dir = inb(global_qtest, FLOPPY_BASE + reg_dir);\n assert_bit_set(dir, DSKCHG);\n@@ -329,8 +330,8 @@ static void test_media_change(void)\n\n /* Eject the floppy and check that DSKCHG is set. Reading it out doesn't\n * reset the bit. */\n- qmp_discard_response(\"{'execute':'eject', 'arguments':{\"\n- \" 'id':'floppy0' }}\");\n+ qmp_async(\"{'execute':'eject', 'arguments':{ 'id':'floppy0' }}\");\n+ qmp_discard_response();\n\n dir = inb(global_qtest, FLOPPY_BASE + reg_dir);\n assert_bit_set(dir, DSKCHG);\ndiff --git a/tests/ide-test.c b/tests/ide-test.c\nindex c47cbb1949..6ba3a8589d 100644\n--- a/tests/ide-test.c\n+++ b/tests/ide-test.c\n@@ -621,7 +621,6 @@ static void test_retry_flush(const char *machine)\n QPCIDevice *dev;\n QPCIBar bmdma_bar, ide_bar;\n uint8_t data;\n- const char *s;\n\n prepare_blkdebug_script(debug_path, \"flush_to_disk\");\n\n@@ -649,8 +648,8 @@ static void test_retry_flush(const char *machine)\n qmp_eventwait(\"STOP\");\n\n /* Complete the command */\n- s = \"{'execute':'cont' }\";\n- qmp_discard_response(s);\n+ qmp_async(\"{'execute':'cont' }\");\n+ qmp_discard_response();\n\n /* Check registers */\n data = qpci_io_readb(dev, ide_bar, reg_device);\ndiff --git a/tests/postcopy-test.c b/tests/postcopy-test.c\nindex 04889b8078..9c995ee3e5 100644\n--- a/tests/postcopy-test.c\n+++ b/tests/postcopy-test.c\n@@ -478,7 +478,8 @@ static void test_migrate(void)\n usleep(10 * 1000);\n } while (dest_byte_a == dest_byte_b);\n\n- qtest_qmp_discard_response(to, \"{ 'execute' : 'stop'}\");\n+ qtest_async_qmp(to, \"{ 'execute' : 'stop'}\");\n+ qtest_qmp_discard_response(to);\n /* With it stopped, check nothing changes */\n memread(to, start_address, &dest_byte_c, 1);\n sleep(1);\ndiff --git a/tests/test-filter-mirror.c b/tests/test-filter-mirror.c\nindex c590698991..3fc1211681 100644\n--- a/tests/test-filter-mirror.c\n+++ b/tests/test-filter-mirror.c\n@@ -57,7 +57,8 @@ static void test_mirror(void)\n };\n\n /* send a qmp command to guarantee that 'connected' is setting to true. */\n- qmp_discard_response(\"{ 'execute' : 'query-status'}\");\n+ qmp_async(\"{ 'execute' : 'query-status'}\");\n+ qmp_discard_response();\n ret = iov_send(send_sock[0], iov, 2, 0, sizeof(size) + sizeof(send_buf));\n g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));\n close(send_sock[0]);\ndiff --git a/tests/test-filter-redirector.c b/tests/test-filter-redirector.c\nindex bcb338e7c1..a10649d4fc 100644\n--- a/tests/test-filter-redirector.c\n+++ b/tests/test-filter-redirector.c\n@@ -104,7 +104,8 @@ static void test_redirector_tx(void)\n g_assert_cmpint(recv_sock, !=, -1);\n\n /* send a qmp command to guarantee that 'connected' is setting to true. */\n- qmp_discard_response(\"{ 'execute' : 'query-status'}\");\n+ qmp_async(\"{ 'execute' : 'query-status'}\");\n+ qmp_discard_response();\n\n struct iovec iov[] = {\n {\n@@ -182,7 +183,8 @@ static void test_redirector_rx(void)\n send_sock = unix_connect(sock_path1, NULL);\n g_assert_cmpint(send_sock, !=, -1);\n /* send a qmp command to guarantee that 'connected' is setting to true. */\n- qmp_discard_response(\"{ 'execute' : 'query-status'}\");\n+ qmp_async(\"{ 'execute' : 'query-status'}\");\n+ qmp_discard_response();\n\n ret = iov_send(send_sock, iov, 2, 0, sizeof(size) + sizeof(send_buf));\n g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));\ndiff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c\nindex ec582c8e1c..78ca44b520 100644\n--- a/tests/virtio-blk-test.c\n+++ b/tests/virtio-blk-test.c\n@@ -410,9 +410,10 @@ static void pci_config(void)\n\n qvirtio_set_driver_ok(&dev->vdev);\n\n- qmp_discard_response(\"{ 'execute': 'block_resize', \"\n- \" 'arguments': { 'device': 'drive0', \"\n- \" 'size': %d } }\", n_size);\n+ qmp_async(\"{ 'execute': 'block_resize', \"\n+ \" 'arguments': { 'device': 'drive0', \"\n+ \" 'size': %d } }\", n_size);\n+ qmp_discard_response();\n qvirtio_wait_config_isr(&dev->vdev, QVIRTIO_BLK_TIMEOUT_US);\n\n capacity = qvirtio_config_readq(&dev->vdev, 0);\n@@ -460,9 +461,10 @@ static void pci_msix(void)\n\n qvirtio_set_driver_ok(&dev->vdev);\n\n- qmp_discard_response(\"{ 'execute': 'block_resize', \"\n- \" 'arguments': { 'device': 'drive0', \"\n- \" 'size': %d } }\", n_size);\n+ qmp_async(\"{ 'execute': 'block_resize', \"\n+ \" 'arguments': { 'device': 'drive0', \"\n+ \" 'size': %d } }\", n_size);\n+ qmp_discard_response();\n\n qvirtio_wait_config_isr(&dev->vdev, QVIRTIO_BLK_TIMEOUT_US);\n\n@@ -702,9 +704,10 @@ static void mmio_basic(void)\n\n test_basic(&dev->vdev, alloc, vq);\n\n- qmp_discard_response(\"{ 'execute': 'block_resize', \"\n- \" 'arguments': { 'device': 'drive0', \"\n- \" 'size': %d } }\", n_size);\n+ qmp_async(\"{ 'execute': 'block_resize', \"\n+ \" 'arguments': { 'device': 'drive0', \"\n+ \" 'size': %d } }\", n_size);\n+ qmp_discard_response();\n\n qvirtio_wait_queue_isr(&dev->vdev, vq, QVIRTIO_BLK_TIMEOUT_US);\n\n", "prefixes": [ "v7", "37/38" ] }