Drop one more client of global_qtest by teaching all fw_cfg test
functionality (invoked through alloc-pc) to pass in an explicit
QTestState, adjusting all callers. In particular, fw_cfg-test
had to reorder things to create the test state prior to creating
the fw_cfg (and drop a pointless strdup in the meantime), but that
test now no longer depends on global_qtest.
Signed-off-by: Eric Blake
---
v7: squash in typedef fixup as well as fw_cfg-test cleanup
---
tests/libqos/fw_cfg.h | 10 ++
tests/libqos/libqos.h | 2 +-
tests/libqos/malloc-pc.h| 4 ++--
tests/libqos/malloc-spapr.h | 2 +-
tests/libqos/malloc.h | 1 +
tests/boot-order-test.c | 6 +++---
tests/e1000e-test.c | 2 +-
tests/fw_cfg-test.c | 13 -
tests/ide-test.c| 2 +-
tests/libqos/fw_cfg.c | 14 --
tests/libqos/libqos.c | 2 +-
tests/libqos/malloc-pc.c| 8
tests/libqos/malloc-spapr.c | 4 ++--
tests/vhost-user-test.c | 2 +-
14 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h
index e8371b2317..0353416af0 100644
--- a/tests/libqos/fw_cfg.h
+++ b/tests/libqos/fw_cfg.h
@@ -13,12 +13,14 @@
#ifndef LIBQOS_FW_CFG_H
#define LIBQOS_FW_CFG_H
+#include "libqtest.h"
typedef struct QFWCFG QFWCFG;
struct QFWCFG
{
uint64_t base;
+QTestState *qts;
void (*select)(QFWCFG *fw_cfg, uint16_t key);
void (*read)(QFWCFG *fw_cfg, void *data, size_t len);
};
@@ -30,12 +32,12 @@ uint16_t qfw_cfg_get_u16(QFWCFG *fw_cfg, uint16_t key);
uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key);
uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key);
-QFWCFG *mm_fw_cfg_init(uint64_t base);
-QFWCFG *io_fw_cfg_init(uint16_t base);
+QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base);
+QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base);
-static inline QFWCFG *pc_fw_cfg_init(void)
+static inline QFWCFG *pc_fw_cfg_init(QTestState *qts)
{
-return io_fw_cfg_init(0x510);
+return io_fw_cfg_init(qts, 0x510);
}
#endif
diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h
index 78e5c044a0..07d4b93d1d 100644
--- a/tests/libqos/libqos.h
+++ b/tests/libqos/libqos.h
@@ -8,7 +8,7 @@
typedef struct QOSState QOSState;
typedef struct QOSOps {
-QGuestAllocator *(*init_allocator)(QAllocOpts);
+QGuestAllocator *(*init_allocator)(QTestState *qts, QAllocOpts);
void (*uninit_allocator)(QGuestAllocator *);
QPCIBus *(*qpci_init)(QTestState *qts, QGuestAllocator *alloc);
void (*qpci_free)(QPCIBus *bus);
diff --git a/tests/libqos/malloc-pc.h b/tests/libqos/malloc-pc.h
index 86ab9f0429..10f3da6cf2 100644
--- a/tests/libqos/malloc-pc.h
+++ b/tests/libqos/malloc-pc.h
@@ -15,8 +15,8 @@
#include "libqos/malloc.h"
-QGuestAllocator *pc_alloc_init(void);
-QGuestAllocator *pc_alloc_init_flags(QAllocOpts flags);
+QGuestAllocator *pc_alloc_init(QTestState *qts);
+QGuestAllocator *pc_alloc_init_flags(QTestState *qts, QAllocOpts flags);
void pc_alloc_uninit(QGuestAllocator *allocator);
#endif
diff --git a/tests/libqos/malloc-spapr.h b/tests/libqos/malloc-spapr.h
index 64d0e770d1..52a9346a26 100644
--- a/tests/libqos/malloc-spapr.h
+++ b/tests/libqos/malloc-spapr.h
@@ -11,7 +11,7 @@
#include "libqos/malloc.h"
QGuestAllocator *spapr_alloc_init(void);
-QGuestAllocator *spapr_alloc_init_flags(QAllocOpts flags);
+QGuestAllocator *spapr_alloc_init_flags(QTestState *qts, QAllocOpts flags);
void spapr_alloc_uninit(QGuestAllocator *allocator);
#endif
diff --git a/tests/libqos/malloc.h b/tests/libqos/malloc.h
index ae9dac8f61..828fddabdb 100644
--- a/tests/libqos/malloc.h
+++ b/tests/libqos/malloc.h
@@ -14,6 +14,7 @@
#define LIBQOS_MALLOC_H
#include "qemu/queue.h"
+#include "libqtest.h"
typedef enum {
ALLOC_NO_FLAGS= 0x00,
diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index 9d516830dd..5fc2ca8e9e 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -135,7 +135,7 @@ static void test_prep_boot_order(void)
static uint64_t read_boot_order_pmac(void)
{
-QFWCFG *fw_cfg = mm_fw_cfg_init(0xf510);
+QFWCFG *fw_cfg = mm_fw_cfg_init(global_qtest, 0xf510);
return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
}
@@ -160,7 +160,7 @@ static void test_pmac_newworld_boot_order(void)
static uint64_t read_boot_order_sun4m(void)
{
-QFWCFG *fw_cfg = mm_fw_cfg_init(0xd0510ULL);
+QFWCFG *fw_cfg = mm_fw_cfg_init(global_qtest, 0xd0510ULL);
return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
}
@@ -172,7 +172,7 @@ static void test_sun4m_boot_order(void)
static uint64_t read_boot_order_sun4u(void)
{
-QFWCFG *fw_cfg = io_fw_cfg_init(0x510);
+QFWCFG *fw_cfg = io_fw_cfg_init(global_qtest, 0x510);
return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
}
diff --git a/tests/e1000e-test.c b/tests/e1000e-test.c
index 3cc081941e..8645485c19 100644
--- a/tests/e1000e-test.c
+++ b/