[PATCH 1/4] conf: Move virDomainObj::originalMemlock into qemuDomainObjPrivate

Michal Privoznik mprivozn at redhat.com
Wed May 11 15:03:16 UTC 2022


Since v1.3.0-90-gafbe1d4c56 the original value of memlock limit
is stored inside virDomainObj struct directly (under
originalMemlock member). This is needless because the value is
used only inside QEMU driver and thus can reside in
qemuDomainObjPrivate struct.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/conf/domain_conf.h | 3 ---
 src/qemu/qemu_domain.c | 9 +++++----
 src/qemu/qemu_domain.h | 3 +++
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 8a48646160..f5d9df3fab 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3064,9 +3064,6 @@ struct _virDomainObj {
     int taint;
     size_t ndeprecations;
     char **deprecations;
-
-    unsigned long long originalMemlock; /* Original RLIMIT_MEMLOCK, zero if no
-                                         * restore will be required later */
 };
 
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainObj, virObjectUnref);
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 7974cdb00b..4edae9cca9 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9445,6 +9445,7 @@ int
 qemuDomainAdjustMaxMemLock(virDomainObj *vm,
                            bool forceVFIO)
 {
+    qemuDomainObjPrivate *priv = vm->privateData;
     unsigned long long currentMemLock = 0;
     unsigned long long desiredMemLock = 0;
 
@@ -9457,8 +9458,8 @@ qemuDomainAdjustMaxMemLock(virDomainObj *vm,
             /* If this is the first time adjusting the limit, save the current
              * value so that we can restore it once memory locking is no longer
              * required */
-            if (vm->originalMemlock == 0) {
-                vm->originalMemlock = currentMemLock;
+            if (priv->originalMemlock == 0) {
+                priv->originalMemlock = currentMemLock;
             }
         } else {
             /* If the limit is already high enough, we can assume
@@ -9471,8 +9472,8 @@ qemuDomainAdjustMaxMemLock(virDomainObj *vm,
     } else {
         /* Once memory locking is no longer required, we can restore the
          * original, usually very low, limit */
-        desiredMemLock = vm->originalMemlock;
-        vm->originalMemlock = 0;
+        desiredMemLock = priv->originalMemlock;
+        priv->originalMemlock = 0;
     }
 
     if (desiredMemLock > 0 &&
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index c7125722e0..248af92649 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -241,6 +241,9 @@ struct _qemuDomainObjPrivate {
     GSList *dbusVMStateIds;
     /* true if -object dbus-vmstate was added */
     bool dbusVMState;
+
+    unsigned long long originalMemlock; /* Original RLIMIT_MEMLOCK, zero if no
+                                         * restore will be required later */
 };
 
 #define QEMU_DOMAIN_PRIVATE(vm) \
-- 
2.35.1



More information about the libvir-list mailing list