Blame SOURCES/0423-virtfs-use-systemd-generator.patch

712866
From ca64eeec79c93b89aea51b3f26d9539db5cf2a65 Mon Sep 17 00:00:00 2001
712866
From: Harald Hoyer <harald@redhat.com>
712866
Date: Thu, 30 Jun 2016 15:22:47 +0200
712866
Subject: [PATCH] virtfs: use systemd generator
712866
712866
use a systemd generator, instead of a dracut hook to mount
712866
---
712866
 modules.d/95virtfs/module-setup.sh     |  7 +++++-
712866
 modules.d/95virtfs/parse-virtfs.sh     |  2 +-
712866
 modules.d/95virtfs/virtfs-generator.sh | 39 ++++++++++++++++++++++++++++++++++
712866
 3 files changed, 46 insertions(+), 2 deletions(-)
712866
 create mode 100755 modules.d/95virtfs/virtfs-generator.sh
712866
712866
diff --git a/modules.d/95virtfs/module-setup.sh b/modules.d/95virtfs/module-setup.sh
5c6c2a
index 12bd354b..3d80b75f 100755
712866
--- a/modules.d/95virtfs/module-setup.sh
712866
+++ b/modules.d/95virtfs/module-setup.sh
712866
@@ -37,5 +37,10 @@ installkernel() {
712866
 
712866
 install() {
712866
     inst_hook cmdline 95 "$moddir/parse-virtfs.sh"
712866
-    inst_hook mount 99 "$moddir/mount-virtfs.sh"
712866
+
712866
+    if ! dracut_module_included "systemd"; then
712866
+        inst_hook mount 99 "$moddir/mount-virtfs.sh"
712866
+    else
712866
+        inst_script "$moddir/virtfs-generator.sh" $systemdutildir/system-generators/dracut-virtfs-generator
712866
+    fi
712866
 }
712866
diff --git a/modules.d/95virtfs/parse-virtfs.sh b/modules.d/95virtfs/parse-virtfs.sh
5c6c2a
index ce6de6d4..a9ad48a9 100755
712866
--- a/modules.d/95virtfs/parse-virtfs.sh
712866
+++ b/modules.d/95virtfs/parse-virtfs.sh
712866
@@ -3,7 +3,7 @@
712866
 # ex: ts=8 sw=4 sts=4 et filetype=sh
712866
 
712866
 if [ "${root%%:*}" = "virtfs" ] ; then
712866
-    modprobe 9pnet_virtio
712866
+    initqueue --onetime modprobe -b -q 9pnet_virtio
712866
 
712866
     rootok=1
712866
 fi
712866
diff --git a/modules.d/95virtfs/virtfs-generator.sh b/modules.d/95virtfs/virtfs-generator.sh
712866
new file mode 100755
5c6c2a
index 00000000..3bdddf11
712866
--- /dev/null
712866
+++ b/modules.d/95virtfs/virtfs-generator.sh
712866
@@ -0,0 +1,39 @@
712866
+#!/bin/sh
712866
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
712866
+# ex: ts=8 sw=4 sts=4 et filetype=sh
712866
+
712866
+type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
712866
+
712866
+[ -z "$root" ] && root=$(getarg root=)
712866
+
712866
+[ "${root%%:*}" = "virtfs" ] || exit 0
712866
+
712866
+GENERATOR_DIR="$2"
712866
+[ -z "$GENERATOR_DIR" ] && exit 1
712866
+
712866
+[ -d "$GENERATOR_DIR" ] || mkdir "$GENERATOR_DIR"
712866
+
712866
+ROOTFLAGS=$(getarg rootflags=) || ROOTFLAGS="trans=virtio,version=9p2000.L"
712866
+ROOTFSTYPE=$(getarg rootfstype=) || ROOTFSTYPE="9p"
712866
+
712866
+root=${root#virtfs:}
712866
+
712866
+if getarg "ro"; then
712866
+    if [ -n "$ROOTFLAGS" ]; then
712866
+        ROOTFLAGS="$ROOTFLAGS,ro"
712866
+    else
712866
+        ROOTFLAGS="ro"
712866
+    fi
712866
+fi
712866
+
712866
+{
712866
+    echo "[Unit]"
712866
+    echo "Before=initrd-root-fs.target"
712866
+    echo "[Mount]"
712866
+    echo "Where=/sysroot"
712866
+    echo "What=${root}"
712866
+    [ -n "$ROOTFSTYPE" ] && echo "Type=${ROOTFSTYPE}"
712866
+    [ -n "$ROOTFLAGS" ] && echo "Options=${ROOTFLAGS}"
712866
+} > "$GENERATOR_DIR"/sysroot.mount
712866
+
712866
+exit 0