From patchwork Tue Jul 6 15:33:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 58031 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 375AEB6EFE for ; Wed, 7 Jul 2010 01:39:55 +1000 (EST) Received: from localhost ([127.0.0.1]:39514 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OWAFT-0000S2-FE for incoming@patchwork.ozlabs.org; Tue, 06 Jul 2010 11:39:51 -0400 Received: from [140.186.70.92] (port=39322 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OWA9V-0006Ko-W4 for qemu-devel@nongnu.org; Tue, 06 Jul 2010 11:33:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OWA9T-00006a-6S for qemu-devel@nongnu.org; Tue, 06 Jul 2010 11:33:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39216) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OWA9S-00006T-Pe for qemu-devel@nongnu.org; Tue, 06 Jul 2010 11:33:39 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o66FXbFO004971 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 6 Jul 2010 11:33:37 -0400 Received: from localhost.localdomain (dhcp-5-217.str.redhat.com [10.32.5.217]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o66FXTsl012071; Tue, 6 Jul 2010 11:33:36 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Tue, 6 Jul 2010 17:33:13 +0200 Message-Id: <1278430406-18667-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1278430406-18667-1-git-send-email-kwolf@redhat.com> References: <1278430406-18667-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 04/17] blockdev: Clean up how readonly persists across virtual media change 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 From: Markus Armbruster Since commit cb4e5f8e, monitor command change makes the new media readonly iff the type hint is BDRV_TYPE_CDROM, i.e. the drive was created with media=cdrom. The intention is to avoid changing a block device's read-only-ness. However, BDRV_TYPE_CDROM is only a hint. It is currently sufficent for read-only. But it's not necessary, and it may not remain sufficient. Use bdrv_is_read_only() instead. Signed-off-by: Markus Armbruster Signed-off-by: Kevin Wolf --- blockdev.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/blockdev.c b/blockdev.c index be88098..0a9dec3 100644 --- a/blockdev.c +++ b/blockdev.c @@ -589,7 +589,7 @@ int do_change_block(Monitor *mon, const char *device, if (eject_device(mon, bs, 0) < 0) { return -1; } - bdrv_flags = bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM ? 0 : BDRV_O_RDWR; + bdrv_flags = bdrv_is_read_only(bs) ? 0 : BDRV_O_RDWR; if (bdrv_open(bs, filename, bdrv_flags, drv) < 0) { qerror_report(QERR_OPEN_FILE_FAILED, filename); return -1;