summaryrefslogtreecommitdiffstats
path: root/lib/libvmmapi/vmmapi.c
diff options
context:
space:
mode:
authorgrehan <grehan@FreeBSD.org>2012-08-26 01:41:41 +0000
committergrehan <grehan@FreeBSD.org>2012-08-26 01:41:41 +0000
commit6c5ad005bed33e80c94460b6694d199348dac472 (patch)
tree4212354c2a326cd5023070f9c5a8a0375e16f787 /lib/libvmmapi/vmmapi.c
parent75106bd2988aa440d8beba6c6a92b55742c691b7 (diff)
downloadFreeBSD-src-6c5ad005bed33e80c94460b6694d199348dac472.zip
FreeBSD-src-6c5ad005bed33e80c94460b6694d199348dac472.tar.gz
Add sysctls to display the total and free amount of hard-wired mem for VMs
# sysctl hw.vmm hw.vmm.mem_free: 2145386496 hw.vmm.mem_total: 2145386496 Submitted by: Takeshi HASEGAWA hasegaw at gmail com
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