From e5d1730d1e5c1f341d2d692ab2ad0d8d2d7f47e1 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 11 Sep 2017 12:19:52 -0500 Subject: 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 Reviewed-by: John Snow Reviewed-by: Thomas Huth [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 --- tests/libqos/libqos.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'tests/libqos/libqos.c') diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c index 306d4c06de..18f08cf1ba 100644 --- a/tests/libqos/libqos.c +++ b/tests/libqos/libqos.c @@ -18,18 +18,14 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap) { char *cmdline; - struct QOSState *qs = g_new(QOSState, 1); + QOSState *qs = g_new0(QOSState, 1); cmdline = g_strdup_vprintf(cmdline_fmt, ap); qs->qts = qtest_start(cmdline); qs->ops = ops; if (ops) { - if (ops->init_allocator) { - qs->alloc = ops->init_allocator(ALLOC_NO_FLAGS); - } - if (ops->qpci_init && qs->alloc) { - qs->pcibus = ops->qpci_init(qs->alloc); - } + qs->alloc = ops->init_allocator(ALLOC_NO_FLAGS); + qs->pcibus = ops->qpci_init(qs->qts, qs->alloc); } g_free(cmdline); -- cgit v1.2.3-55-g7522