[Libguestfs] [PATCH supermin] init: Add a blacklist of kmods that we want to exclude from the mini initrd.

Richard W.M. Jones rjones at redhat.com
Fri Mar 18 12:12:29 UTC 2016


We want to exclude virtio-gpu since it's irrelevant, large, and pulls
in other unwanted dependencies (modeswitching, drm).  Add a second
list of kmods which is a blacklist, applied after the first.

This reduces the libguestfs initrd size from 39M down to 17M, with
concomitant small reductions in boot time.
---
 src/ext2_initrd.ml | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/ext2_initrd.ml b/src/ext2_initrd.ml
index 63ed493..a177018 100644
--- a/src/ext2_initrd.ml
+++ b/src/ext2_initrd.ml
@@ -54,6 +54,13 @@ let kmods = [
   "megaraid*.ko*";
 ]
 
+(* A blacklist of kmods which match the above patterns, but which we
+ * subsequently remove.
+ *)
+let not_kmods = [
+  "virtio-gpu.ko*";
+]
+
 let rec build_initrd debug tmpdir modpath initrd =
   if debug >= 1 then
     printf "supermin: ext2: creating minimal initrd '%s'\n%!" initrd;
@@ -73,7 +80,8 @@ let rec build_initrd debug tmpdir modpath initrd =
       fun topset modl ->
         let m = Filename.basename modl in
         let matches wildcard = fnmatch wildcard m [FNM_PATHNAME] in
-        if List.exists matches kmods then
+        if List.exists matches kmods && not (List.exists matches not_kmods)
+        then
           StringSet.add modl topset
         else
           topset
-- 
2.7.3




More information about the Libguestfs mailing list