From patchwork Wed Aug 3 14:13:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 108207 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 322E4B71D8 for ; Thu, 4 Aug 2011 00:11:52 +1000 (EST) Received: from localhost ([::1]:45125 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QocAh-00009P-7m for incoming@patchwork.ozlabs.org; Wed, 03 Aug 2011 10:11:43 -0400 Received: from eggs.gnu.org ([140.186.70.92]:49713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QocAY-00008B-6T for qemu-devel@nongnu.org; Wed, 03 Aug 2011 10:11:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QocAX-0007Rd-8L for qemu-devel@nongnu.org; Wed, 03 Aug 2011 10:11:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26714) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QocAW-0007RN-Td for qemu-devel@nongnu.org; Wed, 03 Aug 2011 10:11:33 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p73EBVsa008589 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 3 Aug 2011 10:11:31 -0400 Received: from dhcp-5-188.str.redhat.com (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p73EBSMV026900; Wed, 3 Aug 2011 10:11:30 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Wed, 3 Aug 2011 16:13:56 +0200 Message-Id: <1312380864-15605-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1312380864-15605-1-git-send-email-kwolf@redhat.com> References: <1312380864-15605-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 01/29] blockdev: Make eject fail for non-removable drives even with -f 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 From: Markus Armbruster Ejecting hard disk platters can only end in tears. If you need to revoke access to an image, use drive_del, not eject -f. Signed-off-by: Markus Armbruster Signed-off-by: Kevin Wolf --- blockdev.c | 17 +++++++---------- 1 files changed, 7 insertions(+), 10 deletions(-) diff --git a/blockdev.c b/blockdev.c index 0b8d3a4..a25367a 100644 --- a/blockdev.c +++ b/blockdev.c @@ -646,16 +646,13 @@ out: static int eject_device(Monitor *mon, BlockDriverState *bs, int force) { - if (!force) { - if (!bdrv_is_removable(bs)) { - qerror_report(QERR_DEVICE_NOT_REMOVABLE, - bdrv_get_device_name(bs)); - return -1; - } - if (bdrv_is_locked(bs)) { - qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs)); - return -1; - } + if (!bdrv_is_removable(bs)) { + qerror_report(QERR_DEVICE_NOT_REMOVABLE, bdrv_get_device_name(bs)); + return -1; + } + if (!force && bdrv_is_locked(bs)) { + qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs)); + return -1; } bdrv_close(bs); return 0;