From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9cKo-00050M-Py for qemu-devel@nongnu.org; Mon, 29 Jun 2015 12:55:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z9cKn-0007LM-Kl for qemu-devel@nongnu.org; Mon, 29 Jun 2015 12:55:06 -0400 From: Programmingkid Content-Type: multipart/alternative; boundary=Apple-Mail-3--124321611 Date: Mon, 29 Jun 2015 12:54:55 -0400 Message-Id: Mime-Version: 1.0 (Apple Message framework v1084) Subject: [Qemu-devel] [PATCH] raw-posix.c: cd_is_inserted() implementation for Mac OS X List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Qemu-block Cc: Kevin Wolf , qemu-devel qemu-devel --Apple-Mail-3--124321611 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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 --- 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; } =20 -#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 =3D (raw_getlength(bs) > 0) ? 1 : 0; + + if (count =3D=3D 0) { + count++; + returnValue =3D 0; /* get around find_image_format() issue */ + } + + return returnValue; +} + +#endif /* __APPLE__ */ =20 static int hdev_probe_device(const char *filename) { @@ -2365,6 +2384,10 @@ static BlockDriver bdrv_host_device =3D { .bdrv_ioctl =3D hdev_ioctl, .bdrv_aio_ioctl =3D hdev_aio_ioctl, #endif + +#ifdef __APPLE__ + .bdrv_is_inserted =3D cdrom_is_inserted, +#endif }; =20 #ifdef __linux__ --=20 1.7.5.4 --Apple-Mail-3--124321611 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
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
 }

 

+/*
+ * 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)
+{
+    int returnValue =3D = (raw_getlength(bs) > 0) ? 1 : 0;
+
+    if (count =3D=3D 0) = {
+        = returnValue =3D 0; /* get around find_image_format() issue */
+
+    return returnValue;
+
+#endif  /* __APPLE__ */

 

@@ -2365,6 +2384,10 @@ static BlockDriver = bdrv_host_device =3D {
     .bdrv_ioctl     =     =3D hdev_ioctl,
     .bdrv_aio_ioctl =     =3D hdev_aio_ioctl,
 #endif
+#ifdef __APPLE__
+    = .bdrv_is_inserted   =3D cdrom_is_inserted,
 };

 

 #ifdef __linux__
1.7.5.4