qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] w32: Fix access to host devices (regression)
@ 2013-09-01 20:59 Stefan Weil
  2013-09-03  8:51 ` Kevin Wolf
  2013-09-03  9:48 ` Stefan Hajnoczi
  0 siblings, 2 replies; 4+ messages in thread
From: Stefan Weil @ 2013-09-01 20:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Stefan Weil, david.brenner3, Alexander Graf,
	Stefan Hajnoczi

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.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---

This bug was reported by David Brenner.
It should be fixed in QEMU 1.6 as well.

Stefan

 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.7.10.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] w32: Fix access to host devices (regression)
  2013-09-01 20:59 [Qemu-devel] [PATCH] w32: Fix access to host devices (regression) Stefan Weil
@ 2013-09-03  8:51 ` Kevin Wolf
  2013-09-03  9:55   ` Andreas Färber
  2013-09-03  9:48 ` Stefan Hajnoczi
  1 sibling, 1 reply; 4+ messages in thread
From: Kevin Wolf @ 2013-09-03  8:51 UTC (permalink / raw)
  To: Stefan Weil
  Cc: qemu-stable, david.brenner3, qemu-devel, Stefan Hajnoczi,
	Alexander Graf

Am 01.09.2013 um 22:59 hat Stefan Weil geschrieben:
> 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.
> 
> Signed-off-by: Stefan Weil <sw@weilnetz.de>

Reviewed-by: Kevin Wolf <kwolf@redhat.com>

> ---
> 
> This bug was reported by David Brenner.
> It should be fixed in QEMU 1.6 as well.

Cc: qemu-stable@nongnu.org

(Ideally you'd also put this Cc line in your commit message.)

Kevin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] w32: Fix access to host devices (regression)
  2013-09-01 20:59 [Qemu-devel] [PATCH] w32: Fix access to host devices (regression) Stefan Weil
  2013-09-03  8:51 ` Kevin Wolf
@ 2013-09-03  9:48 ` Stefan Hajnoczi
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2013-09-03  9:48 UTC (permalink / raw)
  To: Stefan Weil; +Cc: Kevin Wolf, david.brenner3, qemu-devel, Alexander Graf

On Sun, Sep 01, 2013 at 10:59:25PM +0200, Stefan Weil wrote:
> 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.
> 
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
> 
> This bug was reported by David Brenner.
> It should be fixed in QEMU 1.6 as well.
> 
> Stefan
> 
>  block/raw-win32.c |   36 +++++++++++++++++++++++++++++-------
>  1 file changed, 29 insertions(+), 7 deletions(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] w32: Fix access to host devices (regression)
  2013-09-03  8:51 ` Kevin Wolf
@ 2013-09-03  9:55   ` Andreas Färber
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Färber @ 2013-09-03  9:55 UTC (permalink / raw)
  To: Stefan Weil, Stefan Hajnoczi
  Cc: Kevin Wolf, Alexander Graf, david.brenner3, qemu-stable,
	qemu-devel

Am 03.09.2013 10:51, schrieb Kevin Wolf:
> Am 01.09.2013 um 22:59 hat Stefan Weil geschrieben:
>> 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.
>>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> 
> Reviewed-by: Kevin Wolf <kwolf@redhat.com>
> 
>> ---
>>
>> This bug was reported by David Brenner.
>> It should be fixed in QEMU 1.6 as well.
> 
> Cc: qemu-stable@nongnu.org
> 
> (Ideally you'd also put this Cc line in your commit message.)

...and put the attribution as:

Reported-by: David Brenner <david.brenner3@gmail.com>

Maybe Stefan H. can still add that along with the Cc.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-09-03  9:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-01 20:59 [Qemu-devel] [PATCH] w32: Fix access to host devices (regression) Stefan Weil
2013-09-03  8:51 ` Kevin Wolf
2013-09-03  9:55   ` Andreas Färber
2013-09-03  9:48 ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).