X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=balloon.c;h=914b3662db39d6e825dbf8b19873935ff52f8af4;hb=6b7ac49d570c66754fad1b80cc200c7596d1facd;hp=5d69e8a00b4873b416868d271b45f4e6a39af42e;hpb=6966b2a07190004e18ede33ce50a65009b36f3a6;p=mirror_qemu.git diff --git a/balloon.c b/balloon.c index 5d69e8a00b..914b3662db 100644 --- a/balloon.c +++ b/balloon.c @@ -24,18 +24,36 @@ * THE SOFTWARE. */ -#include "qemu-common.h" +#include "qemu/osdep.h" +#include "qemu/atomic.h" #include "exec/cpu-common.h" #include "sysemu/kvm.h" #include "sysemu/balloon.h" -#include "trace.h" -#include "qmp-commands.h" +#include "trace-root.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" #include "qapi/qmp/qerror.h" -#include "qapi/qmp/qjson.h" static QEMUBalloonEvent *balloon_event_fn; static QEMUBalloonStatus *balloon_stat_fn; static void *balloon_opaque; +static int balloon_inhibit_count; + +bool qemu_balloon_is_inhibited(void) +{ + return atomic_read(&balloon_inhibit_count) > 0; +} + +void qemu_balloon_inhibit(bool 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) {