diff --git a/qemu/tests/balloon_hotplug.py b/qemu/tests/balloon_hotplug.py index 716b86c51b22875dd77d73a96d6102826373ee4a..67bcf598a0886e669d6f2a8d845f07666859c95c 100644 --- a/qemu/tests/balloon_hotplug.py +++ b/qemu/tests/balloon_hotplug.py @@ -1,10 +1,12 @@ import logging import time +import re from virttest.qemu_devices import qdevices from virttest import error_context from virttest import utils_test from qemu.tests import balloon_check +from qemu.tests.balloon_check import BallooningTestWin @error_context.context_aware @@ -14,11 +16,12 @@ def run(test, params, env): 1) Boot up guest w/o balloon device. 2) Hoplug balloon device and check hotplug successfully or not. - 3) Do memory balloon. - 4) Reboot/shutdown/migrate guest after hotplug balloon device(option) - 5) Do memory balloon after guest reboot(option) - 6) Unplug balloon device and check unplug successfully or not. - 7) Reboot/shutdown/migrate guest after unplug balloon device(option) + 3) Install balloon service and check its status in windows guests. + 4) Do memory balloon. + 5) Reboot/shutdown guest after hotplug balloon device(option) + 6) Do memory balloon after guest reboot(option) + 7) Unplug balloon device and check unplug successfully or not. + 8) Reboot/shutdown guest after unplug balloon device(option) :param test: QEMU test object. :param params: Dictionary with the test parameters. @@ -36,6 +39,27 @@ def run(test, params, env): % (pm_test, plug_type), logging.info) utils_test.run_virt_sub_test(test, params, env, pm_test) + def enable_balloon_service(): + """ + Install balloon service and check its status in windows guests + """ + if params['os_type'] != 'windows': + return + error_context.context("Install and check balloon service in windows " + "guest", logging.info) + session = vm.wait_for_login() + driver_name = params.get("driver_name", "balloon") + session = utils_test.qemu.windrv_check_running_verifier(session, + vm, test, + driver_name) + balloon_test = BallooningTestWin(test, params, env) + balloon_test.configure_balloon_service(session) + + output = balloon_test.operate_balloon_service(session, "status") + if not re.search(r"running", output.lower(), re.M): + test.error("Ballooon service status is not running") + session.close() + pause = float(params.get("virtio_balloon_pause", 3.0)) pm_test_after_plug = params.get("pm_test_after_plug") pm_test_after_unplug = params.get("pm_test_after_unplug") @@ -70,6 +94,8 @@ def run(test, params, env): vm.params["balloon_dev_devid"] = "balloon%d" % idx vm.params["balloon_dev_add_bus"] = "yes" + enable_balloon_service() + error_context.context("Check whether balloon device work after hotplug", logging.info) balloon_check.run(test, params, env) diff --git a/qemu/tests/cfg/balloon_hotplug.cfg b/qemu/tests/cfg/balloon_hotplug.cfg index bf6111bd3ed0ecab9d749105067f24754d664a2c..7929691d17fef939ef7ff7e716ae9d24eb4a95ce 100644 --- a/qemu/tests/cfg/balloon_hotplug.cfg +++ b/qemu/tests/cfg/balloon_hotplug.cfg @@ -13,6 +13,18 @@ balloon_type_evict = evict balloon_type_enlarge = enlarge balloon_device = virtio-balloon-pci + Windows: + cdroms += " virtio" + # Please change following cdrom_virtio to the right version + # if necessary + cdrom_virtio = isos/windows/virtio-win.iso + # balloon service related cmd, which will be covered by different + # guest's paths in guest-os cfg. + install_balloon_service = "%s:\Balloon\GUEST_OS\amd64\blnsvr.exe -i" + uninstall_balloon_service = "%s:\Balloon\GUEST_OS\amd64\blnsvr.exe -u" + status_balloon_service = "%s:\Balloon\GUEST_OS\amd64\blnsvr.exe status" + run_balloon_service = "%s:\Balloon\GUEST_OS\amd64\blnsvr.exe -r" + stop_balloon_service = "%s:\Balloon\GUEST_OS\amd64\blnsvr.exe -s" s390x: balloon_device = virtio-balloon-ccw variants: