[Libguestfs] [PATCH 2/3] Remove the --dtb option and all supporting code.

Richard W.M. Jones rjones at redhat.com
Wed Dec 7 14:04:45 UTC 2016


It used to be necessary to specify a DTB manually back in very old
versions of qemu on armv7.

However qemu has constructed a correct DTB for a very long time and
it's almost certainly a mistake if you are using the supermin --dtb
parameter to override that.  (For this reason, supermin will
intentionally give an error now if you try to use --dtb).

libguestfs stopped using this parameter in
commit af762e43424382d895d3a10aa6632adc601fdbad (2015-03-05).
---
 src/build.ml     |  5 ++--
 src/build.mli    |  2 +-
 src/kernel.ml    | 70 +-------------------------------------------------------
 src/kernel.mli   |  9 +++-----
 src/prepare.ml   |  2 +-
 src/prepare.mli  |  2 +-
 src/supermin.ml  |  7 ++----
 src/supermin.pod | 44 +++--------------------------------
 8 files changed, 14 insertions(+), 127 deletions(-)

diff --git a/src/build.ml b/src/build.ml
index 83a0d98..43aedc4 100644
--- a/src/build.ml
+++ b/src/build.ml
@@ -58,7 +58,7 @@ and string_of_file_content = function
   | Excludefiles -> "excludefiles"
 
 let rec build debug
-    (copy_kernel, dtb_wildcard, format, host_cpu,
+    (copy_kernel, format, host_cpu,
      packager_config, tmpdir, use_installed, size,
      include_packagelist)
     inputs outputdir =
@@ -222,11 +222,10 @@ let rec build debug
 
   | Ext2 ->
     let kernel = outputdir // "kernel"
-    and dtb = outputdir // "dtb"
     and appliance = outputdir // "root"
     and initrd = outputdir // "initrd" in
     let kernel_version, modpath =
-      Kernel.build_kernel debug host_cpu dtb_wildcard copy_kernel kernel dtb in
+      Kernel.build_kernel debug host_cpu copy_kernel kernel in
     Ext2.build_ext2 debug basedir files modpath kernel_version appliance size
       packagelist_file;
     Ext2_initrd.build_initrd debug tmpdir modpath initrd
diff --git a/src/build.mli b/src/build.mli
index 6feb4f8..0f8b956 100644
--- a/src/build.mli
+++ b/src/build.mli
@@ -18,6 +18,6 @@
 
 (** Implements the [--build] subcommand. *)
 
-val build : int -> (bool * string option * Types.format * string * string option * string * bool * int64 option * bool) -> string list -> string -> unit
+val build : int -> (bool * Types.format * string * string option * string * bool * int64 option * bool) -> string list -> string -> unit
 (** [build debug (args...) inputs outputdir] performs the
     [supermin --build] subcommand. *)
diff --git a/src/kernel.ml b/src/kernel.ml
index b4e89da..5d1ae66 100644
--- a/src/kernel.ml
+++ b/src/kernel.ml
@@ -39,7 +39,7 @@ let patt_of_cpu host_cpu =
   in
   List.map (fun model -> sprintf "vmlinu?-*-%s" model) models
 
-let rec build_kernel debug host_cpu dtb_wildcard copy_kernel kernel dtb =
+let rec build_kernel debug host_cpu copy_kernel kernel =
   (* Locate the kernel. *)
   let kernel_file, kernel_name, kernel_version, modpath =
     try
@@ -84,13 +84,6 @@ let rec build_kernel debug host_cpu dtb_wildcard copy_kernel kernel dtb =
       ) else
         find_kernel debug host_cpu kernel in
 
-  (* If the user passed --dtb option, locate dtb. *)
-  (match dtb_wildcard with
-  | None -> ()
-  | Some wildcard ->
-    find_dtb debug copy_kernel kernel_name wildcard dtb
-  );
-
   if debug >= 1 then (
     printf "supermin: kernel: kernel_version %s\n" kernel_version;
     printf "supermin: kernel: modules %s\n%!" modpath;
@@ -161,67 +154,6 @@ installed, try installing a fullvirt kernel (only for
 supermin use, you shouldn't boot the Xen guest with it)."
     host_cpu
 
-and find_dtb debug copy_kernel kernel_name wildcard dtb =
-  let dtb_file =
-    try
-      let dtb_file = getenv "SUPERMIN_DTB" in
-      if debug >= 1 then
-        printf "supermin: kernel: SUPERMIN_DTB environment variable = %s\n%!"
-          dtb_file;
-      dtb_file
-    with Not_found ->
-      (* Replace vmlinuz- with dtb- *)
-      if not (string_prefix "vmlinuz-" kernel_name) &&
-        not (string_prefix "vmlinuz-" kernel_name) then
-        no_dtb_dir kernel_name;
-      let dtb_dir =
-        try
-          List.find dir_exists (
-            List.map (fun prefix ->
-              prefix ^ String.sub kernel_name 8 (String.length kernel_name - 8)
-            ) ["/boot/dtb-"; "/usr/lib/linux-image-"])
-        with Not_found ->
-          no_dtb_dir kernel_name; ""
-      in
-
-      let all_files = Sys.readdir dtb_dir in
-      let all_files = Array.to_list all_files in
-
-      let files =
-        List.filter (fun filename -> fnmatch wildcard filename [FNM_NOESCAPE])
-          all_files in
-      if files = [] then
-        no_dtb dtb_dir wildcard;
-
-      let dtb_name = List.hd files in
-      let dtb_file = dtb_dir // dtb_name in
-      if debug >= 1 then
-        printf "supermin: kernel: picked dtb %s\n%!" dtb_file;
-      dtb_file in
-
-  copy_or_symlink_file copy_kernel dtb_file dtb
-
-and no_dtb_dir kernel_name =
-  error "\
-failed to find a dtb (device tree) directory.
-
-I expected to take '%s' and to
-replace vmlinuz- with dtb- to form a directory.
-
-You can set SUPERMIN_KERNEL, SUPERMIN_MODULES and SUPERMIN_DTB
-to override automatic selection.  See supermin(1)."
-    kernel_name
-
-and no_dtb dtb_dir wildcard =
-  error "\
-failed to find a matching device tree.
-
-I looked for a file matching '%s' in directory '%s'.
-
-You can set SUPERMIN_KERNEL, SUPERMIN_MODULES and SUPERMIN_DTB
-to override automatic selection.  See supermin(1)."
-    wildcard dtb_dir
-
 and find_modpath debug kernel_version =
   try
     let modpath = getenv "SUPERMIN_MODULES" in
diff --git a/src/kernel.mli b/src/kernel.mli
index 36b4ab7..35a1273 100644
--- a/src/kernel.mli
+++ b/src/kernel.mli
@@ -21,15 +21,12 @@
 
     See also the {!Ext2} module. *)
 
-val build_kernel : int -> string -> string option -> bool -> string -> string -> string * string
-(** [build_kernel debug host_cpu dtb_wildcard copy_kernel kernel dtb]
+val build_kernel : int -> string -> bool -> string -> string * string
+(** [build_kernel debug host_cpu copy_kernel kernel]
     chooses the kernel to use and links to it or copies it into the
     appliance directory.
 
     The output is written to the file [kernel].
 
     The function returns the [kernel_version, modpath] tuple as a
-    side-effect of locating the kernel.
-
-    The [--dtb] option is also handled here, but that support is
-    now effectively obsolete and will be removed in future. *)
+    side-effect of locating the kernel. *)
diff --git a/src/prepare.ml b/src/prepare.ml
index 830b620..e8cf058 100644
--- a/src/prepare.ml
+++ b/src/prepare.ml
@@ -21,7 +21,7 @@ open Printf
 open Package_handler
 open Utils
 
-let prepare debug (copy_kernel, dtb_wildcard, format, host_cpu,
+let prepare debug (copy_kernel, format, host_cpu,
              packager_config, tmpdir, use_installed, size,
              include_packagelist)
     inputs outputdir =
diff --git a/src/prepare.mli b/src/prepare.mli
index 404302a..e2d677a 100644
--- a/src/prepare.mli
+++ b/src/prepare.mli
@@ -18,6 +18,6 @@
 
 (** Implements the [--prepare] subcommand. *)
 
-val prepare : int -> (bool * string option * Types.format * string * string option * string * bool * int64 option * bool) -> string list -> string -> unit
+val prepare : int -> (bool * Types.format * string * string option * string * bool * int64 option * bool) -> string list -> string -> unit
 (** [prepare debug (args...) inputs outputdir] performs the
     [supermin --prepare] subcommand. *)
diff --git a/src/supermin.ml b/src/supermin.ml
index a09b498..6dd75b2 100644
--- a/src/supermin.ml
+++ b/src/supermin.ml
@@ -86,7 +86,6 @@ let main () =
 
     let copy_kernel = ref false in
     let debug = ref 0 in
-    let dtb_wildcard = ref "" in
     let format = ref None in
     let host_cpu = ref Config.host_cpu in
     let if_newer = ref false in
@@ -134,7 +133,6 @@ or upgrade to libguestfs >= 1.26.
     let argspec = Arg.align [
       "--build",   Arg.Unit set_build_mode,   " Build a full appliance";
       "--copy-kernel", Arg.Set copy_kernel,   " Copy kernel instead of symlinking";
-      "--dtb",     Arg.Set_string dtb_wildcard, "WILDCARD Find device tree matching wildcard";
       "-f",        Arg.String set_format,     "chroot|ext2 Set output format";
       "--format",  Arg.String set_format,     ditto;
       "--host-cpu", Arg.Set_string host_cpu,  "ARCH Set host CPU architecture";
@@ -160,7 +158,6 @@ or upgrade to libguestfs >= 1.26.
 
     let copy_kernel = !copy_kernel in
     let debug = !debug in
-    let dtb_wildcard = match !dtb_wildcard with "" -> None | s -> Some s in
     let host_cpu = !host_cpu in
     let if_newer = !if_newer in
     let inputs = List.rev !inputs in
@@ -191,7 +188,7 @@ or upgrade to libguestfs >= 1.26.
       else outputdir in
 
     debug, mode, if_newer, inputs, lockfile, outputdir,
-    (copy_kernel, dtb_wildcard, format, host_cpu,
+    (copy_kernel, format, host_cpu,
      packager_config, tmpdir, use_installed, size,
      include_packagelist) in
 
@@ -201,7 +198,7 @@ or upgrade to libguestfs >= 1.26.
    * This fails with an error if one could not be located.
    *)
   let () =
-    let (_, _, _, _, packager_config, tmpdir, _, _, _) = args in
+    let (_, _, _, packager_config, tmpdir, _, _, _) = args in
     let settings = {
       debug = debug;
       tmpdir = tmpdir;
diff --git a/src/supermin.pod b/src/supermin.pod
index 8c9aca7..4581201 100644
--- a/src/supermin.pod
+++ b/src/supermin.pod
@@ -143,40 +143,6 @@ the kernel in F</boot>.
 This is fractionally slower, but is necessary if you want to change
 the permissions or SELinux label on the kernel or device tree.
 
-=item B<--dtb> WILDCARD
-
-(I<--build> mode only)
-
-If specified, search for a device tree which is compatible with the
-selected kernel and the name of which matches the given wildcard.  You
-can use a wildcard such as C<vexpress-*a9*.dtb> which would match
-F<vexpress-v2p-ca9.dtb>.
-
-Notes:
-
-=over 4
-
-=item *
-
-You may need to quote the wildcard to prevent it from being expanded
-by your shell.
-
-=item *
-
-If no I<--dtb> option is given, no device tree will be looked for.
-
-=item *
-
-You only need a device tree on architectures such as ARM and PowerPC
-which use them.  On other architectures, don't use this option.
-
-=item *
-
-If you use this option and no compatible device tree can be found,
-supermin will exit with an error.
-
-=back
-
 =item B<-f> FORMAT
 
 =item B<--format> FORMAT
@@ -202,15 +168,15 @@ This is called a C<chroot> because you could literally L<chroot(1)>
 into this directory afterwards, although it's a better idea to use a
 container technology (LXC, etc.).
 
-No kernel, initrd or dtb is generated in this mode because it is
+No kernel or initrd is generated in this mode because it is
 assumed that you will be running the appliance using the host kernel.
 
 =item ext2
 
 An ext2 filesystem disk image.
 
-The output kernel is written to F<OUTPUTDIR/kernel>, the device tree
-(if using) to F<OUTPUTDIR/dtb>, a small initramfs which can mount the
+The output kernel is written to F<OUTPUTDIR/kernel>,
+a small initramfs which can mount the
 appliance to F<OUTPUTDIR/initrd>, and the ext2 filesystem image to
 F<OUTPUTDIR/root>.  (Where F<OUTPUTDIR> is specified by the I<-o>
 option).
@@ -543,10 +509,6 @@ This specifies the kernel modules directory to use.
 The environment variable should point to a module directory,
 eg. F</lib/modules/3.0.x86_64/>
 
-=item SUPERMIN_DTB
-
-Force the given device tree file to be used.
-
 =item SUPERMIN_KERNEL_VERSION
 
 On non-x86 architectures, you may need to set this environment
-- 
2.10.2




More information about the Libguestfs mailing list