From patchwork Sun Mar 21 15:33:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naphtali Sprei X-Patchwork-Id: 48224 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B4253B7CF5 for ; Mon, 22 Mar 2010 02:35:40 +1100 (EST) Received: from localhost ([127.0.0.1]:54351 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NtNBg-0007Jq-Iw for incoming@patchwork.ozlabs.org; Sun, 21 Mar 2010 11:35:36 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NtNA7-0006ng-Fw for qemu-devel@nongnu.org; Sun, 21 Mar 2010 11:33:59 -0400 Received: from [199.232.76.173] (port=56730 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NtNA6-0006nY-QK for qemu-devel@nongnu.org; Sun, 21 Mar 2010 11:33:58 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NtNA5-0004XP-Nb for qemu-devel@nongnu.org; Sun, 21 Mar 2010 11:33:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26944) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NtNA5-0004XH-Ci for qemu-devel@nongnu.org; Sun, 21 Mar 2010 11:33:57 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2LFXt0h032417 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 21 Mar 2010 11:33:56 -0400 Received: from localhost.localdomain (dhcp-0-60.tlv.redhat.com [10.35.0.60]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2LFXsP5023585 for ; Sun, 21 Mar 2010 11:33:55 -0400 From: Naphtali Sprei To: qemu-devel@nongnu.org Date: Sun, 21 Mar 2010 17:33:53 +0200 Message-Id: <1269185633-31750-1-git-send-email-nsprei@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH] read-only: allow read-only CDROM with any interface X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Naphtali Sprei --- vl.c | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-) diff --git a/vl.c b/vl.c index 2e38b77..d3863d7 100644 --- a/vl.c +++ b/vl.c @@ -1255,19 +1255,16 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, bdrv_flags &= ~BDRV_O_NATIVE_AIO; } - if (ro == 1) { + if (media == MEDIA_CDROM) { + ro = 1; + } + if (ro == 1 && + media != MEDIA_CDROM) { /* CDROM is fine for any interface, don't check */ if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY) { fprintf(stderr, "qemu: readonly flag not supported for drive with this interface\n"); return NULL; } } - /* - * cdrom is read-only. Set it now, after above interface checking - * since readonly attribute not explicitly required, so no error. - */ - if (media == MEDIA_CDROM) { - ro = 1; - } bdrv_flags |= ro ? 0 : BDRV_O_RDWR; if (bdrv_open2(dinfo->bdrv, file, bdrv_flags, drv) < 0) {