forked from autotest/virt-test
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test module for the QEMU "-numa" option parsing
Signed-off-by: Eduardo Habkost <[email protected]>
- Loading branch information
Showing
2 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
- numa_opts: | ||
type = numa_opts | ||
# we will start the VM manually, because we will | ||
# manually override the "mem" parameter before starting it | ||
start_vm = no | ||
# paused VMs are enough for our purposes, no need to boot them: | ||
paused_after_start_vm = yes | ||
kill_vm = yes | ||
kill_vm_gracefully = no | ||
encode_video_files = no | ||
|
||
variants: | ||
- nodes.0: | ||
# no extra parameters => zero nodes | ||
numa_nodes = 0 | ||
- nodes.1: | ||
smp_override = 6 | ||
mem_override = 256 | ||
numa_nodes = 1 | ||
extra_params += " -numa node" | ||
numa_node0_cpus = "0 1 2 3 4 5" | ||
numa_node0_size = 256 | ||
- nodes.2: | ||
smp_override = 6 | ||
mem_override = 256 | ||
numa_nodes = 2 | ||
variants: | ||
# default (interleaved) mode: | ||
- defaults: | ||
extra_params += " -numa node -numa node" | ||
numa_node0_cpus = "0 2 4" | ||
numa_node0_size = 128 | ||
numa_node1_cpus = "1 3 5" | ||
numa_node1_size = 128 | ||
# custom memory and CPU values: | ||
- custom_values: | ||
numa_node0_cpus = "4 5" | ||
numa_node0_size = 100 | ||
numa_node1_cpus = "0 1 2 3" | ||
numa_node1_size = 156 | ||
variants: | ||
- implicit_ids: | ||
extra_params += " -numa node,mem=100,cpus=4-5" | ||
extra_params += " -numa node,mem=156,cpus=0-3" | ||
- unordered_ids: | ||
extra_params += " -numa node,mem=156,cpus=0-3,nodeid=1" | ||
extra_params += " -numa node,mem=100,cpus=4-5,nodeid=0" | ||
- nodes.3: | ||
smp_override = 6 | ||
mem_override = 256 | ||
numa_nodes = 3 | ||
variants: | ||
# default (interleaved) mode: | ||
- defaults: | ||
extra_params += " -numa node -numa node -numa node" | ||
# nodes are 8MB-aligned: | ||
numa_node0_cpus = "0 3" | ||
numa_node0_size = 80 | ||
numa_node1_cpus = "1 4" | ||
numa_node1_size = 80 | ||
numa_node2_cpus = "2 5" | ||
# the last node gets all the remaining: | ||
numa_node2_size = 96 | ||
# custom memory and CPU values: | ||
- custom_values: | ||
numa_node0_cpus = "3 4" | ||
numa_node0_size = 50 | ||
numa_node1_cpus = "0 1 2" | ||
numa_node1_size = 100 | ||
numa_node2_cpus = "5" | ||
numa_node2_size = 106 | ||
variants: | ||
- implicit_ids: | ||
extra_params += " -numa node,mem=50,cpus=3-4" | ||
extra_params += " -numa node,mem=100,cpus=0-2" | ||
extra_params += " -numa node,mem=106,cpus=5" | ||
- unordered_ids: | ||
extra_params += " -numa node,mem=106,cpus=5,nodeid=2" | ||
extra_params += " -numa node,mem=50,cpus=3-4,nodeid=0" | ||
extra_params += " -numa node,mem=100,cpus=0-2,nodeid=1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from autotest.client.shared import error | ||
from virttest import qemu_vm | ||
|
||
import logging | ||
logger = logging.getLogger(__name__) | ||
dbg = logger.debug | ||
|
||
def run_numa_opts(test, params, env): | ||
""" | ||
Simple test to check if NUMA options are being parsed properly | ||
This _does not_ test if NUMA information is being properly exposed to the | ||
guest. | ||
""" | ||
|
||
dbg("starting numa_opts test...") | ||
|
||
# work around a test runner bug that makes it override test-specific "mem" | ||
# and "smp" options unconditionally, so we override them manually if | ||
# necessary, using the mem_override/smp_override options: | ||
mem_override = params.get("mem_override") | ||
if mem_override: | ||
params["mem"] = mem_override | ||
smp_override = params.get("smp_override") | ||
if smp_override: | ||
params["smp"] = smp_override | ||
|
||
# we start the VM manually because of the mem/smp workaround above: | ||
vm = env.get_vm(params.get("main_vm")) | ||
vm.create(params=params) | ||
|
||
numa = vm.monitors[0].info_numa() | ||
dbg("info numa reply: %r", numa) | ||
|
||
numa_nodes = params.get("numa_nodes") | ||
if numa_nodes: | ||
numa_nodes = int(params.get("numa_nodes")) | ||
if len(numa) <> numa_nodes: | ||
raise error.TestFail("Wrong number of numa nodes: %d. Expected: %d" % \ | ||
(len(numa), numa_nodes)) | ||
|
||
for nodenr,node in enumerate(numa): | ||
size = params.get("numa_node%d_size" % (nodenr)) | ||
if size is not None: | ||
size = int(size) | ||
if size != numa[nodenr][0]: | ||
raise error.TestFail("Wrong size of numa node %d: %d. Expected: %d" % \ | ||
(nodenr, numa[nodenr][0], size)) | ||
|
||
cpus = params.get("numa_node%d_cpus" % (nodenr)) | ||
if cpus is not None: | ||
cpus = set([int(v) for v in cpus.split()]) | ||
if cpus <> numa[nodenr][1]: | ||
raise error.TestFail("Wrong CPU set on numa node %d: %s. Expected: %s" % \ | ||
(nodenr, numa[nodenr][1], cpus)) |