aboutsummaryrefslogtreecommitdiff
path: root/hw/ide/atapi.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2014-10-07 13:59:18 +0200
committerKevin Wolf <kwolf@redhat.com>2014-10-20 14:02:25 +0200
commit4be746345f13e99e468c60acbd3a355e8183e3ce (patch)
tree16509218f940129beb113cf3b1be158c3501ec1d /hw/ide/atapi.c
parent2a30307f709e6a395d23cf94837e9aae15f8e8fa (diff)
hw: Convert from BlockDriverState to BlockBackend, mostly
Device models should access their block backends only through the block-backend.h API. Convert them, and drop direct includes of inappropriate headers. Just four uses of BlockDriverState are left: * The Xen paravirtual block device backend (xen_disk.c) opens images itself when set up via xenbus, bypassing blockdev.c. I figure it should go through qmp_blockdev_add() instead. * Device model "usb-storage" prompts for keys. No other device model does, and this one probably shouldn't do it, either. * ide_issue_trim_cb() uses bdrv_aio_discard() instead of blk_aio_discard() because it fishes its backend out of a BlockAIOCB, which has only the BlockDriverState. * PC87312State has an unused BlockDriverState[] member. The next two commits take care of the latter two. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/ide/atapi.c')
-rw-r--r--hw/ide/atapi.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
index 10218dfa3a..c63b7e556e 100644
--- a/hw/ide/atapi.c
+++ b/hw/ide/atapi.c
@@ -25,6 +25,7 @@
#include "hw/ide/internal.h"
#include "hw/scsi/scsi.h"
+#include "sysemu/block-backend.h"
static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret);
@@ -110,16 +111,16 @@ static int cd_read_sector(IDEState *s, int lba, uint8_t *buf, int sector_size)
switch(sector_size) {
case 2048:
- block_acct_start(bdrv_get_stats(s->bs), &s->acct,
+ block_acct_start(blk_get_stats(s->blk), &s->acct,
4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);
- ret = bdrv_read(s->bs, (int64_t)lba << 2, buf, 4);
- block_acct_done(bdrv_get_stats(s->bs), &s->acct);
+ ret = blk_read(s->blk, (int64_t)lba << 2, buf, 4);
+ block_acct_done(blk_get_stats(s->blk), &s->acct);
break;
case 2352:
- block_acct_start(bdrv_get_stats(s->bs), &s->acct,
+ block_acct_start(blk_get_stats(s->blk), &s->acct,
4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);
- ret = bdrv_read(s->bs, (int64_t)lba << 2, buf + 16, 4);
- block_acct_done(bdrv_get_stats(s->bs), &s->acct);
+ ret = blk_read(s->blk, (int64_t)lba << 2, buf + 16, 4);
+ block_acct_done(blk_get_stats(s->blk), &s->acct);
if (ret < 0)
return ret;
cd_data_to_raw(buf, lba);
@@ -254,7 +255,7 @@ static void ide_atapi_cmd_reply(IDEState *s, int size, int max_size)
s->io_buffer_index = 0;
if (s->atapi_dma) {
- block_acct_start(bdrv_get_stats(s->bs), &s->acct, size,
+ block_acct_start(blk_get_stats(s->blk), &s->acct, size,
BLOCK_ACCT_READ);
s->status = READY_STAT | SEEK_STAT | DRQ_STAT;
ide_start_dma(s, ide_atapi_cmd_read_dma_cb);
@@ -350,13 +351,13 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret)
s->bus->dma->iov.iov_len = n * 4 * 512;
qemu_iovec_init_external(&s->bus->dma->qiov, &s->bus->dma->iov, 1);
- s->bus->dma->aiocb = bdrv_aio_readv(s->bs, (int64_t)s->lba << 2,
+ s->bus->dma->aiocb = blk_aio_readv(s->blk, (int64_t)s->lba << 2,
&s->bus->dma->qiov, n * 4,
ide_atapi_cmd_read_dma_cb, s);
return;
eot:
- block_acct_done(bdrv_get_stats(s->bs), &s->acct);
+ block_acct_done(blk_get_stats(s->blk), &s->acct);
ide_set_inactive(s, false);
}
@@ -371,7 +372,7 @@ 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;
- block_acct_start(bdrv_get_stats(s->bs), &s->acct, s->packet_transfer_size,
+ block_acct_start(blk_get_stats(s->blk), &s->acct, s->packet_transfer_size,
BLOCK_ACCT_READ);
/* XXX: check if BUSY_STAT should be set */
@@ -504,7 +505,7 @@ static unsigned int event_status_media(IDEState *s,
media_status = 0;
if (s->tray_open) {
media_status = MS_TRAY_OPEN;
- } else if (bdrv_is_inserted(s->bs)) {
+ } else if (blk_is_inserted(s->blk)) {
media_status = MS_MEDIA_PRESENT;
}
@@ -800,7 +801,7 @@ static void cmd_test_unit_ready(IDEState *s, uint8_t *buf)
static void cmd_prevent_allow_medium_removal(IDEState *s, uint8_t* buf)
{
s->tray_locked = buf[4] & 1;
- bdrv_lock_medium(s->bs, buf[4] & 1);
+ blk_lock_medium(s->blk, buf[4] & 1);
ide_atapi_cmd_ok(s);
}
@@ -884,14 +885,14 @@ static void cmd_start_stop_unit(IDEState *s, uint8_t* buf)
if (loej) {
if (!start && !s->tray_open && s->tray_locked) {
- sense = bdrv_is_inserted(s->bs)
+ sense = blk_is_inserted(s->blk)
? NOT_READY : ILLEGAL_REQUEST;
ide_atapi_cmd_error(s, sense, ASC_MEDIA_REMOVAL_PREVENTED);
return;
}
if (s->tray_open != !start) {
- bdrv_eject(s->bs, !start);
+ blk_eject(s->blk, !start);
s->tray_open = !start;
}
}
@@ -1125,7 +1126,7 @@ void ide_atapi_cmd(IDEState *s)
* states rely on this behavior.
*/
if (!(atapi_cmd_table[s->io_buffer[0]].flags & ALLOW_UA) &&
- !s->tray_open && bdrv_is_inserted(s->bs) && s->cdrom_changed) {
+ !s->tray_open && blk_is_inserted(s->blk) && s->cdrom_changed) {
if (s->cdrom_changed == 1) {
ide_atapi_cmd_error(s, NOT_READY, ASC_MEDIUM_NOT_PRESENT);
@@ -1140,7 +1141,7 @@ void ide_atapi_cmd(IDEState *s)
/* Report a Not Ready condition if appropriate for the command */
if ((atapi_cmd_table[s->io_buffer[0]].flags & CHECK_READY) &&
- (!media_present(s) || !bdrv_is_inserted(s->bs)))
+ (!media_present(s) || !blk_is_inserted(s->blk)))
{
ide_atapi_cmd_error(s, NOT_READY, ASC_MEDIUM_NOT_PRESENT);
return;