summaryrefslogtreecommitdiffstats
path: root/lib/libvmmapi/vmmapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libvmmapi/vmmapi.c')
-rw-r--r--lib/libvmmapi/vmmapi.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
index 5882bd2..d7e6143 100644
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -117,6 +117,30 @@ vm_destroy(struct vmctx *vm)
free(vm);
}
+size_t
+vmm_get_mem_total(void)
+{
+ size_t mem_total = 0;
+ size_t oldlen = sizeof(mem_total);
+ int error;
+ error = sysctlbyname("hw.vmm.mem_total", &mem_total, &oldlen, NULL, 0);
+ if (error)
+ return -1;
+ return mem_total;
+}
+
+size_t
+vmm_get_mem_free(void)
+{
+ size_t mem_free = 0;
+ size_t oldlen = sizeof(mem_free);
+ int error;
+ error = sysctlbyname("hw.vmm.mem_free", &mem_free, &oldlen, NULL, 0);
+ if (error)
+ return -1;
+ return mem_free;
+}
+
int
vm_get_memory_seg(struct vmctx *ctx, vm_paddr_t gpa,
vm_paddr_t *ret_hpa, size_t *ret_len)
OpenPOWER on IntegriCloud