-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
guest_os_booting: Add a case of update-device
This PR adds: VIRT-297949 - [Negative] Update device with boot order Signed-off-by: Yingshun Cui <[email protected]>
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
libvirt/tests/cfg/guest_os_booting/negative/update_device_boot_order.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- guest_os_booting.update_device.boot_order: | ||
type = update_device_boot_order | ||
start_vm = no | ||
boot_index = 1 | ||
err_msg = "cannot modify field .*boot order.*" |
42 changes: 42 additions & 0 deletions
42
libvirt/tests/src/guest_os_booting/negative/update_device_boot_order.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from virttest.libvirt_xml import vm_xml | ||
from virttest import virsh | ||
from virttest.utils_test import libvirt | ||
|
||
from provider.guest_os_booting import guest_os_booting_base | ||
|
||
|
||
def run(test, params, env): | ||
""" | ||
Update disk device with boot order | ||
""" | ||
vm_name = guest_os_booting_base.get_vm(params) | ||
boot_index = params.get("boot_index") | ||
err_msg = params.get('err_msg') | ||
|
||
vm = env.get_vm(vm_name) | ||
vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm.name) | ||
bkxml = vmxml.copy() | ||
|
||
try: | ||
test.log.info("TEST_STEP: Prepare a running guest with boot order " | ||
"element in disk xml.") | ||
vm_os = vmxml.os | ||
vm_os.del_boots() | ||
vmxml.os = vm_os | ||
disk_obj = vmxml.devices.by_device_tag('disk')[0] | ||
disk_attrs = disk_obj.fetch_attrs() | ||
vmxml.set_boot_order_by_target_dev( | ||
disk_attrs['target']['dev'], params.get('boot_index')) | ||
vmxml.xmltreefile.write() | ||
test.log.debug(f"vmxml after updating: {vmxml}") | ||
vmxml.sync() | ||
vm.start() | ||
vm.wait_for_login() | ||
|
||
test.log.info("TEST_STEP: Update device.") | ||
disk_obj.boot = int(boot_index) + 1 | ||
res = virsh.update_device(vm.name, disk_obj.xml, debug=True) | ||
libvirt.check_result(res, err_msg) | ||
finally: | ||
test.log.info("TEST_TEARDOWN: Recover test environment.") | ||
bkxml.sync() |