From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:42098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QCVZe-0008Or-Ms for qemu-devel@nongnu.org; Wed, 20 Apr 2011 07:27:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QCVZa-0000od-55 for qemu-devel@nongnu.org; Wed, 20 Apr 2011 07:27:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5067) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QCVZZ-0000oD-P1 for qemu-devel@nongnu.org; Wed, 20 Apr 2011 07:27:54 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3KBRrkK007522 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 20 Apr 2011 07:27:53 -0400 From: Kevin Wolf Date: Wed, 20 Apr 2011 13:30:14 +0200 Message-Id: <1303299015-11036-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1303299015-11036-1-git-send-email-kwolf@redhat.com> References: <1303299015-11036-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH v2 4/5] ide/atapi: Replace bdrv_get_geometry calls by s->nb_sectors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com The disk size can only change when the medium is changed, and the change callback takes care of updating s->nb_sectors in this case. Signed-off-by: Kevin Wolf --- hw/ide/atapi.c | 21 ++++++--------------- 1 files changed, 6 insertions(+), 15 deletions(-) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index d0bf7fd..5835caa 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -416,10 +416,10 @@ static int ide_dvd_read_structure(IDEState *s, int format, if (layer != 0) return -ASC_INV_FIELD_IN_CMD_PACKET; - bdrv_get_geometry(s->bs, &total_sectors); - total_sectors >>= 2; - if (total_sectors == 0) + total_sectors = s->nb_sectors >> 2; + if (total_sectors == 0) { return -ASC_MEDIUM_NOT_PRESENT; + } buf[4] = 1; /* DVD-ROM, part version 1 */ buf[5] = 0xf; /* 120mm disc, minimum rate unspecified */ @@ -881,11 +881,8 @@ static void cmd_read_cd(IDEState *s, uint8_t* buf) static void cmd_seek(IDEState *s, uint8_t* buf) { unsigned int lba; - uint64_t total_sectors; - - bdrv_get_geometry(s->bs, &total_sectors); + uint64_t total_sectors = s->nb_sectors >> 2; - total_sectors >>= 2; if (total_sectors == 0) { ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT); return; @@ -944,12 +941,9 @@ static void cmd_mechanism_status(IDEState *s, uint8_t* buf) static void cmd_read_toc_pma_atip(IDEState *s, uint8_t* buf) { int format, msf, start_track, len; - uint64_t total_sectors; + uint64_t total_sectors = s->nb_sectors >> 2; int max_len; - bdrv_get_geometry(s->bs, &total_sectors); - - total_sectors >>= 2; if (total_sectors == 0) { ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT); return; @@ -990,11 +984,8 @@ static void cmd_read_toc_pma_atip(IDEState *s, uint8_t* buf) static void cmd_read_cdvd_capacity(IDEState *s, uint8_t* buf) { - uint64_t total_sectors; - - bdrv_get_geometry(s->bs, &total_sectors); + uint64_t total_sectors = s->nb_sectors >> 2; - total_sectors >>= 2; if (total_sectors == 0) { ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT); return; -- 1.7.2.3