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

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