diff --git a/qemu/tests/cfg/netkvm_log_check.cfg b/qemu/tests/cfg/netkvm_log_check.cfg new file mode 100644 index 0000000000..3f1e6511dc --- /dev/null +++ b/qemu/tests/cfg/netkvm_log_check.cfg @@ -0,0 +1,12 @@ +- netkvm_log_check: + virt_test_type = qemu + type = netkvm_log_check + only q35 + only Windows + only virtio_net + os_type = Windows + vhost = on + timeout = 360 + smp ~= ${vcpu_maxcpus} + queues = ${smp} + SGT_msg = "Limit m_SGTableCapacity by 64" diff --git a/qemu/tests/netkvm_log_check.py b/qemu/tests/netkvm_log_check.py new file mode 100644 index 0000000000..24d72b34a4 --- /dev/null +++ b/qemu/tests/netkvm_log_check.py @@ -0,0 +1,73 @@ +import re +from virttest import error_context +from virttest import utils_net + + +@error_context.context_aware +def run(test, params, env): + """ + Netkvm log checking using traceview: + + 1) Start the VM + 2) Run `netkvmco.exe setparam 0 TXcapacity 64` in advance + 3) Do the filters to grab the "Limit m_SGTableCapacity by 64 using + `TraceView.exe`" + 4) Run `netkvmco.exe restart 0` or "NIC disabled-enabled" + 5) Check the `TraceView.exe` monitor and get "Limit + m_SGTableCapacity by 64" + + :param test: QEMU test object + :param params: Dictionary with the test parameters + :param env: Dictionary with test environment. + """ + + def netkvmco_setting_and_checking(param_name, param_value): + """ + First, set the netkvm driver parameter 'param_name' to the value + 'param_value', and then verify the results. + + param param_name: the netkvm driver parameter to modify + param param_value: the value to set to + """ + + error_context.context("Start set %s to %s" % (param_name, + param_value), test.log.info) + utils_net.set_netkvm_param_value(vm, param_name, param_value) + + test.log.info("Check value after setting %s", param_name) + cur_value = utils_net.get_netkvm_param_value(vm, param_name) + if cur_value != param_value: + err_msg = "Current value: %s is not equal to target value: %s" + err_msg = err_msg % (cur_value, param_value) + test.fail(err_msg) + + def get_keyword_from_traceview(keyword): + """ + Get the keyword by `TraceView.exe` + + Return the keywords which means that we found it. + """ + + device_mac = vm.virtnet[0].mac + error_context.context( + f"Check {keyword} from the traceview", test.log.info) + output = utils_net.dump_traceview_log_windows(params, vm) + utils_net.restart_guest_network(session, device_mac, params["os_type"]) + mapping_output = re.findall(keyword, output) + if mapping_output == []: + test.fail(f"Can't get {keyword} from traceview") + return mapping_output + + timeout = float(params.get("login_timeout", 240)) + vm_name = params['main_vm'] + vm = env.get_vm(vm_name) + vm.verify_alive() + error_context.context("wji", test.log.info) + session = vm.wait_for_serial_login(timeout=timeout) + netkvmco_setting_and_checking("TXcapacity", "64") + SGT_msg = params.get("SGT_msg") + SGT_log_output = get_keyword_from_traceview(SGT_msg) + if SGT_log_output != []: + error_context.context( + f"Found {SGT_msg} in the traceview log", test.log.info) + session.close()