From c6252b7cea0dfa893cf1f49de3a58f222e910783 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Thu, 10 Oct 2013 15:44:02 +0200 Subject: block/raw-win32: Employ error parameter Make use of the error parameter in the opening and creating functions in block/raw-win32.c. Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- block/raw-win32.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'block/raw-win32.c') diff --git a/block/raw-win32.c b/block/raw-win32.c index 6ef320f16a..c3e4c62d53 100644 --- a/block/raw-win32.c +++ b/block/raw-win32.c @@ -251,8 +251,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, opts = qemu_opts_create_nofail(&raw_runtime_opts); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { - qerror_report_err(local_err); - error_free(local_err); + error_propagate(errp, local_err); ret = -EINVAL; goto fail; } @@ -264,6 +263,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, if ((flags & BDRV_O_NATIVE_AIO) && aio == NULL) { aio = win32_aio_init(); if (aio == NULL) { + error_setg(errp, "Could not initialize AIO"); ret = -EINVAL; goto fail; } @@ -280,6 +280,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, } else { ret = -EINVAL; } + error_setg_errno(errp, -ret, "Could not open file"); goto fail; } @@ -287,6 +288,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, ret = win32_aio_attach(aio, s->hfile); if (ret < 0) { CloseHandle(s->hfile); + error_setg_errno(errp, -ret, "Could not enable AIO"); goto fail; } s->aio = aio; @@ -438,8 +440,10 @@ static int raw_create(const char *filename, QEMUOptionParameter *options, fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); - if (fd < 0) + if (fd < 0) { + error_setg_errno(errp, errno, "Could not create file"); return -EIO; + } set_sparse(fd); ftruncate(fd, total_size * 512); qemu_close(fd); @@ -550,8 +554,7 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags, QemuOpts *opts = qemu_opts_create_nofail(&raw_runtime_opts); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { - qerror_report_err(local_err); - error_free(local_err); + error_propagate(errp, local_err); ret = -EINVAL; goto done; } @@ -560,6 +563,7 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags, if (strstart(filename, "/dev/cdrom", NULL)) { if (find_cdrom(device_name, sizeof(device_name)) < 0) { + error_setg(errp, "Could not open CD-ROM drive"); ret = -ENOENT; goto done; } @@ -586,8 +590,10 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags, int err = GetLastError(); if (err == ERROR_ACCESS_DENIED) { + error_setg_errno(errp, EACCES, "Could not open device"); ret = -EACCES; } else { + error_setg(errp, "Could not open device"); ret = -1; } goto done; -- cgit v1.2.1