From: Thomas Huth <thuth@redhat.com>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: Igor Mammedov <imammedo@redhat.com>, John Snow <jsnow@redhat.com>,
Laurent Vivier <lvivier@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Ben Warren <ben@skyportsystems.com>
Subject: [Qemu-devel] [PATCH for-3.2 4/7] ivshmem-test: Drop dependence on global_qtest
Date: Mon, 12 Nov 2018 20:08:07 +0100 [thread overview]
Message-ID: <1542049690-12826-5-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1542049690-12826-1-git-send-email-thuth@redhat.com>
From: Eric Blake <eblake@redhat.com>
Managing parallel connections to two different monitors via
the implicit global_qtest makes it hard to copy-and-paste code
to tests that are not aware of the implicit state. Since we
have already fixed qpci to avoid global_qtest, we can now
simplify by not using global_qtest anywhere in ivshmem-test.
We can assert that the conversion is correct by checking that
global_qtest remains NULL throughout the test (a later patch
that changes global_qtest to not be a public global variable
will drop the assertions).
Signed-off-by: Eric Blake <eblake@redhat.com>
[thuth: Dropped the changes to test_ivshmem_hotplug() - will be fixed later]
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/ivshmem-test.c | 18 +-----------------
1 file changed, 1 insertion(+), 17 deletions(-)
diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c
index c37b196..089e268 100644
--- a/tests/ivshmem-test.c
+++ b/tests/ivshmem-test.c
@@ -71,13 +71,10 @@ static const char* reg2str(enum Reg reg) {
static inline unsigned in_reg(IVState *s, enum Reg reg)
{
const char *name = reg2str(reg);
- QTestState *qtest = global_qtest;
unsigned res;
- global_qtest = s->qs->qts;
res = qpci_io_readl(s->dev, s->reg_bar, reg);
g_test_message("*%s -> %x\n", name, res);
- global_qtest = qtest;
return res;
}
@@ -85,35 +82,25 @@ static inline unsigned in_reg(IVState *s, enum Reg reg)
static inline void out_reg(IVState *s, enum Reg reg, unsigned v)
{
const char *name = reg2str(reg);
- QTestState *qtest = global_qtest;
- global_qtest = s->qs->qts;
g_test_message("%x -> *%s\n", v, name);
qpci_io_writel(s->dev, s->reg_bar, reg, v);
- global_qtest = qtest;
}
static inline void read_mem(IVState *s, uint64_t off, void *buf, size_t len)
{
- QTestState *qtest = global_qtest;
-
- global_qtest = s->qs->qts;
qpci_memread(s->dev, s->mem_bar, off, buf, len);
- global_qtest = qtest;
}
static inline void write_mem(IVState *s, uint64_t off,
const void *buf, size_t len)
{
- QTestState *qtest = global_qtest;
-
- global_qtest = s->qs->qts;
qpci_memwrite(s->dev, s->mem_bar, off, buf, len);
- global_qtest = qtest;
}
static void cleanup_vm(IVState *s)
{
+ assert(!global_qtest);
g_free(s->dev);
qtest_shutdown(s->qs);
}
@@ -131,7 +118,6 @@ static void setup_vm_cmd(IVState *s, const char *cmd, bool msix)
g_printerr("ivshmem-test tests are only available on x86 or ppc64\n");
exit(EXIT_FAILURE);
}
- global_qtest = s->qs->qts;
s->dev = get_device(s->qs->pcibus);
s->reg_bar = qpci_iomap(s->dev, 0, &barsize);
@@ -354,7 +340,6 @@ static void test_ivshmem_server(bool msi)
g_assert_cmpint(vm1, !=, vm2);
/* check number of MSI-X vectors */
- global_qtest = s1->qs->qts;
if (msi) {
ret = qpci_msix_table_size(s1->dev);
g_assert_cmpuint(ret, ==, nvectors);
@@ -377,7 +362,6 @@ static void test_ivshmem_server(bool msi)
g_assert_cmpuint(ret, !=, 0);
/* ping vm1 -> vm2 on vector 1 */
- global_qtest = s2->qs->qts;
if (msi) {
ret = qpci_msix_pending(s2->dev, 1);
g_assert_cmpuint(ret, ==, 0);
--
1.8.3.1
next prev parent reply other threads:[~2018-11-12 19:08 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-12 19:08 [Qemu-devel] [PATCH v1 for-3.2 0/7] Get rid of global_qtest in some of the qtests Thomas Huth
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 1/7] tests/pvpanic: Make the pvpanic test independent of global_qtest Thomas Huth
2018-11-13 0:47 ` Eric Blake
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 2/7] tests/libqos/pci: Make PCI access functions " Thomas Huth
2018-11-12 19:33 ` Paolo Bonzini
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 3/7] ahci-test: Drop dependence on global_qtest Thomas Huth
2018-11-14 0:10 ` John Snow
2018-11-27 14:55 ` Eric Blake
2018-11-12 19:08 ` Thomas Huth [this message]
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 5/7] tests/acpi-utils: " Thomas Huth
2018-11-27 14:30 ` Igor Mammedov
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 6/7] tests/vmgenid: Make test independent of global_qtest Thomas Huth
2018-11-27 14:38 ` Igor Mammedov
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 7/7] tests/boot-serial: Get rid of global_qtest variable Thomas Huth
2018-11-13 11:38 ` [Qemu-devel] [PATCH v1 for-3.2 0/7] Get rid of global_qtest in some of the qtests no-reply
2018-11-13 12:31 ` Thomas Huth
2018-11-13 13:36 ` Laurent Vivier
2018-11-13 14:28 ` Thomas Huth
2018-11-13 15:11 ` [Qemu-devel] [PATCH] tests/ide: Free pcibus when finishing a test Thomas Huth
2018-11-13 15:54 ` Eric Blake
2018-11-13 16:34 ` Philippe Mathieu-Daudé
2018-11-14 0:56 ` John Snow
2018-11-14 13:05 ` [Qemu-devel] [PATCH v1 for-3.2 0/7] Get rid of global_qtest in some of the qtests no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1542049690-12826-5-git-send-email-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=ben@skyportsystems.com \
--cc=eblake@redhat.com \
--cc=imammedo@redhat.com \
--cc=jsnow@redhat.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).