From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:56818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RyTNS-0003an-DM for qemu-devel@nongnu.org; Fri, 17 Feb 2012 14:21:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RyTNQ-0006NK-T7 for qemu-devel@nongnu.org; Fri, 17 Feb 2012 14:21:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:28484) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RyTNQ-0006NB-MP for qemu-devel@nongnu.org; Fri, 17 Feb 2012 14:21:52 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1HJLp2H023420 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 17 Feb 2012 14:21:52 -0500 From: Luiz Capitulino Date: Fri, 17 Feb 2012 17:21:42 -0200 Message-Id: <1329506504-29152-4-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1329506504-29152-1-git-send-email-lcapitulino@redhat.com> References: <1329506504-29152-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PATCH 3/5] block: Don't call bdrv_eject() if the tray state didn't change List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, eblake@redhat.com, armbru@redhat.com 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 --- 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; } -- 1.7.9.111.gf3fb0.dirty