From: Michal Privoznik <mprivozn(a)redhat.com>
Soon, the QEMU driver, specifically the part that picks firmware
based on firmware descriptor files (qemu_firmware.c) is going to
check for the presence of those firmware blobs (well, for their
realpath()). Just collect the list of all blobs we use in our
tests and mock virFileCanonicalizePath() so that for any path on
that list its strdup()-ed version is returned.
This means, qemuxmlconftest won't touch host files really.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tests/qemuxml2argvmock.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index e3f933c44f..9d10b5655f 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -33,6 +33,7 @@
#include "virscsivhost.h"
#include "virtpm.h"
#include "virutil.h"
+#include "virfile.h"
#include "qemu/qemu_interface.h"
#include "qemu/qemu_command.h"
#include "domain_interface.h"
@@ -296,3 +297,37 @@ virNetDevSetMTU(const char *ifname G_GNUC_UNUSED,
{
return 0;
}
+
+static char *(*real_virFileCanonicalizePath)(const char *path);
+
+char *
+virFileCanonicalizePath(const char *path)
+{
+ size_t i;
+ const char *fws[] = {
+ /* These are locations from our firmware descriptors
+ * stored in qemufirmwaredata/. */
+ "/usr/share/edk2/",
+ "/usr/share/OVMF/",
+ "/usr/share/AAVMF/",
+ "/usr/share/seabios/",
+
+ /* These are 'random' locations from domain XMLs stored
+ * in qemuxmlconfdata/. */
+ "/path/to/OVMF_CODE.fd",
+ "/path/to/guest_BOTH.fd",
+ "/path/to/OVMF_VARS.fd",
+ };
+
+ for (i = 0; i < G_N_ELEMENTS(fws); i++) {
+ if (STRPREFIX(path, fws[i])) {
+ return g_strdup(path);
+ }
+ }
+
+ if (!real_virFileCanonicalizePath) {
+ VIR_MOCK_REAL_INIT(virFileCanonicalizePath);
+ }
+
+ return real_virFileCanonicalizePath(path);
+}
--
2.49.1