]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuxml2xmltest: Set dummy non-hypervisor drivers
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 25 Jun 2020 14:34:30 +0000 (16:34 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 26 Jun 2020 06:50:37 +0000 (08:50 +0200)
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>
tests/qemuxml2xmltest.c

index 5a124853b45d3f10145d546a8f409983c20c74a6..11ff17d83c29ac0d3490a9146c9e7f895caa9ccd 100644 (file)
@@ -135,6 +135,7 @@ mymain(void)
     char *fakerootdir;
     virQEMUDriverConfigPtr cfg = NULL;
     virHashTablePtr capslatest = NULL;
+    g_autoptr(virConnect) conn = NULL;
 
     capslatest = testQemuGetLatestCaps();
     if (!capslatest)
@@ -164,6 +165,16 @@ mymain(void)
     cfg = virQEMUDriverGetConfig(&driver);
     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, ...) \
     do { \
         static struct testQemuInfo info = { \
@@ -1471,6 +1482,7 @@ mymain(void)
     DO_TEST_CAPS_LATEST("virtio-9p-multidevs");
     DO_TEST("downscript", NONE);
 
+ cleanup:
     if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
         virFileDeleteTree(fakerootdir);