pygrub: always append --args
authorOlaf Hering <olaf@aepfle.de>
Tue, 25 Sep 2012 10:03:51 +0000 (11:03 +0100)
committerOlaf Hering <olaf@aepfle.de>
Tue, 25 Sep 2012 10:03:51 +0000 (11:03 +0100)
If a bootloader entry in menu.lst has no additional kernel command line
options listed and the domU.cfg has 'bootargs="--args=something"' the
additional arguments from the config file are not passed to the kernel.
The reason for that incorrect behaviour is that run_grub appends arg
only if the parsed config file has arguments listed.

Fix this by appending args from image section and the config file separatly.
To avoid adding to a NoneType initialize grubcfg['args'] to an empty string.
This does not change behaviour but simplifies the code which appends the
string.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
tools/pygrub/src/pygrub

index ad78c22de0a080886ff5abbd43c49c2220fbf789..fc55d903e1146df2bad721a528141d129b3ee75a 100644 (file)
@@ -615,13 +615,15 @@ def run_grub(file, entry, fs, arg):
     except IndexError:
         img = g.cf.images[0]
 
-    grubcfg = { "kernel": None, "ramdisk": None, "args": None }
+    grubcfg = { "kernel": None, "ramdisk": None, "args": "" }
 
     grubcfg["kernel"] = img.kernel[1]
     if img.initrd:
         grubcfg["ramdisk"] = img.initrd[1]
     if img.args:
-        grubcfg["args"] = img.args + " " + arg
+        grubcfg["args"] += img.args
+    if arg:
+        grubcfg["args"] += " " + args
 
     return grubcfg