From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50871) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDy08-0001PU-FI for qemu-devel@nongnu.org; Thu, 13 Feb 2014 10:15:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDy03-00037s-JA for qemu-devel@nongnu.org; Thu, 13 Feb 2014 10:14:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34166) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDy03-00037o-9b for qemu-devel@nongnu.org; Thu, 13 Feb 2014 10:14:51 -0500 Message-ID: <52FCE165.4080608@redhat.com> Date: Thu, 13 Feb 2014 08:14:45 -0700 From: Eric Blake MIME-Version: 1.0 References: <1392299426-13160-1-git-send-email-imammedo@redhat.com> <1392299426-13160-3-git-send-email-imammedo@redhat.com> In-Reply-To: <1392299426-13160-3-git-send-email-imammedo@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rhp66NNaQPCp0k7o6u94IBCeQM1RJmX6E" Subject: Re: [Qemu-devel] [PATCH v2 2/2] vl: convert -m to QemuOpts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov , qemu-devel@nongnu.org Cc: kwolf@redhat.com, peter.crosthwaite@xilinx.com, akong@redhat.com, stefanha@redhat.com, mjt@tls.msk.ru, armbru@redhat.com, mreitz@redhat.com, aliguori@amazon.com, pbonzini@redhat.com, lcapitulino@redhat.com, lersek@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --rhp66NNaQPCp0k7o6u94IBCeQM1RJmX6E Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 02/13/2014 06:50 AM, Igor Mammedov wrote: > Adds option to -m > "mem" - startup memory amount >=20 > For compatibility with legacy CLI if suffix-less number is passed, > it assumes amount in Mb. >=20 > Otherwise user is free to use suffixed number using suffixes b,k/K,M,G >=20 > Signed-off-by: Igor Mammedov > Signed-off-by: Paolo Bonzini > --- > v2: > - various fixes suggested by Laszlo Ersek > - check for overflow > - check for empty mem=3D"" case > - reshuffle code to avoid conflicts with another series on list > - some style/typo fixes > --- > qemu-options.hx | 12 ++++++--- > vl.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++-= -------- > 2 files changed, 65 insertions(+), 15 deletions(-) >=20 > + " configure guest RAM size\n" > + " mem: initial amount of guest memory (default: " > + stringify(DEFAULT_RAM_SIZE) "MB)\n", MB here... > + QEMU_ARCH_ALL) > STEXI > @item -m @var{megs} > @findex -m > -Set virtual RAM size to @var{megs} megabytes. Default is 128 MiB. Opt= ionally, > +Set virtual RAM size to @var{size} megabytes. Default is 128 MiB. Opt= ionally, > a suffix of ``M'' or ``G'' can be used to signify a value in megabytes= or > -gigabytes respectively. > +gigabytes respectively. If @var{size} is provided without unit suffix = then MB > +is assumed. =2E..and inconsistent on MiB vs MB here. If we're going to use MiB (whic= h is the correct term), it would be worth using it everywhere. > + opts =3D qemu_opts_parse(qemu_find_opts(MEMORY_OPTS), > + optarg, 1); > + if (!opts) { > + exit(1); I prefer EXIT_FAILURE, but that's a change for another patch (you're just following conventions). > + if (!strlen(mem_str)) { More efficient as 'if (!*mem_str)'... > + fprintf(stderr, "qemu: missing 'mem' option value\= n"); > exit(1); > } > - sz =3D QEMU_ALIGN_UP((uint64_t)value, 8192); > + > + sz =3D qemu_opt_get_size(opts, "mem", ram_size); > + > + /* Fix up legacy suffix-less format */ > + if (g_ascii_isdigit(mem_str[strlen(mem_str) - 1])) { =2E..either that, or cache your strlen() result so you only call it once.= > + uint64_t overflow_check =3D sz; > + > + sz <<=3D 20; > + if ((sz >> 20) !=3D overflow_check) { > + fprintf(stderr, "qemu: too large 'mem' option = " > + "value\n"); > + } > + } What? We print the warning, but then use the bogus value? Missing exit()= =2E --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --rhp66NNaQPCp0k7o6u94IBCeQM1RJmX6E Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJS/OFlAAoJEKeha0olJ0NqV30H/A6f9xrCXggBznph1sT2kyvv TEx44Yn1MFCh0pba8DZ+kq6YaRjgM2sIeJeyzWO6Un8MNgVQ5Fpv9qotLCM1yDme cdnypKg6NDOScSO8eEVHHNkJw6WUkA+6dx21OAnnthIdBEImT4f4icraXk32VZF7 cWqbbdsEpsCE7eWPDHBtjRzlUazbZQaxlckWoE16A9YS1x0PSKvERH+2ngpH23ll iHPq5As0YGeTfoII5Td+B79sUmMbYjcrRag363lyGIixheKzQcpOLHH2sx+eujPJ /lT5UUTE0yP9QiNLAG0JrRm9aHi1UKkdkqRlX/JytTLS0IPtYbJnL4xstiuHPBc= =6DNS -----END PGP SIGNATURE----- --rhp66NNaQPCp0k7o6u94IBCeQM1RJmX6E--