1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

qemuxml2xmltest: Set dummy non-hypervisor drivers

When parsing domain XML post parse callbacks are run and one of
them might try and call API from a non-hypervisor driver (e.g.
just like qemuDomainDeviceNetDefPostParse() is doing - it calls a
network API). To avoid this in the test suite, set dummy drivers,
which renders all non-hypervisor APIs return error.

This mimics what qemuxml2argvtest does.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Michal Privoznik 2020-06-25 16:34:30 +02:00
parent bac096fff0
commit b1d5206f4f

View File

@ -135,6 +135,7 @@ mymain(void)
char *fakerootdir; char *fakerootdir;
virQEMUDriverConfigPtr cfg = NULL; virQEMUDriverConfigPtr cfg = NULL;
virHashTablePtr capslatest = NULL; virHashTablePtr capslatest = NULL;
g_autoptr(virConnect) conn = NULL;
capslatest = testQemuGetLatestCaps(); capslatest = testQemuGetLatestCaps();
if (!capslatest) if (!capslatest)
@ -164,6 +165,16 @@ mymain(void)
cfg = virQEMUDriverGetConfig(&driver); cfg = virQEMUDriverGetConfig(&driver);
driver.privileged = true; driver.privileged = true;
if (!(conn = virGetConnect()))
goto cleanup;
virSetConnectInterface(conn);
virSetConnectNetwork(conn);
virSetConnectNWFilter(conn);
virSetConnectNodeDev(conn);
virSetConnectSecret(conn);
virSetConnectStorage(conn);
# define DO_TEST_INTERNAL(_name, suffix, when, ...) \ # define DO_TEST_INTERNAL(_name, suffix, when, ...) \
do { \ do { \
static struct testQemuInfo info = { \ static struct testQemuInfo info = { \
@ -1471,6 +1482,7 @@ mymain(void)
DO_TEST_CAPS_LATEST("virtio-9p-multidevs"); DO_TEST_CAPS_LATEST("virtio-9p-multidevs");
DO_TEST("downscript", NONE); DO_TEST("downscript", NONE);
cleanup:
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
virFileDeleteTree(fakerootdir); virFileDeleteTree(fakerootdir);