diff --git a/libvirt/tests/cfg/virsh_cmd/domain/virsh_guestvcpus.cfg b/libvirt/tests/cfg/virsh_cmd/domain/virsh_guestvcpus.cfg index 80494b2f72..ea6b675847 100644 --- a/libvirt/tests/cfg/virsh_cmd/domain/virsh_guestvcpus.cfg +++ b/libvirt/tests/cfg/virsh_cmd/domain/virsh_guestvcpus.cfg @@ -8,6 +8,7 @@ take_regular_screendumps="no" vcpus_num = "20" vcpus_placement = "static" + max_test = "" option = "" combine = "" error_msg = [] @@ -26,6 +27,16 @@ option = "--enable" - combine: combine = "yes" + - max_test: + status_error = "no" + max_test = "yes" + variants: + - disable: + option = "--disable" + - enable: + option = "--enable" + - combine: + combine = "yes" - error_test: status_error = "yes" variants: diff --git a/libvirt/tests/src/virsh_cmd/domain/virsh_guestvcpus.py b/libvirt/tests/src/virsh_cmd/domain/virsh_guestvcpus.py index 2e61860cb4..bea4e363a3 100644 --- a/libvirt/tests/src/virsh_cmd/domain/virsh_guestvcpus.py +++ b/libvirt/tests/src/virsh_cmd/domain/virsh_guestvcpus.py @@ -26,6 +26,7 @@ def run(test, params, env): vm = env.get_vm(vm_name) vcpus_num = int(params.get("vcpus_num", "20")) vcpus_placement = params.get("vcpus_placement", "static") + max_test = params.get("max_test", "") option = params.get("option", "") combine = params.get("combine", "") invalid_domain = params.get("invalid_domain", "") @@ -40,6 +41,13 @@ def run(test, params, env): vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name) vmxml_bakup = vmxml.copy() + # Max test: set vcpus_num to the host online cpu number + if max_test == "yes": + host_cpu_info = cpuutil.get_cpu_info() + host_online_cpus = int(host_cpu_info["On-line CPU(s) list"].split("-")[1]) + 1 + logging.debug("Host online CPU number: %s" % str(host_online_cpus)) + vcpus_num = host_online_cpus + try: # Modify vm with static vcpus if vm.is_alive(): @@ -51,17 +59,28 @@ def run(test, params, env): # Start guest agent in vm vm.prepare_guest_agent() - # Normal test: disable/ enable guest vcpus + # Disable/enable guest vcpus if option and status_error == "no": - for cpu in range(1, vcpus_num): - virsh.guestvcpus(vm_name, str(cpu), option, debug=True) + if max_test == "yes": + # Max test + vcpus_list = '1' + '-' + str(vcpus_num - 1) + virsh.guestvcpus(vm_name, vcpus_list, option, debug=True) + else: + # Normal test + for cpu in range(1, vcpus_num): + virsh.guestvcpus(vm_name, str(cpu), option, debug=True) - # Normal test: combine: --disable 1-max then --enable 1 + # Combine: --disable 1-max then --enable if combine == "yes" and status_error == "no": vcpus_list = '1' + '-' + str(vcpus_num - 1) option = "--disable" virsh.guestvcpus(vm_name, vcpus_list, option, debug=True) - vcpus_list = '1' + + # Max test: --enable 1-max (no change to vcpus_list) + # Normal test: --enable 1 + if max_test != "yes": + vcpus_list = '1' + option = "--enable" virsh.guestvcpus(vm_name, vcpus_list, option, debug=True) @@ -87,28 +106,32 @@ def run(test, params, env): # Check the test result of query ret_output = dict([item.strip() for item in line.split(":")] for line in output.split("\n")) - if combine == "yes": + if combine == "yes" and max_test != "yes": online_vcpus = '0-1' elif option == "--disable": online_vcpus = '0' else: + # either normal --enable test or max --enable test or max combine test online_vcpus = '0' + '-' + str(vcpus_num - 1) if ret_output["online"] != online_vcpus: test.fail("Query result is different from" - " the '%s' command." % option) + " the '%s' command." + " Expected %s " + " but query result is %s." % (option, online_vcpus, ret_output["online"])) # Check the cpu in guest session = vm.wait_for_login() vm_cpu_info = cpuutil.get_cpu_info(session) session.close() - if combine == "yes": + if combine == "yes" and max_test != "yes": online_vcpus = '0,1' elif option == "--disable": online_vcpus = '0' offline_vcpus = '1' + '-' + str(vcpus_num - 1) else: + # either normal --enable test or max --enable test or max combine test online_vcpus = '0' + '-' + str(vcpus_num - 1) if offline_vcpus: