From patchwork Tue Jan 19 03:39:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 8057911 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 EB6E2BEEE5 for ; Tue, 19 Jan 2016 03:38:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 59F8A2042B for ; Tue, 19 Jan 2016 03:38:41 +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 2CC16203FB for ; Tue, 19 Jan 2016 03:38:40 +0000 (UTC) Received: from localhost ([::1]:34736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLN7v-0007s2-Hl for patchwork-qemu-devel@patchwork.kernel.org; Mon, 18 Jan 2016 22:38:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60358) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLN7l-0007rb-DD for qemu-devel@nongnu.org; Mon, 18 Jan 2016 22:38:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLN7k-0008HS-GY for qemu-devel@nongnu.org; Mon, 18 Jan 2016 22:38:29 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:56114) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLN7k-0008Ek-5Z; Mon, 18 Jan 2016 22:38:28 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 1F765140BA2; Tue, 19 Jan 2016 14:38:25 +1100 (AEDT) From: David Gibson To: armbru@redhat.com, aik@ozlabs.ru, mdroth@linux.vnet.ibm.com Date: Tue, 19 Jan 2016 14:39:15 +1100 Message-Id: <1453174759-22837-5-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1453174759-22837-1-git-send-email-david@gibson.dropbear.id.au> References: <1453174759-22837-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] [PATCHv4 4/8] 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 Reviewed-by: Alexey Kardashevskiy --- 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 fb0e254..1ce9b27 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1238,7 +1238,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: @@ -1249,9 +1249,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; } } @@ -1926,7 +1926,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; }