cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-block-raw-win32-Always-use-errno-in-hdev_open.patch

218e99
From 96aa5a9a7d0dc4bb47e421168857eacbb36065a8 Mon Sep 17 00:00:00 2001
218e99
From: Max Reitz <mreitz@redhat.com>
218e99
Date: Mon, 4 Nov 2013 22:32:21 +0100
218e99
Subject: [PATCH 28/87] block/raw-win32: Always use -errno in hdev_open
218e99
218e99
RH-Author: Max Reitz <mreitz@redhat.com>
218e99
Message-id: <1383604354-12743-31-git-send-email-mreitz@redhat.com>
218e99
Patchwork-id: 55330
218e99
O-Subject: [RHEL-7.0 qemu-kvm PATCH 30/43] block/raw-win32: Always use -errno in hdev_open
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
On one occasion, hdev_open() returned -1 in case of an unknown error
218e99
instead of a proper -errno value. Adjust this to match the behavior of
218e99
raw_open() (in raw-win32), which is to return -EINVAL in this case.
218e99
Also, change the call to error_setg*() to match the one in raw_open() as
218e99
well.
218e99
218e99
Signed-off-by: Max Reitz <mreitz@redhat.com>
218e99
Reviewed-by: Eric Blake <eblake@redhat.com>
218e99
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
218e99
(cherry picked from commit 45d57f6e718e44e55780bcf1d09fa140dce7ec08)
218e99
218e99
Signed-off-by: Max Reitz <mreitz@redhat.com>
218e99
---
218e99
 block/raw-win32.c | 5 ++---
218e99
 1 file changed, 2 insertions(+), 3 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 block/raw-win32.c |    5 ++---
218e99
 1 files changed, 2 insertions(+), 3 deletions(-)
218e99
218e99
diff --git a/block/raw-win32.c b/block/raw-win32.c
218e99
index 5a60ca5..3e0251f 100644
218e99
--- a/block/raw-win32.c
218e99
+++ b/block/raw-win32.c
218e99
@@ -587,12 +587,11 @@ 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
+            ret = -EINVAL;
218e99
         }
218e99
+        error_setg_errno(errp, -ret, "Could not open device");
218e99
         goto done;
218e99
     }
218e99
 
218e99
-- 
218e99
1.7.1
218e99