Received: from eggs.gnu.org ([2001:4830:134:3::10]:33569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zvooa-0006za-4B for qemu-devel@nongnu.org; Mon, 09 Nov 2015 10:57:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZvooW-0004hx-MF for qemu-devel@nongnu.org; Mon, 09 Nov 2015 10:57:04 -0500 Received: from e06smtp08.uk.ibm.com ([195.75.94.104]:34394) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvooW-0004hD-DU for qemu-devel@nongnu.org; Mon, 09 Nov 2015 10:57:00 -0500 Received: from localhost by e06smtp08.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 9 Nov 2015 15:56:59 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id C28D217D8042 for ; Mon, 9 Nov 2015 15:57:14 +0000 (GMT) Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tA9FuuF49503180 for ; Mon, 9 Nov 2015 15:56:56 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tA9Futs1026046 for ; Mon, 9 Nov 2015 08:56:56 -0700 From: Cornelia Huck Date: Mon, 9 Nov 2015 16:56:31 +0100 Message-Id: <1447084592-26322-15-git-send-email-cornelia.huck@de.ibm.com> In-Reply-To: <1447084592-26322-1-git-send-email-cornelia.huck@de.ibm.com> References: <1447084592-26322-1-git-send-email-cornelia.huck@de.ibm.com> Subject: [Qemu-devel] [PATCH for-2.5 14/15] s390x/ipl: switch error reporting to error_setg List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Cornelia Huck , borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, agraf@suse.de, David Hildenbrand From: David Hildenbrand Now that we can report errors in the realize function, let's replace the fprintf's and hw_error's with error_setg. Signed-off-by: David Hildenbrand Signed-off-by: Cornelia Huck --- hw/s390x/ipl.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index c75071d..b91fcc6 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -76,6 +76,7 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) S390IPLState *ipl = S390_IPL(dev); uint64_t pentry = KERN_IMAGE_START; int kernel_size; + Error *l_err = NULL; int bios_size; char *bios_filename; @@ -93,7 +94,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (bios_filename == NULL) { - hw_error("could not find stage1 bootloader\n"); + error_setg(&l_err, "could not find stage1 bootloader\n"); + goto error; } bios_size = load_elf(bios_filename, bios_translate_addr, &fwbase, @@ -111,7 +113,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) g_free(bios_filename); if (bios_size == -1) { - hw_error("could not load bootloader '%s'\n", bios_name); + error_setg(&l_err, "could not load bootloader '%s'\n", bios_name); + goto error; } /* default boot target is the bios */ @@ -125,8 +128,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) kernel_size = load_image_targphys(ipl->kernel, 0, ram_size); } if (kernel_size < 0) { - fprintf(stderr, "could not load kernel '%s'\n", ipl->kernel); - exit(1); + error_setg(&l_err, "could not load kernel '%s'\n", ipl->kernel); + goto error; } /* * Is it a Linux kernel (starting at 0x10000)? If yes, we fill in the @@ -153,9 +156,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) initrd_size = load_image_targphys(ipl->initrd, initrd_offset, ram_size - initrd_offset); if (initrd_size == -1) { - fprintf(stderr, "qemu: could not load initrd '%s'\n", - ipl->initrd); - exit(1); + error_setg(&l_err, "could not load initrd '%s'\n", ipl->initrd); + goto error; } /* @@ -167,6 +169,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) } } qemu_register_reset(qdev_reset_all_fn, dev); +error: + error_propagate(errp, l_err); } static Property s390_ipl_properties[] = { -- 2.6.3