summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bhyveload/bhyveload.c
diff options
context:
space:
mode:
authorneel <neel@FreeBSD.org>2013-03-18 22:38:30 +0000
committerneel <neel@FreeBSD.org>2013-03-18 22:38:30 +0000
commit8d05d984e8a9a632b3de9eed9ad8c765b40f88d9 (patch)
treea6c9b082e1d8d2eb2520edd75fe30f56de9a96a3 /usr.sbin/bhyveload/bhyveload.c
parentee34459918e9cf13e4840cef3ebcc8df7fa218bf (diff)
downloadFreeBSD-src-8d05d984e8a9a632b3de9eed9ad8c765b40f88d9.zip
FreeBSD-src-8d05d984e8a9a632b3de9eed9ad8c765b40f88d9.tar.gz
Simplify the assignment of memory to virtual machines by requiring a single
command line option "-m <memsize in MB>" to specify the memory size. Prior to this change the user needed to explicitly specify the amount of memory allocated below 4G (-m <lowmem>) and the amount above 4G (-M <highmem>). The "-M" option is no longer supported by 'bhyveload' and 'bhyve'. The start of the PCI hole is fixed at 3GB and cannot be directly changed using command line options. However it is still possible to change this in special circumstances via the 'vm_set_lowmem_limit()' API provided by libvmmapi. Submitted by: Dinakar Medavaram (initial version) Reviewed by: grehan Obtained from: NetApp
Diffstat (limited to 'usr.sbin/bhyveload/bhyveload.c')
-rw-r--r--usr.sbin/bhyveload/bhyveload.c57
1 files changed, 22 insertions, 35 deletions
diff --git a/usr.sbin/bhyveload/bhyveload.c b/usr.sbin/bhyveload/bhyveload.c
index ef12d9f..4cd280c 100644
--- a/usr.sbin/bhyveload/bhyveload.c
+++ b/usr.sbin/bhyveload/bhyveload.c
@@ -88,8 +88,7 @@ static char *host_base = "/";
static struct termios term, oldterm;
static int disk_fd = -1;
-static char *vmname, *progname, *membase;
-static uint64_t lowmem, highmem;
+static char *vmname, *progname;
static struct vmctx *ctx;
static uint64_t gdtbase, cr3, rsp;
@@ -323,30 +322,30 @@ cb_diskioctl(void *arg, int unit, u_long cmd, void *data)
static int
cb_copyin(void *arg, const void *from, uint64_t to, size_t size)
{
+ char *ptr;
to &= 0x7fffffff;
- if (to > lowmem)
- return (EFAULT);
- if (to + size > lowmem)
- size = lowmem - to;
- memcpy(&membase[to], from, size);
+ ptr = vm_map_gpa(ctx, to, size);
+ if (ptr == NULL)
+ return (EFAULT);
+ memcpy(ptr, from, size);
return (0);
}
static int
cb_copyout(void *arg, uint64_t from, void *to, size_t size)
{
+ char *ptr;
from &= 0x7fffffff;
- if (from > lowmem)
- return (EFAULT);
- if (from + size > lowmem)
- size = lowmem - from;
- memcpy(to, &membase[from], size);
+ ptr = vm_map_gpa(ctx, from, size);
+ if (ptr == NULL)
+ return (EFAULT);
+ memcpy(to, ptr, size);
return (0);
}
@@ -493,8 +492,8 @@ static void
cb_getmem(void *arg, uint64_t *ret_lowmem, uint64_t *ret_highmem)
{
- *ret_lowmem = lowmem;
- *ret_highmem = highmem;
+ vm_get_memory_seg(ctx, 0, ret_lowmem);
+ vm_get_memory_seg(ctx, 4 * GB, ret_highmem);
}
static const char *
@@ -551,9 +550,9 @@ static void
usage(void)
{
- printf("usage: %s [-d <disk image path>] [-h <host filesystem path>] "
- "[-m <lowmem>][-M <highmem>] "
- "<vmname>\n", progname);
+ fprintf(stderr,
+ "usage: %s [-m mem-size][-d <disk-path>] [-h <host-path>] "
+ "<vmname>\n", progname);
exit(1);
}
@@ -562,16 +561,16 @@ main(int argc, char** argv)
{
void *h;
void (*func)(struct loader_callbacks *, void *, int, int);
+ uint64_t mem_size;
int opt, error;
char *disk_image;
progname = argv[0];
- lowmem = 128 * MB;
- highmem = 0;
+ mem_size = 256 * MB;
disk_image = NULL;
- while ((opt = getopt(argc, argv, "d:h:m:M:")) != -1) {
+ while ((opt = getopt(argc, argv, "d:h:m:")) != -1) {
switch (opt) {
case 'd':
disk_image = optarg;
@@ -582,13 +581,9 @@ main(int argc, char** argv)
break;
case 'm':
- lowmem = strtoul(optarg, NULL, 0) * MB;
+ mem_size = strtoul(optarg, NULL, 0) * MB;
break;
- case 'M':
- highmem = strtoul(optarg, NULL, 0) * MB;
- break;
-
case '?':
usage();
}
@@ -615,20 +610,12 @@ main(int argc, char** argv)
exit(1);
}
- error = vm_setup_memory(ctx, 0, lowmem, &membase);
+ error = vm_setup_memory(ctx, mem_size, VM_MMAP_ALL);
if (error) {
- perror("vm_setup_memory(lowmem)");
+ perror("vm_setup_memory");
exit(1);
}
- if (highmem != 0) {
- error = vm_setup_memory(ctx, 4 * GB, highmem, NULL);
- if (error) {
- perror("vm_setup_memory(highmem)");
- exit(1);
- }
- }
-
tcgetattr(0, &term);
oldterm = term;
term.c_lflag &= ~(ICANON|ECHO);
OpenPOWER on IntegriCloud