[PATCH kvmtool v1 1/2] Factor out getting the host page size

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

 



Factor out getting the page size of the host into a separate
function. This will be used in the subsequent patch.

No functional change intended.

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

diff --git a/builtin-run.c b/builtin-run.c
index b1a27fd..2801735 100644
--- a/builtin-run.c
+++ b/builtin-run.c
@@ -360,9 +360,21 @@ static void kernel_usage_with_options(void)
 		KVM_BINARY_NAME);
 }
 
+static long host_page_size(void)
+{
+	long page_size = sysconf(_SC_PAGE_SIZE);
+
+	if (page_size < 0) {
+		pr_warning("sysconf(_SC_PAGE_SIZE) failed");
+		return 0;
+	}
+
+	return page_size;
+}
+
 static u64 host_ram_size(void)
 {
-	long page_size;
+	long page_size = host_page_size();
 	long nr_pages;
 
 	nr_pages	= sysconf(_SC_PHYS_PAGES);
@@ -371,12 +383,6 @@ static u64 host_ram_size(void)
 		return 0;
 	}
 
-	page_size	= sysconf(_SC_PAGE_SIZE);
-	if (page_size < 0) {
-		pr_warning("sysconf(_SC_PAGE_SIZE) failed");
-		return 0;
-	}
-
 	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