aboutsummaryrefslogtreecommitdiff
path: root/tests/libqos/pci-spapr.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2017-09-11 12:19:52 -0500
committerThomas Huth <thuth@redhat.com>2018-02-14 11:43:02 +0100
commite5d1730d1e5c1f341d2d692ab2ad0d8d2d7f47e1 (patch)
treeced804356dd9e41b2b6e4c9d64c45a3b66ca69a8 /tests/libqos/pci-spapr.c
parent50990b162c471a8de992d43a170a3ccf24462720 (diff)
downloadqemu-e5d1730d1e5c1f341d2d692ab2ad0d8d2d7f47e1.zip
qemu-e5d1730d1e5c1f341d2d692ab2ad0d8d2d7f47e1.tar.gz
qemu-e5d1730d1e5c1f341d2d692ab2ad0d8d2d7f47e1.tar.bz2
libqos: Track QTestState with QPCIBus
When initializing a QPCIBus, track which QTestState the bus is associated with (so that a later patch can then explicitly use that test state for all communication on the bus, rather than blindly relying on global_qtest). Update the initialization functions to take another parameter, and update all callers to pass in state (for now, most callers get away with passing the current global_qtest as the current state, although this required fixing the order of initialization to ensure qtest_start() is called before qpci_init*() in rtl8139-test, and provided an opportunity to pass in the allocator in e1000e-test). Touch up some allocations to use g_new0() rather than g_malloc() while in the area, and simplify some code (all implementations of QOSOps provide a .init_allocator() that never fails). Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> [thuth: Removed hunk from vhost-user-test.c that is not required anymore, fixed conflict in qtest_vboot() and adjusted qpci_init_pc() in sdhci-test] Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/libqos/pci-spapr.c')
-rw-r--r--tests/libqos/pci-spapr.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/libqos/pci-spapr.c b/tests/libqos/pci-spapr.c
index 2043f1e..ef52fcb 100644
--- a/tests/libqos/pci-spapr.c
+++ b/tests/libqos/pci-spapr.c
@@ -154,11 +154,11 @@ static void qpci_spapr_config_writel(QPCIBus *bus, int devfn, uint8_t offset,
#define SPAPR_PCI_MMIO32_WIN_SIZE 0x80000000 /* 2 GiB */
#define SPAPR_PCI_IO_WIN_SIZE 0x10000
-QPCIBus *qpci_init_spapr(QGuestAllocator *alloc)
+QPCIBus *qpci_init_spapr(QTestState *qts, QGuestAllocator *alloc)
{
- QPCIBusSPAPR *ret;
+ QPCIBusSPAPR *ret = g_new0(QPCIBusSPAPR, 1);
- ret = g_malloc(sizeof(*ret));
+ assert(qts);
ret->alloc = alloc;
@@ -197,6 +197,7 @@ QPCIBus *qpci_init_spapr(QGuestAllocator *alloc)
ret->mmio32.pci_base = SPAPR_PCI_MMIO32_WIN_SIZE;
ret->mmio32.size = SPAPR_PCI_MMIO32_WIN_SIZE;
+ ret->bus.qts = qts;
ret->bus.pio_alloc_ptr = 0xc000;
ret->bus.mmio_alloc_ptr = ret->mmio32.pci_base;
ret->bus.mmio_limit = ret->mmio32.pci_base + ret->mmio32.size;