提交 2a94fee3 编写于 作者: P Paolo Bonzini 提交者: Kevin Wolf

curl: correctly propagate errors

Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: NFam Zheng <famz@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 f8d924e4
...@@ -456,30 +456,27 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, ...@@ -456,30 +456,27 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
static int inited = 0; static int inited = 0;
if (flags & BDRV_O_RDWR) { if (flags & BDRV_O_RDWR) {
qerror_report(ERROR_CLASS_GENERIC_ERROR, error_setg(errp, "curl block device does not support writes");
"curl block device does not support writes");
return -EROFS; return -EROFS;
} }
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err); qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) { if (local_err) {
qerror_report_err(local_err); error_propagate(errp, local_err);
error_free(local_err);
goto out_noclean; goto out_noclean;
} }
s->readahead_size = qemu_opt_get_size(opts, "readahead", READ_AHEAD_SIZE); s->readahead_size = qemu_opt_get_size(opts, "readahead", READ_AHEAD_SIZE);
if ((s->readahead_size & 0x1ff) != 0) { if ((s->readahead_size & 0x1ff) != 0) {
fprintf(stderr, "HTTP_READAHEAD_SIZE %zd is not a multiple of 512\n", error_setg(errp, "HTTP_READAHEAD_SIZE %zd is not a multiple of 512",
s->readahead_size); s->readahead_size);
goto out_noclean; goto out_noclean;
} }
file = qemu_opt_get(opts, "url"); file = qemu_opt_get(opts, "url");
if (file == NULL) { if (file == NULL) {
qerror_report(ERROR_CLASS_GENERIC_ERROR, "curl block driver requires " error_setg(errp, "curl block driver requires an 'url' option");
"an 'url' option");
goto out_noclean; goto out_noclean;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册