Blame SOURCES/kvm-balloon-Allow-multiple-inhibit-users.patch

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