File lilo.ppc-kvm.patch of Package lilo
From 0c8e0e927ce74119cdd2647da9f2e9675ca45e9c Mon Sep 17 00:00:00 2001
From: Dinar Valeev <dvaleev@suse.com>
Date: Mon, 13 Aug 2012 13:03:08 +0200
Subject: [PATCH] get OF path for virtio. Don't run nvsetenv where /dev/nvram is not available (under KVM). Extend search of vscsi disks to disk@id,lun
---
lilo-chrp.lib | 29 ++++++++++++++++-------------
lilo.new | 8 +++++++-
show_of_path.sh | 23 +++++++++++++++++++++--
3 files changed, 44 insertions(+), 16 deletions(-)
diff --git a/lilo-chrp.lib b/lilo-chrp.lib
index 92cb2ad..a65c0fd 100644
--- a/lilo-chrp.lib
+++ b/lilo-chrp.lib
@@ -649,8 +649,10 @@ function running_on_chrp () {
fi
if (( fat_boot == 1 )); then
- nvsetenv bootinfo-linux "${boot_path},\\ppc\\bootinfo.txt"
- boot_path=${boot_path},yaboot
+ if [ is_nvram ];then
+ nvsetenv bootinfo-linux "${boot_path},\\ppc\\bootinfo.txt"
+ fi
+ boot_path=${boot_path},yaboot
elif [[ "${p_flags[*]}" != *type=41*type=41* ]]; then
# open firmware is confused about more than one PReP partition, in that
# case keep full OF path
@@ -658,17 +660,18 @@ function running_on_chrp () {
fi
if [ "$OPTION_ACTIVATE" = "yes" ] ; then
- echo "Prepending '$boot_path'" to open firmware variable boot-device
-
- local -a bootdevice=( $(nvsetenv boot-device) )
- bootdevice[0]=${bootdevice[0]#boot-device=}
- for (( i=${#bootdevice[*]}; i-- >0; )); do
- if [[ "${bootdevice[$i]}" == ${boot_path}* ]]; then
- unset bootdevice[$i];
- fi
- done
- nvsetenv boot-device "$boot_path ${bootdevice[*]}"
-
+ if [ is_nvram ];then
+ echo "Prepending '$boot_path'" to open firmware variable boot-device
+
+ local -a bootdevice=( $(nvsetenv boot-device) )
+ bootdevice[0]=${bootdevice[0]#boot-device=}
+ for (( i=${#bootdevice[*]}; i-- >0; )); do
+ if [[ "${bootdevice[$i]}" == ${boot_path}* ]]; then
+ unset bootdevice[$i];
+ fi
+ done
+ nvsetenv boot-device "$boot_path ${bootdevice[*]}"
+ fi
else
warning "boot path not set to boot linux as requested" \
"please add '$boot_path' somewhere to your boot path manually"
diff --git a/lilo.new b/lilo.new
index 39aaa33..21d5180 100755
--- a/lilo.new
+++ b/lilo.new
@@ -672,7 +672,13 @@ while [ "$1" ]; do case "$1" in
;;
esac; shift; done
-
+function is_nvram () {
+ if [ -e /dev/nvram ];then
+ return 0
+ else
+ return 1
+ fi
+}
function running_on_iseries () {
source /lib/lilo/lilo-iseries.lib
diff --git a/show_of_path.sh b/show_of_path.sh
index 52ceb16..1beeace 100644
--- a/show_of_path.sh
+++ b/show_of_path.sh
@@ -327,7 +327,14 @@ case "$file_full_sysfs_path" in
ide_port=$of_disk_scsi_host
ide_channel=$of_disk_scsi_id
- cd ../../..
+ until test -f devspec
+ do
+ cd ..
+ if test "$PWD" = "/"
+ then
+ break
+ fi
+ done
;;
*/host+([0-9])/rport-+([0-9]):+([0-9])-+([0-9])/target+([0-9:])/+([0-9]):+([0-9]):+([0-9]):+([0-9]))
# new sysfs layout starting with kernel 2.6.15
@@ -361,6 +368,11 @@ case "$file_full_sysfs_path" in
fi
done
;;
+ */pci+([0-9:])+([0-9]):*/virtio[0-9])
+ declare spec="${file_full_sysfs_path##*/}"
+ dbg_show spec
+ cd ..
+ ;;
*)
# TODO check the rest of the (hardware) world
: file_full_sysfs_path $file_full_sysfs_path
@@ -481,6 +493,9 @@ if [ -f devspec ] ; then
;;
ieee1394)
;;
+ block)
+ file_storage_type=virtio
+ ;;
*)
error "Unknown device type $(< ${file_of_hw_devtype}/device_type)"
;;
@@ -610,7 +625,7 @@ if [ -f devspec ] ; then
;;
vscsi)
(( of_disk_vscsi_nr = ( (2 << 14) | (of_disk_scsi_chan<<5) | (of_disk_scsi_id<<8) | of_disk_scsi_lun ) <<48 )); #
- if [ -d ${file_of_hw_devtype}/disk ]; then
+ if $(ls -d ${file_of_hw_devtype}/disk* >/dev/null 2>&1); then
of_disk_vscsi_dir=disk
elif [ -d ${file_of_hw_devtype}/sd ]; then
of_disk_vscsi_dir=sd
@@ -627,6 +642,10 @@ if [ -f devspec ] ; then
# MacOS: boot-device=fw/node@1d20000038f29/sbp-2@c000/@0:7,\\:tbxi
file_of_hw_path="${file_of_hw_devtype##/proc/device-tree}"/node@${ieee1394_id}/sbp-2/disk@0
;;
+ virtio)
+ file_of_hw_path="${file_of_hw_devtype##/proc/device-tree}"
+ dbg_show file_of_hw_path
+ ;;
*)
error "Internal error, can't handle storage type '${file_storage_type}'"
;;
--
1.6.0.2