From patchwork Fri Jun 3 19:03:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 98631 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 EBD61B6FB3 for ; Sat, 4 Jun 2011 05:18:56 +1000 (EST) Received: from localhost ([::1]:47558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSZtT-0000B4-Hz for incoming@patchwork.ozlabs.org; Fri, 03 Jun 2011 15:18:51 -0400 Received: from eggs.gnu.org ([140.186.70.92]:59244) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSZfI-0005c7-7w for qemu-devel@nongnu.org; Fri, 03 Jun 2011 15:04:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QSZfG-0002Ti-NN for qemu-devel@nongnu.org; Fri, 03 Jun 2011 15:04:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15529) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSZfG-0002TT-EH for qemu-devel@nongnu.org; Fri, 03 Jun 2011 15:04:10 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p53J49s8024726 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 3 Jun 2011 15:04:09 -0400 Received: from localhost (ovpn-113-26.phx2.redhat.com [10.3.113.26]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p53J481Z029488; Fri, 3 Jun 2011 15:04:09 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Fri, 3 Jun 2011 16:03:53 -0300 Message-Id: <1307127842-12102-2-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1307127842-12102-1-git-send-email-lcapitulino@redhat.com> References: <1307127842-12102-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 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, amit.shah@redhat.com, aliguori@us.ibm.com, armbru@redhat.com Subject: [Qemu-devel] [RFC 01/10] block: bdrv_eject(): Add 'force' parameter 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 It's purpose is to skip the media locked test. This is going to be used by the blockdev-tray-open QMP command. Signed-off-by: Luiz Capitulino --- block.c | 4 ++-- block.h | 2 +- block/raw.c | 2 +- hw/ide/atapi.c | 2 +- hw/scsi-disk.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index effa86f..a3d0556 100644 --- a/block.c +++ b/block.c @@ -2752,12 +2752,12 @@ int bdrv_media_changed(BlockDriverState *bs) /** * If eject_flag is TRUE, eject the media. Otherwise, close the tray */ -int bdrv_eject(BlockDriverState *bs, int eject_flag) +int bdrv_eject(BlockDriverState *bs, int eject_flag, int force) { BlockDriver *drv = bs->drv; int ret; - if (bs->locked) { + if (bs->locked && !force) { return -EBUSY; } diff --git a/block.h b/block.h index da7d39c..131812c 100644 --- a/block.h +++ b/block.h @@ -186,7 +186,7 @@ int bdrv_is_inserted(BlockDriverState *bs); int bdrv_media_changed(BlockDriverState *bs); int bdrv_is_locked(BlockDriverState *bs); void bdrv_set_locked(BlockDriverState *bs, int locked); -int bdrv_eject(BlockDriverState *bs, int eject_flag); +int bdrv_eject(BlockDriverState *bs, int eject_flag, int force); void bdrv_set_change_cb(BlockDriverState *bs, void (*change_cb)(void *opaque, int reason), void *opaque); diff --git a/block/raw.c b/block/raw.c index b0f72d6..0e23c7c 100644 --- a/block/raw.c +++ b/block/raw.c @@ -77,7 +77,7 @@ static int raw_is_inserted(BlockDriverState *bs) static int raw_eject(BlockDriverState *bs, int eject_flag) { - return bdrv_eject(bs->file, eject_flag); + return bdrv_eject(bs->file, eject_flag, 0); } static int raw_set_locked(BlockDriverState *bs, int locked) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index fe2fb0b..8af6e23 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -897,7 +897,7 @@ static void cmd_start_stop_unit(IDEState *s, uint8_t* buf) eject = (buf[4] >> 1) & 1; if (eject) { - err = bdrv_eject(s->bs, !start); + err = bdrv_eject(s->bs, !start, 0); } switch (err) { diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index a8c7372..d3f982e 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -872,7 +872,7 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r, uint8_t *outbuf) case START_STOP: if (s->drive_kind == SCSI_CD && (req->cmd.buf[4] & 2)) { /* load/eject medium */ - bdrv_eject(s->bs, !(req->cmd.buf[4] & 1)); + bdrv_eject(s->bs, !(req->cmd.buf[4] & 1), 0); } break; case ALLOW_MEDIUM_REMOVAL: