Skip to content

Commit

Permalink
thread-context: support new object thread-context
Browse files Browse the repository at this point in the history
Includes support in avocado-vt for a new object:
thread-context. The intention of this new object
is to be used to make NUMA aware of the memory
preallocation threads.

Signed-off-by: mcasquer <[email protected]>
  • Loading branch information
mcasquer committed Jul 24, 2023
1 parent e20d6f4 commit 30da4ce
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
15 changes: 15 additions & 0 deletions virttest/qemu_devices/qcontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2896,6 +2896,21 @@ def throttle_group_define_by_params(self, group_params, name):
props = json.loads(group_params.get("throttle_group_parameters", "{}"))
return QThrottleGroup(name, props)

def thread_context_define_by_params(self, params, name):
"""
Create thread-context object from params.
"""
tc_params = Params()
suffix = '_thread_context'
for key in list(params.keys()):
if key.endswith(suffix):
new_key = key.rsplit(suffix)[0]
tc_params[new_key] = params[key]
backend = "thread-context"
dev = qdevices.ThreadContext(backend, params=tc_params)
dev.set_param("id", "%s-%s" % ("thread_context", name))
return dev

def memory_object_define_by_params(self, params, name):
"""
Create memory object from params, default backend type is
Expand Down
17 changes: 17 additions & 0 deletions virttest/qemu_devices/qdevices.py
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,23 @@ def verify_unplug(self, out, monitor):
return not self._query(monitor)


class ThreadContext(QObject):
"""
thread-context object.
"""

def __init__(self, backend, params=None):
super(ThreadContext, self).__init__(backend, params)

def verify_hotplug(self, monitor):
"""Verify if it is plugged into VM."""
return self._query(monitor)

def verify_unplug(self, monitor):
"""Verify if it is unplugged from VM."""
return not self._query(monitor)


class Memory(QObject):

"""
Expand Down
10 changes: 10 additions & 0 deletions virttest/qemu_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,13 @@ def set_value(opt_string, key, fallback=None):

return secret_cmdline + " -spice %s" % (",".join(spice_opts))

def add_thread_context(devices, params):
devs = []
dev = devices.thread_context_define_by_params(params, "tc1")
devs.append(dev)
devices.insert(devs)
return devices

def add_qxl(qxl_nr, base_addr=29):
"""
adds extra qxl devices
Expand Down Expand Up @@ -1766,6 +1773,9 @@ def add_secure_guest_descriptor(params):
add_memorys(devices, params)
mem = int(params.get("mem", 0))

# Add thread context object
add_thread_context(devices, params)

# Get cpu model, before add smp, to determine cpu topology
cpu_model = params.get("cpu_model", "")
use_default_cpu_model = True
Expand Down

0 comments on commit 30da4ce

Please sign in to comment.