libqos: Use explicit QTestState for remaining libqos operations

Drop one more client of global_qtest by teaching all remaining
libqos stragglers to pass in an explicit QTestState.  Change the
setting of global_qtest from being implicit in libqos' call to
qtest_start() to instead be explicit in all clients that are
still relying on global_qtest.

Note that qmp_execute() can be greatly simplified in the process,
and that we also get rid of interpolation of a JSON string into a
temporary variable when qtest_qmp() can do it more reliably.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Greg Kurz <groug@kaod.org>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
Eric Blake 2017-09-11 12:20:01 -05:00 committed by Thomas Huth
parent 10747e55d5
commit 3d95fb9770
11 changed files with 39 additions and 35 deletions

View file

@ -54,18 +54,21 @@ static QVirtioPCIDevice *virtio_net_pci_init(QPCIBus *bus, int slot)
static QOSState *pci_test_start(int socket)
{
QOSState *qs;
const char *arch = qtest_get_arch();
const char *cmd = "-netdev socket,fd=%d,id=hs0 -device "
"virtio-net-pci,netdev=hs0";
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
return qtest_pc_boot(cmd, socket);
qs = qtest_pc_boot(cmd, socket);
} else if (strcmp(arch, "ppc64") == 0) {
qs = qtest_spapr_boot(cmd, socket);
} else {
g_printerr("virtio-net tests are only available on x86 or ppc64\n");
exit(EXIT_FAILURE);
}
if (strcmp(arch, "ppc64") == 0) {
return qtest_spapr_boot(cmd, socket);
}
g_printerr("virtio-net tests are only available on x86 or ppc64\n");
exit(EXIT_FAILURE);
global_qtest = qs->qts;
return qs;
}
static void driver_init(QVirtioDevice *dev)