summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorneel <neel@FreeBSD.org>2013-10-09 03:56:07 +0000
committerneel <neel@FreeBSD.org>2013-10-09 03:56:07 +0000
commitf9f9a7e61707f80f49be34d2c1af7490549580f9 (patch)
treeacc9a278b9f141070d676a08d2877d23277d20e2 /usr.sbin
parent97e97b35c8417bc9679c023105f5f38512994440 (diff)
downloadFreeBSD-src-f9f9a7e61707f80f49be34d2c1af7490549580f9.zip
FreeBSD-src-f9f9a7e61707f80f49be34d2c1af7490549580f9.tar.gz
Parse the memory size parameter using expand_number() to allow specifying
the memory size more intuitively (e.g. 512M, 4G etc). Submitted by: rodrigc Reviewed by: grehan Approved by: re (blanket)
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bhyve/Makefile4
-rw-r--r--usr.sbin/bhyve/bhyverun.c6
-rw-r--r--usr.sbin/bhyvectl/Makefile4
-rw-r--r--usr.sbin/bhyveload/Makefile4
-rw-r--r--usr.sbin/bhyveload/bhyveload.826
-rw-r--r--usr.sbin/bhyveload/bhyveload.c7
6 files changed, 37 insertions, 14 deletions
diff --git a/usr.sbin/bhyve/Makefile b/usr.sbin/bhyve/Makefile
index ff9425f..0644ed7 100644
--- a/usr.sbin/bhyve/Makefile
+++ b/usr.sbin/bhyve/Makefile
@@ -17,8 +17,8 @@ SRCS+= vmm_instruction_emul.c
NO_MAN=
-DPADD= ${LIBVMMAPI} ${LIBMD} ${LIBPTHREAD}
-LDADD= -lvmmapi -lmd -lpthread
+DPADD= ${LIBVMMAPI} ${LIBMD} ${LIBUTIL} ${LIBPTHREAD}
+LDADD= -lvmmapi -lmd -lutil -lpthread
WARNS?= 2
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index 01a5d07..5359442 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -37,12 +37,14 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
+#include <err.h>
#include <libgen.h>
#include <unistd.h>
#include <assert.h>
#include <errno.h>
#include <pthread.h>
#include <pthread_np.h>
+#include <sysexits.h>
#include <machine/vmm.h>
#include <vmmapi.h>
@@ -529,7 +531,9 @@ main(int argc, char *argv[])
else
break;
case 'm':
- memsize = strtoul(optarg, NULL, 0) * MB;
+ error = vm_parse_memsize(optarg, &memsize);
+ if (error)
+ errx(EX_USAGE, "invalid memsize '%s'", optarg);
break;
case 'H':
guest_vmexit_on_hlt = 1;
diff --git a/usr.sbin/bhyvectl/Makefile b/usr.sbin/bhyvectl/Makefile
index 9fde12c..df3f19c 100644
--- a/usr.sbin/bhyvectl/Makefile
+++ b/usr.sbin/bhyvectl/Makefile
@@ -7,8 +7,8 @@ SRCS= bhyvectl.c
NO_MAN=
-DPADD= ${LIBVMMAPI}
-LDADD= -lvmmapi
+DPADD= ${LIBVMMAPI} ${LIBUTIL}
+LDADD= -lvmmapi -lutil
WARNS?= 3
diff --git a/usr.sbin/bhyveload/Makefile b/usr.sbin/bhyveload/Makefile
index 7b00818..e7b19bd 100644
--- a/usr.sbin/bhyveload/Makefile
+++ b/usr.sbin/bhyveload/Makefile
@@ -4,8 +4,8 @@ PROG= bhyveload
SRCS= bhyveload.c
MAN= bhyveload.8
-DPADD+= ${LIBVMMAPI}
-LDADD+= -lvmmapi
+DPADD+= ${LIBVMMAPI} ${LIBUTIL}
+LDADD+= -lvmmapi -lutil
WARNS?= 3
diff --git a/usr.sbin/bhyveload/bhyveload.8 b/usr.sbin/bhyveload/bhyveload.8
index f2e5e35..2c0edac 100644
--- a/usr.sbin/bhyveload/bhyveload.8
+++ b/usr.sbin/bhyveload/bhyveload.8
@@ -1,4 +1,4 @@
-.\"
+\"
.\" Copyright (c) 2012 NetApp Inc
.\" All rights reserved.
.\"
@@ -60,13 +60,29 @@ 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 mem-size
+.It Fl m Ar mem-size Xo
+.Sm off
+.Op Cm K | k | M | m | G | g | T | t
+.Xc
+.Sm on
+.Ar mem-size
+is the amount of memory allocated to the guest.
+.Pp
+The
.Ar mem-size
-is the amount of memory allocated to the guest in units of megabytes.
+argument may be suffixed with one of
+.Cm K ,
+.Cm M ,
+.Cm G
+or
+.Cm T
+(either upper or lower case) to indicate a multiple of
+Kilobytes, Megabytes, Gigabytes or Terabytes
+respectively.
.Pp
The default value of
.Ar mem-size
-is 256.
+is 256M.
.It Fl d Ar disk-path
The
.Ar disk-path
@@ -83,7 +99,7 @@ that boots off the ISO image
.Pa /freebsd/release.iso
and has 1GB memory allocated to it:
.Pp
-.Dl "bhyveload -m 1024 -d /freebsd/release.iso freebsd-vm"
+.Dl "bhyveload -m 1G -d /freebsd/release.iso freebsd-vm"
.Sh SEE ALSO
.Xr bhyve 4 ,
.Xr bhyve 8 ,
diff --git a/usr.sbin/bhyveload/bhyveload.c b/usr.sbin/bhyveload/bhyveload.c
index c4bafd3..6e541e8 100644
--- a/usr.sbin/bhyveload/bhyveload.c
+++ b/usr.sbin/bhyveload/bhyveload.c
@@ -67,12 +67,14 @@ __FBSDID("$FreeBSD$");
#include <dirent.h>
#include <dlfcn.h>
#include <errno.h>
+#include <err.h>
#include <fcntl.h>
#include <getopt.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sysexits.h>
#include <termios.h>
#include <unistd.h>
@@ -581,9 +583,10 @@ main(int argc, char** argv)
break;
case 'm':
- mem_size = strtoul(optarg, NULL, 0) * MB;
+ error = vm_parse_memsize(optarg, &mem_size);
+ if (error != 0)
+ errx(EX_USAGE, "Invalid memsize '%s'", optarg);
break;
-
case '?':
usage();
}
OpenPOWER on IntegriCloud