Merge tag 'pull-request-2024-06-12' of https://gitlab.com/thuth/qemu into staging
[qemu/kevin.git] / include / sysemu / accel-blocker.h
blobf07f36835854904b700d571e2407fc0fbe604064
1 /*
2 * Accelerator blocking API, to prevent new ioctls from starting and wait the
3 * running ones finish.
4 * This mechanism differs from pause/resume_all_vcpus() in that it does not
5 * release the BQL.
7 * Copyright (c) 2022 Red Hat Inc.
9 * Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
11 * This work is licensed under the terms of the GNU GPL, version 2 or later.
12 * See the COPYING file in the top-level directory.
14 #ifndef ACCEL_BLOCKER_H
15 #define ACCEL_BLOCKER_H
17 #include "sysemu/cpus.h"
19 void accel_blocker_init(void);
22 * accel_{cpu_}ioctl_begin/end:
23 * Mark when ioctl is about to run or just finished.
25 * accel_{cpu_}ioctl_begin will block after accel_ioctl_inhibit_begin() is
26 * called, preventing new ioctls to run. They will continue only after
27 * accel_ioctl_inibith_end().
29 void accel_ioctl_begin(void);
30 void accel_ioctl_end(void);
31 void accel_cpu_ioctl_begin(CPUState *cpu);
32 void accel_cpu_ioctl_end(CPUState *cpu);
35 * accel_ioctl_inhibit_begin: start critical section
37 * This function makes sure that:
38 * 1) incoming accel_{cpu_}ioctl_begin() calls block
39 * 2) wait that all ioctls that were already running reach
40 * accel_{cpu_}ioctl_end(), kicking vcpus if necessary.
42 * This allows the caller to access shared data or perform operations without
43 * worrying of concurrent vcpus accesses.
45 void accel_ioctl_inhibit_begin(void);
48 * accel_ioctl_inhibit_end: end critical section started by
49 * accel_ioctl_inhibit_begin()
51 * This function allows blocked accel_{cpu_}ioctl_begin() to continue.
53 void accel_ioctl_inhibit_end(void);
55 #endif /* ACCEL_BLOCKER_H */