diff options
author | Peter Maydell | 2018-08-17 19:24:38 +0200 |
---|---|---|
committer | Peter Maydell | 2018-08-17 19:24:38 +0200 |
commit | a544c9110d3971cc764c2dcd86a55b28534e4a63 (patch) | |
tree | ab1e426f7787fc7ea16e1556c737d27a01afac6f /balloon.c | |
parent | Merge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-request' in... (diff) | |
parent | vfio/ccw/pci: Allow devices to opt-in for ballooning (diff) | |
download | qemu-a544c9110d3971cc764c2dcd86a55b28534e4a63.tar.gz qemu-a544c9110d3971cc764c2dcd86a55b28534e4a63.tar.xz qemu-a544c9110d3971cc764c2dcd86a55b28534e4a63.zip |
Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20180817.0' into staging
VFIO update 2018-08-17
- Enhance balloon inhibitor for multiple users and use around vfio
device assignment (Alex Williamson)
# gpg: Signature made Fri 17 Aug 2018 17:43:37 BST
# gpg: using RSA key 239B9B6E3BB08B22
# gpg: Good signature from "Alex Williamson <alex.williamson@redhat.com>"
# gpg: aka "Alex Williamson <alex@shazbot.org>"
# gpg: aka "Alex Williamson <alwillia@redhat.com>"
# gpg: aka "Alex Williamson <alex.l.williamson@gmail.com>"
# Primary key fingerprint: 42F6 C04E 540B D1A9 9E7B 8A90 239B 9B6E 3BB0 8B22
* remotes/awilliam/tags/vfio-update-20180817.0:
vfio/ccw/pci: Allow devices to opt-in for ballooning
vfio: Inhibit ballooning based on group attachment to a container
kvm: Use inhibit to prevent ballooning without synchronous mmu
balloon: Allow multiple inhibit users
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'balloon.c')
-rw-r--r-- | balloon.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -26,6 +26,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/atomic.h" #include "exec/cpu-common.h" #include "sysemu/kvm.h" #include "sysemu/balloon.h" @@ -37,16 +38,22 @@ static QEMUBalloonEvent *balloon_event_fn; static QEMUBalloonStatus *balloon_stat_fn; static void *balloon_opaque; -static bool balloon_inhibited; +static int balloon_inhibit_count; bool qemu_balloon_is_inhibited(void) { - return balloon_inhibited; + return atomic_read(&balloon_inhibit_count) > 0; } void qemu_balloon_inhibit(bool state) { - balloon_inhibited = state; + if (state) { + atomic_inc(&balloon_inhibit_count); + } else { + atomic_dec(&balloon_inhibit_count); + } + + assert(atomic_read(&balloon_inhibit_count) >= 0); } static bool have_balloon(Error **errp) |