From patchwork Mon Jul 17 14:45:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 789532 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xB5kL1sVFz9sRg for ; Tue, 18 Jul 2017 00:47:54 +1000 (AEST) Received: from localhost ([::1]:50827 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX7JQ-00055c-6d for incoming@patchwork.ozlabs.org; Mon, 17 Jul 2017 10:47:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX7HO-0003rk-5x for qemu-devel@nongnu.org; Mon, 17 Jul 2017 10:45:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX7HJ-0008QF-AC for qemu-devel@nongnu.org; Mon, 17 Jul 2017 10:45:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50660) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX7HJ-0008Px-0P for qemu-devel@nongnu.org; Mon, 17 Jul 2017 10:45:41 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F30E0624BB; Mon, 17 Jul 2017 14:45:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F30E0624BB Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lvivier@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com F30E0624BB Received: from thinkpad.redhat.com (ovpn-116-168.ams2.redhat.com [10.36.116.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2ACB77E91C; Mon, 17 Jul 2017 14:45:28 +0000 (UTC) From: Laurent Vivier To: Paolo Bonzini Date: Mon, 17 Jul 2017 16:45:27 +0200 Message-Id: <20170717144527.24534-1-lvivier@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 17 Jul 2017 14:45:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2] accel: cleanup error output X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Ben Warren , "Michael S . Tsirkin" , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Only emit "XXX accelerator not found", if there are not further accelerators listed. eg accel=kvm:tcg doesn't print a "KVM accelerator not found" warning when it falls back to tcg, but a accel=kvm prints a warning, since no fallback is given. Suggested-by: Daniel P. Berrange Suggested-by: Paolo Bonzini Signed-off-by: Laurent Vivier Reviewed-by: Eric Blake Tested-by: Thomas Huth --- v2: replace "fprintf(stderr, ...)" by error_report() accel/accel.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/accel/accel.c b/accel/accel.c index fa85844..8ae40e1 100644 --- a/accel/accel.c +++ b/accel/accel.c @@ -33,6 +33,7 @@ #include "sysemu/qtest.h" #include "hw/xen/xen.h" #include "qom/object.h" +#include "qemu/error-report.h" static const TypeInfo accel_type = { .name = TYPE_ACCEL, @@ -69,19 +70,20 @@ static int accel_init_machine(AccelClass *acc, MachineState *ms) void configure_accelerator(MachineState *ms) { - const char *p; + const char *accel, *p; char buf[10]; int ret; bool accel_initialised = false; bool init_failed = false; AccelClass *acc = NULL; - p = qemu_opt_get(qemu_get_machine_opts(), "accel"); - if (p == NULL) { + accel = qemu_opt_get(qemu_get_machine_opts(), "accel"); + if (accel == NULL) { /* Use the default "accelerator", tcg */ - p = "tcg"; + accel = "tcg"; } + p = accel; while (!accel_initialised && *p != '\0') { if (*p == ':') { p++; @@ -89,7 +91,6 @@ void configure_accelerator(MachineState *ms) p = get_opt_name(buf, sizeof(buf), p, ':'); acc = accel_find(buf); if (!acc) { - fprintf(stderr, "\"%s\" accelerator not found.\n", buf); continue; } if (acc->available && !acc->available()) { @@ -100,9 +101,8 @@ void configure_accelerator(MachineState *ms) ret = accel_init_machine(acc, ms); if (ret < 0) { init_failed = true; - fprintf(stderr, "failed to initialize %s: %s\n", - acc->name, - strerror(-ret)); + error_report("failed to initialize %s: %s", + acc->name, strerror(-ret)); } else { accel_initialised = true; } @@ -110,13 +110,13 @@ void configure_accelerator(MachineState *ms) if (!accel_initialised) { if (!init_failed) { - fprintf(stderr, "No accelerator found!\n"); + error_report("-machine accel=%s: No accelerator found", accel); } exit(1); } if (init_failed) { - fprintf(stderr, "Back to %s accelerator.\n", acc->name); + error_report("Back to %s accelerator", acc->name); } }