|
|
9ae3a8 |
From 8e0778982e9a71000c6a1d999e0caf5934bebd61 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Alex Williamson <alex.williamson@redhat.com>
|
|
|
9ae3a8 |
Date: Thu, 13 Dec 2018 21:54:44 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 2/5] balloon: Allow multiple inhibit users
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Alex Williamson <alex.williamson@redhat.com>
|
|
|
9ae3a8 |
Message-id: <154473808463.22725.5535931320059757090.stgit@gimli.home>
|
|
|
9ae3a8 |
Patchwork-id: 83494
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.7 qemu-kvm PATCH 2/5] balloon: Allow multiple inhibit users
|
|
|
9ae3a8 |
Bugzilla: 1659229
|
|
|
9ae3a8 |
RH-Acked-by: Peter Xu <peterx@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Bugzilla: 1659229
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
A simple true/false internal state does not allow multiple users. Fix
|
|
|
9ae3a8 |
this within the existing interface by converting to a counter, so long
|
|
|
9ae3a8 |
as the counter is elevated, ballooning is inhibited.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Reviewed-by: David Hildenbrand <david@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Peter Xu <peterx@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 01ccbec7bdf6f89f1b7d46dda05e4c1fd2dd5ade)
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
balloon.c | 13 ++++++++++---
|
|
|
9ae3a8 |
1 file changed, 10 insertions(+), 3 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/balloon.c b/balloon.c
|
|
|
9ae3a8 |
index c7a0cf1..6a17096 100644
|
|
|
9ae3a8 |
--- a/balloon.c
|
|
|
9ae3a8 |
+++ b/balloon.c
|
|
|
9ae3a8 |
@@ -25,6 +25,7 @@
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#include "monitor/monitor.h"
|
|
|
9ae3a8 |
+#include "qemu/atomic.h"
|
|
|
9ae3a8 |
#include "exec/cpu-common.h"
|
|
|
9ae3a8 |
#include "sysemu/kvm.h"
|
|
|
9ae3a8 |
#include "sysemu/balloon.h"
|
|
|
9ae3a8 |
@@ -35,16 +36,22 @@
|
|
|
9ae3a8 |
static QEMUBalloonEvent *balloon_event_fn;
|
|
|
9ae3a8 |
static QEMUBalloonStatus *balloon_stat_fn;
|
|
|
9ae3a8 |
static void *balloon_opaque;
|
|
|
9ae3a8 |
-static bool balloon_inhibited;
|
|
|
9ae3a8 |
+static int balloon_inhibit_count;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
bool qemu_balloon_is_inhibited(void)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- return balloon_inhibited;
|
|
|
9ae3a8 |
+ return atomic_read(&balloon_inhibit_count) > 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
void qemu_balloon_inhibit(bool state)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- balloon_inhibited = state;
|
|
|
9ae3a8 |
+ if (state) {
|
|
|
9ae3a8 |
+ atomic_inc(&balloon_inhibit_count);
|
|
|
9ae3a8 |
+ } else {
|
|
|
9ae3a8 |
+ atomic_dec(&balloon_inhibit_count);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ assert(atomic_read(&balloon_inhibit_count) >= 0);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
int qemu_add_balloon_handler(QEMUBalloonEvent *event_func,
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|