[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 08/42] w32: Fix access to host devices (regression)
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 08/42] w32: Fix access to host devices (regression) |
Date: |
Fri, 6 Sep 2013 17:38:39 +0200 |
From: Stefan Weil <address@hidden>
QEMU failed to open host devices like \\.\PhysicalDrive0 (first hard disk)
since some time (commit 8a79380b8ef1b02d2abd705dd026a18863b09020?).
Those devices use hdev_open which did not use the latest API for options.
This resulted in a fatal runtime error:
Block protocol 'host_device' doesn't support the option 'filename'
Duplicate code from raw_open to fix this.
Cc: address@hidden
Reported-by: David Brenner <address@hidden>
Signed-off-by: Stefan Weil <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/raw-win32.c | 36 +++++++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 7 deletions(-)
diff --git a/block/raw-win32.c b/block/raw-win32.c
index 9b5b2af..d2d2d9f 100644
--- a/block/raw-win32.c
+++ b/block/raw-win32.c
@@ -535,13 +535,29 @@ static int hdev_open(BlockDriverState *bs, QDict
*options, int flags)
{
BDRVRawState *s = bs->opaque;
int access_flags, create_flags;
+ int ret = 0;
DWORD overlapped;
char device_name[64];
- const char *filename = qdict_get_str(options, "filename");
+
+ Error *local_err = NULL;
+ const char *filename;
+
+ 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);
+ ret = -EINVAL;
+ goto done;
+ }
+
+ filename = qemu_opt_get(opts, "filename");
if (strstart(filename, "/dev/cdrom", NULL)) {
- if (find_cdrom(device_name, sizeof(device_name)) < 0)
- return -ENOENT;
+ if (find_cdrom(device_name, sizeof(device_name)) < 0) {
+ ret = -ENOENT;
+ goto done;
+ }
filename = device_name;
} else {
/* transform drive letters into device name */
@@ -564,11 +580,17 @@ static int hdev_open(BlockDriverState *bs, QDict
*options, int flags)
if (s->hfile == INVALID_HANDLE_VALUE) {
int err = GetLastError();
- if (err == ERROR_ACCESS_DENIED)
- return -EACCES;
- return -1;
+ if (err == ERROR_ACCESS_DENIED) {
+ ret = -EACCES;
+ } else {
+ ret = -1;
+ }
+ goto done;
}
- return 0;
+
+done:
+ qemu_opts_del(opts);
+ return ret;
}
static BlockDriver bdrv_host_device = {
--
1.8.3.1
- [Qemu-devel] [PULL 00/42] Block patches, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 01/42] throttle: Add a new throttling API implementing continuous leaky bucket., Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 03/42] block: Enable the new throttling code in the block layer., Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 02/42] throttle: Add units tests, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 04/42] block: Add support for throttling burst max in QMP and the command line., Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 05/42] block: Add iops_size to do the iops accounting for a given io size., Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 06/42] qemu-iotests: Adjust test result 039, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 08/42] w32: Fix access to host devices (regression),
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 07/42] add qemu-img convert -n option (skip target volume creation), Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 10/42] vvfat: use bdrv_new() to allocate BlockDriverState, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 09/42] aio / timers: fix build of test/test-aio.c on non-linux platforms, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 11/42] iscsi: use bdrv_new() instead of stack structure, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 12/42] block: implement reference count for BlockDriverState, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 13/42] block: make bdrv_delete() static, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 14/42] migration: omit drive ref as we have bdrv_ref now, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 15/42] xen_disk: simplify blk_disconnect with refcnt, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 27/42] qemu-img: always probe the input image for allocated sectors, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 28/42] block: make bdrv_has_zero_init return false for copy-on-write-images, Stefan Hajnoczi, 2013/09/06