mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 23:03:54 -06:00
util: Introduce qemu_thread_set_affinity() and qemu_thread_get_affinity()
Usually, we let upper layers handle CPU pinning, because pthread_setaffinity_np() (-> sched_setaffinity()) is blocked via seccomp when starting QEMU with -sandbox enable=on,resourcecontrol=deny However, we want to configure and observe the CPU affinity of threads from QEMU directly in some cases when the sandbox option is either not enabled or not active yet. So let's add a way to configure CPU pinning via qemu_thread_set_affinity() and obtain CPU affinity via qemu_thread_get_affinity() and implement them under POSIX using pthread_setaffinity_np() + pthread_getaffinity_np(). Implementation under Windows is possible using SetProcessAffinityMask() + GetProcessAffinityMask(), however, that is left as future work. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Message-Id: <20221014134720.168738-3-david@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com>
This commit is contained in:
parent
6556aadc18
commit
7730f32c28
4 changed files with 102 additions and 0 deletions
|
@ -477,6 +477,18 @@ void qemu_thread_create(QemuThread *thread, const char *name,
|
|||
thread->data = data;
|
||||
}
|
||||
|
||||
int qemu_thread_set_affinity(QemuThread *thread, unsigned long *host_cpus,
|
||||
unsigned long nbits)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
int qemu_thread_get_affinity(QemuThread *thread, unsigned long **host_cpus,
|
||||
unsigned long *nbits)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
void qemu_thread_get_self(QemuThread *thread)
|
||||
{
|
||||
thread->data = qemu_thread_data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue