From patchwork Mon Jan 18 04:24:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 8052211 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E33B7BEEE5 for ; Mon, 18 Jan 2016 04:26:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 513B52021A for ; Mon, 18 Jan 2016 04:26:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 99D22201FE for ; Mon, 18 Jan 2016 04:26:11 +0000 (UTC) Received: from localhost ([::1]:57381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aL1OM-0005nf-TP for patchwork-qemu-devel@patchwork.kernel.org; Sun, 17 Jan 2016 23:26:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aL1MA-0001TT-9b for qemu-devel@nongnu.org; Sun, 17 Jan 2016 23:23:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aL1M9-0001I5-6L for qemu-devel@nongnu.org; Sun, 17 Jan 2016 23:23:54 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:43275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aL1M8-0001HW-SE; Sun, 17 Jan 2016 23:23:53 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 24D36140B04; Mon, 18 Jan 2016 15:23:50 +1100 (AEDT) From: David Gibson To: aik@ozlabs.ru, mdroth@linux.vnet.ibm.com, armbru@redhat.com Date: Mon, 18 Jan 2016 15:24:39 +1100 Message-Id: <1453091083-13931-6-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1453091083-13931-1-git-send-email-david@gibson.dropbear.id.au> References: <1453091083-13931-1-git-send-email-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2401:3900:2:1::2 Cc: lvivier@redhat.com, thuth@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson Subject: [Qemu-devel] [PATCHv3 5/9] pseries: Cleanup error handling in spapr_vga_init() 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use error_setg() to return an error rather than an explicit exit(). Previously it was an exit(0) instead of a non-zero exit code, which was simply a bug. Also improve the error message. While we're at it change the type of spapr_vga_init() to bool since that's how we're using it anyway. Signed-off-by: David Gibson Reviewed-by: Thomas Huth --- hw/ppc/spapr.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 87097bc..bb5eaa5 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1246,7 +1246,7 @@ static void spapr_rtc_create(sPAPRMachineState *spapr) } /* Returns whether we want to use VGA or not */ -static int spapr_vga_init(PCIBus *pci_bus) +static bool spapr_vga_init(PCIBus *pci_bus, Error **errp) { switch (vga_interface_type) { case VGA_NONE: @@ -1257,9 +1257,9 @@ static int spapr_vga_init(PCIBus *pci_bus) case VGA_VIRTIO: return pci_vga_init(pci_bus) != NULL; default: - fprintf(stderr, "This vga model is not supported," - "currently it only supports -vga std\n"); - exit(0); + error_setg(errp, + "Unsupported VGA mode, only -vga std or -vga virtio is supported"); + return false; } } @@ -1934,7 +1934,7 @@ static void ppc_spapr_init(MachineState *machine) } /* Graphics */ - if (spapr_vga_init(phb->bus)) { + if (spapr_vga_init(phb->bus, &error_fatal)) { spapr->has_graphics = true; machine->usb |= defaults_enabled() && !machine->usb_disabled; }