[Libguestfs] [PATCH 1/2] utils: Move UEFI firmware lists to src/uefi.c.

Richard W.M. Jones rjones at redhat.com
Sun May 22 20:34:19 UTC 2016


Just code motion, no functional change.
---
 docs/C_SOURCE_FILES             |  1 +
 src/Makefile.am                 |  1 +
 src/guestfs-internal-frontend.h |  1 +
 src/uefi.c                      | 68 +++++++++++++++++++++++++++++++++++++++++
 src/utils.c                     | 40 ------------------------
 v2v/utils.ml                    |  2 +-
 6 files changed, 72 insertions(+), 41 deletions(-)
 create mode 100644 src/uefi.c

diff --git a/docs/C_SOURCE_FILES b/docs/C_SOURCE_FILES
index d60974e..bd55f40 100644
--- a/docs/C_SOURCE_FILES
+++ b/docs/C_SOURCE_FILES
@@ -261,6 +261,7 @@ src/structs-copy.c
 src/structs-free.c
 src/structs-print.c
 src/tmpdirs.c
+src/uefi.c
 src/umask.c
 src/unit-tests.c
 src/utils.c
diff --git a/src/Makefile.am b/src/Makefile.am
index bdac5e3..d659f8d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -235,6 +235,7 @@ libutils_la_SOURCES = \
 	structs-cleanup.c \
 	structs-print.c \
 	structs-print.h \
+	uefi.c \
 	utils.c
 libutils_la_CPPFLAGS = $(libguestfs_la_CPPFLAGS)
 libutils_la_CFLAGS = $(libguestfs_la_CFLAGS)
diff --git a/src/guestfs-internal-frontend.h b/src/guestfs-internal-frontend.h
index 8ba8a25..1490c6e 100644
--- a/src/guestfs-internal-frontend.h
+++ b/src/guestfs-internal-frontend.h
@@ -92,6 +92,7 @@ extern void guestfs_int_fadvise_noreuse (int fd);
 //extern void guestfs_int_fadvise_willneed (int fd);
 extern char *guestfs_int_shell_unquote (const char *str);
 
+/* uefi.c */
 struct uefi_firmware {
   const char *code;		/* code file (NULL = end of list) */
   const char *code_debug;	/* code file with debugging msgs (may be NULL)*/
diff --git a/src/uefi.c b/src/uefi.c
new file mode 100644
index 0000000..0dd2adb
--- /dev/null
+++ b/src/uefi.c
@@ -0,0 +1,68 @@
+/* libguestfs
+ * Copyright (C) 2009-2016 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * Locations of UEFI files.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+
+/* NB: MUST NOT include "guestfs-internal.h". */
+#include "guestfs-internal-frontend.h"
+
+/* See src/appliance.c:guestfs_int_get_uefi. */
+struct uefi_firmware
+guestfs_int_ovmf_i386_firmware[] = {
+  { "/usr/share/edk2.git/ovmf-ia32/OVMF_CODE-pure-efi.fd",
+    NULL,
+    "/usr/share/edk2.git/ovmf-ia32/OVMF_VARS-pure-efi.fd" },
+
+  { NULL }
+};
+
+struct uefi_firmware
+guestfs_int_ovmf_x86_64_firmware[] = {
+  { "/usr/share/OVMF/OVMF_CODE.fd",
+    NULL,
+    "/usr/share/OVMF/OVMF_VARS.fd" },
+
+  { "/usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd",
+    NULL,
+    "/usr/share/edk2.git/ovmf-x64/OVMF_VARS-pure-efi.fd" },
+
+  { "/usr/share/qemu/ovmf-x86_64-code.bin",
+    NULL,
+    "/usr/share/qemu/ovmf-x86_64-vars.bin" },
+
+  { NULL }
+};
+
+struct uefi_firmware
+guestfs_int_aavmf_firmware[] = {
+  { "/usr/share/AAVMF/AAVMF_CODE.fd",
+    "/usr/share/AAVMF/AAVMF_CODE.verbose.fd",
+    "/usr/share/AAVMF/AAVMF_VARS.fd" },
+
+  { "/usr/share/edk2.git/aarch64/QEMU_EFI-pflash.raw",
+    NULL,
+    "/usr/share/edk2.git/aarch64/vars-template-pflash.raw" },
+
+  { NULL }
+};
diff --git a/src/utils.c b/src/utils.c
index 4faff9e..47ff9f8 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -354,46 +354,6 @@ guestfs_int_is_true (const char *str)
   return -1;
 }
 
-/* See src/appliance.c:guestfs_int_get_uefi. */
-struct uefi_firmware
-guestfs_int_ovmf_i386_firmware[] = {
-  { "/usr/share/edk2.git/ovmf-ia32/OVMF_CODE-pure-efi.fd",
-    NULL,
-    "/usr/share/edk2.git/ovmf-ia32/OVMF_VARS-pure-efi.fd" },
-
-  { NULL }
-};
-
-struct uefi_firmware
-guestfs_int_ovmf_x86_64_firmware[] = {
-  { "/usr/share/OVMF/OVMF_CODE.fd",
-    NULL,
-    "/usr/share/OVMF/OVMF_VARS.fd" },
-
-  { "/usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd",
-    NULL,
-    "/usr/share/edk2.git/ovmf-x64/OVMF_VARS-pure-efi.fd" },
-
-  { "/usr/share/qemu/ovmf-x86_64-code.bin",
-    NULL,
-    "/usr/share/qemu/ovmf-x86_64-vars.bin" },
-
-  { NULL }
-};
-
-struct uefi_firmware
-guestfs_int_aavmf_firmware[] = {
-  { "/usr/share/AAVMF/AAVMF_CODE.fd",
-    "/usr/share/AAVMF/AAVMF_CODE.verbose.fd",
-    "/usr/share/AAVMF/AAVMF_VARS.fd" },
-
-  { "/usr/share/edk2.git/aarch64/QEMU_EFI-pflash.raw",
-    NULL,
-    "/usr/share/edk2.git/aarch64/vars-template-pflash.raw" },
-
-  { NULL }
-};
-
 #if 0 /* not used yet */
 /**
  * Hint that we will read or write the file descriptor normally.
diff --git a/v2v/utils.ml b/v2v/utils.ml
index fc1c502..2dff6aa 100644
--- a/v2v/utils.ml
+++ b/v2v/utils.ml
@@ -93,7 +93,7 @@ external aavmf_firmware : unit -> uefi_firmware list = "v2v_utils_aavmf_firmware
 (* Find the UEFI firmware. *)
 let find_uefi_firmware guest_arch =
   let files =
-    (* The lists of firmware are actually defined in src/utils.c. *)
+    (* The lists of firmware are actually defined in src/uefi.c. *)
     match guest_arch with
     | "i386" | "i486" | "i586" | "i686" -> ovmf_i386_firmware ()
     | "x86_64" -> ovmf_x86_64_firmware ()
-- 
2.7.4




More information about the Libguestfs mailing list