qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Programmingkid <programmingkidx@gmail.com>
To: Qemu-block <qemu-block@nongnu.org>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-devel qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] raw-posix.c: cd_is_inserted() implementation for Mac OS X
Date: Mon, 29 Jun 2015 12:54:55 -0400	[thread overview]
Message-ID: <C3D7DD34-3469-4A16-B6AA-63673CA30810@gmail.com> (raw)

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

             reply	other threads:[~2015-06-29 16:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-29 16:54 Programmingkid [this message]
2015-06-29 17:11 ` [Qemu-devel] [PATCH] raw-posix.c: cd_is_inserted() implementation for Mac OS X 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C3D7DD34-3469-4A16-B6AA-63673CA30810@gmail.com \
    --to=programmingkidx@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).