[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH] cleanup booty x86 flag.serial handling (#589773)



Bug 589773 is caused by booty's x86 flag.serial handling not setting
self.serial at all, when serial is present on the cmdline, but no
console= argument it present and the system is not ia64.

Looking closer at the code I also noticed that it will try to
access the options list at index 1, even though it is empty, when
console=ttyS0 is passed rather then console=ttyS0,...

All in all the code was rather messy, so this patch rewrites it to
better readable, hopefully obviously correct code.
---
 booty/bootloaderInfo.py |   43 ++++++++++++++++++++-----------------------
 1 files changed, 20 insertions(+), 23 deletions(-)

diff --git a/booty/bootloaderInfo.py b/booty/bootloaderInfo.py
index 2aaac7a..d63c9a1 100644
--- a/booty/bootloaderInfo.py
+++ b/booty/bootloaderInfo.py
@@ -556,6 +556,9 @@ class bootloaderInfo(object):
         self.above1024 = 0
         self.timeout = None
         self.storage = anaconda.storage
+        self.serial = 0
+        self.serialDevice = None
+        self.serialOptions = None
 
         # this has somewhat strange semantics.  if 0, act like a normal
         # "install" case.  if 1, update lilo.conf (since grubby won't do that)
@@ -567,34 +570,28 @@ class bootloaderInfo(object):
         self._drivelist = None
 
         if flags.serial != 0:
-            options = ""
-            device = ""
-            console = flags.cmdline.get("console", "")
+            self.serial = 1
+            self.timeout = 5
 
-            # the options are everything after the comma
-            comma = console.find(",")
-            if comma != -1:
-                options = console[comma:]
-                device = console[:comma]
+            console = flags.cmdline.get("console", "")
+            if console:
+                # the options are everything after the comma
+                comma = console.find(",")
+                if comma != -1:
+                    self.serialDevice = console[:comma]
+                    self.serialOptions = console[comma + 1:]
+                else:
+                    self.serialDevice = console
+                    self.serialOptions = ""
             else:
-                device = console
-
-            if not device and iutil.isIA64():
                 self.serialDevice = "ttyS0"
                 self.serialOptions = ""
+
+            if self.serialOptions:
+                self.args.append("console=%s,%s" %(self.serialDevice,
+                                                   self.serialOptions))
             else:
-                self.serialDevice = device
-                # don't keep the comma in the options
-                self.serialOptions = options[1:]
-
-            if self.serialDevice:
-                self.args.append("console=%s%s" %(self.serialDevice, options))
-                self.serial = 1
-                self.timeout = 5
-        else:
-            self.serial = 0
-            self.serialDevice = None
-            self.serialOptions = None
+                self.args.append("console=%s,%s" % self.serialDevice)
 
         if flags.virtpconsole is not None:
             if flags.virtpconsole.startswith("/dev/"):
-- 
1.7.0.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]