diff options
author | Stefan Weil <sw@weilnetz.de> | 2013-09-01 22:59:25 +0200 |
---|---|---|
committer | SeokYeon Hwang <syeon.hwang@samsung.com> | 2013-11-07 13:48:35 +0900 |
commit | f307ee0beee37aa8f977582d5aa87e472623b1b5 (patch) | |
tree | 329d187208476edf33af5d3b8018bc40ab823d9b | |
parent | e8e136f51176910297b6df3fca6ad89911a0f2c4 (diff) | |
download | qemu-f307ee0beee37aa8f977582d5aa87e472623b1b5.tar.gz qemu-f307ee0beee37aa8f977582d5aa87e472623b1b5.tar.bz2 qemu-f307ee0beee37aa8f977582d5aa87e472623b1b5.zip |
w32: Fix access to host devices (regression)
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: qemu-stable@nongnu.org
Reported-by: David Brenner <david.brenner3@gmail.com>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit 68dc036488dfea170627a55e6ee3dfd7f2c2063e)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r-- | block/raw-win32.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/block/raw-win32.c b/block/raw-win32.c index ae2a98caa7..9686afe702 100644 --- a/block/raw-win32.c +++ b/block/raw-win32.c @@ -578,18 +578,34 @@ static int hdev_probe_device(const char *filename) static int hdev_open(BlockDriverState *bs, QDict *options, int flags) { BDRVRawState *s = bs->opaque; - char device_name[64]; - const char *filename = qdict_get_str(options, "filename"); #ifndef CONFIG_MARU int access_flags, create_flags; DWORD overlapped; #else - int open_flags, ret; + int open_flags; #endif + int ret = 0; + char device_name[64]; + + 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 */ @@ -613,9 +629,12 @@ 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; } #else /* @@ -650,6 +669,10 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags) s->hfile = (HANDLE)_get_osfhandle(ret); #endif return 0; + +done: + qemu_opts_del(opts); + return ret; } static BlockDriver bdrv_host_device = { |