Skip to content

Commit

Permalink
hotplug_virtio_mem: implements virtio-mem hotunplug
Browse files Browse the repository at this point in the history
Implements virtio-mem hotunplug as the final step of
the test case. At first, it tries to unplug the virtio-mem
device with some memory plugged in; as expected the
exception is catched. Finally resizes the device to zero
and the hotunplug is successfully done.

Signed-off-by: mcasquer <[email protected]>
  • Loading branch information
mcasquer committed Feb 19, 2024
1 parent 67154b1 commit 661f5e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions qemu/tests/cfg/hotplug_virtio_mem.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@
kernel_extra_params_add = "memhp_default_state=online_movable"
pcie_extra_root_port = 1
requested-size_test_vmem0 = "4G 2G"
error_msg = "virtio-mem device cannot get unplugged while 'size' != '0'"
13 changes: 13 additions & 0 deletions qemu/tests/hotplug_virtio_mem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from virttest import error_context

from virttest.qemu_monitor import QMPCmdError
from virttest.utils_misc import normalize_data_size
from virttest.utils_test.qemu import MemoryHotplugTest
from provider import virtio_mem_utils
Expand All @@ -24,6 +25,7 @@ def run(test, params, env):

timeout = params.get_numeric("login_timeout", 240)
threshold = params.get_numeric("threshold", target_type=float)
error_msg = params.get("error_msg")
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
session = vm.wait_for_login(timeout=timeout)
Expand Down Expand Up @@ -53,4 +55,15 @@ def run(test, params, env):
threshold, vm, test)
virtio_mem_utils.check_numa_plugged_mem(node_id, requested_size,
threshold, vm, test)
try:
hotplug_test.unplug_memory(vm, target_mem)
except QMPCmdError as e:
if error_msg not in str(e.data):
test.fail("Unexpected error message: %s" % str(e.data))
test.log.info(error_msg)

vm.monitor.qom_set(device_id, "requested-size", 0)
time.sleep(10)
hotplug_test.unplug_memory(vm, target_mem)

session.close()

0 comments on commit 661f5e2

Please sign in to comment.