From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOCRq-0002Sb-To for qemu-devel@nongnu.org; Wed, 18 Feb 2015 16:46:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOCRq-0003Vb-2K for qemu-devel@nongnu.org; Wed, 18 Feb 2015 16:46:22 -0500 Received: from mail.kernel.org ([198.145.29.136]:51460) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOCRp-0003VU-PU for qemu-devel@nongnu.org; Wed, 18 Feb 2015 16:46:22 -0500 Date: Wed, 18 Feb 2015 22:46:15 +0100 From: "Michael S. Tsirkin" Message-ID: <1424295164-4774-23-git-send-email-mst@redhat.com> References: <1424295164-4774-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1424295164-4774-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 22/96] vl.c: Fix error messages when parsing maxmem parameters List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Peter Krempa , Juan Quintela , dgilbert@redhat.com, Anthony Liguori , Paolo Bonzini From: Peter Krempa Produce more human readable error messages and fix few spelling mistakes. Also remove a redundant check for the max memory size. Signed-off-by: Peter Krempa Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Signed-off-by: Peter Krempa --- vl.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/vl.c b/vl.c index 8c8f142..8270549 100644 --- a/vl.c +++ b/vl.c @@ -2697,29 +2697,27 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size) uint64_t slots; sz = qemu_opt_get_size(opts, "maxmem", 0); + slots = qemu_opt_get_number(opts, "slots", 0); if (sz < ram_size) { - error_report("invalid -m option value: maxmem " - "(0x%" PRIx64 ") <= initial memory (0x" - RAM_ADDR_FMT ")", sz, ram_size); + error_report("invalid value of -m option maxmem: " + "maximum memory size (0x%" PRIx64 ") must be at least " + "the initial memory size (0x" RAM_ADDR_FMT ")", + sz, ram_size); exit(EXIT_FAILURE); - } - - slots = 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); + } else if (sz > ram_size) { + if (!slots) { + error_report("invalid value of -m option: maxmem was " + "specified, but no hotplug slots were specified"); + exit(EXIT_FAILURE); + } + } else if (slots) { + error_report("invalid value of -m option maxmem: " + "memory slots were specified but maximum memory size " + "(0x%" PRIx64 ") is equal to the initial memory size " + "(0x" RAM_ADDR_FMT ")", sz, ram_size); exit(EXIT_FAILURE); } - if ((sz <= ram_size) && slots) { - error_report("invalid -m option value: %" - PRIu64 " hotplug slots where specified but " - "maxmem (0x%" PRIx64 ") <= initial memory (0x" - RAM_ADDR_FMT ")", slots, sz, ram_size); - exit(EXIT_FAILURE); - } *maxram_size = sz; *ram_slots = slots; } else if ((!maxmem_str && slots_str) || -- MST