render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
4372d3
From 00c5cab2b92b653edbf491d9ef60359578c3d59a Mon Sep 17 00:00:00 2001
4372d3
Message-Id: <00c5cab2b92b653edbf491d9ef60359578c3d59a@dist-git>
11fcb6
From: Michal Privoznik <mprivozn@redhat.com>
11fcb6
Date: Wed, 11 May 2022 16:27:18 +0200
11fcb6
Subject: [PATCH] conf: Move virDomainObj::originalMemlock into
11fcb6
 qemuDomainObjPrivate
11fcb6
11fcb6
Since v1.3.0-90-gafbe1d4c56 the original value of memlock limit
11fcb6
is stored inside virDomainObj struct directly (under
11fcb6
originalMemlock member). This is needless because the value is
11fcb6
used only inside QEMU driver and thus can reside in
11fcb6
qemuDomainObjPrivate struct.
11fcb6
11fcb6
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11fcb6
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
11fcb6
(cherry picked from commit 75df6d2c291c48d65c1e54dd93e3d2d3cb0712e7)
11fcb6
4372d3
https://bugzilla.redhat.com/show_bug.cgi?id=2089433
11fcb6
11fcb6
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11fcb6
---
11fcb6
 src/conf/domain_conf.h | 3 ---
11fcb6
 src/qemu/qemu_domain.c | 9 +++++----
11fcb6
 src/qemu/qemu_domain.h | 3 +++
11fcb6
 3 files changed, 8 insertions(+), 7 deletions(-)
11fcb6
11fcb6
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
4372d3
index d0d0fdc815..45976beb2b 100644
11fcb6
--- a/src/conf/domain_conf.h
11fcb6
+++ b/src/conf/domain_conf.h
4372d3
@@ -3031,9 +3031,6 @@ struct _virDomainObj {
11fcb6
     int taint;
11fcb6
     size_t ndeprecations;
11fcb6
     char **deprecations;
11fcb6
-
11fcb6
-    unsigned long long originalMemlock; /* Original RLIMIT_MEMLOCK, zero if no
11fcb6
-                                         * restore will be required later */
11fcb6
 };
11fcb6
 
11fcb6
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainObj, virObjectUnref);
11fcb6
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
11fcb6
index 40fe9985e6..86d673dafa 100644
11fcb6
--- a/src/qemu/qemu_domain.c
11fcb6
+++ b/src/qemu/qemu_domain.c
11fcb6
@@ -9269,6 +9269,7 @@ int
11fcb6
 qemuDomainAdjustMaxMemLock(virDomainObj *vm,
11fcb6
                            bool forceVFIO)
11fcb6
 {
11fcb6
+    qemuDomainObjPrivate *priv = vm->privateData;
11fcb6
     unsigned long long currentMemLock = 0;
11fcb6
     unsigned long long desiredMemLock = 0;
11fcb6
 
11fcb6
@@ -9281,8 +9282,8 @@ qemuDomainAdjustMaxMemLock(virDomainObj *vm,
11fcb6
             /* If this is the first time adjusting the limit, save the current
11fcb6
              * value so that we can restore it once memory locking is no longer
11fcb6
              * required */
11fcb6
-            if (vm->originalMemlock == 0) {
11fcb6
-                vm->originalMemlock = currentMemLock;
11fcb6
+            if (priv->originalMemlock == 0) {
11fcb6
+                priv->originalMemlock = currentMemLock;
11fcb6
             }
11fcb6
         } else {
11fcb6
             /* If the limit is already high enough, we can assume
11fcb6
@@ -9295,8 +9296,8 @@ qemuDomainAdjustMaxMemLock(virDomainObj *vm,
11fcb6
     } else {
11fcb6
         /* Once memory locking is no longer required, we can restore the
11fcb6
          * original, usually very low, limit */
11fcb6
-        desiredMemLock = vm->originalMemlock;
11fcb6
-        vm->originalMemlock = 0;
11fcb6
+        desiredMemLock = priv->originalMemlock;
11fcb6
+        priv->originalMemlock = 0;
11fcb6
     }
11fcb6
 
11fcb6
     if (desiredMemLock > 0 &&
11fcb6
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
11fcb6
index e5046367e3..e9497d20de 100644
11fcb6
--- a/src/qemu/qemu_domain.h
11fcb6
+++ b/src/qemu/qemu_domain.h
11fcb6
@@ -241,6 +241,9 @@ struct _qemuDomainObjPrivate {
11fcb6
     GSList *dbusVMStateIds;
11fcb6
     /* true if -object dbus-vmstate was added */
11fcb6
     bool dbusVMState;
11fcb6
+
11fcb6
+    unsigned long long originalMemlock; /* Original RLIMIT_MEMLOCK, zero if no
11fcb6
+                                         * restore will be required later */
11fcb6
 };
11fcb6
 
11fcb6
 #define QEMU_DOMAIN_PRIVATE(vm) \
11fcb6
-- 
11fcb6
2.35.1
11fcb6