* [Qemu-devel] [PATCH 1/6] tests/migration: Do not use functions anymore that rely on global_qtest
2019-09-03 6:18 [Qemu-devel] [PATCH 0/6] Make the core libqtest library independe from global_qtest Thomas Huth
@ 2019-09-03 6:18 ` Thomas Huth
2019-09-03 8:12 ` Laurent Vivier
2019-09-03 6:18 ` [Qemu-devel] [PATCH 2/6] tests/libqos/e1000e: Make e1000e libqos functions independent from global_qtest Thomas Huth
` (4 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Thomas Huth @ 2019-09-03 6:18 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel; +Cc: Paolo Bonzini, Stefan Hajnoczi
The migration tests deal with multiple test states, so we really should
not use functions here that rely on the single global_qtest variable.
Switch from qtest_start() to qtest_init() to make sure that global_qtest
is not set anymore. This also revealed a regression in the migrate()
function: It has once been converted to use the qtest_qmp() function,
but commit b5bbd3f315d686bd511 ("Clean up string interpolation into QMP,
part 2") accidentally reverted it back to qmp().
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/migration-test.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/migration-test.c b/tests/migration-test.c
index b87ba99a9e..a9f81cc185 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -490,7 +490,7 @@ static void migrate(QTestState *who, const char *uri, const char *fmt, ...)
g_assert(!qdict_haskey(args, "uri"));
qdict_put_str(args, "uri", uri);
- rsp = qmp("{ 'execute': 'migrate', 'arguments': %p}", args);
+ rsp = qtest_qmp(who, "{ 'execute': 'migrate', 'arguments': %p}", args);
g_assert(qdict_haskey(rsp, "return"));
qobject_unref(rsp);
@@ -625,7 +625,7 @@ static int test_migrate_start(QTestState **from, QTestState **to,
cmd_dst = tmp;
}
- *from = qtest_start(cmd_src);
+ *from = qtest_init(cmd_src);
g_free(cmd_src);
*to = qtest_init(cmd_dst);
@@ -715,7 +715,7 @@ static void test_deprecated(void)
{
QTestState *from;
- from = qtest_start("-machine none");
+ from = qtest_init("-machine none");
deprecated_set_downtime(from, 0.12345);
deprecated_set_speed(from, 12345);
--
2.18.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 1/6] tests/migration: Do not use functions anymore that rely on global_qtest
2019-09-03 6:18 ` [Qemu-devel] [PATCH 1/6] tests/migration: Do not use functions anymore that rely on global_qtest Thomas Huth
@ 2019-09-03 8:12 ` Laurent Vivier
0 siblings, 0 replies; 10+ messages in thread
From: Laurent Vivier @ 2019-09-03 8:12 UTC (permalink / raw)
To: Thomas Huth, qemu-devel; +Cc: Paolo Bonzini, Stefan Hajnoczi
On 03/09/2019 08:18, Thomas Huth wrote:
> The migration tests deal with multiple test states, so we really should
> not use functions here that rely on the single global_qtest variable.
> Switch from qtest_start() to qtest_init() to make sure that global_qtest
> is not set anymore. This also revealed a regression in the migrate()
> function: It has once been converted to use the qtest_qmp() function,
> but commit b5bbd3f315d686bd511 ("Clean up string interpolation into QMP,
> part 2") accidentally reverted it back to qmp().
>
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
> tests/migration-test.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 2/6] tests/libqos/e1000e: Make e1000e libqos functions independent from global_qtest
2019-09-03 6:18 [Qemu-devel] [PATCH 0/6] Make the core libqtest library independe from global_qtest Thomas Huth
2019-09-03 6:18 ` [Qemu-devel] [PATCH 1/6] tests/migration: Do not use functions anymore that rely on global_qtest Thomas Huth
@ 2019-09-03 6:18 ` Thomas Huth
2019-09-03 8:34 ` Laurent Vivier
2019-09-03 6:18 ` [Qemu-devel] [PATCH 3/6] tests/libqos: Replace clock_step with qtest_clock_step in virtio code Thomas Huth
` (3 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Thomas Huth @ 2019-09-03 6:18 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel; +Cc: Paolo Bonzini, Stefan Hajnoczi
libqos library functions should never depend on functions (like memread(),
memwrite() or clock_step()) that require global_qtest to be set, since
library functions might get used in qtests that track multiple states, too.
Thus let's replace the global_qtest-related functions with their independent
counterparts.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/libqos/e1000e.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/tests/libqos/e1000e.c b/tests/libqos/e1000e.c
index 1d0592974e..560e7a2bb2 100644
--- a/tests/libqos/e1000e.c
+++ b/tests/libqos/e1000e.c
@@ -85,26 +85,32 @@ static uint32_t e1000e_macreg_read(QE1000E *d, uint32_t reg)
void e1000e_tx_ring_push(QE1000E *d, void *descr)
{
+ QE1000E_PCI *d_pci = container_of(d, QE1000E_PCI, e1000e);
uint32_t tail = e1000e_macreg_read(d, E1000E_TDT);
uint32_t len = e1000e_macreg_read(d, E1000E_TDLEN) / E1000E_TXD_LEN;
- memwrite(d->tx_ring + tail * E1000E_TXD_LEN, descr, E1000E_TXD_LEN);
+ qtest_memwrite(d_pci->pci_dev.bus->qts, d->tx_ring + tail * E1000E_TXD_LEN,
+ descr, E1000E_TXD_LEN);
e1000e_macreg_write(d, E1000E_TDT, (tail + 1) % len);
/* Read WB data for the packet transmitted */
- memread(d->tx_ring + tail * E1000E_TXD_LEN, descr, E1000E_TXD_LEN);
+ qtest_memread(d_pci->pci_dev.bus->qts, d->tx_ring + tail * E1000E_TXD_LEN,
+ descr, E1000E_TXD_LEN);
}
void e1000e_rx_ring_push(QE1000E *d, void *descr)
{
+ QE1000E_PCI *d_pci = container_of(d, QE1000E_PCI, e1000e);
uint32_t tail = e1000e_macreg_read(d, E1000E_RDT);
uint32_t len = e1000e_macreg_read(d, E1000E_RDLEN) / E1000E_RXD_LEN;
- memwrite(d->rx_ring + tail * E1000E_RXD_LEN, descr, E1000E_RXD_LEN);
+ qtest_memwrite(d_pci->pci_dev.bus->qts, d->rx_ring + tail * E1000E_RXD_LEN,
+ descr, E1000E_RXD_LEN);
e1000e_macreg_write(d, E1000E_RDT, (tail + 1) % len);
/* Read WB data for the packet received */
- memread(d->rx_ring + tail * E1000E_RXD_LEN, descr, E1000E_RXD_LEN);
+ qtest_memread(d_pci->pci_dev.bus->qts, d->rx_ring + tail * E1000E_RXD_LEN,
+ descr, E1000E_RXD_LEN);
}
static void e1000e_foreach_callback(QPCIDevice *dev, int devfn, void *data)
@@ -123,7 +129,7 @@ void e1000e_wait_isr(QE1000E *d, uint16_t msg_id)
if (qpci_msix_pending(&d_pci->pci_dev, msg_id)) {
return;
}
- clock_step(10000);
+ qtest_clock_step(d_pci->pci_dev.bus->qts, 10000);
} while (g_get_monotonic_time() < end_time);
g_error("Timeout expired");
--
2.18.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 2/6] tests/libqos/e1000e: Make e1000e libqos functions independent from global_qtest
2019-09-03 6:18 ` [Qemu-devel] [PATCH 2/6] tests/libqos/e1000e: Make e1000e libqos functions independent from global_qtest Thomas Huth
@ 2019-09-03 8:34 ` Laurent Vivier
0 siblings, 0 replies; 10+ messages in thread
From: Laurent Vivier @ 2019-09-03 8:34 UTC (permalink / raw)
To: Thomas Huth, qemu-devel; +Cc: Paolo Bonzini, Stefan Hajnoczi
On 03/09/2019 08:18, Thomas Huth wrote:
> libqos library functions should never depend on functions (like memread(),
> memwrite() or clock_step()) that require global_qtest to be set, since
> library functions might get used in qtests that track multiple states, too.
> Thus let's replace the global_qtest-related functions with their independent
> counterparts.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
> tests/libqos/e1000e.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 3/6] tests/libqos: Replace clock_step with qtest_clock_step in virtio code
2019-09-03 6:18 [Qemu-devel] [PATCH 0/6] Make the core libqtest library independe from global_qtest Thomas Huth
2019-09-03 6:18 ` [Qemu-devel] [PATCH 1/6] tests/migration: Do not use functions anymore that rely on global_qtest Thomas Huth
2019-09-03 6:18 ` [Qemu-devel] [PATCH 2/6] tests/libqos/e1000e: Make e1000e libqos functions independent from global_qtest Thomas Huth
@ 2019-09-03 6:18 ` Thomas Huth
2019-09-03 8:52 ` Laurent Vivier
2019-09-03 6:18 ` [Qemu-devel] [PATCH 4/6] tests: Remove unnecessary global_qtest references Thomas Huth
` (2 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Thomas Huth @ 2019-09-03 6:18 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel; +Cc: Paolo Bonzini, Stefan Hajnoczi
Library functions should not rely on functions that require global_qtest
(since they might get used in tests that deal with multiple states).
Commit 1999a70a05ad603d ("Make generic virtio code independent from
global_qtest") already tried to clean the libqos virtio code, but I
missed to replace the clock_step() function. Thus change it now to
qtest_clock_step() instead.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/libqos/virtio.c | 15 ++++++++-------
tests/libqos/virtio.h | 5 +++--
tests/virtio-blk-test.c | 8 +++++---
3 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c
index 91ce06954b..5a2ed7a1a5 100644
--- a/tests/libqos/virtio.c
+++ b/tests/libqos/virtio.c
@@ -82,13 +82,13 @@ void qvirtio_set_driver_ok(QVirtioDevice *d)
VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_ACKNOWLEDGE);
}
-void qvirtio_wait_queue_isr(QVirtioDevice *d,
+void qvirtio_wait_queue_isr(QTestState *qts, QVirtioDevice *d,
QVirtQueue *vq, gint64 timeout_us)
{
gint64 start_time = g_get_monotonic_time();
for (;;) {
- clock_step(100);
+ qtest_clock_step(qts, 100);
if (d->bus->get_queue_isr_status(d, vq)) {
return;
}
@@ -109,8 +109,8 @@ uint8_t qvirtio_wait_status_byte_no_isr(QTestState *qts, QVirtioDevice *d,
gint64 start_time = g_get_monotonic_time();
uint8_t val;
- while ((val = readb(addr)) == 0xff) {
- clock_step(100);
+ while ((val = qtest_readb(qts, addr)) == 0xff) {
+ qtest_clock_step(qts, 100);
g_assert(!d->bus->get_queue_isr_status(d, vq));
g_assert(g_get_monotonic_time() - start_time <= timeout_us);
}
@@ -137,7 +137,7 @@ void qvirtio_wait_used_elem(QTestState *qts, QVirtioDevice *d,
for (;;) {
uint32_t got_desc_idx;
- clock_step(100);
+ qtest_clock_step(qts, 100);
if (d->bus->get_queue_isr_status(d, vq) &&
qvirtqueue_get_buf(qts, vq, &got_desc_idx, len)) {
@@ -149,12 +149,13 @@ void qvirtio_wait_used_elem(QTestState *qts, QVirtioDevice *d,
}
}
-void qvirtio_wait_config_isr(QVirtioDevice *d, gint64 timeout_us)
+void qvirtio_wait_config_isr(QTestState *qts, QVirtioDevice *d,
+ gint64 timeout_us)
{
gint64 start_time = g_get_monotonic_time();
for (;;) {
- clock_step(100);
+ qtest_clock_step(qts, 100);
if (d->bus->get_config_isr_status(d)) {
return;
}
diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h
index 037176dbd8..1a93f9b1de 100644
--- a/tests/libqos/virtio.h
+++ b/tests/libqos/virtio.h
@@ -112,7 +112,7 @@ void qvirtio_set_acknowledge(QVirtioDevice *d);
void qvirtio_set_driver(QVirtioDevice *d);
void qvirtio_set_driver_ok(QVirtioDevice *d);
-void qvirtio_wait_queue_isr(QVirtioDevice *d,
+void qvirtio_wait_queue_isr(QTestState *qts, QVirtioDevice *d,
QVirtQueue *vq, gint64 timeout_us);
uint8_t qvirtio_wait_status_byte_no_isr(QTestState *qts, QVirtioDevice *d,
QVirtQueue *vq,
@@ -123,7 +123,8 @@ void qvirtio_wait_used_elem(QTestState *qts, QVirtioDevice *d,
uint32_t desc_idx,
uint32_t *len,
gint64 timeout_us);
-void qvirtio_wait_config_isr(QVirtioDevice *d, gint64 timeout_us);
+void qvirtio_wait_config_isr(QTestState *qts, QVirtioDevice *d,
+ gint64 timeout_us);
QVirtQueue *qvirtqueue_setup(QVirtioDevice *d,
QGuestAllocator *alloc, uint16_t index);
void qvirtqueue_cleanup(const QVirtioBus *bus, QVirtQueue *vq,
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index 982ff1538c..247fef0b0f 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -435,6 +435,7 @@ static void config(void *obj, void *data, QGuestAllocator *t_alloc)
QVirtioDevice *dev = blk_if->vdev;
int n_size = TEST_IMAGE_SIZE / 2;
uint64_t capacity;
+ QTestState *qts = global_qtest;
capacity = qvirtio_config_readq(dev, 0);
g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
@@ -444,7 +445,7 @@ static void config(void *obj, void *data, QGuestAllocator *t_alloc)
qmp_discard_response("{ 'execute': 'block_resize', "
" 'arguments': { 'device': 'drive0', "
" 'size': %d } }", n_size);
- qvirtio_wait_config_isr(dev, QVIRTIO_BLK_TIMEOUT_US);
+ qvirtio_wait_config_isr(qts, dev, QVIRTIO_BLK_TIMEOUT_US);
capacity = qvirtio_config_readq(dev, 0);
g_assert_cmpint(capacity, ==, n_size / 512);
@@ -494,7 +495,7 @@ static void msix(void *obj, void *u_data, QGuestAllocator *t_alloc)
" 'arguments': { 'device': 'drive0', "
" 'size': %d } }", n_size);
- qvirtio_wait_config_isr(dev, QVIRTIO_BLK_TIMEOUT_US);
+ qvirtio_wait_config_isr(qts, dev, QVIRTIO_BLK_TIMEOUT_US);
capacity = qvirtio_config_readq(dev, 0);
g_assert_cmpint(capacity, ==, n_size / 512);
@@ -737,6 +738,7 @@ static void resize(void *obj, void *data, QGuestAllocator *t_alloc)
int n_size = TEST_IMAGE_SIZE / 2;
uint64_t capacity;
QVirtQueue *vq;
+ QTestState *qts = global_qtest;
vq = qvirtqueue_setup(dev, t_alloc, 0);
@@ -746,7 +748,7 @@ static void resize(void *obj, void *data, QGuestAllocator *t_alloc)
" 'arguments': { 'device': 'drive0', "
" 'size': %d } }", n_size);
- qvirtio_wait_queue_isr(dev, vq, QVIRTIO_BLK_TIMEOUT_US);
+ qvirtio_wait_queue_isr(qts, dev, vq, QVIRTIO_BLK_TIMEOUT_US);
capacity = qvirtio_config_readq(dev, 0);
g_assert_cmpint(capacity, ==, n_size / 512);
--
2.18.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 3/6] tests/libqos: Replace clock_step with qtest_clock_step in virtio code
2019-09-03 6:18 ` [Qemu-devel] [PATCH 3/6] tests/libqos: Replace clock_step with qtest_clock_step in virtio code Thomas Huth
@ 2019-09-03 8:52 ` Laurent Vivier
0 siblings, 0 replies; 10+ messages in thread
From: Laurent Vivier @ 2019-09-03 8:52 UTC (permalink / raw)
To: Thomas Huth, qemu-devel; +Cc: Paolo Bonzini, Stefan Hajnoczi
On 03/09/2019 08:18, Thomas Huth wrote:
> Library functions should not rely on functions that require global_qtest
> (since they might get used in tests that deal with multiple states).
> Commit 1999a70a05ad603d ("Make generic virtio code independent from
> global_qtest") already tried to clean the libqos virtio code, but I
> missed to replace the clock_step() function. Thus change it now to
> qtest_clock_step() instead.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
> tests/libqos/virtio.c | 15 ++++++++-------
> tests/libqos/virtio.h | 5 +++--
> tests/virtio-blk-test.c | 8 +++++---
> 3 files changed, 16 insertions(+), 12 deletions(-)
>
> diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c
> index 91ce06954b..5a2ed7a1a5 100644
> --- a/tests/libqos/virtio.c
> +++ b/tests/libqos/virtio.c
> @@ -82,13 +82,13 @@ void qvirtio_set_driver_ok(QVirtioDevice *d)
> VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_ACKNOWLEDGE);
> }
>
> -void qvirtio_wait_queue_isr(QVirtioDevice *d,
> +void qvirtio_wait_queue_isr(QTestState *qts, QVirtioDevice *d,
> QVirtQueue *vq, gint64 timeout_us)
> {
> gint64 start_time = g_get_monotonic_time();
>
> for (;;) {
> - clock_step(100);
> + qtest_clock_step(qts, 100);
> if (d->bus->get_queue_isr_status(d, vq)) {
> return;
> }
> @@ -109,8 +109,8 @@ uint8_t qvirtio_wait_status_byte_no_isr(QTestState *qts, QVirtioDevice *d,
> gint64 start_time = g_get_monotonic_time();
> uint8_t val;
>
> - while ((val = readb(addr)) == 0xff) {
> - clock_step(100);
> + while ((val = qtest_readb(qts, addr)) == 0xff) {
> + qtest_clock_step(qts, 100);
> g_assert(!d->bus->get_queue_isr_status(d, vq));
> g_assert(g_get_monotonic_time() - start_time <= timeout_us);
> }
> @@ -137,7 +137,7 @@ void qvirtio_wait_used_elem(QTestState *qts, QVirtioDevice *d,
> for (;;) {
> uint32_t got_desc_idx;
>
> - clock_step(100);
> + qtest_clock_step(qts, 100);
>
> if (d->bus->get_queue_isr_status(d, vq) &&
> qvirtqueue_get_buf(qts, vq, &got_desc_idx, len)) {
> @@ -149,12 +149,13 @@ void qvirtio_wait_used_elem(QTestState *qts, QVirtioDevice *d,
> }
> }
>
> -void qvirtio_wait_config_isr(QVirtioDevice *d, gint64 timeout_us)
> +void qvirtio_wait_config_isr(QTestState *qts, QVirtioDevice *d,
> + gint64 timeout_us)
> {
> gint64 start_time = g_get_monotonic_time();
>
> for (;;) {
> - clock_step(100);
> + qtest_clock_step(qts, 100);
> if (d->bus->get_config_isr_status(d)) {
> return;
> }
> diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h
> index 037176dbd8..1a93f9b1de 100644
> --- a/tests/libqos/virtio.h
> +++ b/tests/libqos/virtio.h
> @@ -112,7 +112,7 @@ void qvirtio_set_acknowledge(QVirtioDevice *d);
> void qvirtio_set_driver(QVirtioDevice *d);
> void qvirtio_set_driver_ok(QVirtioDevice *d);
>
> -void qvirtio_wait_queue_isr(QVirtioDevice *d,
> +void qvirtio_wait_queue_isr(QTestState *qts, QVirtioDevice *d,
> QVirtQueue *vq, gint64 timeout_us);
> uint8_t qvirtio_wait_status_byte_no_isr(QTestState *qts, QVirtioDevice *d,
> QVirtQueue *vq,
> @@ -123,7 +123,8 @@ void qvirtio_wait_used_elem(QTestState *qts, QVirtioDevice *d,
> uint32_t desc_idx,
> uint32_t *len,
> gint64 timeout_us);
> -void qvirtio_wait_config_isr(QVirtioDevice *d, gint64 timeout_us);
> +void qvirtio_wait_config_isr(QTestState *qts, QVirtioDevice *d,
> + gint64 timeout_us);
> QVirtQueue *qvirtqueue_setup(QVirtioDevice *d,
> QGuestAllocator *alloc, uint16_t index);
> void qvirtqueue_cleanup(const QVirtioBus *bus, QVirtQueue *vq,
> diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
> index 982ff1538c..247fef0b0f 100644
> --- a/tests/virtio-blk-test.c
> +++ b/tests/virtio-blk-test.c
> @@ -435,6 +435,7 @@ static void config(void *obj, void *data, QGuestAllocator *t_alloc)
> QVirtioDevice *dev = blk_if->vdev;
> int n_size = TEST_IMAGE_SIZE / 2;
> uint64_t capacity;
> + QTestState *qts = global_qtest;
>
> capacity = qvirtio_config_readq(dev, 0);
> g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
> @@ -444,7 +445,7 @@ static void config(void *obj, void *data, QGuestAllocator *t_alloc)
> qmp_discard_response("{ 'execute': 'block_resize', "
> " 'arguments': { 'device': 'drive0', "
> " 'size': %d } }", n_size);
> - qvirtio_wait_config_isr(dev, QVIRTIO_BLK_TIMEOUT_US);
> + qvirtio_wait_config_isr(qts, dev, QVIRTIO_BLK_TIMEOUT_US);
qvirtio_wait_config_isr() calls get_config_isr_status() that will
extract qts from PCI bus or MMIO structure. I think you should not add a
parameter here and move all the stuff to
qvirtio_mmio_get_config_isr_status() and
qvirtio_pci_get_config_isr_status().
Thanks,
Laurent
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 4/6] tests: Remove unnecessary global_qtest references
2019-09-03 6:18 [Qemu-devel] [PATCH 0/6] Make the core libqtest library independe from global_qtest Thomas Huth
` (2 preceding siblings ...)
2019-09-03 6:18 ` [Qemu-devel] [PATCH 3/6] tests/libqos: Replace clock_step with qtest_clock_step in virtio code Thomas Huth
@ 2019-09-03 6:18 ` Thomas Huth
2019-09-03 6:18 ` [Qemu-devel] [PATCH 5/6] tests/libqtest: Move global_test wrapper function into a separate header Thomas Huth
2019-09-03 6:18 ` [Qemu-devel] [PATCH 6/6] tests/libqtest: Use libqtest-single.h in tests that require global_qtest Thomas Huth
5 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2019-09-03 6:18 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel; +Cc: Paolo Bonzini, Stefan Hajnoczi
We are going to remove global_qtest from the main libqtest library
soon, so tests that do not urgently need global_qtest anymore
should be cleaned from the unnecessary references.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/ahci-test.c | 1 -
tests/bios-tables-test.c | 1 -
tests/ivshmem-test.c | 3 ---
tests/rtas-test.c | 1 -
4 files changed, 6 deletions(-)
diff --git a/tests/ahci-test.c b/tests/ahci-test.c
index 086811e602..c8d42ceea0 100644
--- a/tests/ahci-test.c
+++ b/tests/ahci-test.c
@@ -200,7 +200,6 @@ static void ahci_shutdown(AHCIQState *ahci)
{
QOSState *qs = ahci->parent;
- assert(!global_qtest);
ahci_clean_mem(ahci);
free_ahci_device(ahci->dev);
g_free(ahci);
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index a356ac3489..9b3d8b0d1b 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -626,7 +626,6 @@ static void test_acpi_one(const char *params, test_data *data)
test_smbios_structs(data);
}
- assert(!global_qtest);
qtest_quit(data->qts);
g_free(args);
}
diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c
index b76457948b..be9aa92a61 100644
--- a/tests/ivshmem-test.c
+++ b/tests/ivshmem-test.c
@@ -100,7 +100,6 @@ static inline void write_mem(IVState *s, uint64_t off,
static void cleanup_vm(IVState *s)
{
- assert(!global_qtest);
g_free(s->dev);
qtest_shutdown(s->qs);
}
@@ -388,7 +387,6 @@ static void test_ivshmem_hotplug(void)
qts = qtest_init("-object memory-backend-ram,size=1M,id=mb1");
- global_qtest = qts; /* TODO: Get rid of global_qtest here */
qtest_qmp_device_add(qts, "ivshmem-plain", "iv1",
"{'addr': %s, 'memdev': 'mb1'}",
stringify(PCI_SLOT_HP));
@@ -397,7 +395,6 @@ static void test_ivshmem_hotplug(void)
}
qtest_quit(qts);
- global_qtest = NULL;
}
static void test_ivshmem_memdev(void)
diff --git a/tests/rtas-test.c b/tests/rtas-test.c
index ee888676ed..167b42db38 100644
--- a/tests/rtas-test.c
+++ b/tests/rtas-test.c
@@ -14,7 +14,6 @@ static void test_rtas_get_time_of_day(void)
time_t t1, t2;
qs = qtest_spapr_boot("-machine pseries");
- global_qtest = qs->qts;
t1 = time(NULL);
ret = qrtas_get_time_of_day(qs->qts, &qs->alloc, &tm, &ns);
--
2.18.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 5/6] tests/libqtest: Move global_test wrapper function into a separate header
2019-09-03 6:18 [Qemu-devel] [PATCH 0/6] Make the core libqtest library independe from global_qtest Thomas Huth
` (3 preceding siblings ...)
2019-09-03 6:18 ` [Qemu-devel] [PATCH 4/6] tests: Remove unnecessary global_qtest references Thomas Huth
@ 2019-09-03 6:18 ` Thomas Huth
2019-09-03 6:18 ` [Qemu-devel] [PATCH 6/6] tests/libqtest: Use libqtest-single.h in tests that require global_qtest Thomas Huth
5 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2019-09-03 6:18 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel; +Cc: Paolo Bonzini, Stefan Hajnoczi
We want libqtest.h to become completely independen from global_qtest
(so that the wrapper functions are not used by accident anymore). As
a first step, move the wrapper functions into a separate header file.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
MAINTAINERS | 2 +-
tests/libqtest-single.h | 311 ++++++++++++++++++++++++++++++++++++++++
tests/libqtest.c | 11 --
tests/libqtest.h | 287 +-----------------------------------
4 files changed, 313 insertions(+), 298 deletions(-)
create mode 100644 tests/libqtest-single.h
diff --git a/MAINTAINERS b/MAINTAINERS
index ef6c01084b..b01bf0902a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2078,7 +2078,7 @@ R: Paolo Bonzini <pbonzini@redhat.com>
S: Maintained
F: qtest.c
F: accel/qtest.c
-F: tests/libqtest.*
+F: tests/libqtest*
F: tests/libqos/
F: tests/*-test.c
diff --git a/tests/libqtest-single.h b/tests/libqtest-single.h
new file mode 100644
index 0000000000..49259558a5
--- /dev/null
+++ b/tests/libqtest-single.h
@@ -0,0 +1,311 @@
+/*
+ * QTest - wrappers for test with single QEMU instances
+ *
+ * Copyright IBM, Corp. 2012
+ * Copyright Red Hat, Inc. 2012
+ * Copyright SUSE LINUX Products GmbH 2013
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef LIBQTEST_SINGLE_H
+#define LIBQTEST_SINGLE_H
+
+/**
+ * qtest_start:
+ * @args: other arguments to pass to QEMU
+ *
+ * Start QEMU and assign the resulting #QTestState to a global variable.
+ * The global variable is used by "shortcut" functions documented below.
+ *
+ * Returns: #QTestState instance.
+ */
+static inline QTestState *qtest_start(const char *args)
+{
+ global_qtest = qtest_init(args);
+ return global_qtest;
+}
+
+/**
+ * qtest_end:
+ *
+ * Shut down the QEMU process started by qtest_start().
+ */
+static inline void qtest_end(void)
+{
+ if (!global_qtest) {
+ return;
+ }
+ qtest_quit(global_qtest);
+ global_qtest = NULL;
+}
+
+/**
+ * qmp:
+ * @fmt...: QMP message to send to qemu, formatted like
+ * qobject_from_jsonf_nofail(). See parse_escape() for what's
+ * supported after '%'.
+ *
+ * Sends a QMP message to QEMU and returns the response.
+ */
+GCC_FMT_ATTR(1, 2)
+static inline QDict *qmp(const char *fmt, ...)
+{
+ va_list ap;
+ QDict *response;
+
+ va_start(ap, fmt);
+ response = qtest_vqmp(global_qtest, fmt, ap);
+ va_end(ap);
+ return response;
+}
+
+/**
+ * qmp_eventwait:
+ * @s: #event event to wait for.
+ *
+ * Continuously polls for QMP responses until it receives the desired event.
+ */
+static inline void qmp_eventwait(const char *event)
+{
+ return qtest_qmp_eventwait(global_qtest, event);
+}
+
+/**
+ * get_irq:
+ * @num: Interrupt to observe.
+ *
+ * Returns: The level of the @num interrupt.
+ */
+static inline bool get_irq(int num)
+{
+ return qtest_get_irq(global_qtest, num);
+}
+
+/**
+ * outb:
+ * @addr: I/O port to write to.
+ * @value: Value being written.
+ *
+ * Write an 8-bit value to an I/O port.
+ */
+static inline void outb(uint16_t addr, uint8_t value)
+{
+ qtest_outb(global_qtest, addr, value);
+}
+
+/**
+ * outw:
+ * @addr: I/O port to write to.
+ * @value: Value being written.
+ *
+ * Write a 16-bit value to an I/O port.
+ */
+static inline void outw(uint16_t addr, uint16_t value)
+{
+ qtest_outw(global_qtest, addr, value);
+}
+
+/**
+ * outl:
+ * @addr: I/O port to write to.
+ * @value: Value being written.
+ *
+ * Write a 32-bit value to an I/O port.
+ */
+static inline void outl(uint16_t addr, uint32_t value)
+{
+ qtest_outl(global_qtest, addr, value);
+}
+
+/**
+ * inb:
+ * @addr: I/O port to read from.
+ *
+ * Reads an 8-bit value from an I/O port.
+ *
+ * Returns: Value read.
+ */
+static inline uint8_t inb(uint16_t addr)
+{
+ return qtest_inb(global_qtest, addr);
+}
+
+/**
+ * inw:
+ * @addr: I/O port to read from.
+ *
+ * Reads a 16-bit value from an I/O port.
+ *
+ * Returns: Value read.
+ */
+static inline uint16_t inw(uint16_t addr)
+{
+ return qtest_inw(global_qtest, addr);
+}
+
+/**
+ * inl:
+ * @addr: I/O port to read from.
+ *
+ * Reads a 32-bit value from an I/O port.
+ *
+ * Returns: Value read.
+ */
+static inline uint32_t inl(uint16_t addr)
+{
+ return qtest_inl(global_qtest, addr);
+}
+
+/**
+ * writeb:
+ * @addr: Guest address to write to.
+ * @value: Value being written.
+ *
+ * Writes an 8-bit value to guest memory.
+ */
+static inline void writeb(uint64_t addr, uint8_t value)
+{
+ qtest_writeb(global_qtest, addr, value);
+}
+
+/**
+ * writew:
+ * @addr: Guest address to write to.
+ * @value: Value being written.
+ *
+ * Writes a 16-bit value to guest memory.
+ */
+static inline void writew(uint64_t addr, uint16_t value)
+{
+ qtest_writew(global_qtest, addr, value);
+}
+
+/**
+ * writel:
+ * @addr: Guest address to write to.
+ * @value: Value being written.
+ *
+ * Writes a 32-bit value to guest memory.
+ */
+static inline void writel(uint64_t addr, uint32_t value)
+{
+ qtest_writel(global_qtest, addr, value);
+}
+
+/**
+ * writeq:
+ * @addr: Guest address to write to.
+ * @value: Value being written.
+ *
+ * Writes a 64-bit value to guest memory.
+ */
+static inline void writeq(uint64_t addr, uint64_t value)
+{
+ qtest_writeq(global_qtest, addr, value);
+}
+
+/**
+ * readb:
+ * @addr: Guest address to read from.
+ *
+ * Reads an 8-bit value from guest memory.
+ *
+ * Returns: Value read.
+ */
+static inline uint8_t readb(uint64_t addr)
+{
+ return qtest_readb(global_qtest, addr);
+}
+
+/**
+ * readw:
+ * @addr: Guest address to read from.
+ *
+ * Reads a 16-bit value from guest memory.
+ *
+ * Returns: Value read.
+ */
+static inline uint16_t readw(uint64_t addr)
+{
+ return qtest_readw(global_qtest, addr);
+}
+
+/**
+ * readl:
+ * @addr: Guest address to read from.
+ *
+ * Reads a 32-bit value from guest memory.
+ *
+ * Returns: Value read.
+ */
+static inline uint32_t readl(uint64_t addr)
+{
+ return qtest_readl(global_qtest, addr);
+}
+
+/**
+ * readq:
+ * @addr: Guest address to read from.
+ *
+ * Reads a 64-bit value from guest memory.
+ *
+ * Returns: Value read.
+ */
+static inline uint64_t readq(uint64_t addr)
+{
+ return qtest_readq(global_qtest, addr);
+}
+
+/**
+ * memread:
+ * @addr: Guest address to read from.
+ * @data: Pointer to where memory contents will be stored.
+ * @size: Number of bytes to read.
+ *
+ * Read guest memory into a buffer.
+ */
+static inline void memread(uint64_t addr, void *data, size_t size)
+{
+ qtest_memread(global_qtest, addr, data, size);
+}
+
+/**
+ * memwrite:
+ * @addr: Guest address to write to.
+ * @data: Pointer to the bytes that will be written to guest memory.
+ * @size: Number of bytes to write.
+ *
+ * Write a buffer to guest memory.
+ */
+static inline void memwrite(uint64_t addr, const void *data, size_t size)
+{
+ qtest_memwrite(global_qtest, addr, data, size);
+}
+
+/**
+ * clock_step_next:
+ *
+ * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
+ *
+ * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
+ */
+static inline int64_t clock_step_next(void)
+{
+ return qtest_clock_step_next(global_qtest);
+}
+
+/**
+ * clock_step:
+ * @step: Number of nanoseconds to advance the clock by.
+ *
+ * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
+ *
+ * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
+ */
+static inline int64_t clock_step(int64_t step)
+{
+ return qtest_clock_step(global_qtest, step);
+}
+
+#endif
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 2713b86cf7..e5101d9d3a 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -1106,17 +1106,6 @@ void qtest_memset(QTestState *s, uint64_t addr, uint8_t pattern, size_t size)
qtest_rsp(s, 0);
}
-QDict *qmp(const char *fmt, ...)
-{
- va_list ap;
- QDict *response;
-
- va_start(ap, fmt);
- response = qtest_vqmp(global_qtest, fmt, ap);
- va_end(ap);
- return response;
-}
-
void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...)
{
va_list ap;
diff --git a/tests/libqtest.h b/tests/libqtest.h
index 07ea35867c..6a7d7e41ad 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -628,45 +628,6 @@ void qtest_add_data_func_full(const char *str, void *data,
void qtest_add_abrt_handler(GHookFunc fn, const void *data);
-/**
- * qtest_start:
- * @args: other arguments to pass to QEMU
- *
- * Start QEMU and assign the resulting #QTestState to a global variable.
- * The global variable is used by "shortcut" functions documented below.
- *
- * Returns: #QTestState instance.
- */
-static inline QTestState *qtest_start(const char *args)
-{
- global_qtest = qtest_init(args);
- return global_qtest;
-}
-
-/**
- * qtest_end:
- *
- * Shut down the QEMU process started by qtest_start().
- */
-static inline void qtest_end(void)
-{
- if (!global_qtest) {
- return;
- }
- qtest_quit(global_qtest);
- global_qtest = NULL;
-}
-
-/**
- * qmp:
- * @fmt...: QMP message to send to qemu, formatted like
- * qobject_from_jsonf_nofail(). See parse_escape() for what's
- * supported after '%'.
- *
- * Sends a QMP message to QEMU and returns the response.
- */
-QDict *qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
-
/**
* qtest_qmp_assert_success:
* @qts: QTestState instance to operate on
@@ -680,253 +641,7 @@ QDict *qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...)
GCC_FMT_ATTR(2, 3);
-/*
- * qmp_eventwait:
- * @s: #event event to wait for.
- *
- * Continuously polls for QMP responses until it receives the desired event.
- */
-static inline void qmp_eventwait(const char *event)
-{
- return qtest_qmp_eventwait(global_qtest, event);
-}
-
-/**
- * get_irq:
- * @num: Interrupt to observe.
- *
- * Returns: The level of the @num interrupt.
- */
-static inline bool get_irq(int num)
-{
- return qtest_get_irq(global_qtest, num);
-}
-
-/**
- * outb:
- * @addr: I/O port to write to.
- * @value: Value being written.
- *
- * Write an 8-bit value to an I/O port.
- */
-static inline void outb(uint16_t addr, uint8_t value)
-{
- qtest_outb(global_qtest, addr, value);
-}
-
-/**
- * outw:
- * @addr: I/O port to write to.
- * @value: Value being written.
- *
- * Write a 16-bit value to an I/O port.
- */
-static inline void outw(uint16_t addr, uint16_t value)
-{
- qtest_outw(global_qtest, addr, value);
-}
-
-/**
- * outl:
- * @addr: I/O port to write to.
- * @value: Value being written.
- *
- * Write a 32-bit value to an I/O port.
- */
-static inline void outl(uint16_t addr, uint32_t value)
-{
- qtest_outl(global_qtest, addr, value);
-}
-
-/**
- * inb:
- * @addr: I/O port to read from.
- *
- * Reads an 8-bit value from an I/O port.
- *
- * Returns: Value read.
- */
-static inline uint8_t inb(uint16_t addr)
-{
- return qtest_inb(global_qtest, addr);
-}
-
-/**
- * inw:
- * @addr: I/O port to read from.
- *
- * Reads a 16-bit value from an I/O port.
- *
- * Returns: Value read.
- */
-static inline uint16_t inw(uint16_t addr)
-{
- return qtest_inw(global_qtest, addr);
-}
-
-/**
- * inl:
- * @addr: I/O port to read from.
- *
- * Reads a 32-bit value from an I/O port.
- *
- * Returns: Value read.
- */
-static inline uint32_t inl(uint16_t addr)
-{
- return qtest_inl(global_qtest, addr);
-}
-
-/**
- * writeb:
- * @addr: Guest address to write to.
- * @value: Value being written.
- *
- * Writes an 8-bit value to guest memory.
- */
-static inline void writeb(uint64_t addr, uint8_t value)
-{
- qtest_writeb(global_qtest, addr, value);
-}
-
-/**
- * writew:
- * @addr: Guest address to write to.
- * @value: Value being written.
- *
- * Writes a 16-bit value to guest memory.
- */
-static inline void writew(uint64_t addr, uint16_t value)
-{
- qtest_writew(global_qtest, addr, value);
-}
-
-/**
- * writel:
- * @addr: Guest address to write to.
- * @value: Value being written.
- *
- * Writes a 32-bit value to guest memory.
- */
-static inline void writel(uint64_t addr, uint32_t value)
-{
- qtest_writel(global_qtest, addr, value);
-}
-
-/**
- * writeq:
- * @addr: Guest address to write to.
- * @value: Value being written.
- *
- * Writes a 64-bit value to guest memory.
- */
-static inline void writeq(uint64_t addr, uint64_t value)
-{
- qtest_writeq(global_qtest, addr, value);
-}
-
-/**
- * readb:
- * @addr: Guest address to read from.
- *
- * Reads an 8-bit value from guest memory.
- *
- * Returns: Value read.
- */
-static inline uint8_t readb(uint64_t addr)
-{
- return qtest_readb(global_qtest, addr);
-}
-
-/**
- * readw:
- * @addr: Guest address to read from.
- *
- * Reads a 16-bit value from guest memory.
- *
- * Returns: Value read.
- */
-static inline uint16_t readw(uint64_t addr)
-{
- return qtest_readw(global_qtest, addr);
-}
-
-/**
- * readl:
- * @addr: Guest address to read from.
- *
- * Reads a 32-bit value from guest memory.
- *
- * Returns: Value read.
- */
-static inline uint32_t readl(uint64_t addr)
-{
- return qtest_readl(global_qtest, addr);
-}
-
-/**
- * readq:
- * @addr: Guest address to read from.
- *
- * Reads a 64-bit value from guest memory.
- *
- * Returns: Value read.
- */
-static inline uint64_t readq(uint64_t addr)
-{
- return qtest_readq(global_qtest, addr);
-}
-
-/**
- * memread:
- * @addr: Guest address to read from.
- * @data: Pointer to where memory contents will be stored.
- * @size: Number of bytes to read.
- *
- * Read guest memory into a buffer.
- */
-static inline void memread(uint64_t addr, void *data, size_t size)
-{
- qtest_memread(global_qtest, addr, data, size);
-}
-
-/**
- * memwrite:
- * @addr: Guest address to write to.
- * @data: Pointer to the bytes that will be written to guest memory.
- * @size: Number of bytes to write.
- *
- * Write a buffer to guest memory.
- */
-static inline void memwrite(uint64_t addr, const void *data, size_t size)
-{
- qtest_memwrite(global_qtest, addr, data, size);
-}
-
-/**
- * clock_step_next:
- *
- * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
- *
- * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
- */
-static inline int64_t clock_step_next(void)
-{
- return qtest_clock_step_next(global_qtest);
-}
-
-/**
- * clock_step:
- * @step: Number of nanoseconds to advance the clock by.
- *
- * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
- *
- * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
- */
-static inline int64_t clock_step(int64_t step)
-{
- return qtest_clock_step(global_qtest, step);
-}
+#include "libqtest-single.h"
QDict *qmp_fd_receive(int fd);
void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num,
--
2.18.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 6/6] tests/libqtest: Use libqtest-single.h in tests that require global_qtest
2019-09-03 6:18 [Qemu-devel] [PATCH 0/6] Make the core libqtest library independe from global_qtest Thomas Huth
` (4 preceding siblings ...)
2019-09-03 6:18 ` [Qemu-devel] [PATCH 5/6] tests/libqtest: Move global_test wrapper function into a separate header Thomas Huth
@ 2019-09-03 6:18 ` Thomas Huth
5 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2019-09-03 6:18 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel; +Cc: Paolo Bonzini, Stefan Hajnoczi
Tests that require global_qtest or the related wrapper functions now
use the libqtest-single.h header that is dedicated for everything
related to global_qtest. The core libqtest.c and libqtest.h files are
now completely indepedent from global_qtest, so that the core library
is now not depending on a global state anymore.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/cpu-plug-test.c | 2 +-
tests/display-vga-test.c | 2 +-
tests/e1000e-test.c | 2 +-
tests/fdc-test.c | 2 +-
tests/i440fx-test.c | 2 +-
tests/i82801b11-test.c | 2 +-
tests/intel-hda-test.c | 2 +-
tests/ioh3420-test.c | 2 +-
tests/ipmi-kcs-test.c | 3 +--
tests/libqtest-single.h | 4 ++++
tests/libqtest.c | 2 --
tests/libqtest.h | 4 ----
tests/qos-test.c | 2 +-
tests/rtc-test.c | 2 +-
tests/rtl8139-test.c | 2 +-
tests/test-netfilter.c | 2 +-
tests/test-x86-cpuid-compat.c | 2 +-
tests/tmp105-test.c | 2 +-
tests/tpm-crb-test.c | 2 +-
tests/tpm-tests.c | 2 +-
tests/tpm-tis-test.c | 2 +-
tests/usb-hcd-ohci-test.c | 2 +-
tests/usb-hcd-uhci-test.c | 2 +-
tests/usb-hcd-xhci-test.c | 2 +-
tests/vhost-user-test.c | 2 +-
tests/virtio-blk-test.c | 2 +-
tests/virtio-ccw-test.c | 2 +-
tests/virtio-net-test.c | 2 +-
tests/virtio-scsi-test.c | 2 +-
tests/virtio-serial-test.c | 2 +-
30 files changed, 31 insertions(+), 34 deletions(-)
diff --git a/tests/cpu-plug-test.c b/tests/cpu-plug-test.c
index 3049620854..776407e1b6 100644
--- a/tests/cpu-plug-test.c
+++ b/tests/cpu-plug-test.c
@@ -10,7 +10,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "qapi/qmp/qdict.h"
struct PlugTestData {
diff --git a/tests/display-vga-test.c b/tests/display-vga-test.c
index bd176dcf3a..ace3bb28e0 100644
--- a/tests/display-vga-test.c
+++ b/tests/display-vga-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
static void pci_cirrus(void)
{
diff --git a/tests/e1000e-test.c b/tests/e1000e-test.c
index 93628c588d..1a232a663a 100644
--- a/tests/e1000e-test.c
+++ b/tests/e1000e-test.c
@@ -26,7 +26,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "qemu-common.h"
#include "libqos/pci-pc.h"
#include "qemu/sockets.h"
diff --git a/tests/fdc-test.c b/tests/fdc-test.c
index 31cd3295c1..26b69f7c5c 100644
--- a/tests/fdc-test.c
+++ b/tests/fdc-test.c
@@ -25,7 +25,7 @@
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "qapi/qmp/qdict.h"
#include "qemu-common.h"
diff --git a/tests/i440fx-test.c b/tests/i440fx-test.c
index 69205b58a8..1f57d9684b 100644
--- a/tests/i440fx-test.c
+++ b/tests/i440fx-test.c
@@ -14,7 +14,7 @@
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "libqos/pci.h"
#include "libqos/pci-pc.h"
#include "hw/pci/pci_regs.h"
diff --git a/tests/i82801b11-test.c b/tests/i82801b11-test.c
index a6e31594c9..4345da338b 100644
--- a/tests/i82801b11-test.c
+++ b/tests/i82801b11-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
/* Tests only initialization so far. TODO: Replace with functional tests */
static void nop(void)
diff --git a/tests/intel-hda-test.c b/tests/intel-hda-test.c
index b782b2e944..fc25ccc33c 100644
--- a/tests/intel-hda-test.c
+++ b/tests/intel-hda-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#define HDA_ID "hda0"
#define CODEC_DEVICES " -device hda-output,bus=" HDA_ID ".0" \
diff --git a/tests/ioh3420-test.c b/tests/ioh3420-test.c
index b54c4b9f11..f6ca43cca7 100644
--- a/tests/ioh3420-test.c
+++ b/tests/ioh3420-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
/* Tests only initialization so far. TODO: Replace with functional tests */
static void nop(void)
diff --git a/tests/ipmi-kcs-test.c b/tests/ipmi-kcs-test.c
index a2354c10c7..693a6aacb5 100644
--- a/tests/ipmi-kcs-test.c
+++ b/tests/ipmi-kcs-test.c
@@ -24,8 +24,7 @@
#include "qemu/osdep.h"
-
-#include "libqtest.h"
+#include "libqtest-single.h"
#define IPMI_IRQ 5
diff --git a/tests/libqtest-single.h b/tests/libqtest-single.h
index 49259558a5..6f1bb1331c 100644
--- a/tests/libqtest-single.h
+++ b/tests/libqtest-single.h
@@ -11,6 +11,10 @@
#ifndef LIBQTEST_SINGLE_H
#define LIBQTEST_SINGLE_H
+#include "libqtest.h"
+
+QTestState *global_qtest __attribute__((common, weak));
+
/**
* qtest_start:
* @args: other arguments to pass to QEMU
diff --git a/tests/libqtest.c b/tests/libqtest.c
index e5101d9d3a..0a6b91737e 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -35,8 +35,6 @@
#define SOCKET_TIMEOUT 50
#define SOCKET_MAX_FDS 16
-QTestState *global_qtest;
-
struct QTestState
{
int fd;
diff --git a/tests/libqtest.h b/tests/libqtest.h
index 6a7d7e41ad..c8cffe5d68 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -22,8 +22,6 @@
typedef struct QTestState QTestState;
-extern QTestState *global_qtest;
-
/**
* qtest_initf:
* @fmt...: Format for creating other arguments to pass to QEMU, formatted
@@ -641,8 +639,6 @@ void qtest_add_abrt_handler(GHookFunc fn, const void *data);
void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...)
GCC_FMT_ATTR(2, 3);
-#include "libqtest-single.h"
-
QDict *qmp_fd_receive(int fd);
void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num,
const char *fmt, va_list ap) GCC_FMT_ATTR(4, 0);
diff --git a/tests/qos-test.c b/tests/qos-test.c
index 3c0071b3b7..fd70d73ea5 100644
--- a/tests/qos-test.c
+++ b/tests/qos-test.c
@@ -18,7 +18,7 @@
#include "qemu/osdep.h"
#include <getopt.h>
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qstring.h"
diff --git a/tests/rtc-test.c b/tests/rtc-test.c
index 509be707e3..6309b0ef6c 100644
--- a/tests/rtc-test.c
+++ b/tests/rtc-test.c
@@ -13,7 +13,7 @@
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "qemu/timer.h"
#include "hw/timer/mc146818rtc_regs.h"
diff --git a/tests/rtl8139-test.c b/tests/rtl8139-test.c
index d6d0c24909..4506049264 100644
--- a/tests/rtl8139-test.c
+++ b/tests/rtl8139-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "libqos/pci-pc.h"
#include "qemu/timer.h"
#include "qemu-common.h"
diff --git a/tests/test-netfilter.c b/tests/test-netfilter.c
index e47075dd06..22927ee6ab 100644
--- a/tests/test-netfilter.c
+++ b/tests/test-netfilter.c
@@ -9,7 +9,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "qapi/qmp/qdict.h"
/* add a netfilter to a netdev and then remove it */
diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c
index e75b959950..772287bdb4 100644
--- a/tests/test-x86-cpuid-compat.c
+++ b/tests/test-x86-cpuid-compat.c
@@ -4,7 +4,7 @@
#include "qapi/qmp/qlist.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qbool.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
static char *get_cpu0_qom_path(void)
{
diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c
index f599309a4a..f930a96b83 100644
--- a/tests/tmp105-test.c
+++ b/tests/tmp105-test.c
@@ -9,7 +9,7 @@
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "libqos/qgraph.h"
#include "libqos/i2c.h"
#include "qapi/qmp/qdict.h"
diff --git a/tests/tpm-crb-test.c b/tests/tpm-crb-test.c
index a139caa51d..632fb7fbd8 100644
--- a/tests/tpm-crb-test.c
+++ b/tests/tpm-crb-test.c
@@ -15,7 +15,7 @@
#include "hw/acpi/tpm.h"
#include "io/channel-socket.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "qemu/module.h"
#include "tpm-emu.h"
diff --git a/tests/tpm-tests.c b/tests/tpm-tests.c
index e640777aa9..6e45a0ba85 100644
--- a/tests/tpm-tests.c
+++ b/tests/tpm-tests.c
@@ -15,7 +15,7 @@
#include "qemu/osdep.h"
#include <glib/gstdio.h>
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "tpm-tests.h"
static bool
diff --git a/tests/tpm-tis-test.c b/tests/tpm-tis-test.c
index 92a7e95aad..dcf30e05b7 100644
--- a/tests/tpm-tis-test.c
+++ b/tests/tpm-tis-test.c
@@ -17,7 +17,7 @@
#include "hw/acpi/tpm.h"
#include "io/channel-socket.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "qemu/module.h"
#include "tpm-emu.h"
diff --git a/tests/usb-hcd-ohci-test.c b/tests/usb-hcd-ohci-test.c
index 0cd73b7363..19d760f3fb 100644
--- a/tests/usb-hcd-ohci-test.c
+++ b/tests/usb-hcd-ohci-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "qemu/module.h"
#include "libqos/usb.h"
#include "libqos/qgraph.h"
diff --git a/tests/usb-hcd-uhci-test.c b/tests/usb-hcd-uhci-test.c
index 2eef8e3d1c..7a117b64d9 100644
--- a/tests/usb-hcd-uhci-test.c
+++ b/tests/usb-hcd-uhci-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "libqos/libqos.h"
#include "libqos/usb.h"
#include "libqos/libqos-pc.h"
diff --git a/tests/usb-hcd-xhci-test.c b/tests/usb-hcd-xhci-test.c
index 01845371f9..10ef9d2a91 100644
--- a/tests/usb-hcd-xhci-test.c
+++ b/tests/usb-hcd-xhci-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "libqos/usb.h"
diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 6ae8a23688..91ea373ba5 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -10,7 +10,7 @@
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "qapi/error.h"
#include "qapi/qmp/qdict.h"
#include "qemu/config-file.h"
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index 247fef0b0f..b41d907dc3 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -9,7 +9,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "qemu/bswap.h"
#include "qemu/module.h"
#include "standard-headers/linux/virtio_blk.h"
diff --git a/tests/virtio-ccw-test.c b/tests/virtio-ccw-test.c
index 9f445ef4ad..d05236407b 100644
--- a/tests/virtio-ccw-test.c
+++ b/tests/virtio-ccw-test.c
@@ -14,7 +14,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "libqos/virtio.h"
static void virtio_balloon_nop(void)
diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c
index 840875aaae..a08e2ffe12 100644
--- a/tests/virtio-net-test.c
+++ b/tests/virtio-net-test.c
@@ -9,7 +9,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "qemu/iov.h"
#include "qemu/module.h"
#include "qapi/qmp/qdict.h"
diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c
index 09348765d7..7c8f9b27f8 100644
--- a/tests/virtio-scsi-test.c
+++ b/tests/virtio-scsi-test.c
@@ -9,7 +9,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "qemu/module.h"
#include "scsi/constants.h"
#include "libqos/libqos-pc.h"
diff --git a/tests/virtio-serial-test.c b/tests/virtio-serial-test.c
index e584ad76e8..2541034822 100644
--- a/tests/virtio-serial-test.c
+++ b/tests/virtio-serial-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqtest-single.h"
#include "qemu/module.h"
#include "libqos/virtio-serial.h"
--
2.18.1
^ permalink raw reply related [flat|nested] 10+ messages in thread