From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkFAe-0005WB-Sq for qemu-devel@nongnu.org; Tue, 13 May 2014 12:03:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkFAR-0008Gi-Ct for qemu-devel@nongnu.org; Tue, 13 May 2014 12:03:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58149) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkFAR-0008GM-4I for qemu-devel@nongnu.org; Tue, 13 May 2014 12:02:59 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4DG2vtJ020922 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 13 May 2014 12:02:58 -0400 From: Markus Armbruster Date: Tue, 13 May 2014 18:02:44 +0200 Message-Id: <1399996972-23429-11-git-send-email-armbru@redhat.com> In-Reply-To: <1399996972-23429-1-git-send-email-armbru@redhat.com> References: <1399996972-23429-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH 10/18] block/vvfat: Propagate errors through enable_write_target() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com Continues the conversion of the open method to Error started in commit 015a103. Signed-off-by: Markus Armbruster --- block/vvfat.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index c3af7ff..3eccd68 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -979,7 +979,7 @@ static int init_directories(BDRVVVFATState* s, static BDRVVVFATState *vvv = NULL; #endif -static int enable_write_target(BDRVVVFATState *s); +static int enable_write_target(BDRVVVFATState *s, Error **errp); static int is_consistent(BDRVVVFATState *s); static void vvfat_rebind(BlockDriverState *bs) @@ -1160,7 +1160,7 @@ DLOG(if (stderr == NULL) { s->sector_count = cyls * heads * secs - (s->first_sectors_number - 1); if (qemu_opt_get_bool(opts, "rw", false)) { - ret = enable_write_target(s); + ret = enable_write_target(s, errp); if (ret < 0) { goto fail; } @@ -2904,11 +2904,10 @@ static BlockDriver vvfat_write_target = { .bdrv_close = write_target_close, }; -static int enable_write_target(BDRVVVFATState *s) +static int enable_write_target(BDRVVVFATState *s, Error **errp) { BlockDriver *bdrv_qcow; QEMUOptionParameter *options; - Error *local_err = NULL; int ret; int size = sector2cluster(s, s->sector_count); s->used_clusters = calloc(size, 1); @@ -2918,6 +2917,7 @@ static int enable_write_target(BDRVVVFATState *s) s->qcow_filename = g_malloc(1024); ret = get_tmp_filename(s->qcow_filename, 1024); if (ret < 0) { + error_setg_errno(errp, -ret, "can't create temporary file"); goto err; } @@ -2926,20 +2926,16 @@ static int enable_write_target(BDRVVVFATState *s) set_option_parameter_int(options, BLOCK_OPT_SIZE, s->sector_count * 512); set_option_parameter(options, BLOCK_OPT_BACKING_FILE, "fat:"); - ret = bdrv_create(bdrv_qcow, s->qcow_filename, options, &local_err); + ret = bdrv_create(bdrv_qcow, s->qcow_filename, options, errp); if (ret < 0) { - qerror_report_err(local_err); - error_free(local_err); goto err; } s->qcow = NULL; ret = bdrv_open(&s->qcow, s->qcow_filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH, bdrv_qcow, - &local_err); + errp); if (ret < 0) { - qerror_report_err(local_err); - error_free(local_err); goto err; } -- 1.8.1.4