blob: b4901ad5813cdffb9cec162f4902f3c767fe1e2e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index c88f86c..1fa3e05 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -38,6 +38,8 @@
# include <sys/types.h>
# include <sys/sysctl.h>
# include <sys/resource.h>
+#elif defined(__linux__)
+# include <sys/sysinfo.h>
#endif
#include "c-ctype.h"
@@ -1042,6 +1044,7 @@ int nodeGetInfo(virNodeInfoPtr nodeinfo)
{
int ret = -1;
FILE *cpuinfo = fopen(CPUINFO_PATH, "r");
+ struct sysinfo si;
if (!cpuinfo) {
virReportSystemError(errno,
_("cannot open %s"), CPUINFO_PATH);
@@ -1053,7 +1056,11 @@ int nodeGetInfo(virNodeInfoPtr nodeinfo)
goto cleanup;
/* Convert to KB. */
- nodeinfo->memory = physmem_total() / 1024;
+ if (sysinfo(&si) == 0) {
+ nodeinfo->memory = si.totalram / 1024;
+ } else {
+ nodeinfo->memory = physmem_total() / 1024;
+ }
cleanup:
VIR_FORCE_FCLOSE(cpuinfo);
|