qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-block] [PATCH] raw-posix.c: cd_is_inserted() implementation for Ma


From: Programmingkid
Subject: [Qemu-block] [PATCH] raw-posix.c: cd_is_inserted() implementation for Mac OS X
Date: Mon, 29 Jun 2015 12:54:55 -0400

Fix a problem with QEMU not being able to use real cd's on
Mac OS X hosts. Implements a function called
cd_is_inserted().

Signed-off-by: John Arbuckle <address@hidden>

---
 block/raw-posix.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index a967464..9420602 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -2018,7 +2018,26 @@ kern_return_t GetBSDPath( io_iterator_t mediaIterator, char *bsdPath, CFIndex ma
     return kernResult;
 }

 

-#endif
+/*
+ * Determines if a real cdrom is inserted into the host computer's optical
+ * drive. Uses the fact that find_image_format() calls this function first
+ * in order to go around a bug involving trying to determine a real cd's
+ * format.
+ */
+static int cdrom_is_inserted(BlockDriverState *bs)
+{
+    static int count;
+    int returnValue = (raw_getlength(bs) > 0) ? 1 : 0;
+
+    if (count == 0) {
+        count++;
+        returnValue = 0; /* get around find_image_format() issue */
+    }
+
+    return returnValue;
+}
+
+#endif  /* __APPLE__ */

 

 static int hdev_probe_device(const char *filename)
 {
@@ -2365,6 +2384,10 @@ static BlockDriver bdrv_host_device = {
     .bdrv_ioctl         = hdev_ioctl,
     .bdrv_aio_ioctl     = hdev_aio_ioctl,
 #endif
+
+#ifdef __APPLE__
+    .bdrv_is_inserted   = cdrom_is_inserted,
+#endif
 };

 

 #ifdef __linux__
-- 
1.7.5.4


reply via email to

[Prev in Thread] Current Thread [Next in Thread]