Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/812494/?format=api
{ "id": 812494, "url": "http://patchwork.ozlabs.org/api/patches/812494/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170911172022.4738-10-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-10-eblake@redhat.com>", "list_archive_url": null, "date": "2017-09-11T17:19:53", "name": "[v7,09/38] libqos: Track QTestState with QVirtioBus", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "dc432716ac5949c504af7e6c40e3089d3f4b942c", "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-10-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/812494/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/812494/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-mx05.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com", "ext-mx05.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 3xrZyF2Kgvz9s81\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 03:42:45 +1000 (AEST)", "from localhost ([::1]:59435 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 1drSjL-0001E5-7F\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 13:42:43 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:38322)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1drSOF-0007Av-0a\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:20:56 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1drSOB-00015H-Aw\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:20:54 -0400", "from mx1.redhat.com ([209.132.183.28]:42628)\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 1drSO7-00013f-GQ; Mon, 11 Sep 2017 13:20:47 -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 99CD12FFC50;\n\tMon, 11 Sep 2017 17:20:46 +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 B824D5D968;\n\tMon, 11 Sep 2017 17:20:42 +0000 (UTC)" ], "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com 99CD12FFC50", "From": "Eric Blake <eblake@redhat.com>", "To": "qemu-devel@nongnu.org", "Date": "Mon, 11 Sep 2017 12:19:53 -0500", "Message-Id": "<20170911172022.4738-10-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.29]);\n\tMon, 11 Sep 2017 17:20:46 +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 09/38] libqos: Track QTestState with\n\tQVirtioBus", "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, thuth@redhat.com,\n\t\"open list:virtio-blk\" <qemu-block@nongnu.org>,\n\tarmbru@redhat.com, Stefan Hajnoczi <stefanha@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": "When initializing a QVirtioDevice (which always has an associated\nQVirtioBus), we want to track which QTestState to use for all\nI/O processed through that bus and device. Copy the paradigm\nused for QPCIBus, and track the test state at the bus level; this\nin turn requires a separate bus object per device (and associated\ncleanup) rather than just sharing a const version of the dispatch\ntable. Update all affected callers.\n\nLikewise, let QVirtQueue trace back to its associated QVirtioDevice.\n\nA later patch can then explicitly use the QTestState associated\nwith the bus rather than blindly relying on global_qtest.\n\nSigned-off-by: Eric Blake <eblake@redhat.com>\n---\n tests/libqos/virtio-mmio.h | 6 +++---\n tests/libqos/virtio-pci.h | 2 --\n tests/libqos/virtio.h | 7 ++++++-\n tests/libqos/virtio-mmio.c | 12 ++++++++++--\n tests/libqos/virtio-pci.c | 6 ++++--\n tests/libqos/virtio.c | 10 ++++++++++\n tests/virtio-blk-test.c | 5 +++--\n 7 files changed, 36 insertions(+), 12 deletions(-)", "diff": "diff --git a/tests/libqos/virtio-mmio.h b/tests/libqos/virtio-mmio.h\nindex e3e52b9ce1..fe7fa636b8 100644\n--- a/tests/libqos/virtio-mmio.h\n+++ b/tests/libqos/virtio-mmio.h\n@@ -39,8 +39,8 @@ typedef struct QVirtioMMIODevice {\n uint32_t features; /* As it cannot be read later, save it */\n } QVirtioMMIODevice;\n\n-extern const QVirtioBus qvirtio_mmio;\n-\n-QVirtioMMIODevice *qvirtio_mmio_init_device(uint64_t addr, uint32_t page_size);\n+QVirtioMMIODevice *qvirtio_mmio_init_device(QTestState *qts, uint64_t addr,\n+ uint32_t page_size);\n+void qvirtio_mmio_device_free(QVirtioMMIODevice *dev);\n\n #endif\ndiff --git a/tests/libqos/virtio-pci.h b/tests/libqos/virtio-pci.h\nindex 6ef19094cb..bcd0594245 100644\n--- a/tests/libqos/virtio-pci.h\n+++ b/tests/libqos/virtio-pci.h\n@@ -29,8 +29,6 @@ typedef struct QVirtQueuePCI {\n uint32_t msix_data;\n } QVirtQueuePCI;\n\n-extern const QVirtioBus qvirtio_pci;\n-\n QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type);\n QVirtioPCIDevice *qvirtio_pci_device_find_slot(QPCIBus *bus,\n uint16_t device_type, int slot);\ndiff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h\nindex 8fbcd1869c..def46ad9bb 100644\n--- a/tests/libqos/virtio.h\n+++ b/tests/libqos/virtio.h\n@@ -18,12 +18,13 @@\n typedef struct QVirtioBus QVirtioBus;\n\n typedef struct QVirtioDevice {\n- const QVirtioBus *bus;\n+ QVirtioBus *bus;\n /* Device type */\n uint16_t device_type;\n } QVirtioDevice;\n\n typedef struct QVirtQueue {\n+ QVirtioDevice *dev;\n uint64_t desc; /* This points to an array of struct vring_desc */\n uint64_t avail; /* This points to a struct vring_avail */\n uint64_t used; /* This points to a struct vring_used */\n@@ -88,6 +89,8 @@ struct QVirtioBus {\n\n /* Notify changes in virtqueue */\n void (*virtqueue_kick)(QVirtioDevice *d, QVirtQueue *vq);\n+\n+ QTestState *qts;\n };\n\n static inline bool qvirtio_is_big_endian(QVirtioDevice *d)\n@@ -103,6 +106,8 @@ static inline uint32_t qvring_size(uint32_t num, uint32_t align)\n + sizeof(uint16_t) * 3 + sizeof(struct vring_used_elem) * num;\n }\n\n+QVirtioBus *qvirtio_init_bus(QTestState *qts, const QVirtioBus *base);\n+\n uint8_t qvirtio_config_readb(QVirtioDevice *d, uint64_t addr);\n uint16_t qvirtio_config_readw(QVirtioDevice *d, uint64_t addr);\n uint32_t qvirtio_config_readl(QVirtioDevice *d, uint64_t addr);\ndiff --git a/tests/libqos/virtio-mmio.c b/tests/libqos/virtio-mmio.c\nindex 7aa8383338..12770319cd 100644\n--- a/tests/libqos/virtio-mmio.c\n+++ b/tests/libqos/virtio-mmio.c\n@@ -131,6 +131,7 @@ static QVirtQueue *qvirtio_mmio_virtqueue_setup(QVirtioDevice *d,\n qvirtio_mmio_queue_select(d, index);\n writel(dev->addr + QVIRTIO_MMIO_QUEUE_ALIGN, dev->page_size);\n\n+ vq->dev = d;\n vq->index = index;\n vq->size = qvirtio_mmio_get_queue_size(d);\n vq->free_head = 0;\n@@ -187,7 +188,8 @@ const QVirtioBus qvirtio_mmio = {\n .virtqueue_kick = qvirtio_mmio_virtqueue_kick,\n };\n\n-QVirtioMMIODevice *qvirtio_mmio_init_device(uint64_t addr, uint32_t page_size)\n+QVirtioMMIODevice *qvirtio_mmio_init_device(QTestState *qts, uint64_t addr,\n+ uint32_t page_size)\n {\n QVirtioMMIODevice *dev;\n uint32_t magic;\n@@ -199,9 +201,15 @@ QVirtioMMIODevice *qvirtio_mmio_init_device(uint64_t addr, uint32_t page_size)\n dev->addr = addr;\n dev->page_size = page_size;\n dev->vdev.device_type = readl(addr + QVIRTIO_MMIO_DEVICE_ID);\n- dev->vdev.bus = &qvirtio_mmio;\n+ dev->vdev.bus = qvirtio_init_bus(qts, &qvirtio_mmio);\n\n writel(addr + QVIRTIO_MMIO_GUEST_PAGE_SIZE, page_size);\n\n return dev;\n }\n+\n+void qvirtio_mmio_device_free(QVirtioMMIODevice *dev)\n+{\n+ g_free(dev->vdev.bus);\n+ g_free(dev);\n+}\ndiff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c\nindex 7ac15c04e1..6225e6df9b 100644\n--- a/tests/libqos/virtio-pci.c\n+++ b/tests/libqos/virtio-pci.c\n@@ -31,6 +31,7 @@ typedef struct QVirtioPCIForeachData {\n\n void qvirtio_pci_device_free(QVirtioPCIDevice *dev)\n {\n+ g_free(dev->vdev.bus);\n g_free(dev->pdev);\n g_free(dev);\n }\n@@ -233,6 +234,7 @@ static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d,\n feat = qvirtio_pci_get_guest_features(d);\n\n qvirtio_pci_queue_select(d, index);\n+ vqpci->vq.dev = d;\n vqpci->vq.index = index;\n vqpci->vq.size = qvirtio_pci_get_queue_size(d);\n vqpci->vq.free_head = 0;\n@@ -315,7 +317,7 @@ QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type)\n qvirtio_pci_foreach(bus, device_type, false, 0,\n qvirtio_pci_assign_device, &dev);\n\n- dev->vdev.bus = &qvirtio_pci;\n+ dev->vdev.bus = qvirtio_init_bus(bus->qts, &qvirtio_pci);\n\n return dev;\n }\n@@ -328,7 +330,7 @@ QVirtioPCIDevice *qvirtio_pci_device_find_slot(QPCIBus *bus,\n qvirtio_pci_foreach(bus, device_type, true, slot,\n qvirtio_pci_assign_device, &dev);\n\n- dev->vdev.bus = &qvirtio_pci;\n+ dev->vdev.bus = qvirtio_init_bus(bus->qts, &qvirtio_pci);\n\n return dev;\n }\ndiff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c\nindex 9880a6964e..2b7d9e62c4 100644\n--- a/tests/libqos/virtio.c\n+++ b/tests/libqos/virtio.c\n@@ -13,6 +13,16 @@\n #include \"standard-headers/linux/virtio_config.h\"\n #include \"standard-headers/linux/virtio_ring.h\"\n\n+QVirtioBus *qvirtio_init_bus(QTestState *qts, const QVirtioBus *base)\n+{\n+ QVirtioBus *bus = g_new0(QVirtioBus, 1);\n+\n+ assert(qts);\n+ *bus = *base;\n+ bus->qts = qts;\n+ return bus;\n+}\n+\n uint8_t qvirtio_config_readb(QVirtioDevice *d, uint64_t addr)\n {\n return d->bus->config_readb(d, addr);\ndiff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c\nindex 0576cb16ba..ca4ee645b7 100644\n--- a/tests/virtio-blk-test.c\n+++ b/tests/virtio-blk-test.c\n@@ -687,7 +687,8 @@ static void mmio_basic(void)\n\n arm_test_start();\n\n- dev = qvirtio_mmio_init_device(MMIO_DEV_BASE_ADDR, MMIO_PAGE_SIZE);\n+ dev = qvirtio_mmio_init_device(global_qtest, MMIO_DEV_BASE_ADDR,\n+ MMIO_PAGE_SIZE);\n g_assert(dev != NULL);\n g_assert_cmphex(dev->vdev.device_type, ==, VIRTIO_ID_BLOCK);\n\n@@ -711,7 +712,7 @@ static void mmio_basic(void)\n\n /* End test */\n qvirtqueue_cleanup(dev->vdev.bus, vq, alloc);\n- g_free(dev);\n+ qvirtio_mmio_device_free(dev);\n generic_alloc_uninit(alloc);\n test_end();\n }\n", "prefixes": [ "v7", "09/38" ] }