]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuxml2xmltest: Redirect access to FW descriptor dirs
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Mon, 12 Aug 2019 15:06:22 +0000 (12:06 -0300)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 13 Aug 2019 07:48:39 +0000 (09:48 +0200)
If /etc/qemu/firmware directory exists, but is not readable then
qemuxml2xmltest fails. This is because once domain XML is parsed
it is validated. For that domain capabilities are needed.
However, when constructing domain capabilities, FW descriptors
are loaded and this is the point where the test fails, because it
fails to open one of the directories.

Fixes: 5b9819eedc domain capabilities: Expose firmware auto selection feature
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
tests/Makefile.am
tests/qemuxml2xmltest.c

index 1c92e3ca6f059c29716ad2cde49d65b7228d6db5..31a22ebefdc9d8dfe265af592393a69a8f6702de 100644 (file)
@@ -573,7 +573,8 @@ qemuxml2argvmock_la_LIBADD = $(MOCKLIBS_LIBS)
 
 qemuxml2xmltest_SOURCES = \
        qemuxml2xmltest.c testutilsqemu.c testutilsqemu.h \
-       testutils.c testutils.h
+       testutils.c testutils.h \
+       virfilewrapper.c virfilewrapper.h
 qemuxml2xmltest_LDADD = $(qemu_LDADDS)
 
 qemumonitorjsontest_SOURCES = \
index 525eb9a74061454ac0fb1721347e7cdb2d319d51..e67f1c7460766a1a7c91b972881b14a185649a2f 100644 (file)
@@ -14,6 +14,8 @@
 # include "qemu/qemu_domain.h"
 # include "testutilsqemu.h"
 # include "virstring.h"
+# include "virfilewrapper.h"
+# include "configmake.h"
 
 # define VIR_FROM_THIS VIR_FROM_NONE
 
@@ -167,6 +169,15 @@ mymain(void)
 
     setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
 
+    /* Required for tpm-emulator tests
+     */
+    virFileWrapperAddPrefix(SYSCONFDIR "/qemu/firmware",
+                            abs_srcdir "/qemufirmwaredata/etc/qemu/firmware");
+    virFileWrapperAddPrefix(PREFIX "/share/qemu/firmware",
+                            abs_srcdir "/qemufirmwaredata/usr/share/qemu/firmware");
+    virFileWrapperAddPrefix("/home/user/.config/qemu/firmware",
+                            abs_srcdir "/qemufirmwaredata/home/user/.config/qemu/firmware");
+
     if (qemuTestDriverInit(&driver) < 0)
         return EXIT_FAILURE;
 
@@ -1325,6 +1336,7 @@ mymain(void)
     virHashFree(capslatest);
     qemuTestDriverFree(&driver);
     VIR_FREE(fakerootdir);
+    virFileWrapperClearPrefixes();
 
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }