From owner-freebsd-virtualization@FreeBSD.ORG Wed Oct 9 04:00:44 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 95DA26CC; Wed, 9 Oct 2013 04:00:44 +0000 (UTC) (envelope-from neelnatu@gmail.com) Received: from mail-qc0-x232.google.com (mail-qc0-x232.google.com [IPv6:2607:f8b0:400d:c01::232]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 33AE92762; Wed, 9 Oct 2013 04:00:44 +0000 (UTC) Received: by mail-qc0-f178.google.com with SMTP id r5so175359qcx.37 for ; Tue, 08 Oct 2013 21:00:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=H5/w1UVfisuI3n8HBSFZqsUSAPAy12XljVbX6lgAVjg=; b=lyRZT2SM0gJh0HodHNuoobhDHYTDHrBLvbt+baHneN7w2+qZq7g6m6YPx2H0mBP4H1 gONYiV2bnxOjZsXQ9C0q9nZcES4ojNChiWXN9SEFc1X00MZklkZrnNRZhVlAAT6xyWSd hX0nbMnDxaguihBlr+A96s9NcSubqTqUkyHe1OnzJRCxHJcr7zl9ftodYbpowCKYpbAE BBwdtLygEqQWCr/K1BmqL7jGHTByvq4pOU0IX7Bk4VKuTVnBKcM4dOF2wqRxJHzPxtCj M78u1dwI8b2YTDkReyKs2SCpTQFilkaQnKQUOa4sKxg1M1YiXTNJqtk9zHOllodsvxbl ttEw== MIME-Version: 1.0 X-Received: by 10.49.70.129 with SMTP id m1mr6541075qeu.69.1381291243263; Tue, 08 Oct 2013 21:00:43 -0700 (PDT) Received: by 10.140.102.38 with HTTP; Tue, 8 Oct 2013 21:00:43 -0700 (PDT) In-Reply-To: References: <524F27A5.5010307@freebsd.org> Date: Tue, 8 Oct 2013 21:00:43 -0700 Message-ID: Subject: Re: Use humanize_number() inside bhyveload? From: Neel Natu To: Craig Rodrigues Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: "freebsd-virtualization@freebsd.org" 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: Wed, 09 Oct 2013 04:00:44 -0000 Hi Craig, On Sun, Oct 6, 2013 at 11:31 PM, Craig Rodrigues wrote: > On Fri, Oct 4, 2013 at 1:40 PM, Peter Grehan wrote: > > > Hi Craig, > > > > > > Can we use expand_number() in bhyve_load? > >> > > > > Please commit this change :) > > > > later, > > > > Peter. > > > > > Here is a bigger patch, which uses expand_number() in bhyveload and bhyve, > and also changes comments > in vmrun.sh to reflect the change. > > Thanks for the patch - submitted as r256176 with some modifications to preserve backward compatibility. best Neel > Index: share/examples/bhyve/vmrun.sh > =================================================================== > --- share/examples/bhyve/vmrun.sh (revision 256073) > +++ share/examples/bhyve/vmrun.sh (working copy) > @@ -31,7 +31,7 @@ > BHYVECTL=/usr/sbin/bhyvectl > FBSDRUN=/usr/sbin/bhyve > > -DEFAULT_MEMSIZE=512 > +DEFAULT_MEMSIZE=512M > DEFAULT_CPUS=2 > DEFAULT_TAPDEV=tap0 > > @@ -47,7 +47,7 @@ > echo " -g: listen for connection from kgdb at " > echo " -i: force boot of the Installation CDROM image" > echo " -I: Installation CDROM image location (default is > ${DEFAULT_ISOFILE})" > - echo " -m: memory size in MB (default is ${DEFAULT_MEMSIZE}MB)" > + echo " -m: memory size (default is ${DEFAULT_MEMSIZE})" > echo " -t: tap device for virtio-net (default is $DEFAULT_TAPDEV)" > echo "" > echo " This script needs to be executed with superuser privileges" > Index: usr.sbin/bhyve/Makefile > =================================================================== > --- usr.sbin/bhyve/Makefile (revision 256073) > +++ usr.sbin/bhyve/Makefile (working copy) > @@ -17,8 +17,8 @@ > > NO_MAN= > > -DPADD= ${LIBVMMAPI} ${LIBMD} ${LIBPTHREAD} > -LDADD= -lvmmapi -lmd -lpthread > +DPADD= ${LIBVMMAPI} ${LIBMD} ${LIBUTIL} ${LIBPTHREAD} > +LDADD= -lvmmapi -lmd -lutil -lpthread > > WARNS?= 2 > > Index: usr.sbin/bhyve/bhyverun.c > =================================================================== > --- usr.sbin/bhyve/bhyverun.c (revision 256073) > +++ usr.sbin/bhyve/bhyverun.c (working copy) > @@ -37,7 +37,9 @@ > > #include > #include > +#include > #include > +#include > #include > #include > #include > @@ -541,6 +543,9 @@ > break; > case 'm': > memsize = strtoul(optarg, NULL, 0) * MB; > + if (expand_number(optarg, &memsize) == -1) > + errx(EXIT_FAILURE, > + "invalid size argument `%s'", optarg); > break; > case 'H': > guest_vmexit_on_hlt = 1; > Index: usr.sbin/bhyveload/Makefile > =================================================================== > --- usr.sbin/bhyveload/Makefile (revision 256073) > +++ 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 256073) > +++ usr.sbin/bhyveload/bhyveload.8 (working copy) > @@ -1,4 +1,4 @@ > -.\" > +\" > .\" Copyright (c) 2012 NetApp Inc > .\" All rights reserved. > .\" > @@ -60,13 +60,29 @@ > .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 in units of megabytes. > +is the amount of memory allocated to the guest. > .Pp > +The > +.Ar mem-size > +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 @@ > .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 256073) > +++ 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 '?': > _______________________________________________ > freebsd-virtualization@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization > To unsubscribe, send any mail to " > freebsd-virtualization-unsubscribe@freebsd.org" >