qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] raw-posix.c: cd_is_inserted() implementation for Mac OS X
@ 2015-06-29 16:54 Programmingkid
  2015-06-29 17:11 ` Peter Maydell
  0 siblings, 1 reply; 7+ messages in thread
From: Programmingkid @ 2015-06-29 16:54 UTC (permalink / raw)
  To: Qemu-block; +Cc: Kevin Wolf, qemu-devel qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1493 bytes --]

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 <programmingkidx@gmail.com>

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


[-- Attachment #2: Type: text/html, Size: 9695 bytes --]

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

end of thread, other threads:[~2015-06-29 20:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-29 16:54 [Qemu-devel] [PATCH] raw-posix.c: cd_is_inserted() implementation for Mac OS X Programmingkid
2015-06-29 17:11 ` Peter Maydell
2015-06-29 18:04   ` Programmingkid
2015-06-29 18:16     ` Peter Maydell
2015-06-29 18:37       ` Programmingkid
2015-06-29 20:43         ` Laurent Vivier
2015-06-29 20:55           ` Programmingkid

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