From patchwork Thu Feb 23 14:42:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 142645 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 C4286B6EEE for ; Fri, 24 Feb 2012 01:44:25 +1100 (EST) Received: from localhost ([::1]:57898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0Zu8-0006xB-T9 for incoming@patchwork.ozlabs.org; Thu, 23 Feb 2012 09:44:20 -0500 Received: from eggs.gnu.org ([140.186.70.92]:48142) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0Zt2-0003R9-0b for qemu-devel@nongnu.org; Thu, 23 Feb 2012 09:43:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S0Zss-000710-Tq for qemu-devel@nongnu.org; Thu, 23 Feb 2012 09:43:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15269) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0Zss-00070u-Gd for qemu-devel@nongnu.org; Thu, 23 Feb 2012 09:43:02 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1NEh1LV030573 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 23 Feb 2012 09:43:01 -0500 Received: from localhost (ovpn-113-76.phx2.redhat.com [10.3.113.76]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q1NEh0D5007904; Thu, 23 Feb 2012 09:43:01 -0500 From: Luiz Capitulino To: aliguori@us.ibm.com Date: Thu, 23 Feb 2012 12:42:52 -0200 Message-Id: <1330008174-26084-4-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1330008174-26084-1-git-send-email-lcapitulino@redhat.com> References: <1330008174-26084-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 3/5] block: Don't call bdrv_eject() if the tray state didn't change 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 not needed. Besides we can then assume that bdrv_eject() is only called when there's a tray state change, which is useful to the DEVICE_TRAY_MOVED event (going to be added in a future commit). Signed-off-by: Luiz Capitulino Reviewed-by: Markus Armbruster Acked-by: Kevin Wolf --- hw/ide/atapi.c | 7 +++++-- hw/scsi-disk.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 0adb27b..5919cf5 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -883,8 +883,11 @@ static void cmd_start_stop_unit(IDEState *s, uint8_t* buf) ide_atapi_cmd_error(s, sense, ASC_MEDIA_REMOVAL_PREVENTED); return; } - bdrv_eject(s->bs, !start); - s->tray_open = !start; + + if (s->tray_open != !start) { + bdrv_eject(s->bs, !start); + s->tray_open = !start; + } } ide_atapi_cmd_ok(s); diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index a5d2fd1..091ecdc 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -1050,8 +1050,11 @@ static int scsi_disk_emulate_start_stop(SCSIDiskReq *r) : SENSE_CODE(NOT_READY_REMOVAL_PREVENTED)); return -1; } - bdrv_eject(s->qdev.conf.bs, !start); - s->tray_open = !start; + + if (s->tray_open != !start) { + bdrv_eject(s->qdev.conf.bs, !start); + s->tray_open = !start; + } } return 0; }