diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2010-09-21 17:50:58 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2010-09-21 17:50:58 -0500 |
commit | e1bb0a1a6c7c6d51443856ca90bd538b1ef5feeb (patch) | |
tree | ec271a0d224608382eb146d68298fd9e9fd0d3c9 /hw | |
parent | f36d53ef6cb848d5cf204b0854b12e0359f0fd7e (diff) | |
parent | d9d334176c5dba23b47be07192f431b0c030928d (diff) | |
download | qemu-e1bb0a1a6c7c6d51443856ca90bd538b1ef5feeb.zip qemu-e1bb0a1a6c7c6d51443856ca90bd538b1ef5feeb.tar.gz qemu-e1bb0a1a6c7c6d51443856ca90bd538b1ef5feeb.tar.bz2 |
Merge remote branch 'kwolf/for-anthony' into staging
Diffstat (limited to 'hw')
-rw-r--r-- | hw/ide/core.c | 4 | ||||
-rw-r--r-- | hw/scsi-bus.c | 3 | ||||
-rw-r--r-- | hw/scsi-disk.c | 10 | ||||
-rw-r--r-- | hw/scsi-generic.c | 21 | ||||
-rw-r--r-- | hw/sd.c | 2 | ||||
-rw-r--r-- | hw/virtio-blk.c | 1 |
6 files changed, 32 insertions, 9 deletions
diff --git a/hw/ide/core.c b/hw/ide/core.c index 1e466d1..06b6e14 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2645,6 +2645,7 @@ int ide_init_drive(IDEState *s, BlockDriverState *bs, if (bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM) { s->drive_kind = IDE_CD; bdrv_set_change_cb(bs, cdrom_change_cb, s); + bs->buffer_alignment = 2048; } else { if (!bdrv_is_inserted(s->bs)) { error_report("Device needs media, but drive is empty"); @@ -2679,7 +2680,8 @@ static void ide_init1(IDEBus *bus, int unit) s->bus = bus; s->unit = unit; s->drive_serial = drive_serial++; - s->io_buffer = qemu_blockalign(s->bs, IDE_DMA_BUF_SECTORS*512 + 4); + /* we need at least 2k alignment for accessing CDROMs using O_DIRECT */ + s->io_buffer = qemu_memalign(2048, IDE_DMA_BUF_SECTORS*512 + 4); s->io_buffer_total_len = IDE_DMA_BUF_SECTORS*512 + 4; s->smart_selftest_data = qemu_blockalign(s->bs, 512); s->sector_write_timer = qemu_new_timer(vm_clock, diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index 7aa0bcd..5a3fd4b 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -208,6 +208,8 @@ static int scsi_req_length(SCSIRequest *req, uint8_t *cmd) case SEEK_6: case WRITE_FILEMARKS: case SPACE: + case RESERVE: + case RELEASE: case ERASE: case ALLOW_MEDIUM_REMOVAL: case VERIFY: @@ -319,7 +321,6 @@ static void scsi_req_xfer_mode(SCSIRequest *req) case WRITE_BUFFER: case FORMAT_UNIT: case REASSIGN_BLOCKS: - case RESERVE: case SEARCH_EQUAL: case SEARCH_HIGH: case SEARCH_LOW: diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 1446ca6..9628b39 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -70,14 +70,15 @@ struct SCSIDiskState char *serial; }; -static SCSIDiskReq *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun) +static SCSIDiskReq *scsi_new_request(SCSIDiskState *s, uint32_t tag, + uint32_t lun) { SCSIRequest *req; SCSIDiskReq *r; - req = scsi_req_alloc(sizeof(SCSIDiskReq), d, tag, lun); + req = scsi_req_alloc(sizeof(SCSIDiskReq), &s->qdev, tag, lun); r = DO_UPCAST(SCSIDiskReq, req, req); - r->iov.iov_base = qemu_memalign(512, SCSI_DMA_BUF_SIZE); + r->iov.iov_base = qemu_blockalign(s->bs, SCSI_DMA_BUF_SIZE); return r; } @@ -939,7 +940,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, } /* ??? Tags are not unique for different luns. We only implement a single lun, so this should not matter. */ - r = scsi_new_request(d, tag, lun); + r = scsi_new_request(s, tag, lun); outbuf = (uint8_t *)r->iov.iov_base; is_write = 0; DPRINTF("Command: lun=%d tag=0x%x data=0x%02x", lun, tag, buf[0]); @@ -1177,6 +1178,7 @@ static int scsi_disk_initfn(SCSIDevice *dev) s->qdev.blocksize = s->qdev.conf.logical_block_size; } s->cluster_size = s->qdev.blocksize / 512; + s->bs->buffer_alignment = s->qdev.blocksize; s->qdev.type = TYPE_DISK; qemu_add_vm_change_state_handler(scsi_dma_restart_cb, s); diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c index 9538027..7212091 100644 --- a/hw/scsi-generic.c +++ b/hw/scsi-generic.c @@ -455,15 +455,31 @@ static int get_stream_blocksize(BlockDriverState *bdrv) return (buf[9] << 16) | (buf[10] << 8) | buf[11]; } -static void scsi_destroy(SCSIDevice *d) +static void scsi_generic_purge_requests(SCSIGenericState *s) { - SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, d); SCSIGenericReq *r; while (!QTAILQ_EMPTY(&s->qdev.requests)) { r = DO_UPCAST(SCSIGenericReq, req, QTAILQ_FIRST(&s->qdev.requests)); + if (r->req.aiocb) { + bdrv_aio_cancel(r->req.aiocb); + } scsi_remove_request(r); } +} + +static void scsi_generic_reset(DeviceState *dev) +{ + SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev.qdev, dev); + + scsi_generic_purge_requests(s); +} + +static void scsi_destroy(SCSIDevice *d) +{ + SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, d); + + scsi_generic_purge_requests(s); blockdev_mark_auto_del(s->qdev.conf.bs); } @@ -537,6 +553,7 @@ static SCSIDeviceInfo scsi_generic_info = { .qdev.name = "scsi-generic", .qdev.desc = "pass through generic scsi device (/dev/sg*)", .qdev.size = sizeof(SCSIGenericState), + .qdev.reset = scsi_generic_reset, .init = scsi_generic_initfn, .destroy = scsi_destroy, .send_command = scsi_send_command, @@ -440,7 +440,7 @@ SDState *sd_init(BlockDriverState *bs, int is_spi) SDState *sd; sd = (SDState *) qemu_mallocz(sizeof(SDState)); - sd->buf = qemu_memalign(512, 512); + sd->buf = qemu_blockalign(bs, 512); sd->spi = is_spi; sd->enable = 1; sd_reset(sd, bs); diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index bd6bbe6..a1df26d 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -540,6 +540,7 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf) register_savevm(dev, "virtio-blk", virtio_blk_id++, 2, virtio_blk_save, virtio_blk_load, s); bdrv_set_removable(s->bs, 0); + s->bs->buffer_alignment = conf->logical_block_size; return &s->vdev; } |