mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
block: Make the block accounting functions operate on BlockAcctStats
This is the next step for decoupling block accounting functions from BlockDriverState. In a future commit the BlockAcctStats structure will be moved from BlockDriverState to the device models structures. Note that bdrv_get_stats was introduced so device models can retrieve the BlockAcctStats structure of a BlockDriverState without being aware of it's layout. This function should go away when BlockAcctStats will be embedded in the device models structures. CC: Kevin Wolf <kwolf@redhat.com> CC: Stefan Hajnoczi <stefanha@redhat.com> CC: Keith Busch <keith.busch@intel.com> CC: Anthony Liguori <aliguori@amazon.com> CC: "Michael S. Tsirkin" <mst@redhat.com> CC: Paolo Bonzini <pbonzini@redhat.com> CC: Eric Blake <eblake@redhat.com> CC: Peter Maydell <peter.maydell@linaro.org> CC: Michael Tokarev <mjt@tls.msk.ru> CC: John Snow <jsnow@redhat.com> CC: Markus Armbruster <armbru@redhat.com> CC: Alexander Graf <agraf@suse.de> CC: Max Reitz <mreitz@redhat.com> Signed-off-by: Benoît Canet <benoit.canet@nodalink.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
28298fd3d9
commit
5366d0c8bc
13 changed files with 108 additions and 79 deletions
|
@ -110,14 +110,16 @@ static int cd_read_sector(IDEState *s, int lba, uint8_t *buf, int sector_size)
|
|||
|
||||
switch(sector_size) {
|
||||
case 2048:
|
||||
bdrv_acct_start(s->bs, &s->acct, 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);
|
||||
block_acct_start(bdrv_get_stats(s->bs), &s->acct,
|
||||
4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);
|
||||
ret = bdrv_read(s->bs, (int64_t)lba << 2, buf, 4);
|
||||
bdrv_acct_done(s->bs, &s->acct);
|
||||
block_acct_done(bdrv_get_stats(s->bs), &s->acct);
|
||||
break;
|
||||
case 2352:
|
||||
bdrv_acct_start(s->bs, &s->acct, 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);
|
||||
block_acct_start(bdrv_get_stats(s->bs), &s->acct,
|
||||
4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);
|
||||
ret = bdrv_read(s->bs, (int64_t)lba << 2, buf + 16, 4);
|
||||
bdrv_acct_done(s->bs, &s->acct);
|
||||
block_acct_done(bdrv_get_stats(s->bs), &s->acct);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
cd_data_to_raw(buf, lba);
|
||||
|
@ -253,7 +255,8 @@ static void ide_atapi_cmd_reply(IDEState *s, int size, int max_size)
|
|||
s->io_buffer_index = 0;
|
||||
|
||||
if (s->atapi_dma) {
|
||||
bdrv_acct_start(s->bs, &s->acct, size, BLOCK_ACCT_READ);
|
||||
block_acct_start(bdrv_get_stats(s->bs), &s->acct, size,
|
||||
BLOCK_ACCT_READ);
|
||||
s->status = READY_STAT | SEEK_STAT | DRQ_STAT;
|
||||
ide_start_dma(s, ide_atapi_cmd_read_dma_cb);
|
||||
} else {
|
||||
|
@ -354,7 +357,7 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret)
|
|||
return;
|
||||
|
||||
eot:
|
||||
bdrv_acct_done(s->bs, &s->acct);
|
||||
block_acct_done(bdrv_get_stats(s->bs), &s->acct);
|
||||
ide_set_inactive(s, false);
|
||||
}
|
||||
|
||||
|
@ -369,7 +372,8 @@ static void ide_atapi_cmd_read_dma(IDEState *s, int lba, int nb_sectors,
|
|||
s->io_buffer_size = 0;
|
||||
s->cd_sector_size = sector_size;
|
||||
|
||||
bdrv_acct_start(s->bs, &s->acct, s->packet_transfer_size, BLOCK_ACCT_READ);
|
||||
block_acct_start(bdrv_get_stats(s->bs), &s->acct, s->packet_transfer_size,
|
||||
BLOCK_ACCT_READ);
|
||||
|
||||
/* XXX: check if BUSY_STAT should be set */
|
||||
s->status = READY_STAT | SEEK_STAT | DRQ_STAT | BUSY_STAT;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue