diff options
Diffstat (limited to 'usr.sbin/bhyveload')
-rw-r--r-- | usr.sbin/bhyveload/bhyveload.8 | 32 | ||||
-rw-r--r-- | usr.sbin/bhyveload/bhyveload.c | 57 |
2 files changed, 29 insertions, 60 deletions
diff --git a/usr.sbin/bhyveload/bhyveload.8 b/usr.sbin/bhyveload/bhyveload.8 index 4a05116..97ce791 100644 --- a/usr.sbin/bhyveload/bhyveload.8 +++ b/usr.sbin/bhyveload/bhyveload.8 @@ -35,8 +35,7 @@ guest inside a bhyve virtual machine .Sh SYNOPSIS .Nm -.Op Fl m Ar lowmem -.Op Fl M Ar highmem +.Op Fl m Ar mem-size .Op Fl d Ar disk-path .Op Fl h Ar host-path .Ar vmname @@ -61,22 +60,13 @@ and will be created if it does not already exist. .Sh OPTIONS The following options are available: .Bl -tag -width indent -.It Fl m Ar lowmem -.Ar lowmem -is the amount of memory allocated below 4GB in the guest's physical address -space. +.It Fl m Ar mem-size +.Ar mem-size +is the amount of memory allocated to the guest in units of megabytes. .Pp The default value of -.Ar lowmem -is 256MB. -.It Fl M Ar highmem -.Ar highmem -is the amount of memory allocated above 4GB in the guest's physical address -space. -.Pp -The default value of -.Ar highmem -is 0MB. +.Ar mem-size +is 256. .It Fl d Ar disk-path The .Ar disk-path @@ -93,16 +83,8 @@ that boots off the ISO image .Pa /freebsd/release.iso and has 1GB memory allocated to it: .Pp -.Dl "bhyveload -m 256 -M 768 -d /freebsd/release.iso freebsd-vm" +.Dl "bhyveload -m 1024 -d /freebsd/release.iso freebsd-vm" .Pp -In the example above the 1GB allocation is split in two segments: -.Pp -.Bl -dash -compact -.It -256MB below the 4GB boundary (0MB - 256MB) -.It -768MB above the 4GB boundary (4096MB - 4864MB) -.El .Sh SEE ALSO .Xr bhyve 4 , .Xr bhyve 8 , 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); |