[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 07/11] ide/atapi: Replace bdrv_get_geometry calls by
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 07/11] ide/atapi: Replace bdrv_get_geometry calls by s->nb_sectors |
Date: |
Wed, 27 Apr 2011 15:43:06 +0200 |
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 <address@hidden>
---
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 ba35d4d..0d14439 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
- [Qemu-devel] [PULL 00/11] Block patches, Kevin Wolf, 2011/04/27
- [Qemu-devel] [PATCH 02/11] atapi: Add 'medium ready' to 'medium not ready' transition on cd change, Kevin Wolf, 2011/04/27
- [Qemu-devel] [PATCH 01/11] qemu-img: allow rebase to a NULL backing file when unsafe, Kevin Wolf, 2011/04/27
- [Qemu-devel] [PATCH 03/11] Improve accuracy of block migration bandwidth calculation, Kevin Wolf, 2011/04/27
- [Qemu-devel] [PATCH 06/11] ide/atapi: Use table instead of switch for commands, Kevin Wolf, 2011/04/27
- [Qemu-devel] [PATCH 05/11] ide/atapi: Factor commands out, Kevin Wolf, 2011/04/27
- [Qemu-devel] [PATCH 08/11] ide/atapi: Introduce CHECK_READY flag for commands, Kevin Wolf, 2011/04/27
- [Qemu-devel] [PATCH 04/11] ide: Split atapi.c out, Kevin Wolf, 2011/04/27
- [Qemu-devel] [PATCH 11/11] Remove obsolete 'enabled' variable from progress state, Kevin Wolf, 2011/04/27
- [Qemu-devel] [PATCH 07/11] ide/atapi: Replace bdrv_get_geometry calls by s->nb_sectors,
Kevin Wolf <=
- [Qemu-devel] [PATCH 09/11] qed: Fix consistency check on 32-bit hosts, Kevin Wolf, 2011/04/27
- [Qemu-devel] [PATCH 10/11] Add dd-style SIGUSR1 progress reporting, Kevin Wolf, 2011/04/27
- Re: [Qemu-devel] [PULL 00/11] Block patches, Aurelien Jarno, 2011/04/27