[PATCH kvmtool v2 2/3] Factor out getting the number of physical memory host pages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Factor out getting the number of physical pages available for the
host into a separate function. This will be used in a subsequent
patch.

No functional change intended.

Signed-off-by: Fuad Tabba <tabba@xxxxxxxxxx>
---
 builtin-run.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/builtin-run.c b/builtin-run.c
index 2801735..44ea690 100644
--- a/builtin-run.c
+++ b/builtin-run.c
@@ -372,17 +372,23 @@ static long host_page_size(void)
 	return page_size;
 }
 
-static u64 host_ram_size(void)
+static long host_ram_nrpages(void)
 {
-	long page_size = host_page_size();
-	long nr_pages;
+	long nr_pages = sysconf(_SC_PHYS_PAGES);
 
-	nr_pages	= sysconf(_SC_PHYS_PAGES);
 	if (nr_pages < 0) {
 		pr_warning("sysconf(_SC_PHYS_PAGES) failed");
 		return 0;
 	}
 
+	return nr_pages;
+}
+
+static u64 host_ram_size(void)
+{
+	long page_size = host_page_size();
+	long nr_pages = host_ram_nrpages();
+
 	return (u64)nr_pages * page_size;
 }
 
-- 
2.41.0.255.g8b1d071c50-goog




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux