kdump-anaconda-addon/dont-call-pyanaconda-function-for-total-memory.patch
2021-08-07 10:31:04 +08:00

50 lines
1.5 KiB
Diff

From 6577df4d909ae3501b4ff2b623a8bef53d0a4588 Mon Sep 17 00:00:00 2001
From: Dave Young <dyoung@redhat.com>
Date: Thu, 7 Jul 2016 15:46:37 +0800
Subject: [PATCH] Do not call pyanaconda function for total_memory
Resolves: bz1349308
Jan reported another installer hang which is caused by this function
callback.
Switch to read meminfo directly instead of call the function.
---
com_redhat_kdump/common.py | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/com_redhat_kdump/common.py b/com_redhat_kdump/common.py
index d7c0517..d45304e 100644
--- a/com_redhat_kdump/common.py
+++ b/com_redhat_kdump/common.py
@@ -19,12 +19,11 @@
# Red Hat Author(s): David Shea <dshea@redhat.com>
#
import os
+import re
__all__ = ["getReservedMemory", "getTotalMemory", "getMemoryBounds"]
import blivet.arch
-from pyanaconda.isys import total_memory
-
_reservedMemory = None
def getReservedMemory():
"""Return the amount of memory currently reserved for kdump in MB."""
@@ -47,9 +46,14 @@ def getTotalMemory():
This is the amount reported by /proc/meminfo plus the aount
currently reserved for kdump.
"""
+ memkb = 0
+ fd = open('/proc/meminfo').read()
+ matched = re.search(r'^MemTotal:\s+(\d+)', fd)
+ if matched:
+ memkb = int(matched.groups()[0])
# total_memory return memory in KB, convert to MB
- availMem = total_memory() / 1024
+ availMem = memkb / 1024
return availMem + getReservedMemory()