From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGAg1-0002VL-DB for qemu-devel@nongnu.org; Tue, 27 Jan 2015 13:15:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGAfv-0005EQ-JL for qemu-devel@nongnu.org; Tue, 27 Jan 2015 13:15:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60051) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGAfv-0005E9-Cv for qemu-devel@nongnu.org; Tue, 27 Jan 2015 13:15:43 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0RIFg08029823 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 27 Jan 2015 13:15:42 -0500 Message-ID: <54C7D5CD.5010406@redhat.com> Date: Tue, 27 Jan 2015 11:15:41 -0700 From: Eric Blake MIME-Version: 1.0 References: In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5IEM8PCPrnnUtd6CxtUXCKfFjnr7j4K0n" Subject: Re: [Qemu-devel] [PATCH 1/2] vl.c: Fix error messages when parsing maxmem parameters List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Krempa , qemu-devel@nongnu.org Cc: Igor Mammedov This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --5IEM8PCPrnnUtd6CxtUXCKfFjnr7j4K0n Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/26/2015 08:31 AM, Peter Krempa wrote: > Produce more human readable error messages and fix few spelling > mistakes. >=20 > Also remove a redundant check for the max memory size. >=20 > Signed-off-by: Peter Krempa > --- > vl.c | 22 +++++++--------------- > 1 file changed, 7 insertions(+), 15 deletions(-) >=20 > diff --git a/vl.c b/vl.c > index 983259b..cdc920c 100644 > --- a/vl.c > +++ b/vl.c > @@ -2694,29 +2694,21 @@ static void set_memory_options(uint64_t *ram_sl= ots, ram_addr_t *maxram_size) > uint64_t slots; >=20 > sz =3D qemu_opt_get_size(opts, "maxmem", 0); > - if (sz < ram_size) { > - error_report("invalid -m option value: maxmem " > - "(0x%" PRIx64 ") <=3D initial memory (0x" > - RAM_ADDR_FMT ")", sz, ram_size); > + if (sz <=3D ram_size) { Why are we changing from '<' to '<=3D'? I think the error was in the message, not in the code, and that setting max =3D=3D size should be allowed. [1] > + error_report("invalid value of -m option maxmem: " > + "maximum memory size (0x%" PRIx64 ") must be = greater " > + "than initial memory size (0x" RAM_ADDR_FMT = ")", Why two spaces? If I'm correct that we want '<' in the condition, then the wording 'must be at least the initial memory size' would be better. > + sz, ram_size); > exit(EXIT_FAILURE); > } >=20 > slots =3D qemu_opt_get_number(opts, "slots", 0); > if ((sz > ram_size) && !slots) { > - error_report("invalid -m option value: maxmem " > - "(0x%" PRIx64 ") more than initial memory (0x" > - RAM_ADDR_FMT ") but no hotplug slots where " > - "specified", sz, ram_size); > + error_report("invalid value of -m option: maxmem was speci= fied, " > + "but no hotplug slots were specified"); > exit(EXIT_FAILURE); > } >=20 > - if ((sz <=3D ram_size) && slots) { > - error_report("invalid -m option value: %" > - PRIu64 " hotplug slots where specified but " > - "maxmem (0x%" PRIx64 ") <=3D initial memory (0x" > - RAM_ADDR_FMT ")", slots, sz, ram_size); > - exit(EXIT_FAILURE); > - } Okay, I see. This is dead if condition [1] is changed to '<=3D', but still reachable (sz =3D=3D ram_size) if condition [1] is left at '<'. Ma= ybe better logic would be: if (sz < ram_size) { max cannot be less than memory } if (sz > ram_size) { if (!slots) { max cannot be larger than size without hotplug slots } } else if (slots) { max must be larger than size to support hotplug slots } to allow max=3D=3Dram_size when slots is not present. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --5IEM8PCPrnnUtd6CxtUXCKfFjnr7j4K0n 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/ iQEcBAEBCAAGBQJUx9XOAAoJEKeha0olJ0NqnH4H/i63+tihvu0iKKBByAuUitvx zl+RmYc8D5iT1/7FGQoFVdpqLUrXhOGTxxNOIKJ1jxkUDRE1W+m3ZjIxVPa4QZG0 k7lCnsX7LiDto0M6JrwOk1mVVsZoxjt6za5qm0E1RhsQ8yhZVaZGAKa83/pE6/ka 1FMZkHa7N/qqoQkuv2REVMbUNq8XikVd9/JeghaBhBvpwU3Z4d2NjXZ8piSIBL/d CwH5ezhl9DHwgvMshVnWHfxyXB5B5X0869lBOOdIFQt8UAnn3fxYUmONyUzoBJx7 HrHe7+mUAGAOpGStNHfrjiKa0dBa0JB7tiLiMISGC/tvE/Vqn3utNGyDITSrYXI= =gJ3D -----END PGP SIGNATURE----- --5IEM8PCPrnnUtd6CxtUXCKfFjnr7j4K0n--