Date: Fri, 4 Oct 2013 12:35:53 -0700 From: Craig Rodrigues <rodrigc@FreeBSD.org> To: "freebsd-virtualization@freebsd.org" <freebsd-virtualization@freebsd.org> Subject: Use humanize_number() inside bhyveload? Message-ID: <CAG=rPVeed2TDoSeCWO%2B8SQXtsn0uOFfC2y8dmTDT=9JW%2BApRBg@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Hi, In /usr/src/usr.bin/truncate/truncate.c , you can see that the '-s' parameter to the truncate utility is parsed with the expand_number() utility. Can we use expand_number() in bhyve_load? That will allow people to enter parameters like: -m 2G This is handy and consistent with other FreeBSD utilities. Index: usr.sbin/bhyveload/Makefile =================================================================== --- usr.sbin/bhyveload/Makefile (revision 256057) +++ usr.sbin/bhyveload/Makefile (working copy) @@ -4,8 +4,8 @@ SRCS= bhyveload.c MAN= bhyveload.8 -DPADD+= ${LIBVMMAPI} -LDADD+= -lvmmapi +DPADD+= ${LIBVMMAPI} ${LIBUTIL} +LDADD+= -lvmmapi -lutil WARNS?= 3 Index: usr.sbin/bhyveload/bhyveload.8 =================================================================== --- usr.sbin/bhyveload/bhyveload.8 (revision 256057) +++ usr.sbin/bhyveload/bhyveload.8 (working copy) @@ -62,11 +62,11 @@ .Bl -tag -width indent .It Fl m Ar mem-size .Ar mem-size -is the amount of memory allocated to the guest in units of megabytes. +is the amount of memory allocated to the guest. .Pp The default value of .Ar mem-size -is 256. +is 256 MB. .It Fl d Ar disk-path The .Ar disk-path @@ -83,7 +83,7 @@ .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 , Index: usr.sbin/bhyveload/bhyveload.c =================================================================== --- usr.sbin/bhyveload/bhyveload.c (revision 256057) +++ usr.sbin/bhyveload/bhyveload.c (working copy) @@ -67,9 +67,11 @@ #include <dirent.h> #include <dlfcn.h> #include <errno.h> +#include <err.h> #include <fcntl.h> #include <getopt.h> #include <limits.h> +#include <libutil.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -581,7 +583,9 @@ break; case 'm': - mem_size = strtoul(optarg, NULL, 0) * MB; + if (expand_number(optarg, &mem_size) == -1) + errx(EXIT_FAILURE, + "invalid size argument `%s'", optarg); break; case '?': -- Craig
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG=rPVeed2TDoSeCWO%2B8SQXtsn0uOFfC2y8dmTDT=9JW%2BApRBg>