Skip to content

Commit

Permalink
block/vvfat: Propagate errors through enable_write_target()
Browse files Browse the repository at this point in the history
Continues the conversion of the open method to Error started in commit
015a103.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
Markus Armbruster authored and stefanhaRH committed May 28, 2014
1 parent 5496fb1 commit 68c70af
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions block/vvfat.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}

Expand All @@ -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);
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH,
bdrv_qcow, errp);
if (ret < 0) {
qerror_report_err(local_err);
error_free(local_err);
goto err;
}

Expand Down

0 comments on commit 68c70af

Please sign in to comment.