From patchwork Mon Jun 29 16:54:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 489356 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2A6921401EF for ; Tue, 30 Jun 2015 02:55:38 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=OFrLP95x; dkim-atps=neutral Received: from localhost ([::1]:43157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9cLG-0005UJ-Qu for incoming@patchwork.ozlabs.org; Mon, 29 Jun 2015 12:55:34 -0400 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 Received: from mail-qc0-x230.google.com ([2607:f8b0:400d:c01::230]:36646) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9cKg-00071k-H8; Mon, 29 Jun 2015 12:54:58 -0400 Received: by qczu9 with SMTP id u9so18054136qcz.3; Mon, 29 Jun 2015 09:54:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:subject:date:message-id:cc:to:mime-version; bh=vy02i8nga87b3StZhY2wYK0A84dN6/5GROshaHZ3tPI=; b=OFrLP95xZVtYnLouDNU/Kv8Xw7FsqkPufLso3x2AsO11MoHzRMLlp5+p8AXRA3IpLT omZao0tdutJ61R5z/H75IQe+nPUPlZ1GolExFQzAWX7oLydmZTQ6mq/8QjQljE7B+9SY LhF0P6q/CQc/phNRZuQGwtq8oZx7YMuW0AQXiXbCi45XJuWAGnKf3ZYCbYQzKr+LgB4F k+V6XpHEgWhWikfErSv0hGMVKarAJNnPhBWY4Ia8fJazTeIrNF+Ba+zLHMeWQLeWAAQT mClz32fLi4B87d+TxfFflDBrL2DrPznCxVQtaNWAxIc7FlNhf332EW6HU7X65vbi+i/t qeCQ== X-Received: by 10.140.218.5 with SMTP id o5mr21563284qhb.13.1435596898053; Mon, 29 Jun 2015 09:54:58 -0700 (PDT) Received: from [192.168.0.7] (d199-74-164-53.col.wideopenwest.com. [74.199.53.164]) by mx.google.com with ESMTPSA id 47sm11765584qgt.15.2015.06.29.09.54.56 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 29 Jun 2015 09:54:57 -0700 (PDT) From: Programmingkid Date: Mon, 29 Jun 2015 12:54:55 -0400 Message-Id: To: Qemu-block Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c01::230 Cc: Kevin Wolf , qemu-devel qemu-devel Subject: [Qemu-devel] [PATCH] raw-posix.c: cd_is_inserted() implementation for Mac OS X X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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; } -#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__