dracut/0024-qemu-module-setup.sh-provide-alternative-for-systemd.patch
Harald Hoyer 12f6cc01aa dracut-022-63.git20120727
- fixed dracut-install bug if /var/tmp contains a symlink
- fixed some partx issues
2012-07-27 06:28:40 +02:00

71 lines
2.2 KiB
Diff

From f1040fc4702778b38e6cc9eaf5b4c1ff24a7c26c Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Wed, 25 Jul 2012 16:03:49 +0200
Subject: [PATCH] qemu*/module-setup.sh: provide alternative for
systemd-detect-virt
---
modules.d/90qemu-net/module-setup.sh | 19 +++++++++++++++----
modules.d/90qemu/module-setup.sh | 18 ++++++++++++++----
2 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/modules.d/90qemu-net/module-setup.sh b/modules.d/90qemu-net/module-setup.sh
index 35c8f0f..e617230 100755
--- a/modules.d/90qemu-net/module-setup.sh
+++ b/modules.d/90qemu-net/module-setup.sh
@@ -3,10 +3,21 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
- vm=$(systemd-detect-virt --vm &>/dev/null)
- (($? != 0)) && return 255
- [[ $vm = "qemu" ]] && return 0
- [[ $vm = "kvm" ]] && return 0
+ if type -P systemd-detect-virt &>/dev/null; then
+ vm=$(systemd-detect-virt --vm &>/dev/null)
+ (($? != 0)) && return 255
+ [[ $vm = "qemu" ]] && return 0
+ [[ $vm = "kvm" ]] && return 0
+ [[ $vm = "bochs" ]] && return 0
+ fi
+
+ for i in /sys/class/dmi/id/*_vendor; do
+ [[ -f $i ]] || continue
+ read vendor < $i
+ [[ "$vendor" == "QEMU" ]] && return 0
+ [[ "$vendor" == "Bochs" ]] && return 0
+ done
+
return 255
}
diff --git a/modules.d/90qemu/module-setup.sh b/modules.d/90qemu/module-setup.sh
index 3e55f23..fc258ac 100755
--- a/modules.d/90qemu/module-setup.sh
+++ b/modules.d/90qemu/module-setup.sh
@@ -3,10 +3,20 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
- vm=$(systemd-detect-virt --vm &>/dev/null)
- (($? != 0)) && return 255
- [[ $vm = "qemu" ]] && return 0
- [[ $vm = "kvm" ]] && return 0
+ if type -P systemd-detect-virt &>/dev/null; then
+ vm=$(systemd-detect-virt --vm &>/dev/null)
+ (($? != 0)) && return 255
+ [[ $vm = "qemu" ]] && return 0
+ [[ $vm = "kvm" ]] && return 0
+ [[ $vm = "bochs" ]] && return 0
+ fi
+
+ for i in /sys/class/dmi/id/*_vendor; do
+ [[ -f $i ]] || continue
+ read vendor < $i
+ [[ "$vendor" == "QEMU" ]] && return 0
+ [[ "$vendor" == "Bochs" ]] && return 0
+ done
return 255
}