Patchwork [3/7] atapi: guessing if the cdrom device is a scsi device.

login
register
mail settings
Submitter Ian Jackson
Date Aug. 11, 2009, 3:36 p.m.
Message ID <E1MbHTh-0007lD-6Z@mariner.uk.xensource.com>
Download mbox | patch
Permalink /patch/31224/
State Superseded
Headers show

Comments

Ian Jackson - Aug. 11, 2009, 3:36 p.m.
ATAPI pass through code is enabled when the block device is a scsi
device. So we have to guess if the block device is a scsi device in
cdrom_open().

Signed-off-by: Alexandre Bique <alexandre.bique@citrix.com>
---
 block/raw-posix.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

Patch

diff --git a/block/raw-posix.c b/block/raw-posix.c
index bdee07f..ebb13d4 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1305,6 +1305,14 @@  static int cdrom_open(BlockDriverState *bs, const char *filename, int flags)
     s->type = FTYPE_CD;
 
     /* open will not fail even if no CD is inserted, so add O_NONBLOCK */
+#if defined(__linux__) && defined(CONFIG_AIO)
+    if (strstart(filename, "/dev/sg", NULL) ||
+        strstart(filename, "/dev/cd", NULL) ||
+        strstart(filename, "/dev/dvd", NULL) ||
+        strstart(filename, "/dev/sr", NULL)) {
+        bs->sg = 1;
+    }
+#endif
     return raw_open_common(bs, filename, flags, O_NONBLOCK);
 }