Commit 135c6a1d authored by Natanael Copa's avatar Natanael Copa
Browse files

main/libvirt: fix available memory reporting

fixes #1401
parent b04ab376
# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=libvirt
pkgver=0.10.2
pkgrel=2
pkgrel=3
pkgdesc="A virtualization API for several hypervisor and container systems"
url="http://libvirt.org/"
arch="all"
......@@ -20,6 +20,7 @@ source="http://libvirt.org/sources/$pkgname-$pkgver.tar.gz
libvirt.initd
libvirt-0.10.2-legacy-xen-driver.patch
libvirt-0.10.2-support-xen-sysctl-v9.patch
uclibc-physmem.patch
"
_builddir="$srcdir"/$pkgname-$pkgver
......@@ -126,4 +127,5 @@ md5sums="a5e50860d9da238ba270b528411c4a0d libvirt-0.10.2.tar.gz
1c84a7baeafe0a7f4e9d7ae5180311b7 libvirt.confd
7067215010da2d7282d878ba43070c5d libvirt.initd
31c0c6ca4fe85bd1cfc00756ec47ea06 libvirt-0.10.2-legacy-xen-driver.patch
e259b3e5b7257c9301a36186b748195b libvirt-0.10.2-support-xen-sysctl-v9.patch"
e259b3e5b7257c9301a36186b748195b libvirt-0.10.2-support-xen-sysctl-v9.patch
df9cbfaf8a6e520a4822914a300add4d uclibc-physmem.patch"
--- ./gnulib/lib/physmem.c.orig
+++ ./gnulib/lib/physmem.c
@@ -23,6 +23,7 @@
#include "physmem.h"
#include <unistd.h>
+#include <stdio.h>
#if HAVE_SYS_PSTAT_H
# include <sys/pstat.h>
@@ -81,6 +82,22 @@
double
physmem_total (void)
{
+#if defined(__UCLIBC__)
+ char line[128];
+ FILE *f = fopen("/proc/meminfo", "r");
+ long double result = -1;
+ if (f == NULL)
+ return 0;
+ while (!feof(f) && fgets(line, sizeof(line)-1, f)) {
+ if (sscanf(line, "MemTotal: %Lf kB", &result) == 1) {
+ result *= 1024;
+ break;
+ }
+ }
+ fclose(f);
+ return result;
+#endif
+
#if defined _SC_PHYS_PAGES && defined _SC_PAGESIZE
{ /* This works on linux-gnu, solaris2 and cygwin. */
double pages = sysconf (_SC_PHYS_PAGES);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment