From owner-freebsd-virtualization@FreeBSD.ORG Fri Oct 4 19:35:56 2013 Return-Path: Delivered-To: freebsd-virtualization@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 33544466 for ; Fri, 4 Oct 2013 19:35:56 +0000 (UTC) (envelope-from crodr001@gmail.com) Received: from mail-la0-x230.google.com (mail-la0-x230.google.com [IPv6:2a00:1450:4010:c03::230]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 9A4E42253 for ; Fri, 4 Oct 2013 19:35:55 +0000 (UTC) Received: by mail-la0-f48.google.com with SMTP id er20so3576971lab.21 for ; Fri, 04 Oct 2013 12:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=341/Z76fEGxdUMicXwJCuji/4IogSg8pkrhamm5eeXw=; b=FoxuyeJrmyIIhIWLRsYblXb3BQaq8GReVj64y1jqAs1eIN7KaV0kxOUZRxhqoTgYnN ejoav/ACM2bvrCG4QqohJc8qYLtYCUftst+w6qiuZ9Cl1kNik2v/G+f7adT+5ADUD2E3 uuOwRGYJprYf4v4+Wm3zOs6wnr+o2xquzteTxWBVHh48T9zVwucsKqgCFa60MBI/7L5I Tbentniq/ntTba7DbIStylbrHIPMu+Y5ntcqx33oTW5AU7pAzeIfkPv6TazcCpvJ3Wle 1etS75YhXzZ4a7eZBZw5Z2THZOdp48XbeqcLrJvM8jwxwriZZreFGuc5d/aTBKKAG1Qy RP0g== MIME-Version: 1.0 X-Received: by 10.152.170.166 with SMTP id an6mr13211995lac.20.1380915353632; Fri, 04 Oct 2013 12:35:53 -0700 (PDT) Sender: crodr001@gmail.com Received: by 10.112.139.132 with HTTP; Fri, 4 Oct 2013 12:35:53 -0700 (PDT) Date: Fri, 4 Oct 2013 12:35:53 -0700 X-Google-Sender-Auth: ZAj10zkSUbts7Sbh5vdhROPucIE Message-ID: Subject: Use humanize_number() inside bhyveload? From: Craig Rodrigues To: "freebsd-virtualization@freebsd.org" Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Oct 2013 19:35:56 -0000 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 #include #include +#include #include #include #include +#include #include #include #include @@ -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