From 67cc81f6b13311269e87200d89cd1c60729afd3d Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Wed, 4 Sep 2013 11:57:26 -0400 Subject: [PATCH] virt-install: Add --boot useserial=on Which gives bios output over serial console via sgabios --- man/virt-install.pod | 5 +++++ tests/xmlparse-xml/change-guest-out.xml | 1 + tests/xmlparse.py | 1 + virtinst/cli.py | 28 +++++++++++++------------ virtinst/osxml.py | 1 + 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/man/virt-install.pod b/man/virt-install.pod index c3f9a31a3..456f21c26 100644 --- a/man/virt-install.pod +++ b/man/virt-install.pod @@ -361,6 +361,11 @@ configurations like ARM or PPC Use BIOSPATH as the virtual machine BIOS. Only valid for fully virtualized guests. +=item B<--boot menu=on,useserial=on> + +Enable the bios boot menu, and enable sending bios text output over +serial console. + =back =back diff --git a/tests/xmlparse-xml/change-guest-out.xml b/tests/xmlparse-xml/change-guest-out.xml index ca350b1cf..9cd0ddf76 100644 --- a/tests/xmlparse-xml/change-guest-out.xml +++ b/tests/xmlparse-xml/change-guest-out.xml @@ -9,6 +9,7 @@ /sbin/init + diff --git a/tests/xmlparse.py b/tests/xmlparse.py index d8725bd80..d32d43776 100644 --- a/tests/xmlparse.py +++ b/tests/xmlparse.py @@ -137,6 +137,7 @@ class XMLParseTest(unittest.TestCase): check("init", None, "/sbin/init") check("bootorder", ["hd"], ["fd"]) check("enable_bootmenu", None, False) + check("useserial", None, True) check("kernel", None) check("initrd", None) check("kernel_args", None) diff --git a/virtinst/cli.py b/virtinst/cli.py index 09070fa0f..855343410 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -374,10 +374,13 @@ def yes_or_no_convert(s): if s is None: return None + tvalues = ["y", "yes", "1", "true", "t", "on"] + fvalues = ["n", "no", "0", "false", "f", "off"] + s = s.lower() - if s in ("y", "yes", "1", "true", "t"): + if s in tvalues: return True - elif s in ("n", "no", "0", "false", "f"): + elif s in fvalues: return False return None @@ -1284,7 +1287,6 @@ def parse_boot(guest, optstring): """ opts = parse_optstr(optstring) optlist = [x[0] for x in parse_optstr_tuples(optstring)] - menu = None def set_param(paramname, dictname, val=None): val = get_opt_param(opts, dictname, val) @@ -1294,20 +1296,20 @@ def parse_boot(guest, optstring): setattr(guest.os, paramname, val) # Convert menu= value + menu = None if "menu" in opts: - menustr = opts["menu"] - menu = None - - if menustr.lower() == "on": - menu = True - elif menustr.lower() == "off": - menu = False - else: - menu = yes_or_no_convert(menustr) - + menu = yes_or_no_convert(opts["menu"]) if menu is None: fail(_("--boot menu must be 'on' or 'off'")) + # Convert useserial= value + useserial = None + if "useserial" in opts: + useserial = yes_or_no_convert(opts["useserial"]) + if useserial is None: + fail(_("--boot useserial must be 'on' or 'off'")) + + set_param("useserial", "useserial", useserial) set_param("enable_bootmenu", "menu", menu) set_param("kernel", "kernel") set_param("initrd", "initrd") diff --git a/virtinst/osxml.py b/virtinst/osxml.py index f815ba31d..c5fd0f1c5 100644 --- a/virtinst/osxml.py +++ b/virtinst/osxml.py @@ -102,6 +102,7 @@ class OSXML(XMLBuilder): bootorder = property(_get_bootorder, _set_bootorder) enable_bootmenu = XMLProperty(xpath="./os/bootmenu/@enable", is_yesno=True) + useserial = XMLProperty(xpath="./os/bios/@useserial", is_yesno=True) kernel = XMLProperty(xpath="./os/kernel") initrd = XMLProperty(xpath="./os/initrd")