]> git.proxmox.com Git - mirror_qemu.git/blob - include/sysemu/accel-blocker.h
Merge tag 'pull-request-2023-11-14' of https://gitlab.com/thuth/qemu into staging
[mirror_qemu.git] / include / sysemu / accel-blocker.h
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.
6 *
7 * Copyright (c) 2022 Red Hat Inc.
8 *
9 * Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
10 *
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.
13 */
14 #ifndef ACCEL_BLOCKER_H
15 #define ACCEL_BLOCKER_H
16
17 #include "sysemu/cpus.h"
18
19 void accel_blocker_init(void);
20
21 /*
22 * accel_{cpu_}ioctl_begin/end:
23 * Mark when ioctl is about to run or just finished.
24 *
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().
28 */
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);
33
34 /*
35 * accel_ioctl_inhibit_begin: start critical section
36 *
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.
41 *
42 * This allows the caller to access shared data or perform operations without
43 * worrying of concurrent vcpus accesses.
44 */
45 void accel_ioctl_inhibit_begin(void);
46
47 /*
48 * accel_ioctl_inhibit_end: end critical section started by
49 * accel_ioctl_inhibit_begin()
50 *
51 * This function allows blocked accel_{cpu_}ioctl_begin() to continue.
52 */
53 void accel_ioctl_inhibit_end(void);
54
55 #endif /* ACCEL_BLOCKER_H */