From patchwork Tue Mar 23 10:17:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naphtali Sprei X-Patchwork-Id: 48329 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 7815CB7C48 for ; Tue, 23 Mar 2010 21:24:38 +1100 (EST) Received: from localhost ([127.0.0.1]:57340 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nu1Fg-0000op-UV for incoming@patchwork.ozlabs.org; Tue, 23 Mar 2010 06:22:24 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nu1Ap-000791-Qv for qemu-devel@nongnu.org; Tue, 23 Mar 2010 06:17:23 -0400 Received: from [199.232.76.173] (port=43915 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nu1Ap-00078Z-1b for qemu-devel@nongnu.org; Tue, 23 Mar 2010 06:17:23 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nu1Al-0004X4-Nj for qemu-devel@nongnu.org; Tue, 23 Mar 2010 06:17:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43359) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nu1Al-0004Wy-CQ for qemu-devel@nongnu.org; Tue, 23 Mar 2010 06:17:19 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2NAHHUA014793 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 23 Mar 2010 06:17:18 -0400 Received: from localhost.localdomain (dhcp-0-60.tlv.redhat.com [10.35.0.60]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2NAHGqE002920 for ; Tue, 23 Mar 2010 06:17:17 -0400 From: Naphtali Sprei To: qemu-devel@nongnu.org Date: Tue, 23 Mar 2010 12:17:16 +0200 Message-Id: <1269339436-23166-1-git-send-email-nsprei@redhat.com> In-Reply-To: <1269185633-31750-1-git-send-email-nsprei@redhat.com> References: <1269185633-31750-1-git-send-email-nsprei@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH v2] 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 v1 -> v2 cosmetic change of if block arrangement Signed-off-by: Naphtali Sprei --- vl.c | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-) diff --git a/vl.c b/vl.c index d69250c..11c68f2 100644 --- a/vl.c +++ b/vl.c @@ -1222,19 +1222,16 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, bdrv_flags &= ~BDRV_O_NATIVE_AIO; } - if (ro == 1) { + if (media == MEDIA_CDROM) { + /* CDROM is fine for any interface, don't check. */ + ro = 1; + } else if (ro == 1) { 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) {