]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
tools: config-create: Make sanity checks the first code we run
authorHenning Schild <henning.schild@siemens.com>
Wed, 27 Aug 2014 11:57:41 +0000 (13:57 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Thu, 28 Aug 2014 06:36:29 +0000 (08:36 +0200)
Move the sanity check functions to the top of the script.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
tools/jailhouse-config-create

index 7fc8671fd548488334fae117f21dbe0f86b4cfaa..dce9f6d44a302e791b753befe610d47fca6fee05 100755 (executable)
@@ -607,13 +607,6 @@ class MMConfig:
         return MMConfig(base, end_bus)
 
 
-if (
-    (options.generate_collector is False) and (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)
-
 def get_cpu_vendor():
     with input_open('/proc/cpuinfo', 'r') as f:
         for line in f:
@@ -624,6 +617,21 @@ def get_cpu_vendor():
                 return value.strip()
 
 
+if (
+    (options.generate_collector is False) and (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)
+
+jh_enabled = input_readline('/sys/devices/jailhouse/enabled',
+                            True).rstrip()
+if options.generate_collector is False and jh_enabled == '1':
+    print('ERROR: Jailhouse was enabled when collecting input files! '
+          'Disable jailhouse and try again.',
+          file=sys.stderr)
+    sys.exit(1)
+
 (pcidevices, pcicaps) = parse_pcidevices()
 
 product = [input_readline('/sys/class/dmi/id/sys_vendor',
@@ -669,14 +677,6 @@ cpucount = count_cpus()
 
 pm_timer_base = parse_ioports()
 
-jh_enabled = input_readline('/sys/devices/jailhouse/enabled',
-                            True).rstrip()
-if options.generate_collector is False and jh_enabled == '1':
-    print('ERROR: Jailhouse was enabled when collecting input files! '
-          'Disable jailhouse and try again.',
-          file=sys.stderr)
-    sys.exit(1)
-
 f = open(options.file, 'w')
 
 if options.generate_collector: