From patchwork Fri Jun 7 13:00:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 249724 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D47892C008F for ; Fri, 7 Jun 2013 23:22:58 +1000 (EST) Received: from localhost ([::1]:46361 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ukwd6-0006R3-CU for incoming@patchwork.ozlabs.org; Fri, 07 Jun 2013 09:22:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkwHf-0004pf-OT for qemu-devel@nongnu.org; Fri, 07 Jun 2013 09:00:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkwHX-0000EW-6N for qemu-devel@nongnu.org; Fri, 07 Jun 2013 09:00:47 -0400 Received: from oxygen.pond.sub.org ([2a01:4f8:121:10e4::3]:45306) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkwHW-0000Dn-Tz for qemu-devel@nongnu.org; Fri, 07 Jun 2013 09:00:39 -0400 Received: from blackfin.pond.sub.org (p5B32AF77.dip0.t-ipconnect.de [91.50.175.119]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 4352EA62D5; Fri, 7 Jun 2013 15:00:37 +0200 (CEST) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 916B6200B7; Fri, 7 Jun 2013 15:00:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 7 Jun 2013 15:00:33 +0200 Message-Id: <1370610036-10577-4-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1370610036-10577-1-git-send-email-armbru@redhat.com> References: <1370610036-10577-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:4f8:121:10e4::3 Cc: aliguori@us.ibm.com, lersek@redhat.com Subject: [Qemu-devel] [PATCH v2 3/6] smbios: Convert to error_report() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Improves diagnistics from ad hoc messages like Invalid SMBIOS UUID string to qemu-system-x86_64: -smbios type=1,uuid=gaga: Invalid UUID Signed-off-by: Markus Armbruster --- arch_init.c | 1 - hw/i386/smbios.c | 24 ++++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/arch_init.c b/arch_init.c index 5d32ecf..5d71870 100644 --- a/arch_init.c +++ b/arch_init.c @@ -1053,7 +1053,6 @@ void do_smbios_option(const char *optarg) { #ifdef TARGET_I386 if (smbios_entry_add(optarg) < 0) { - fprintf(stderr, "Wrong smbios provided\n"); exit(1); } #endif diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c index c00bb2f..a67a328 100644 --- a/hw/i386/smbios.c +++ b/hw/i386/smbios.c @@ -13,6 +13,7 @@ * GNU GPL, version 2 or (at your option) any later version. */ +#include "qemu/error-report.h" #include "sysemu/sysemu.h" #include "hw/i386/smbios.h" #include "hw/loader.h" @@ -48,8 +49,7 @@ static int smbios_type4_count = 0; static void smbios_validate_table(void) { if (smbios_type4_count && smbios_type4_count != smp_cpus) { - fprintf(stderr, - "Number of SMBIOS Type 4 tables must match cpu count.\n"); + error_report("Number of SMBIOS Type 4 tables must match cpu count"); exit(1); } } @@ -82,16 +82,16 @@ static void smbios_check_collision(int type, int entry) if (entry == SMBIOS_TABLE_ENTRY && header->type == SMBIOS_FIELD_ENTRY) { struct smbios_field *field = (void *)header; if (type == field->type) { - fprintf(stderr, "SMBIOS type %d field already defined, " - "cannot add table\n", type); + error_report("SMBIOS type %d field already defined, " + "cannot add table", type); exit(1); } } else if (entry == SMBIOS_FIELD_ENTRY && header->type == SMBIOS_TABLE_ENTRY) { struct smbios_structure_header *table = (void *)(header + 1); if (type == table->type) { - fprintf(stderr, "SMBIOS type %d table already defined, " - "cannot add field\n", type); + error_report("SMBIOS type %d table already defined, " + "cannot add field", type); exit(1); } } @@ -166,7 +166,7 @@ static void smbios_build_type_1_fields(const char *t) strlen(buf) + 1, buf); if (get_param_value(buf, sizeof(buf), "uuid", t)) { if (qemu_uuid_parse(buf, qemu_uuid) != 0) { - fprintf(stderr, "Invalid SMBIOS UUID string\n"); + error_report("Invalid UUID"); exit(1); } } @@ -188,7 +188,7 @@ int smbios_entry_add(const char *t) int size = get_image_size(buf); if (size == -1 || size < sizeof(struct smbios_structure_header)) { - fprintf(stderr, "Cannot read smbios file %s\n", buf); + error_report("Cannot read SMBIOS file %s", buf); exit(1); } @@ -204,7 +204,7 @@ int smbios_entry_add(const char *t) table->header.length = cpu_to_le16(sizeof(*table) + size); if (load_image(buf, table->data) != size) { - fprintf(stderr, "Failed to load smbios file %s", buf); + error_report("Failed to load SMBIOS file %s", buf); exit(1); } @@ -230,12 +230,12 @@ int smbios_entry_add(const char *t) smbios_build_type_1_fields(t); return 0; default: - fprintf(stderr, "Don't know how to build fields for SMBIOS type " - "%ld\n", type); + error_report("Don't know how to build fields for SMBIOS type %ld", + type); exit(1); } } - fprintf(stderr, "smbios: must specify type= or file=\n"); + error_report("Must specify type= or file="); return -1; }