diff --git a/qemu/tests/cfg/seabios_strict.cfg b/qemu/tests/cfg/seabios_strict.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3368ce3af8ce1163e64ce656d6ba47d896ca2914 --- /dev/null +++ b/qemu/tests/cfg/seabios_strict.cfg @@ -0,0 +1,29 @@ +- seabios_strict: + virt_test_type = qemu + only i386, x86_64 + type = seabios_strict + boot_menu = on + enable_sga = yes + images = 'stg' + bootindex_stg = 1 + image_name_stg = 'images/stg' + image_size_stg = 200M + force_create_image_stg = yes + remove_image_stg = yes + nics = 'nic1' + device_id_nic1 = 'idNic1' + bootindex_nic1 = 2 + cdroms = "test" + cdrom_test = /tmp/test.iso + start_vm = no + boot_fail_infos = "Booting from Hard Disk.*" + boot_fail_infos += "Boot failed: not a bootable disk.*" + boot_fail_infos += "PXE \(PCI.*\) starting execution.*" + boot_fail_infos += "No more network devices.*" + boot_fail_infos_extra = "Booting from DVD/CD.*" + boot_fail_infos_extra += "Boot failed: Could not read from CDROM.*" + variants: + - on: + boot_strict = on + - off: + boot_strict = off diff --git a/qemu/tests/seabios_strict.py b/qemu/tests/seabios_strict.py new file mode 100644 index 0000000000000000000000000000000000000000..759297d1e59c460e66e217ec04638b68a2a13cb5 --- /dev/null +++ b/qemu/tests/seabios_strict.py @@ -0,0 +1,89 @@ +import os +import re +import logging + +from virttest import error_context +from virttest import utils_misc +from virttest import data_dir +from virttest import env_process + +from avocado.utils import process + + +@error_context.context_aware +def run(test, params, env): + """ + KVM seabios test: + 1) Start guest with sga bios + 2) Check the boot result when '-boot strict=on/off' + on: Hard Disk -> NIC + off: Hard Disk -> NIC -> DVD/CD ... + + :param test: QEMU test object + :param params: Dictionary with the test parameters + :param env: Dictionary with test environment. + """ + + def create_cdrom(): + """ + Create 'test' cdrom + """ + logging.info("creating test cdrom") + cdrom_test = params.get("cdrom_test", '/tmp/test.iso') + cdrom_test = utils_misc.get_path(data_dir.get_data_dir(), cdrom_test) + process.run("dd if=/dev/urandom of=test bs=10M count=1") + process.run("mkisofs -o %s test" % cdrom_test) + process.run("rm -f test") + + def cleanup_cdrom(): + """ + Remove 'test' cdrom + """ + logging.info("cleaning up test cdrom") + cdrom_test = utils_misc.get_path(data_dir.get_data_dir(), + params.get("cdrom_test")) + os.remove(cdrom_test) + + def boot_check(info): + """ + boot info check + """ + return re.search(info, vm.serial_console.get_stripped_output(), re.S) + + error_context.context("Start guest with sga bios", logging.info) + create_cdrom() + params["start_vm"] = "yes" + env_process.preprocess_vm(test, params, env, params.get("main_vm")) + + vm = env.get_vm(params["main_vm"]) + vm.verify_alive() + vm.pause() + + # Disable nic device, boot fail from nic device except user model + if params['nettype'] != 'user': + for nic in vm.virtnet: + process.system("ifconfig %s down" % nic.ifname) + vm.resume() + + timeout = float(params.get("login_timeout", 240)) + fail_infos = params['boot_fail_infos'] + fail_infos_ex = params['boot_fail_infos_extra'] + boot_strict = (params['boot_strict'] == 'on') + + try: + error_context.context("Check guest boot result", logging.info) + if not utils_misc.wait_for(lambda: boot_check(fail_infos), timeout, 1): + err = "Guest does not boot from Hard Disk first and then NIC" + test.fail(err) + + if utils_misc.wait_for(lambda: boot_check(fail_infos_ex), timeout, 1): + if boot_strict: + err = "Guest tries to boot from DVD/CD when 'strict' is on" + test.fail(err) + else: + if not boot_strict: + err = "Guest does not try to boot from DVD/CD" + err += " when 'strict' is off" + test.fail(err) + finally: + cleanup_cdrom()