Harald Hoyer b3dfe7
From 21789cbb0a6d103176a2e10c9dd456cdcdcb4b94 Mon Sep 17 00:00:00 2001
Harald Hoyer b3dfe7
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer b3dfe7
Date: Wed, 25 Oct 2017 12:53:47 +0200
Harald Hoyer b3dfe7
Subject: [PATCH] make qemu and qemu-net a default module in non-hostonly mode
Harald Hoyer b3dfe7
Harald Hoyer b3dfe7
---
Harald Hoyer b3dfe7
 modules.d/90qemu-net/module-setup.sh | 31 ++++++++++++++++--------------
Harald Hoyer b3dfe7
 modules.d/90qemu/module-setup.sh     | 37 ++++++++++++++++++++----------------
Harald Hoyer b3dfe7
 2 files changed, 38 insertions(+), 30 deletions(-)
Harald Hoyer b3dfe7
Harald Hoyer b3dfe7
diff --git a/modules.d/90qemu-net/module-setup.sh b/modules.d/90qemu-net/module-setup.sh
Harald Hoyer b3dfe7
index 58f12339..121e83df 100755
Harald Hoyer b3dfe7
--- a/modules.d/90qemu-net/module-setup.sh
Harald Hoyer b3dfe7
+++ b/modules.d/90qemu-net/module-setup.sh
Harald Hoyer b3dfe7
@@ -2,22 +2,25 @@
Harald Hoyer b3dfe7
 
Harald Hoyer b3dfe7
 # called by dracut
Harald Hoyer b3dfe7
 check() {
Harald Hoyer b3dfe7
-    if type -P systemd-detect-virt >/dev/null 2>&1; then
Harald Hoyer b3dfe7
-        vm=$(systemd-detect-virt --vm >/dev/null 2>&1)
Harald Hoyer b3dfe7
-        (($? != 0)) && return 255
Harald Hoyer b3dfe7
-        [[ $vm = "qemu" ]] && return 0
Harald Hoyer b3dfe7
-        [[ $vm = "kvm" ]] && return 0
Harald Hoyer b3dfe7
-        [[ $vm = "bochs" ]] && return 0
Harald Hoyer b3dfe7
-    fi
Harald Hoyer b3dfe7
+    if [[ $hostonly ]] || [[ $mount_needs ]]; then
Harald Hoyer b3dfe7
+        if type -P systemd-detect-virt >/dev/null 2>&1; then
Harald Hoyer b3dfe7
+            vm=$(systemd-detect-virt --vm >/dev/null 2>&1)
Harald Hoyer b3dfe7
+            (($? != 0)) && return 255
Harald Hoyer b3dfe7
+            [[ $vm = "qemu" ]] && return 0
Harald Hoyer b3dfe7
+            [[ $vm = "kvm" ]] && return 0
Harald Hoyer b3dfe7
+            [[ $vm = "bochs" ]] && return 0
Harald Hoyer b3dfe7
+        fi
Harald Hoyer b3dfe7
 
Harald Hoyer b3dfe7
-    for i in /sys/class/dmi/id/*_vendor; do
Harald Hoyer b3dfe7
-        [[ -f $i ]] || continue
Harald Hoyer b3dfe7
-        read vendor < $i
Harald Hoyer b3dfe7
-        [[  "$vendor" == "QEMU" ]] && return 0
Harald Hoyer b3dfe7
-        [[  "$vendor" == "Bochs" ]] && return 0
Harald Hoyer b3dfe7
-    done
Harald Hoyer b3dfe7
+        for i in /sys/class/dmi/id/*_vendor; do
Harald Hoyer b3dfe7
+            [[ -f $i ]] || continue
Harald Hoyer b3dfe7
+            read vendor < $i
Harald Hoyer b3dfe7
+            [[  "$vendor" == "QEMU" ]] && return 0
Harald Hoyer b3dfe7
+            [[  "$vendor" == "Bochs" ]] && return 0
Harald Hoyer b3dfe7
+        done
Harald Hoyer b3dfe7
 
Harald Hoyer b3dfe7
-    return 255
Harald Hoyer b3dfe7
+        return 255
Harald Hoyer b3dfe7
+    fi
Harald Hoyer b3dfe7
+    return 0
Harald Hoyer b3dfe7
 }
Harald Hoyer b3dfe7
 
Harald Hoyer b3dfe7
 # called by dracut
Harald Hoyer b3dfe7
diff --git a/modules.d/90qemu/module-setup.sh b/modules.d/90qemu/module-setup.sh
Harald Hoyer b3dfe7
index 9f8495a6..7e5ea6a4 100755
Harald Hoyer b3dfe7
--- a/modules.d/90qemu/module-setup.sh
Harald Hoyer b3dfe7
+++ b/modules.d/90qemu/module-setup.sh
Harald Hoyer b3dfe7
@@ -2,28 +2,33 @@
Harald Hoyer b3dfe7
 
Harald Hoyer b3dfe7
 # called by dracut
Harald Hoyer b3dfe7
 check() {
Harald Hoyer b3dfe7
-    if type -P systemd-detect-virt >/dev/null 2>&1; then
Harald Hoyer b3dfe7
-        vm=$(systemd-detect-virt --vm 2>/dev/null)
Harald Hoyer b3dfe7
-        (($? != 0)) && return 255
Harald Hoyer b3dfe7
-        [[ $vm = "qemu" ]] && return 0
Harald Hoyer b3dfe7
-        [[ $vm = "kvm" ]] && return 0
Harald Hoyer b3dfe7
-        [[ $vm = "bochs" ]] && return 0
Harald Hoyer b3dfe7
+    if [[ $hostonly ]] || [[ $mount_needs ]]; then
Harald Hoyer b3dfe7
+        if type -P systemd-detect-virt >/dev/null 2>&1; then
Harald Hoyer b3dfe7
+            vm=$(systemd-detect-virt --vm 2>/dev/null)
Harald Hoyer b3dfe7
+            (($? != 0)) && return 255
Harald Hoyer b3dfe7
+            [[ $vm = "qemu" ]] && return 0
Harald Hoyer b3dfe7
+            [[ $vm = "kvm" ]] && return 0
Harald Hoyer b3dfe7
+            [[ $vm = "bochs" ]] && return 0
Harald Hoyer b3dfe7
+        fi
Harald Hoyer b3dfe7
+
Harald Hoyer b3dfe7
+        for i in /sys/class/dmi/id/*_vendor; do
Harald Hoyer b3dfe7
+            [[ -f $i ]] || continue
Harald Hoyer b3dfe7
+            read vendor < $i
Harald Hoyer b3dfe7
+            [[ "$vendor" == "QEMU" ]] && return 0
Harald Hoyer b3dfe7
+            [[ "$vendor" == "Red Hat" ]] && return 0
Harald Hoyer b3dfe7
+            [[ "$vendor" == "Bochs" ]] && return 0
Harald Hoyer b3dfe7
+        done
Harald Hoyer b3dfe7
+
Harald Hoyer b3dfe7
+        return 255
Harald Hoyer b3dfe7
     fi
Harald Hoyer b3dfe7
 
Harald Hoyer b3dfe7
-    for i in /sys/class/dmi/id/*_vendor; do
Harald Hoyer b3dfe7
-        [[ -f $i ]] || continue
Harald Hoyer b3dfe7
-        read vendor < $i
Harald Hoyer b3dfe7
-        [[ "$vendor" == "QEMU" ]] && return 0
Harald Hoyer b3dfe7
-        [[ "$vendor" == "Red Hat" ]] && return 0
Harald Hoyer b3dfe7
-        [[ "$vendor" == "Bochs" ]] && return 0
Harald Hoyer b3dfe7
-    done
Harald Hoyer b3dfe7
-    return 255
Harald Hoyer b3dfe7
+    return 0
Harald Hoyer b3dfe7
 }
Harald Hoyer b3dfe7
 
Harald Hoyer b3dfe7
 # called by dracut
Harald Hoyer b3dfe7
 installkernel() {
Harald Hoyer b3dfe7
-        # qemu specific modules
Harald Hoyer b3dfe7
-        hostonly='' instmods \
Harald Hoyer b3dfe7
+    # qemu specific modules
Harald Hoyer b3dfe7
+    hostonly='' instmods \
Harald Hoyer b3dfe7
             ata_piix ata_generic pata_acpi cdrom sr_mod ahci \
Harald Hoyer b3dfe7
             virtio_blk virtio virtio_ring virtio_pci \
Harald Hoyer b3dfe7
             virtio_scsi virtio_console virtio_rng \
Harald Hoyer b3dfe7