From a24cdd19640fc6c542fa9603ed02078e0c84a380 Mon Sep 17 00:00:00 2001 From: Hugues Fafard Date: Wed, 28 Jul 2021 14:58:07 +0200 Subject: [PATCH] cli: --boot: Completed options for guest-based bootloader Adds support for `bootmenu.timeout` suboption. --- .../virt-install-boot-guest-loader-bios.xml | 31 +++++++++++++++++++ .../virt-install-boot-guest-loader-efi.xml | 31 +++++++++++++++++++ .../virt-install-singleton-config-3.xml | 2 +- tests/data/xmlparse/change-guest-out.xml | 4 +-- tests/test_cli.py | 4 ++- tests/test_xmlparse.py | 6 ++-- virtManager/object/domain.py | 4 +-- virtinst/cli.py | 7 +++-- virtinst/domain/os.py | 13 ++++---- 9 files changed, 85 insertions(+), 17 deletions(-) create mode 100644 tests/data/cli/compare/virt-install-boot-guest-loader-bios.xml create mode 100644 tests/data/cli/compare/virt-install-boot-guest-loader-efi.xml diff --git a/tests/data/cli/compare/virt-install-boot-guest-loader-bios.xml b/tests/data/cli/compare/virt-install-boot-guest-loader-bios.xml new file mode 100644 index 000000000..ae9572bce --- /dev/null +++ b/tests/data/cli/compare/virt-install-boot-guest-loader-bios.xml @@ -0,0 +1,31 @@ + + vm1 + 00000000-1111-2222-3333-444444444444 + 65536 + 65536 + 1 + + hvm + /path/to/loader + + + + + + + + + + + + + + /usr/bin/test-hv + + + + + + + + diff --git a/tests/data/cli/compare/virt-install-boot-guest-loader-efi.xml b/tests/data/cli/compare/virt-install-boot-guest-loader-efi.xml new file mode 100644 index 000000000..d3a213136 --- /dev/null +++ b/tests/data/cli/compare/virt-install-boot-guest-loader-efi.xml @@ -0,0 +1,31 @@ + + vm1 + 00000000-1111-2222-3333-444444444444 + 65536 + 65536 + 1 + + hvm + /path/to/loader + /path/to/nvram + + + + + + + + + + + + + /usr/bin/test-hv + + + + + + + + diff --git a/tests/data/cli/compare/virt-install-singleton-config-3.xml b/tests/data/cli/compare/virt-install-singleton-config-3.xml index 0cfcb9d08..46e7ce406 100644 --- a/tests/data/cli/compare/virt-install-singleton-config-3.xml +++ b/tests/data/cli/compare/virt-install-singleton-config-3.xml @@ -47,7 +47,7 @@ root=/foo - + diff --git a/tests/data/xmlparse/change-guest-out.xml b/tests/data/xmlparse/change-guest-out.xml index 17af0826b..457156550 100644 --- a/tests/data/xmlparse/change-guest-out.xml +++ b/tests/data/xmlparse/change-guest-out.xml @@ -13,8 +13,8 @@ /foo/loader /sbin/init - - + + foo bar baz frib diff --git a/tests/test_cli.py b/tests/test_cli.py index 0f032bbf0..5a0e16247 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -563,7 +563,7 @@ c.add_compare(""" --disk none --features apic.eoi=off,hap=on,hyperv.synic.state=on,hyperv.reset.state=off,hyperv.spinlocks.state=on,hyperv.spinlocks.retries=5678,pae=on,pmu.state=on,pvspinlock.state=off,smm.state=off,viridian=on,vmcoreinfo.state=on,vmport.state=off,kvm.hidden.state=on,hyperv.vapic.state=off,hyperv.relaxed.state=off,gic.version=host,kvm.hint-dedicated.state=on,kvm.poll-control.state=on --clock rtc_present=no,pit_present=yes,pit_tickpolicy=catchup,tsc_present=no,platform_present=no,hypervclock_present=no,platform_tickpolicy=foo,hpet_tickpolicy=bar,tsc_tickpolicy=wibble,kvmclock_tickpolicy=wobble,hypervclock_tickpolicy=woo ---boot bios.useserial=no,bios.rebootTimeout=60,cmdline=root=/foo,smbios.mode=host,bootmenu.enable=yes,loader_ro=yes,loader.type=rom,loader=/tmp/foo +--boot bios.useserial=no,bios.rebootTimeout=60,cmdline=root=/foo,smbios.mode=host,bootmenu.enable=yes,bootmenu.timeout=5000,loader_ro=yes,loader.type=rom,loader=/tmp/foo --memorybacking access.mode=shared,source.type=anonymous,hugepages=on --graphics spice,gl=yes --rng type=egd,backend.type=nmdm,backend.source.master=/dev/foo1,backend.source.slave=/dev/foo2 @@ -756,6 +756,8 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser c = vinst.add_category("boot", "--nographics --noautoconsole --import --disk none --controller usb,model=none") c.add_compare("--boot loader=/path/to/loader,loader_secure=yes", "boot-loader-secure") +c.add_compare("--boot firmware=bios,loader=/path/to/loader,loader.readonly=yes,loader.secure=no,loader.type=rom,bios.rebootTimeout=5000,bootmenu.enable=yes,bootmenu.timeout=5000", "boot-guest-loader-bios") +c.add_compare("--boot firmware=efi,loader=/path/to/loader,loader.readonly=yes,loader.secure=yes,loader.type=pflash,bios.useserial=yes,nvram=/path/to/nvram", "boot-guest-loader-efi") diff --git a/tests/test_xmlparse.py b/tests/test_xmlparse.py index 6d1aaddb8..e6bd2fb83 100644 --- a/tests/test_xmlparse.py +++ b/tests/test_xmlparse.py @@ -134,8 +134,10 @@ def testAlterGuest(): check("loader", None, "/foo/loader") check("init", None, "/sbin/init") check("bootorder", ["hd"], ["fd"]) - check("enable_bootmenu", None, False) - check("useserial", None, True) + check("bootmenu_enable", None, False) + check("bootmenu_timeout", None, 30000) + check("bios_useserial", None, True) + check("bios_rebootTimeout", None, -1) check("kernel", None) check("initrd", None) check("kernel_args", None) diff --git a/virtManager/object/domain.py b/virtManager/object/domain.py index 6c734df9b..c07af1457 100644 --- a/virtManager/object/domain.py +++ b/virtManager/object/domain.py @@ -703,7 +703,7 @@ class vmmDomain(vmmLibvirtObject): guest.set_boot_order(boot_order, legacy=legacy) if boot_menu != _SENTINEL: - guest.os.enable_bootmenu = bool(boot_menu) + guest.os.bootmenu_enable = bool(boot_menu) if init != _SENTINEL: guest.os.init = init guest.os.set_initargs_string(initargs) @@ -1259,7 +1259,7 @@ class vmmDomain(vmmLibvirtObject): def get_boot_menu(self): guest = self.get_xmlobj() - return bool(guest.os.enable_bootmenu) + return bool(guest.os.bootmenu_enable) def get_boot_kernel_info(self): guest = self.get_xmlobj() return (guest.os.kernel, guest.os.initrd, diff --git a/virtinst/cli.py b/virtinst/cli.py index 116a98db8..89d5dbbf6 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -2674,9 +2674,10 @@ class ParserBoot(VirtCLIParser): find_inst_cb=cls.feature_find_inst_cb) cls.add_arg("boot[0-9]*.dev", "dev", find_inst_cb=cls.boot_find_inst_cb) - cls.add_arg("bootmenu.enable", "enable_bootmenu", is_onoff=True) - cls.add_arg("bios.useserial", "useserial", is_onoff=True) - cls.add_arg("bios.rebootTimeout", "rebootTimeout") + cls.add_arg("bootmenu.enable", "bootmenu_enable", is_onoff=True) + cls.add_arg("bootmenu.timeout", "bootmenu_timeout") + cls.add_arg("bios.useserial", "bios_useserial", is_onoff=True) + cls.add_arg("bios.rebootTimeout", "bios_rebootTimeout") cls.add_arg("init", "init") cls.add_arg("initargs", "initargs", cb=cls.set_initargs_cb) cls.add_arg("initarg[0-9]*", "val", diff --git a/virtinst/domain/os.py b/virtinst/domain/os.py index 56859ef68..4c2d56fcf 100644 --- a/virtinst/domain/os.py +++ b/virtinst/domain/os.py @@ -78,6 +78,7 @@ class DomainOs(XMLBuilder): "initdir", "inituser", "initgroup", "kernel_args", "dtb", "bootdevs", "smbios_mode"] + # BIOS bootloader def _get_bootorder(self): return [dev.dev for dev in self.bootdevs] def _set_bootorder(self, newdevs): @@ -87,8 +88,13 @@ class DomainOs(XMLBuilder): for d in newdevs: dev = self.bootdevs.add_new() dev.dev = d - bootdevs = XMLChildProperty(_BootDevice) bootorder = property(_get_bootorder, _set_bootorder) + bootdevs = XMLChildProperty(_BootDevice) + smbios_mode = XMLProperty("./smbios/@mode") + bootmenu_enable = XMLProperty("./bootmenu/@enable", is_yesno=True) + bootmenu_timeout = XMLProperty("./bootmenu/@timeout", is_int=True) + bios_rebootTimeout = XMLProperty("./bios/@rebootTimeout", is_int=True) + bios_useserial = XMLProperty("./bios/@useserial", is_yesno=True) initargs = XMLChildProperty(_InitArg) def set_initargs_string(self, argstring): @@ -99,10 +105,6 @@ class DomainOs(XMLBuilder): obj = self.initargs.add_new() obj.val = val - enable_bootmenu = XMLProperty("./bootmenu/@enable", is_yesno=True) - rebootTimeout = XMLProperty("./bios/@rebootTimeout") - useserial = XMLProperty("./bios/@useserial", is_yesno=True) - kernel = XMLProperty("./kernel", do_abspath=True) initrd = XMLProperty("./initrd", do_abspath=True) dtb = XMLProperty("./dtb", do_abspath=True) @@ -116,7 +118,6 @@ class DomainOs(XMLBuilder): loader_ro = XMLProperty("./loader/@readonly", is_yesno=True) loader_type = XMLProperty("./loader/@type") loader_secure = XMLProperty("./loader/@secure", is_yesno=True) - smbios_mode = XMLProperty("./smbios/@mode") nvram = XMLProperty("./nvram", do_abspath=True) nvram_template = XMLProperty("./nvram/@template") arch = XMLProperty("./type/@arch")