|
|
9ae3a8 |
From c9f57b61fd600b60276a1f50be5af3eed7d8bafd Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 4 Nov 2013 22:32:07 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 14/87] w32: Fix access to host devices (regression)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1383604354-12743-17-git-send-email-mreitz@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 55316
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH 16/43] w32: Fix access to host devices (regression)
|
|
|
9ae3a8 |
Bugzilla: 1026524
|
|
|
9ae3a8 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Stefan Weil <sw@weilnetz.de>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
BZ: 1026524
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
QEMU failed to open host devices like \\.\PhysicalDrive0 (first hard disk)
|
|
|
9ae3a8 |
since some time (commit 8a79380b8ef1b02d2abd705dd026a18863b09020?).
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Those devices use hdev_open which did not use the latest API for options.
|
|
|
9ae3a8 |
This resulted in a fatal runtime error:
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Block protocol 'host_device' doesn't support the option 'filename'
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Duplicate code from raw_open to fix this.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Cc: qemu-stable@nongnu.org
|
|
|
9ae3a8 |
Reported-by: David Brenner <david.brenner3@gmail.com>
|
|
|
9ae3a8 |
Signed-off-by: Stefan Weil <sw@weilnetz.de>
|
|
|
9ae3a8 |
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 68dc036488dfea170627a55e6ee3dfd7f2c2063e)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/raw-win32.c | 36 +++++++++++++++++++++++++++++-------
|
|
|
9ae3a8 |
1 file changed, 29 insertions(+), 7 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/raw-win32.c | 36 +++++++++++++++++++++++++++++-------
|
|
|
9ae3a8 |
1 files changed, 29 insertions(+), 7 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/raw-win32.c b/block/raw-win32.c
|
|
|
9ae3a8 |
index 7c03b6d..a324e5b 100644
|
|
|
9ae3a8 |
--- a/block/raw-win32.c
|
|
|
9ae3a8 |
+++ b/block/raw-win32.c
|
|
|
9ae3a8 |
@@ -534,13 +534,29 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
BDRVRawState *s = bs->opaque;
|
|
|
9ae3a8 |
int access_flags, create_flags;
|
|
|
9ae3a8 |
+ int ret = 0;
|
|
|
9ae3a8 |
DWORD overlapped;
|
|
|
9ae3a8 |
char device_name[64];
|
|
|
9ae3a8 |
- const char *filename = qdict_get_str(options, "filename");
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ Error *local_err = NULL;
|
|
|
9ae3a8 |
+ const char *filename;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ QemuOpts *opts = qemu_opts_create_nofail(&raw_runtime_opts);
|
|
|
9ae3a8 |
+ qemu_opts_absorb_qdict(opts, options, &local_err);
|
|
|
9ae3a8 |
+ if (error_is_set(&local_err)) {
|
|
|
9ae3a8 |
+ qerror_report_err(local_err);
|
|
|
9ae3a8 |
+ error_free(local_err);
|
|
|
9ae3a8 |
+ ret = -EINVAL;
|
|
|
9ae3a8 |
+ goto done;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ filename = qemu_opt_get(opts, "filename");
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (strstart(filename, "/dev/cdrom", NULL)) {
|
|
|
9ae3a8 |
- if (find_cdrom(device_name, sizeof(device_name)) < 0)
|
|
|
9ae3a8 |
- return -ENOENT;
|
|
|
9ae3a8 |
+ if (find_cdrom(device_name, sizeof(device_name)) < 0) {
|
|
|
9ae3a8 |
+ ret = -ENOENT;
|
|
|
9ae3a8 |
+ goto done;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
filename = device_name;
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
/* transform drive letters into device name */
|
|
|
9ae3a8 |
@@ -563,11 +579,17 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags)
|
|
|
9ae3a8 |
if (s->hfile == INVALID_HANDLE_VALUE) {
|
|
|
9ae3a8 |
int err = GetLastError();
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- if (err == ERROR_ACCESS_DENIED)
|
|
|
9ae3a8 |
- return -EACCES;
|
|
|
9ae3a8 |
- return -1;
|
|
|
9ae3a8 |
+ if (err == ERROR_ACCESS_DENIED) {
|
|
|
9ae3a8 |
+ ret = -EACCES;
|
|
|
9ae3a8 |
+ } else {
|
|
|
9ae3a8 |
+ ret = -1;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ goto done;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
- return 0;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+done:
|
|
|
9ae3a8 |
+ qemu_opts_del(opts);
|
|
|
9ae3a8 |
+ return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static int hdev_has_zero_init(BlockDriverState *bs)
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|