Skip to content

Commit

Permalink
bios: Boot order for OVMF guest with dev=hd
Browse files Browse the repository at this point in the history
This commit adds script for automating VIRT-45958. It checks boot
element in <os> part of VMXML. The device is always hd.
  • Loading branch information
Vaclav Hodina committed Oct 5, 2022
1 parent 56bacf1 commit 50c701a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
31 changes: 26 additions & 5 deletions libvirt/tests/cfg/bios/boot_order_ovmf.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,37 @@
start_vm = "no"
only x86_64
variants:
- bootable_first:
- boot_dev:
xml_boot_in_os = "yes"
target_bus = "sata"
target_dev = "sda"
variants:
- boot_order_element:
- hd_dev:
boot_dev = "hd"
image_size = "1G"
- boot_order:
xml_boot_in_os = "no"
variants:
- file_disk:
variants:
- positive_test:
status_error = "no"
variants:
- bootable_dev:
use_bootable_dev = "yes"
boot_order_bootable_first = "yes"
target_dev = "sda"
- bootable_second:
variants:
- boot_order_element:
- unbootable_dev_first:
only boot_dev
use_unbootable_dev_first = "yes"
boot_order_bootable_first = "no"
unbootable_target_dev = "sda"
target_dev = "sdb"
- negative_test:
status_error = "yes"
variants:
- no_dev:
only boot_dev
- unbootable_dev:
only boot_dev
use_unbootable_dev = "yes"
16 changes: 10 additions & 6 deletions libvirt/tests/src/bios/boot_order_ovmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def set_domain_disk(vm, blk_source, params):
use_unbootable_dev = "yes" == params.get("use_unbootable_dev", "no")
use_unbootable_dev_first = "yes" == params.get("use_unbootable_dev_first", "no")
boot_order_bootable_first = "yes" == params.get("boot_order_bootable_first")
xml_boot_in_os = "yes" == params.get("xml_boot_in_os")

# use_unbootable_dev_first means the xml contain both type of device
# the one which is not bootable has higher order without "boot order" element
Expand All @@ -74,14 +75,16 @@ def set_domain_disk(vm, blk_source, params):

vmxml = vm_xml.VMXML.new_from_dumpxml(vm.name)
vmxml.remove_all_disk()
vmxml.remove_all_boots()
if not xml_boot_in_os:
vmxml.remove_all_boots()
vmxml.sync()
if use_unbootable_dev:
unbootable_source = os.path.join(data_dir.get_data_dir(), "unbootable.img")
unbootable_disk_params = {'source': {'attrs': {'file': unbootable_source}},
'driver': {'name': driver_name, 'type': driver_type},
'target': {'dev': unbootable_target_dev, 'bus': target_bus},
'device': disk_device}
if not boot_order_bootable_first:
if not xml_boot_in_os and not boot_order_bootable_first:
unbootable_disk_params["boot"] = 1

libvirt.create_local_disk(disk_type, unbootable_source, image_size, disk_format)
Expand All @@ -94,10 +97,11 @@ def set_domain_disk(vm, blk_source, params):
'driver': {'name': driver_name, 'type': driver_type},
'target': {'dev': target_dev, 'bus': target_bus},
'device': disk_device}
if boot_order_bootable_first:
bootable_disk_params["boot"] = 1
else:
bootable_disk_params["boot"] = 2
if not xml_boot_in_os:
if boot_order_bootable_first:
bootable_disk_params["boot"] = 1
else:
bootable_disk_params["boot"] = 2

libvirt_vmxml.modify_vm_device(vmxml=vmxml, dev_type='disk',
dev_dict=bootable_disk_params, index=1)
Expand Down

0 comments on commit 50c701a

Please sign in to comment.