This addresses three issues that were introduced while factoring out the
sysfs parser from the the config generator:
- sysfs_parser.root_dir cannot be set from outside of he module -
introduce a setter function instead
- we need to initialize the root dir prior to performing the jailhouse
enabled check
- os.path.join drops any earlier elements if a later one is an absolute
path - switch back to plain '+'
Fixes: 20a83313ea74 ("Splitting up helpers used in sysfs parsing")
Signed-off-by: Jan Kiszka <[email protected]>
---
pyjailhouse/sysfs_parser.py | 8 ++++++--
tools/jailhouse-config-create | 4 ++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/pyjailhouse/sysfs_parser.py b/pyjailhouse/sysfs_parser.py
index c4154736..e050af47 100644
--- a/pyjailhouse/sysfs_parser.py
+++ b/pyjailhouse/sysfs_parser.py
@@ -24,6 +24,10 @@ import fnmatch
root_dir = "/"
+def set_root_dir(dir):
+ global root_dir
+ root_dir = dir
+
inputs = {
'files': set(),
'files_opt': set(),
@@ -73,7 +77,7 @@ def check_input_listed(name, optional=False):
def input_open(name, mode='r', optional=False):
check_input_listed(name, optional)
try:
- f = open(os.path.join(root_dir, name), mode)
+ f = open(root_dir + name, mode)
except Exception as e:
if optional:
return open("/dev/null", mode)
@@ -84,7 +88,7 @@ def input_open(name, mode='r', optional=False):
def input_listdir(dir, wildcards):
for w in wildcards:
check_input_listed(os.path.join(dir, w))
- dirs = os.listdir(os.path.join(root_dir, dir))
+ dirs = os.listdir(root_dir + dir)
dirs.sort()
return dirs
diff --git a/tools/jailhouse-config-create b/tools/jailhouse-config-create
index 65a832dc..55601a6d 100755
--- a/tools/jailhouse-config-create
+++ b/tools/jailhouse-config-create
@@ -243,6 +243,8 @@ if ((options.root is '/') and (os.geteuid() is not 0)):
print('ERROR: You have to be root to work on "/"!', file=sys.stderr)
sys.exit(1)
+sysfs_parser.set_root_dir(options.root)
+
jh_enabled = input_readline('/sys/devices/jailhouse/enabled', True).rstrip()
if jh_enabled == '1':
print('ERROR: Jailhouse was enabled when collecting input files! '
@@ -253,8 +255,6 @@ if jh_enabled == '1':
IOAPIC_MAX_PINS = 120
int_src_count = IOAPIC_MAX_PINS
-sysfs_parser.root_dir = options.root
-
(pcidevices, pcicaps, cnt) = sysfs_parser.parse_pcidevices()
int_src_count += cnt
--
2.16.4
--
You received this message because you are subscribed to the Google Groups
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.