[PATCH 1/2] qemuxml2argvmock: Pretend FW blobs are always present

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Michal Privoznik <mprivozn@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux