qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] raw-posix: improve detection of scsi-generic devices
@ 2010-09-06 15:06 Bernhard Kohl
  2010-09-06 15:39 ` Alexander Graf
  0 siblings, 1 reply; 6+ messages in thread
From: Bernhard Kohl @ 2010-09-06 15:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Bernhard Kohl, Bernhard Kohl

From: Bernhard Kohl <bernhard.kohl@gmx.net>

Allow symbolic links which point to /dev/sgX devices.

Signed-off-by: Bernhard Kohl <bernhard.kohl@nsn.com>
---
 block/raw-posix.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index 72fb8ce..4544a57 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -48,6 +48,7 @@
 #endif
 #ifdef __linux__
 #include <sys/ioctl.h>
+#include <sys/param.h>
 #include <linux/cdrom.h>
 #include <linux/fd.h>
 #endif
@@ -868,8 +869,13 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
 
     s->type = FTYPE_FILE;
 #if defined(__linux__)
-    if (strstart(filename, "/dev/sg", NULL)) {
-        bs->sg = 1;
+    {
+        char resolved_path[ MAXPATHLEN ], *temp;
+
+        temp = realpath(filename, resolved_path);
+        if (temp && strstart(temp, "/dev/sg", NULL)) {
+            bs->sg = 1;
+        }
     }
 #endif
 
-- 
1.7.2.2

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

* Re: [Qemu-devel] [PATCH] raw-posix: improve detection of scsi-generic devices
  2010-09-06 15:06 [Qemu-devel] [PATCH] raw-posix: improve detection of scsi-generic devices Bernhard Kohl
@ 2010-09-06 15:39 ` Alexander Graf
  2010-09-07  2:04   ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: Alexander Graf @ 2010-09-06 15:39 UTC (permalink / raw)
  To: Bernhard Kohl; +Cc: kwolf, qemu-devel, Bernhard Kohl


On 06.09.2010, at 17:06, Bernhard Kohl wrote:

> From: Bernhard Kohl <bernhard.kohl@gmx.net>
> 
> Allow symbolic links which point to /dev/sgX devices.

Couldn't you send an SG_IO test ioctl over and see if it works? I really dislike the whole file name magic matching.


Alex

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

* Re: [Qemu-devel] [PATCH] raw-posix: improve detection of scsi-generic devices
  2010-09-06 15:39 ` Alexander Graf
@ 2010-09-07  2:04   ` Christoph Hellwig
  2010-09-07  9:40     ` Bernhard Kohl
  2010-09-07  9:47     ` Kevin Wolf
  0 siblings, 2 replies; 6+ messages in thread
From: Christoph Hellwig @ 2010-09-07  2:04 UTC (permalink / raw)
  To: Alexander Graf; +Cc: kwolf, Bernhard Kohl, qemu-devel, Bernhard Kohl

On Mon, Sep 06, 2010 at 05:39:00PM +0200, Alexander Graf wrote:
> 
> On 06.09.2010, at 17:06, Bernhard Kohl wrote:
> 
> > From: Bernhard Kohl <bernhard.kohl@gmx.net>
> > 
> > Allow symbolic links which point to /dev/sgX devices.
> 
> Couldn't you send an SG_IO test ioctl over and see if it works? I really dislike the whole file name magic matching.

You could, but the result would not be what you expect, given that every
/dev/sd* device and more in Linux support it.

What we really need is to stop shoe-horning scsi pass through support
into the block layer.  Once we finally get our generic thread offload
facilily there is no need for it anymore at all, scsi-generic can
simplify offload the SG_IO ioctl and be done with it.  I even have an
old prototype for this, just waiting for the generic thread offload
to get merged before resurrecting it.

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

* Re: [Qemu-devel] [PATCH] raw-posix: improve detection of scsi-generic devices
  2010-09-07  2:04   ` Christoph Hellwig
@ 2010-09-07  9:40     ` Bernhard Kohl
  2010-09-07  9:44       ` Alexander Graf
  2010-09-07  9:47     ` Kevin Wolf
  1 sibling, 1 reply; 6+ messages in thread
From: Bernhard Kohl @ 2010-09-07  9:40 UTC (permalink / raw)
  To: ext Christoph Hellwig; +Cc: kwolf, Alexander Graf, Bernhard Kohl, qemu-devel

Am 07.09.2010 04:04, schrieb ext Christoph Hellwig:
> On Mon, Sep 06, 2010 at 05:39:00PM +0200, Alexander Graf wrote:
>    
>> On 06.09.2010, at 17:06, Bernhard Kohl wrote:
>>
>>      
>>> From: Bernhard Kohl<bernhard.kohl@gmx.net>
>>>
>>> Allow symbolic links which point to /dev/sgX devices.
>>>        
>> Couldn't you send an SG_IO test ioctl over and see if it works? I really dislike the whole file name magic matching.
>>      
> You could, but the result would not be what you expect, given that every
> /dev/sd* device and more in Linux support it.
>
> What we really need is to stop shoe-horning scsi pass through support
> into the block layer.  Once we finally get our generic thread offload
> facilily there is no need for it anymore at all, scsi-generic can
> simplify offload the SG_IO ioctl and be done with it.  I even have an
> old prototype for this, just waiting for the generic thread offload
> to get merged before resurrecting it.
>    

Wouldn't it be OK to apply this patch in the meantime before we get
this complete new solution? I need to handle about 15 /dev/sg* disks
which are randomly numbered. With this patch I can use the udev
generated links in /dev/disk/by*, which makes life much easier.

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

* Re: [Qemu-devel] [PATCH] raw-posix: improve detection of scsi-generic devices
  2010-09-07  9:40     ` Bernhard Kohl
@ 2010-09-07  9:44       ` Alexander Graf
  0 siblings, 0 replies; 6+ messages in thread
From: Alexander Graf @ 2010-09-07  9:44 UTC (permalink / raw)
  To: Bernhard Kohl; +Cc: kwolf, ext Christoph Hellwig, Bernhard Kohl, qemu-devel


On 07.09.2010, at 11:40, Bernhard Kohl wrote:

> Am 07.09.2010 04:04, schrieb ext Christoph Hellwig:
>> On Mon, Sep 06, 2010 at 05:39:00PM +0200, Alexander Graf wrote:
>>   
>>> On 06.09.2010, at 17:06, Bernhard Kohl wrote:
>>> 
>>>     
>>>> From: Bernhard Kohl<bernhard.kohl@gmx.net>
>>>> 
>>>> Allow symbolic links which point to /dev/sgX devices.
>>>>       
>>> Couldn't you send an SG_IO test ioctl over and see if it works? I really dislike the whole file name magic matching.
>>>     
>> You could, but the result would not be what you expect, given that every
>> /dev/sd* device and more in Linux support it.
>> 
>> What we really need is to stop shoe-horning scsi pass through support
>> into the block layer.  Once we finally get our generic thread offload
>> facilily there is no need for it anymore at all, scsi-generic can
>> simplify offload the SG_IO ioctl and be done with it.  I even have an
>> old prototype for this, just waiting for the generic thread offload
>> to get merged before resurrecting it.
>>   
> 
> Wouldn't it be OK to apply this patch in the meantime before we get
> this complete new solution? I need to handle about 15 /dev/sg* disks
> which are randomly numbered. With this patch I can use the udev
> generated links in /dev/disk/by*, which makes life much easier.
> 

I agree. I'd take this one in for now, as it improves the situation and then when all world blossoms we can take Christoph's game-changing framework :).

Kevin, what do you think?


Alex

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

* Re: [Qemu-devel] [PATCH] raw-posix: improve detection of scsi-generic devices
  2010-09-07  2:04   ` Christoph Hellwig
  2010-09-07  9:40     ` Bernhard Kohl
@ 2010-09-07  9:47     ` Kevin Wolf
  1 sibling, 0 replies; 6+ messages in thread
From: Kevin Wolf @ 2010-09-07  9:47 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Bernhard Kohl, Alexander Graf, Bernhard Kohl, qemu-devel

Am 07.09.2010 04:04, schrieb Christoph Hellwig:
> On Mon, Sep 06, 2010 at 05:39:00PM +0200, Alexander Graf wrote:
>>
>> On 06.09.2010, at 17:06, Bernhard Kohl wrote:
>>
>>> From: Bernhard Kohl <bernhard.kohl@gmx.net>
>>>
>>> Allow symbolic links which point to /dev/sgX devices.
>>
>> Couldn't you send an SG_IO test ioctl over and see if it works? I really dislike the whole file name magic matching.
> 
> You could, but the result would not be what you expect, given that every
> /dev/sd* device and more in Linux support it.
> 
> What we really need is to stop shoe-horning scsi pass through support
> into the block layer.  Once we finally get our generic thread offload
> facilily there is no need for it anymore at all, scsi-generic can
> simplify offload the SG_IO ioctl and be done with it.  I even have an
> old prototype for this, just waiting for the generic thread offload
> to get merged before resurrecting it.

Let's apply this patch for the time being then, and remove the code
altogether as soon as possible.

Kevin

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

end of thread, other threads:[~2010-09-07  9:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-06 15:06 [Qemu-devel] [PATCH] raw-posix: improve detection of scsi-generic devices Bernhard Kohl
2010-09-06 15:39 ` Alexander Graf
2010-09-07  2:04   ` Christoph Hellwig
2010-09-07  9:40     ` Bernhard Kohl
2010-09-07  9:44       ` Alexander Graf
2010-09-07  9:47     ` Kevin Wolf

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