summaryrefslogtreecommitdiffstats
path: root/lib/libvmmapi
diff options
context:
space:
mode:
authorneel <neel@FreeBSD.org>2014-05-13 16:40:27 +0000
committerneel <neel@FreeBSD.org>2014-05-13 16:40:27 +0000
commitf14c076ec7c8287b78e1359e537ee6d6e2adb9ea (patch)
tree8dd38e30d588937f075d090074ca872066ef16f7 /lib/libvmmapi
parent681730d4b1912a06a4378919ec36145765be0c92 (diff)
downloadFreeBSD-src-f14c076ec7c8287b78e1359e537ee6d6e2adb9ea.zip
FreeBSD-src-f14c076ec7c8287b78e1359e537ee6d6e2adb9ea.tar.gz
Don't include the guest memory segments in the bhyve(8) process core dump.
This has not added a lot of value when debugging bhyve issues while greatly increasing the time and space required to store the core file. Passing the "-C" option to bhyve(8) will change the default and dump guest memory in the core dump. Requested by: grehan Reviewed by: grehan
Diffstat (limited to 'lib/libvmmapi')
-rw-r--r--lib/libvmmapi/vmmapi.c18
-rw-r--r--lib/libvmmapi/vmmapi.h3
2 files changed, 18 insertions, 3 deletions
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
index 4a7f852..b853ae7 100644
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -57,6 +57,7 @@ struct vmctx {
int fd;
uint32_t lowmem_limit;
enum vm_mmap_style vms;
+ int memflags;
size_t lowmem;
char *lowmem_addr;
size_t highmem;
@@ -101,6 +102,7 @@ vm_open(const char *name)
assert(vm != NULL);
vm->fd = -1;
+ vm->memflags = 0;
vm->lowmem_limit = 3 * GB;
vm->name = (char *)(vm + 1);
strcpy(vm->name, name);
@@ -180,10 +182,17 @@ vm_set_lowmem_limit(struct vmctx *ctx, uint32_t limit)
ctx->lowmem_limit = limit;
}
+void
+vm_set_memflags(struct vmctx *ctx, int flags)
+{
+
+ ctx->memflags = flags;
+}
+
static int
setup_memory_segment(struct vmctx *ctx, vm_paddr_t gpa, size_t len, char **addr)
{
- int error;
+ int error, mmap_flags;
struct vm_memory_segment seg;
/*
@@ -195,8 +204,11 @@ setup_memory_segment(struct vmctx *ctx, vm_paddr_t gpa, size_t len, char **addr)
seg.len = len;
error = ioctl(ctx->fd, VM_MAP_MEMORY, &seg);
if (error == 0 && addr != NULL) {
- *addr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED,
- ctx->fd, gpa);
+ mmap_flags = MAP_SHARED;
+ if ((ctx->memflags & VM_MEM_F_INCORE) == 0)
+ mmap_flags |= MAP_NOCORE;
+ *addr = mmap(NULL, len, PROT_READ | PROT_WRITE, mmap_flags,
+ ctx->fd, gpa);
}
return (error);
}
diff --git a/lib/libvmmapi/vmmapi.h b/lib/libvmmapi/vmmapi.h
index 2a2ca6b..c1a4b35 100644
--- a/lib/libvmmapi/vmmapi.h
+++ b/lib/libvmmapi/vmmapi.h
@@ -42,6 +42,8 @@ enum vm_mmap_style {
VM_MMAP_SPARSE, /* mappings created on-demand */
};
+#define VM_MEM_F_INCORE 0x01 /* include guest memory in core file */
+
int vm_create(const char *name);
struct vmctx *vm_open(const char *name);
void vm_destroy(struct vmctx *ctx);
@@ -53,6 +55,7 @@ void *vm_map_gpa(struct vmctx *ctx, vm_paddr_t gaddr, size_t len);
int vm_get_gpa_pmap(struct vmctx *, uint64_t gpa, uint64_t *pte, int *num);
uint32_t vm_get_lowmem_limit(struct vmctx *ctx);
void vm_set_lowmem_limit(struct vmctx *ctx, uint32_t limit);
+void vm_set_memflags(struct vmctx *ctx, int flags);
int vm_set_desc(struct vmctx *ctx, int vcpu, int reg,
uint64_t base, uint32_t limit, uint32_t access);
int vm_get_desc(struct vmctx *ctx, int vcpu, int reg,
OpenPOWER on IntegriCloud