cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
218e99
From 50ff46f7848a999267c7f15dac727fe690dabfd7 Mon Sep 17 00:00:00 2001
218e99
From: Max Reitz <mreitz@redhat.com>
218e99
Date: Mon, 4 Nov 2013 22:32:17 +0100
218e99
Subject: [PATCH 24/87] block/raw-win32: Employ error parameter
218e99
218e99
RH-Author: Max Reitz <mreitz@redhat.com>
218e99
Message-id: <1383604354-12743-27-git-send-email-mreitz@redhat.com>
218e99
Patchwork-id: 55326
218e99
O-Subject: [RHEL-7.0 qemu-kvm PATCH 26/43] block/raw-win32: Employ error parameter
218e99
Bugzilla: 1026524
218e99
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
218e99
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
218e99
RH-Acked-by: Fam Zheng <famz@redhat.com>
218e99
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
218e99
218e99
BZ: 1026524
218e99
218e99
Make use of the error parameter in the opening and creating functions in
218e99
block/raw-win32.c.
218e99
218e99
Signed-off-by: Max Reitz <mreitz@redhat.com>
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
(cherry picked from commit c6252b7cea0dfa893cf1f49de3a58f222e910783)
218e99
218e99
Signed-off-by: Max Reitz <mreitz@redhat.com>
218e99
---
218e99
 block/raw-win32.c | 16 +++++++++++-----
218e99
 1 file changed, 11 insertions(+), 5 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 block/raw-win32.c |   16 +++++++++++-----
218e99
 1 files changed, 11 insertions(+), 5 deletions(-)
218e99
218e99
diff --git a/block/raw-win32.c b/block/raw-win32.c
218e99
index 9ebb083..5a60ca5 100644
218e99
--- a/block/raw-win32.c
218e99
+++ b/block/raw-win32.c
218e99
@@ -250,8 +250,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
218e99
     opts = qemu_opts_create_nofail(&raw_runtime_opts);
218e99
     qemu_opts_absorb_qdict(opts, options, &local_err);
218e99
     if (error_is_set(&local_err)) {
218e99
-        qerror_report_err(local_err);
218e99
-        error_free(local_err);
218e99
+        error_propagate(errp, local_err);
218e99
         ret = -EINVAL;
218e99
         goto fail;
218e99
     }
218e99
@@ -263,6 +262,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
218e99
     if ((flags & BDRV_O_NATIVE_AIO) && aio == NULL) {
218e99
         aio = win32_aio_init();
218e99
         if (aio == NULL) {
218e99
+            error_setg(errp, "Could not initialize AIO");
218e99
             ret = -EINVAL;
218e99
             goto fail;
218e99
         }
218e99
@@ -279,6 +279,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
218e99
         } else {
218e99
             ret = -EINVAL;
218e99
         }
218e99
+        error_setg_errno(errp, -ret, "Could not open file");
218e99
         goto fail;
218e99
     }
218e99
 
218e99
@@ -286,6 +287,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
218e99
         ret = win32_aio_attach(aio, s->hfile);
218e99
         if (ret < 0) {
218e99
             CloseHandle(s->hfile);
218e99
+            error_setg_errno(errp, -ret, "Could not enable AIO");
218e99
             goto fail;
218e99
         }
218e99
         s->aio = aio;
218e99
@@ -437,8 +439,10 @@ static int raw_create(const char *filename, QEMUOptionParameter *options,
218e99
 
218e99
     fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
218e99
                    0644);
218e99
-    if (fd < 0)
218e99
+    if (fd < 0) {
218e99
+        error_setg_errno(errp, errno, "Could not create file");
218e99
         return -EIO;
218e99
+    }
218e99
     set_sparse(fd);
218e99
     ftruncate(fd, total_size * 512);
218e99
     qemu_close(fd);
218e99
@@ -547,8 +551,7 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
218e99
     QemuOpts *opts = qemu_opts_create_nofail(&raw_runtime_opts);
218e99
     qemu_opts_absorb_qdict(opts, options, &local_err);
218e99
     if (error_is_set(&local_err)) {
218e99
-        qerror_report_err(local_err);
218e99
-        error_free(local_err);
218e99
+        error_propagate(errp, local_err);
218e99
         ret = -EINVAL;
218e99
         goto done;
218e99
     }
218e99
@@ -557,6 +560,7 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
218e99
 
218e99
     if (strstart(filename, "/dev/cdrom", NULL)) {
218e99
         if (find_cdrom(device_name, sizeof(device_name)) < 0) {
218e99
+            error_setg(errp, "Could not open CD-ROM drive");
218e99
             ret = -ENOENT;
218e99
             goto done;
218e99
         }
218e99
@@ -583,8 +587,10 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
218e99
         int err = GetLastError();
218e99
 
218e99
         if (err == ERROR_ACCESS_DENIED) {
218e99
+            error_setg_errno(errp, EACCES, "Could not open device");
218e99
             ret = -EACCES;
218e99
         } else {
218e99
+            error_setg(errp, "Could not open device");
218e99
             ret = -1;
218e99
         }
218e99
         goto done;
218e99
-- 
218e99
1.7.1
218e99