Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bios: Boot order for OVMF guest with dev=hd #4466

Merged
merged 1 commit into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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