From patchwork Wed Jul 1 22:13:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 490380 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 17755140157 for ; Thu, 2 Jul 2015 08:13:42 +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=ymh+DiZk; dkim-atps=neutral Received: from localhost ([::1]:33057 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAQGB-0001sy-OX for incoming@patchwork.ozlabs.org; Wed, 01 Jul 2015 18:13:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34349) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAQFt-0001bP-RK for qemu-devel@nongnu.org; Wed, 01 Jul 2015 18:13:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAQFo-0000Wa-RH for qemu-devel@nongnu.org; Wed, 01 Jul 2015 18:13:21 -0400 Received: from mail-qg0-x231.google.com ([2607:f8b0:400d:c04::231]:35542) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAQFo-0000UY-LK; Wed, 01 Jul 2015 18:13:16 -0400 Received: by qget71 with SMTP id t71so25445941qge.2; Wed, 01 Jul 2015 15:13:14 -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=iiOMST5O3lQaMcThs8Dplffxo4TzK9+mQ+nWkJKXJrE=; b=ymh+DiZkx0YbAtN8yl8EOj6MPScaxsYQPmCR7PYmsVUZTCE5lotDsmim/L0CURDyYY I71ZQCf57RtmktGe1cKmzm05GLpp82jvVfJBD+hbp4OrOLKS+Iw0HvHTAFB1TmEiS7Y+ ZEXxzATaLPKwq/xO1m+/ma6louMiAdG33LNpB+lzJEuB7R4dCs2hJYTtDxkVRvY0FDKn Qu+YjhJzu9CHZVAM+jgjIfJlU+hb4n/tZfwBOYhuZXwAsOOFTvEiQZM074nH8yBZM+pO YVhysWbNI+Ckk4NXuYeskWjjJM+LhtkD3FTDajEv5h5zYU2xM3RCdygNek4py66bgqKt 0rgA== X-Received: by 10.140.194.199 with SMTP id p190mr39515087qha.76.1435788794794; Wed, 01 Jul 2015 15:13:14 -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 d64sm1747232qkh.45.2015.07.01.15.13.12 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 01 Jul 2015 15:13:13 -0700 (PDT) From: Programmingkid Date: Wed, 1 Jul 2015 18:13:11 -0400 Message-Id: To: Stefan Hajnoczi , Peter Maydell , Paolo Bonzini 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:c04::231 Cc: Kevin Wolf , Laurent Vivier , John Snow , qemu-devel qemu-devel , Qemu-block Subject: [Qemu-devel] [PATCH] raw-posix.c: remove raw device access for cdrom 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 real cdrom access in Mac OS X so it can be used in QEMU. It simply removes the r from a device file's name. This allows for a real cdrom to be accessible to the guest. It has been successfully tested with a Windows XP guest in qemu-system-i386. The qemu-system-ppc emulator doesn't quit anymore, but there is another problem that prevents a real cdrom from working. Signed-off-by: John Arbuckle --- block/raw-posix.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index a967464..3585ed9 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -2096,6 +2096,16 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags, kernResult = FindEjectableCDMedia( &mediaIterator ); kernResult = GetBSDPath( mediaIterator, bsdPath, sizeof( bsdPath ) ); + /* + * Remove the r from cdrom block device if needed. + * /dev/rdisk1 would become /dev/disk1. + * The r means raw access. It doesn't work well. + */ + int sizeOfString = strlen("/dev/r"); + if (strncmp("/dev/r", bsdPath, sizeOfString) == 0) { + sprintf(bsdPath, "/dev/%s", bsdPath + sizeOfString); + } + if ( bsdPath[ 0 ] != '\0' ) { strcat(bsdPath,"s0"); /* some CDs don't have a partition 0 */