get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/808905/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 808905,
    "url": "http://patchwork.ozlabs.org/api/patches/808905/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170901180340.30009-18-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": "<20170901180340.30009-18-eblake@redhat.com>",
    "list_archive_url": null,
    "date": "2017-09-01T18:03:28",
    "name": "[v6,17/29] ahci-test: Drop dependence on global_qtest",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "bfe5f131beeee90a480161bb1c00983a96e8cf29",
    "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/20170901180340.30009-18-eblake@redhat.com/mbox/",
    "series": [
        {
            "id": 1089,
            "url": "http://patchwork.ozlabs.org/api/series/1089/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=1089",
            "date": "2017-09-01T18:03:12",
            "name": "Preliminary libqtest cleanups",
            "version": 6,
            "mbox": "http://patchwork.ozlabs.org/series/1089/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/808905/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/808905/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-mx07.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com",
            "ext-mx07.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 3xkS1B3V1Jz9s3w\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat,  2 Sep 2017 04:09:02 +1000 (AEST)",
            "from localhost ([::1]:53108 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 1dnqNI-0002te-D0\n\tfor incoming@patchwork.ozlabs.org; Fri, 01 Sep 2017 14:09:00 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:56291)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dnqIw-0007Yk-0S\n\tfor qemu-devel@nongnu.org; Fri, 01 Sep 2017 14:04:32 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dnqIt-00024f-Be\n\tfor qemu-devel@nongnu.org; Fri, 01 Sep 2017 14:04:29 -0400",
            "from mx1.redhat.com ([209.132.183.28]:35256)\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 1dnqIf-0001oO-TE; Fri, 01 Sep 2017 14:04:14 -0400",
            "from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15])\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 E0639C04B93A;\n\tFri,  1 Sep 2017 18:04:12 +0000 (UTC)",
            "from red.redhat.com (ovpn-121-149.rdu2.redhat.com [10.10.121.149])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id EFB2C17142;\n\tFri,  1 Sep 2017 18:04:11 +0000 (UTC)"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com E0639C04B93A",
        "From": "Eric Blake <eblake@redhat.com>",
        "To": "qemu-devel@nongnu.org",
        "Date": "Fri,  1 Sep 2017 13:03:28 -0500",
        "Message-Id": "<20170901180340.30009-18-eblake@redhat.com>",
        "In-Reply-To": "<20170901180340.30009-1-eblake@redhat.com>",
        "References": "<20170901180340.30009-1-eblake@redhat.com>",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.15",
        "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.31]);\n\tFri, 01 Sep 2017 18:04:13 +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 v6 17/29] ahci-test: Drop dependence on\n\tglobal_qtest",
        "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": "pbonzini@redhat.com, John Snow <jsnow@redhat.com>, armbru@redhat.com,\n\t\"open list:IDE\" <qemu-block@nongnu.org>",
        "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": "Managing parallel connections to two different monitors via\nthe implicit global_qtest makes it hard to copy-and-paste code\nto tests that are not aware of the implicit state; the\nmanagement of global_qtest is even harder to follow because\nit was masked behind set_context().\n\nInstead, explicitly pass QTestState* around (generally, by\nreusing the member already present in ahci->parent QOSState),\nand call explicit qtest_* functions on all places that\ninteract with a monitor.\n\nWe can assert that the conversion is correct by checking that\nglobal_qtest remains NULL throughout the test (a later patch\nthat changes global_qtest to not be a public global variable\nwill drop the assertions).\n\nBonus: there were several spots that were constructing a JSON\nstring, then passing that through qmp() as the format, rather\nthan directly using qmp() to construct the JSON.  Fixing that\ngets us one step closer to enabling -Wformat checking on\nconstructed JSON.\n\nSigned-off-by: Eric Blake <eblake@redhat.com>\n---\n tests/libqos/libqos.h    |  1 -\n tests/ahci-test.c        | 83 +++++++++++++++++++++++-------------------------\n tests/libqos/ahci.c      | 45 +++++++++++++-------------\n tests/libqos/libqos-pc.c |  2 +-\n tests/libqos/libqos.c    | 37 ++++++---------------\n 5 files changed, 73 insertions(+), 95 deletions(-)",
    "diff": "diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h\nindex 07d4b93d1d..9e020efb10 100644\n--- a/tests/libqos/libqos.h\n+++ b/tests/libqos/libqos.h\n@@ -29,7 +29,6 @@ void qtest_shutdown(QOSState *qs);\n bool have_qemu_img(void);\n void mkimg(const char *file, const char *fmt, unsigned size_mb);\n void mkqcow2(const char *file, unsigned size_mb);\n-void set_context(QOSState *s);\n void migrate(QOSState *from, QOSState *to, const char *uri);\n void prepare_blkdebug_script(const char *debug_fn, const char *event);\n void generate_pattern(void *buffer, size_t len, size_t cycle_len);\ndiff --git a/tests/ahci-test.c b/tests/ahci-test.c\nindex c94d1bd712..ba3f643d09 100644\n--- a/tests/ahci-test.c\n+++ b/tests/ahci-test.c\n@@ -157,6 +157,7 @@ static AHCIQState *ahci_vboot(const char *cli, va_list ap)\n\n     s = g_malloc0(sizeof(AHCIQState));\n     s->parent = qtest_pc_vboot(cli, ap);\n+    global_qtest = NULL;\n     alloc_set_flags(s->parent->alloc, ALLOC_LEAK_ASSERT);\n\n     /* Verify that we have an AHCI device present. */\n@@ -196,7 +197,7 @@ static void ahci_shutdown(AHCIQState *ahci)\n {\n     QOSState *qs = ahci->parent;\n\n-    set_context(qs);\n+    assert(!global_qtest);\n     ahci_clean_mem(ahci);\n     free_ahci_device(ahci->dev);\n     g_free(ahci);\n@@ -869,15 +870,15 @@ static void ahci_test_io_rw_simple(AHCIQState *ahci, unsigned bufsize,\n\n     /* Write some indicative pattern to our buffer. */\n     generate_pattern(tx, bufsize, AHCI_SECTOR_SIZE);\n-    bufwrite(ptr, tx, bufsize);\n+    qtest_bufwrite(ahci->parent->qts, ptr, tx, bufsize);\n\n     /* Write this buffer to disk, then read it back to the DMA buffer. */\n     ahci_guest_io(ahci, port, write_cmd, ptr, bufsize, sector);\n-    qmemset(ptr, 0x00, bufsize);\n+    qtest_memset(ahci->parent->qts, ptr, 0x00, bufsize);\n     ahci_guest_io(ahci, port, read_cmd, ptr, bufsize, sector);\n\n     /*** Read back the Data ***/\n-    bufread(ptr, rx, bufsize);\n+    qtest_bufread(ahci->parent->qts, ptr, rx, bufsize);\n     g_assert_cmphex(memcmp(tx, rx, bufsize), ==, 0);\n\n     ahci_free(ahci, ptr);\n@@ -918,7 +919,7 @@ static void ahci_test_max(AHCIQState *ahci)\n     }\n\n     port = ahci_test_nondata(ahci, cmd);\n-    memread(ahci->port[port].fb + 0x40, d2h, 0x20);\n+    qtest_memread(ahci->parent->qts, ahci->port[port].fb + 0x40, d2h, 0x20);\n     nsect = (uint64_t)d2h->lba_hi[2] << 40 |\n         (uint64_t)d2h->lba_hi[1] << 32 |\n         (uint64_t)d2h->lba_hi[0] << 24 |\n@@ -1036,7 +1037,7 @@ static void test_dma_fragmented(void)\n     /* Create a DMA buffer in guest memory, and write our pattern to it. */\n     ptr = guest_alloc(ahci->parent->alloc, bufsize);\n     g_assert(ptr);\n-    bufwrite(ptr, tx, bufsize);\n+    qtest_bufwrite(ahci->parent->qts, ptr, tx, bufsize);\n\n     cmd = ahci_command_create(CMD_WRITE_DMA);\n     ahci_command_adjust(cmd, 0, ptr, bufsize, 32);\n@@ -1053,7 +1054,7 @@ static void test_dma_fragmented(void)\n     ahci_command_free(cmd);\n\n     /* Read back the guest's receive buffer into local memory */\n-    bufread(ptr, rx, bufsize);\n+    qtest_bufread(ahci->parent->qts, ptr, rx, bufsize);\n     guest_free(ahci->parent->alloc, ptr);\n\n     g_assert_cmphex(memcmp(tx, rx, bufsize), ==, 0);\n@@ -1164,8 +1165,6 @@ static void ahci_migrate_simple(uint8_t cmd_read, uint8_t cmd_write)\n                     \"-drive if=ide,format=%s,file=%s \"\n                     \"-incoming %s\", imgfmt, tmp_path, uri);\n\n-    set_context(src->parent);\n-\n     /* initialize */\n     px = ahci_port_select(src);\n     ahci_port_clear(src, px);\n@@ -1233,7 +1232,7 @@ static void ahci_halted_io_test(uint8_t cmd_read, uint8_t cmd_write)\n     generate_pattern(tx, bufsize, AHCI_SECTOR_SIZE);\n     ptr = ahci_alloc(ahci, bufsize);\n     g_assert(ptr);\n-    memwrite(ptr, tx, bufsize);\n+    qtest_memwrite(ahci->parent->qts, ptr, tx, bufsize);\n\n     /* Attempt to write (and fail) */\n     cmd = ahci_guest_io_halt(ahci, port, cmd_write,\n@@ -1299,8 +1298,6 @@ static void ahci_migrate_halted_io(uint8_t cmd_read, uint8_t cmd_write)\n                     \"-incoming %s\",\n                     tmp_path, imgfmt, uri);\n\n-    set_context(src->parent);\n-\n     /* Initialize and prepare */\n     port = ahci_port_select(src);\n     ahci_port_clear(src, port);\n@@ -1309,7 +1306,7 @@ static void ahci_migrate_halted_io(uint8_t cmd_read, uint8_t cmd_write)\n     /* create DMA source buffer and write pattern */\n     ptr = ahci_alloc(src, bufsize);\n     g_assert(ptr);\n-    memwrite(ptr, tx, bufsize);\n+    qtest_memwrite(src->parent->qts, ptr, tx, bufsize);\n\n     /* Write, trigger the VM to stop, migrate, then resume. */\n     cmd = ahci_guest_io_halt(src, port, cmd_write,\n@@ -1350,7 +1347,6 @@ static void test_flush_migrate(void)\n     AHCIQState *src, *dst;\n     AHCICommand *cmd;\n     uint8_t px;\n-    const char *s;\n     char *uri = g_strdup_printf(\"unix:%s\", mig_socket);\n\n     prepare_blkdebug_script(debug_path, \"flush_to_disk\");\n@@ -1368,8 +1364,6 @@ static void test_flush_migrate(void)\n                     \"-device ide-hd,drive=drive0 \"\n                     \"-incoming %s\", tmp_path, imgfmt, uri);\n\n-    set_context(src->parent);\n-\n     px = ahci_port_select(src);\n     ahci_port_clear(src, px);\n\n@@ -1380,15 +1374,14 @@ static void test_flush_migrate(void)\n     cmd = ahci_command_create(CMD_FLUSH_CACHE);\n     ahci_command_commit(src, cmd, px);\n     ahci_command_issue_async(src, cmd);\n-    qmp_eventwait(\"STOP\");\n+    qtest_qmp_eventwait(src->parent->qts, \"STOP\");\n\n     /* Migrate over */\n     ahci_migrate(src, dst, uri);\n\n     /* Complete the command */\n-    s = \"{'execute':'cont' }\";\n-    qmp_async(s);\n-    qmp_eventwait(\"RESUME\");\n+    qtest_async_qmp(dst->parent->qts, \"{'execute':'cont'}\");\n+    qtest_qmp_eventwait(dst->parent->qts, \"RESUME\");\n     ahci_command_wait(dst, cmd);\n     ahci_command_verify(dst, cmd);\n\n@@ -1480,7 +1473,7 @@ static int ahci_cb_cmp_buff(AHCIQState *ahci, AHCICommand *cmd,\n     }\n\n     rx = g_malloc0(opts->size);\n-    bufread(opts->buffer, rx, opts->size);\n+    qtest_bufread(ahci->parent->qts, opts->buffer, rx, opts->size);\n     g_assert_cmphex(memcmp(tx, rx, opts->size), ==, 0);\n     g_free(rx);\n\n@@ -1555,9 +1548,10 @@ static void test_atapi_bcl(void)\n }\n\n\n-static void atapi_wait_tray(bool open)\n+static void atapi_wait_tray(AHCIQState *ahci, bool open)\n {\n-    QDict *rsp = qmp_eventwait_ref(\"DEVICE_TRAY_MOVED\");\n+    QDict *rsp = qtest_qmp_eventwait_ref(ahci->parent->qts,\n+                                         \"DEVICE_TRAY_MOVED\");\n     QDict *data = qdict_get_qdict(rsp, \"data\");\n     if (open) {\n         g_assert(qdict_get_bool(data, \"tray-open\"));\n@@ -1584,43 +1578,46 @@ static void test_atapi_tray(void)\n     port = ahci_port_select(ahci);\n\n     ahci_atapi_eject(ahci, port);\n-    atapi_wait_tray(true);\n+    atapi_wait_tray(ahci, true);\n\n     ahci_atapi_load(ahci, port);\n-    atapi_wait_tray(false);\n+    atapi_wait_tray(ahci, false);\n\n     /* Remove media */\n-    qmp_async(\"{'execute': 'blockdev-open-tray', \"\n-               \"'arguments': {'device': 'drive0'}}\");\n-    atapi_wait_tray(true);\n-    rsp = qmp_receive();\n+    qtest_async_qmp(ahci->parent->qts, \"{'execute': 'blockdev-open-tray', \"\n+                    \"'arguments': {'device': 'drive0'}}\");\n+    atapi_wait_tray(ahci, true);\n+    rsp = qtest_qmp_receive(ahci->parent->qts);\n     QDECREF(rsp);\n\n-    qmp_discard_response(\"{'execute': 'x-blockdev-remove-medium', \"\n-                         \"'arguments': {'device': 'drive0'}}\");\n+    qtest_qmp_discard_response(ahci->parent->qts,\n+                               \"{'execute': 'x-blockdev-remove-medium', \"\n+                               \"'arguments': {'device': 'drive0'}}\");\n\n     /* Test the tray without a medium */\n     ahci_atapi_load(ahci, port);\n-    atapi_wait_tray(false);\n+    atapi_wait_tray(ahci, false);\n\n     ahci_atapi_eject(ahci, port);\n-    atapi_wait_tray(true);\n+    atapi_wait_tray(ahci, true);\n\n     /* Re-insert media */\n-    qmp_discard_response(\"{'execute': 'blockdev-add', \"\n-                          \"'arguments': {'node-name': 'node0', \"\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-    qmp_discard_response(\"{'execute': 'x-blockdev-insert-medium',\"\n-                          \"'arguments': { 'device': 'drive0', \"\n+    qtest_qmp_discard_response(ahci->parent->qts,\n+                               \"{'execute': 'x-blockdev-insert-medium',\"\n+                               \"'arguments': { 'device': 'drive0', \"\n                                          \"'node-name': 'node0' }}\");\n\n     /* Again, the event shows up first */\n-    qmp_async(\"{'execute': 'blockdev-close-tray', \"\n-               \"'arguments': {'device': 'drive0'}}\");\n-    atapi_wait_tray(false);\n-    rsp = qmp_receive();\n+    qtest_async_qmp(ahci->parent->qts, \"{'execute': 'blockdev-close-tray', \"\n+                    \"'arguments': {'device': 'drive0'}}\");\n+    atapi_wait_tray(ahci, false);\n+    rsp = qtest_qmp_receive(ahci->parent->qts);\n     QDECREF(rsp);\n\n     /* Now, to convince ATAPI we understand the media has changed... */\n@@ -1640,10 +1637,10 @@ static void test_atapi_tray(void)\n\n     /* Final tray test. */\n     ahci_atapi_eject(ahci, port);\n-    atapi_wait_tray(true);\n+    atapi_wait_tray(ahci, true);\n\n     ahci_atapi_load(ahci, port);\n-    atapi_wait_tray(false);\n+    atapi_wait_tray(ahci, false);\n\n     /* Cleanup */\n     g_free(tx);\ndiff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c\nindex 790ef991b3..ba79cd77a0 100644\n--- a/tests/libqos/ahci.c\n+++ b/tests/libqos/ahci.c\n@@ -283,7 +283,8 @@ void ahci_hba_enable(AHCIQState *ahci)\n         /* Allocate Memory for the Command List Buffer & FIS Buffer */\n         /* PxCLB space ... 0x20 per command, as in 4.2.2 p 36 */\n         ahci->port[i].clb = ahci_alloc(ahci, num_cmd_slots * 0x20);\n-        qmemset(ahci->port[i].clb, 0x00, num_cmd_slots * 0x20);\n+        qtest_memset(ahci->parent->qts, ahci->port[i].clb, 0x00,\n+                     num_cmd_slots * 0x20);\n         g_test_message(\"CLB: 0x%08\" PRIx64, ahci->port[i].clb);\n         ahci_px_wreg(ahci, i, AHCI_PX_CLB, ahci->port[i].clb);\n         g_assert_cmphex(ahci->port[i].clb, ==,\n@@ -291,7 +292,7 @@ void ahci_hba_enable(AHCIQState *ahci)\n\n         /* PxFB space ... 0x100, as in 4.2.1 p 35 */\n         ahci->port[i].fb = ahci_alloc(ahci, 0x100);\n-        qmemset(ahci->port[i].fb, 0x00, 0x100);\n+        qtest_memset(ahci->parent->qts, ahci->port[i].fb, 0x00, 0x100);\n         g_test_message(\"FB: 0x%08\" PRIx64, ahci->port[i].fb);\n         ahci_px_wreg(ahci, i, AHCI_PX_FB, ahci->port[i].fb);\n         g_assert_cmphex(ahci->port[i].fb, ==,\n@@ -397,7 +398,7 @@ void ahci_port_clear(AHCIQState *ahci, uint8_t port)\n     g_assert_cmphex(ahci_px_rreg(ahci, port, AHCI_PX_IS), ==, 0);\n\n     /* Wipe the FIS-Receive Buffer */\n-    qmemset(ahci->port[port].fb, 0x00, 0x100);\n+    qtest_memset(ahci->parent->qts, ahci->port[port].fb, 0x00, 0x100);\n }\n\n /**\n@@ -466,7 +467,7 @@ void ahci_port_check_d2h_sanity(AHCIQState *ahci, uint8_t port, uint8_t slot)\n     RegD2HFIS *d2h = g_malloc0(0x20);\n     uint32_t reg;\n\n-    memread(ahci->port[port].fb + 0x40, d2h, 0x20);\n+    qtest_memread(ahci->parent->qts, ahci->port[port].fb + 0x40, d2h, 0x20);\n     g_assert_cmphex(d2h->fis_type, ==, 0x34);\n\n     reg = ahci_px_rreg(ahci, port, AHCI_PX_TFD);\n@@ -484,7 +485,7 @@ void ahci_port_check_pio_sanity(AHCIQState *ahci, uint8_t port,\n     /* We cannot check the Status or E_Status registers, because\n      * the status may have again changed between the PIO Setup FIS\n      * and the conclusion of the command with the D2H Register FIS. */\n-    memread(ahci->port[port].fb + 0x20, pio, 0x20);\n+    qtest_memread(ahci->parent->qts, ahci->port[port].fb + 0x20, pio, 0x20);\n     g_assert_cmphex(pio->fis_type, ==, 0x5f);\n\n     /* BUG: PIO Setup FIS as utilized by QEMU tries to fit the entire\n@@ -516,7 +517,7 @@ void ahci_get_command_header(AHCIQState *ahci, uint8_t port,\n {\n     uint64_t ba = ahci->port[port].clb;\n     ba += slot * sizeof(AHCICommandHeader);\n-    memread(ba, cmd, sizeof(AHCICommandHeader));\n+    qtest_memread(ahci->parent->qts, ba, cmd, sizeof(AHCICommandHeader));\n\n     cmd->flags = le16_to_cpu(cmd->flags);\n     cmd->prdtl = le16_to_cpu(cmd->prdtl);\n@@ -537,7 +538,7 @@ void ahci_set_command_header(AHCIQState *ahci, uint8_t port,\n     tmp.prdbc = cpu_to_le32(cmd->prdbc);\n     tmp.ctba = cpu_to_le64(cmd->ctba);\n\n-    memwrite(ba, &tmp, sizeof(AHCICommandHeader));\n+    qtest_memwrite(ahci->parent->qts, ba, &tmp, sizeof(AHCICommandHeader));\n }\n\n void ahci_destroy_command(AHCIQState *ahci, uint8_t port, uint8_t slot)\n@@ -575,7 +576,7 @@ void ahci_write_fis(AHCIQState *ahci, AHCICommand *cmd)\n         tmp.count = cpu_to_le16(tmp.count);\n     }\n\n-    memwrite(addr, &tmp, sizeof(tmp));\n+    qtest_memwrite(ahci->parent->qts, addr, &tmp, sizeof(tmp));\n }\n\n unsigned ahci_pick_cmd(AHCIQState *ahci, uint8_t port)\n@@ -636,7 +637,7 @@ void ahci_exec(AHCIQState *ahci, uint8_t port,\n     if (opts->size && !opts->buffer) {\n         opts->buffer = ahci_alloc(ahci, opts->size);\n         g_assert(opts->buffer);\n-        qmemset(opts->buffer, 0x00, opts->size);\n+        qtest_memset(ahci->parent->qts, opts->buffer, 0x00, opts->size);\n     }\n\n     /* Command creation */\n@@ -661,15 +662,15 @@ void ahci_exec(AHCIQState *ahci, uint8_t port,\n     ahci_command_commit(ahci, cmd, port);\n     ahci_command_issue_async(ahci, cmd);\n     if (opts->error) {\n-        qmp_eventwait(\"STOP\");\n+        qtest_qmp_eventwait(ahci->parent->qts, \"STOP\");\n     }\n     if (opts->mid_cb) {\n         rc = opts->mid_cb(ahci, cmd, opts);\n         g_assert_cmpint(rc, ==, 0);\n     }\n     if (opts->error) {\n-        qmp_async(\"{'execute':'cont' }\");\n-        qmp_eventwait(\"RESUME\");\n+        qtest_async_qmp(ahci->parent->qts, \"{'execute':'cont' }\");\n+        qtest_qmp_eventwait(ahci->parent->qts, \"RESUME\");\n     }\n\n     /* Wait for command to complete and verify sanity */\n@@ -697,7 +698,7 @@ AHCICommand *ahci_guest_io_halt(AHCIQState *ahci, uint8_t port,\n     ahci_command_adjust(cmd, sector, buffer, bufsize, 0);\n     ahci_command_commit(ahci, cmd, port);\n     ahci_command_issue_async(ahci, cmd);\n-    qmp_eventwait(\"STOP\");\n+    qtest_qmp_eventwait(ahci->parent->qts, \"STOP\");\n\n     return cmd;\n }\n@@ -706,8 +707,8 @@ AHCICommand *ahci_guest_io_halt(AHCIQState *ahci, uint8_t port,\n void ahci_guest_io_resume(AHCIQState *ahci, AHCICommand *cmd)\n {\n     /* Complete the command */\n-    qmp_async(\"{'execute':'cont' }\");\n-    qmp_eventwait(\"RESUME\");\n+    qtest_async_qmp(ahci->parent->qts, \"{'execute':'cont' }\");\n+    qtest_qmp_eventwait(ahci->parent->qts, \"RESUME\");\n     ahci_command_wait(ahci, cmd);\n     ahci_command_verify(ahci, cmd);\n     ahci_command_free(cmd);\n@@ -754,16 +755,16 @@ void ahci_io(AHCIQState *ahci, uint8_t port, uint8_t ide_cmd,\n     g_assert(props);\n     ptr = ahci_alloc(ahci, bufsize);\n     g_assert(!bufsize || ptr);\n-    qmemset(ptr, 0x00, bufsize);\n+    qtest_memset(ahci->parent->qts, ptr, 0x00, bufsize);\n\n     if (bufsize && props->write) {\n-        bufwrite(ptr, buffer, bufsize);\n+        qtest_bufwrite(ahci->parent->qts, ptr, buffer, bufsize);\n     }\n\n     ahci_guest_io(ahci, port, ide_cmd, ptr, bufsize, sector);\n\n     if (bufsize && props->read) {\n-        bufread(ptr, buffer, bufsize);\n+        qtest_bufread(ahci->parent->qts, ptr, buffer, bufsize);\n     }\n\n     ahci_free(ahci, ptr);\n@@ -901,7 +902,7 @@ static int copy_buffer(AHCIQState *ahci, AHCICommand *cmd,\n                         const AHCIOpts *opts)\n {\n     unsigned char *rx = opts->opaque;\n-    bufread(opts->buffer, rx, opts->size);\n+    qtest_bufread(ahci->parent->qts, opts->buffer, rx, opts->size);\n     return 0;\n }\n\n@@ -1141,7 +1142,7 @@ void ahci_command_commit(AHCIQState *ahci, AHCICommand *cmd, uint8_t port)\n     ahci_write_fis(ahci, cmd);\n     /* Then ATAPI CMD, if needed */\n     if (cmd->props->atapi) {\n-        memwrite(table_ptr + 0x40, cmd->atapi_cmd, 16);\n+        qtest_memwrite(ahci->parent->qts, table_ptr + 0x40, cmd->atapi_cmd, 16);\n     }\n\n     /* Construct and write the PRDs to the command table */\n@@ -1162,8 +1163,8 @@ void ahci_command_commit(AHCIQState *ahci, AHCICommand *cmd, uint8_t port)\n         prd.dbc |= cpu_to_le32(0x80000000); /* Request DPS Interrupt */\n\n         /* Commit the PRD entry to the Command Table */\n-        memwrite(table_ptr + 0x80 + (i * sizeof(PRD)),\n-                 &prd, sizeof(PRD));\n+        qtest_memwrite(ahci->parent->qts, table_ptr + 0x80 + (i * sizeof(PRD)),\n+                       &prd, sizeof(PRD));\n     }\n\n     /* Bookmark the PRDTL and CTBA values */\ndiff --git a/tests/libqos/libqos-pc.c b/tests/libqos/libqos-pc.c\nindex b554758802..a9c1aceaa7 100644\n--- a/tests/libqos/libqos-pc.c\n+++ b/tests/libqos/libqos-pc.c\n@@ -25,7 +25,7 @@ QOSState *qtest_pc_boot(const char *cmdline_fmt, ...)\n     qs = qtest_vboot(&qos_ops, cmdline_fmt, ap);\n     va_end(ap);\n\n-    qtest_irq_intercept_in(global_qtest, \"ioapic\");\n+    qtest_irq_intercept_in(qs->qts, \"ioapic\");\n\n     return qs;\n }\ndiff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c\nindex 62d2f39b93..24e8156fe2 100644\n--- a/tests/libqos/libqos.c\n+++ b/tests/libqos/libqos.c\n@@ -79,34 +79,19 @@ void qtest_shutdown(QOSState *qs)\n     }\n }\n\n-void set_context(QOSState *s)\n+static QDict *qmp_execute(QTestState *qts, const char *command)\n {\n-    global_qtest = s->qts;\n-}\n-\n-static QDict *qmp_execute(const char *command)\n-{\n-    char *fmt;\n-    QDict *rsp;\n-\n-    fmt = g_strdup_printf(\"{ 'execute': '%s' }\", command);\n-    rsp = qmp(fmt);\n-    g_free(fmt);\n-\n-    return rsp;\n+    return qtest_qmp(qts, \"{ 'execute': %s }\", command);\n }\n\n void migrate(QOSState *from, QOSState *to, const char *uri)\n {\n     const char *st;\n-    char *s;\n     QDict *rsp, *sub;\n     bool running;\n\n-    set_context(from);\n-\n     /* Is the machine currently running? */\n-    rsp = qmp_execute(\"query-status\");\n+    rsp = qmp_execute(from->qts, \"query-status\");\n     g_assert(qdict_haskey(rsp, \"return\"));\n     sub = qdict_get_qdict(rsp, \"return\");\n     g_assert(qdict_haskey(sub, \"running\"));\n@@ -114,30 +99,27 @@ void migrate(QOSState *from, QOSState *to, const char *uri)\n     QDECREF(rsp);\n\n     /* Issue the migrate command. */\n-    s = g_strdup_printf(\"{ 'execute': 'migrate',\"\n-                        \"'arguments': { 'uri': '%s' } }\",\n-                        uri);\n-    rsp = qmp(s);\n-    g_free(s);\n+    rsp = qtest_qmp(from->qts,\n+                    \"{ 'execute': 'migrate', 'arguments': { 'uri': %s }}\",\n+                    uri);\n     g_assert(qdict_haskey(rsp, \"return\"));\n     QDECREF(rsp);\n\n     /* Wait for STOP event, but only if we were running: */\n     if (running) {\n-        qmp_eventwait(\"STOP\");\n+        qtest_qmp_eventwait(from->qts, \"STOP\");\n     }\n\n     /* If we were running, we can wait for an event. */\n     if (running) {\n         migrate_allocator(from->alloc, to->alloc);\n-        set_context(to);\n-        qmp_eventwait(\"RESUME\");\n+        qtest_qmp_eventwait(to->qts, \"RESUME\");\n         return;\n     }\n\n     /* Otherwise, we need to wait: poll until migration is completed. */\n     while (1) {\n-        rsp = qmp_execute(\"query-migrate\");\n+        rsp = qmp_execute(from->qts, \"query-migrate\");\n         g_assert(qdict_haskey(rsp, \"return\"));\n         sub = qdict_get_qdict(rsp, \"return\");\n         g_assert(qdict_haskey(sub, \"status\"));\n@@ -160,7 +142,6 @@ void migrate(QOSState *from, QOSState *to, const char *uri)\n     }\n\n     migrate_allocator(from->alloc, to->alloc);\n-    set_context(to);\n }\n\n bool have_qemu_img(void)\n",
    "prefixes": [
        "v6",
        "17/29"
    ]
}