guest-tools: Fix "There are no ccwgroup devices"

The error occures if the directory '/sys/bus/ccwgroup/' does not
exist (znetconf is checking for that). This directory gets created
when the 'ccwgroup' kernel module is initialized. Therefore the
solution is to ensure that this kernel module is loaded.

Change-Id: Ifc8917b702f7a8913c5662fcbb9f15c1248ed55d
Closes-Bug: #1666524
This commit is contained in:
Andreas Scheuring 2017-02-24 09:40:32 +01:00
parent 93929b09a3
commit 3c02543ea8
4 changed files with 29 additions and 0 deletions

View File

@ -41,6 +41,7 @@ REGEX="($REGEX_DEV_NO),([0-1])(,$REGEX_MAC)?;"
CMDLINE=$(get_cmdline)
log "Start"
ensure_ccwgroup_module
# Default return code
rc=0

View File

@ -219,6 +219,14 @@ function configure_device {
return "$?"
}
function ensure_ccwgroup_module {
if ! [ -d $(_change_root "/sys/bus/ccwgroup") ]; then
log "Loading ccwgroup kernel module..."
local cmd=$(_change_root "modprobe ccwgroup")
eval "$cmd"
fi
}
function get_cmdline {
#Example: "some stuff nics=0001,0,aabbccddeeff;abcd,1,001122334455;"
echo $(cat $(_change_root "/proc/cmdline"))

View File

@ -0,0 +1,6 @@
#! /bin/bash
# modprobe ccwgroup
if ! [[ "$@" == "ccwgroup" ]]; then
exit 1
fi

View File

@ -160,3 +160,17 @@ class TestDPMGuestImageTools(base.BaseTestCase):
self.env = dict()
self._test_function("_change_root", ["/foo/bar"])
self._assert(0, "/foo/bar")
def test_ensure_ccwgroup_module_already_loaded(self):
# As /sys/bus/ccwgroup exists, modprobe is not being called. It does
# not even exist in the default root dir, therefore a call would result
# in a test failure
self._test_function("ensure_ccwgroup_module", [])
self._assert(0)
def test_ensure_ccwgroup_module_good(self):
# change the root dir as the directory /sys/bus/ccwgroup already
# exists in the default root dir
self.env = dict(os.environ, ROOT_DIR=base_path + "/root_dir_modprobe")
self._test_function("ensure_ccwgroup_module", [])
self._assert(0)