Change in vdsm[master]: virt: Set timeout on boot menu

mzamazal at redhat.com mzamazal at redhat.com
Wed Apr 20 12:58:28 UTC 2016


Milan Zamazal has uploaded a new change for review.

Change subject: virt: Set timeout on boot menu
......................................................................

virt: Set timeout on boot menu

The default timeout for boot menu (3 s) is too short for some scenarios,
e.g. with network delays.  Although the best way to handle boot menu is
to run a VM in paused mode, we can change the timeout to make boot menu
better available even on regular runs.  So this patch sets the boot menu
timeout to 10 s and makes the value configurable.

Change-Id: I0f3501e8500e366e785f5a8ddfdf78fd34c997a2
Bug-Url: https://bugzilla.redhat.com/1324375
Signed-off-by: Milan Zamazal <mzamazal at redhat.com>
---
M lib/vdsm/config.py.in
M tests/vmTests.py
M vdsm/virt/vmxml.py
3 files changed, 38 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/93/56393/1

diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in
index e058527..1cba4bf 100644
--- a/lib/vdsm/config.py.in
+++ b/lib/vdsm/config.py.in
@@ -237,6 +237,9 @@
         ('migration_create_timeout', '600',
             'Time in seconds defining how long we are going to wait for '
             'create migration response.'),
+
+        ('boot_menu_timeout', '10',
+            'Boot menu timeout in seconds.'),
     ]),
 
     # Section: [rpc]
diff --git a/tests/vmTests.py b/tests/vmTests.py
index 6a9f90f..c4dc571 100644
--- a/tests/vmTests.py
+++ b/tests/vmTests.py
@@ -62,6 +62,7 @@
 from vdsm import host
 from vdsm import utils
 from vdsm import libvirtconnection
+from vdsm.config import config
 from monkeypatch import MonkeyPatch, MonkeyPatchScope
 from testlib import namedTemporaryDir
 from testValidation import slowtest
@@ -159,7 +160,7 @@
             <os>
                  <type arch="x86_64" machine="pc">hvm</type>
                  <smbios mode="sysinfo"/>
-                 <bootmenu enable="yes"/>
+                 <bootmenu enable="yes" timeout="10000"/>
             </os>""", """
             <os>
                  <type arch="x86_64" machine="pc">hvm</type>
@@ -168,7 +169,7 @@
             <os>
                  <type arch="x86_64" machine="pc">hvm</type>
                  <smbios mode="sysinfo"/>
-                 <bootmenu enable="yes"/>
+                 <bootmenu enable="yes" timeout="10000"/>
             </os>""", """
             <os>
                  <type arch="x86_64" machine="pc">hvm</type>
@@ -178,7 +179,7 @@
                  <type arch="x86_64" machine="pc">hvm</type>
                  <cmdline>console=ttyS0 1</cmdline>
                  <smbios mode="sysinfo"/>
-                 <bootmenu enable="yes"/>
+                 <bootmenu enable="yes" timeout="10000"/>
             </os>""", """
             <os>
                  <type arch="x86_64" machine="pc">hvm</type>
@@ -192,6 +193,29 @@
             xml = find_xml_element(domxml.dom.toxml(), './os')
             self.assertXMLEqual(xml, osXML)
 
+    def testOSXMLBootMenuTimeout(self):
+        orig_config_getint = config.getint
+
+        def fake_config_getint(*args):
+            if args == ('vars', 'boot_menu_timeout',):
+                return 20
+            else:
+                return orig_config_getint(*args)
+
+        with MonkeyPatchScope([(config, 'getint', fake_config_getint)]):
+            conf = {'bootMenuEnable': 'true'}
+            conf.update(self.conf)
+            domxml = vmxml.Domain(conf, self.log, cpuarch.X86_64)
+            domxml.appendOs()
+            xml = find_xml_element(domxml.dom.toxml(), './os')
+            osxml = """
+                <os>
+                     <type arch="x86_64" machine="pc">hvm</type>
+                     <smbios mode="sysinfo"/>
+                     <bootmenu enable="yes" timeout="20000"/>
+                </os>"""
+            self.assertXMLEqual(xml, osxml)
+
     def testOSXMLX86_64(self):
         expectedXMLs = ["""
             <os>
diff --git a/vdsm/virt/vmxml.py b/vdsm/virt/vmxml.py
index 9cb663a..c951d42 100644
--- a/vdsm/virt/vmxml.py
+++ b/vdsm/virt/vmxml.py
@@ -26,6 +26,7 @@
 from vdsm import constants
 from vdsm import cpuarch
 from vdsm import utils
+from vdsm.config import config
 
 METADATA_VM_TUNE_URI = 'http://ovirt.org/vm/tune/1.0'
 METADATA_VM_TUNE_ELEMENT = 'qos'
@@ -298,7 +299,13 @@
             oselem.appendChildWithArgs('smbios', mode='sysinfo')
 
         if utils.tobool(self.conf.get('bootMenuEnable', False)):
-            oselem.appendChildWithArgs('bootmenu', enable='yes')
+            timeout = config.getint('vars', 'boot_menu_timeout') * 1000
+            if timeout < 0:
+                timeout = 0
+            elif timeout > 65535:
+                timeout = 65535
+            oselem.appendChildWithArgs('bootmenu', enable='yes',
+                                       timeout=unicode(timeout))
 
         if use_serial_console and cpuarch.is_x86(self.arch):
             oselem.appendChildWithArgs('bios', useserial='yes')


-- 
To view, visit https://gerrit.ovirt.org/56393
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0f3501e8500e366e785f5a8ddfdf78fd34c997a2
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Milan Zamazal <mzamazal at redhat.com>


More information about the vdsm-patches mailing list