[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 08/18] block: rename buffer_alignment to guest_bl
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH v2 08/18] block: rename buffer_alignment to guest_block_size |
Date: |
Thu, 26 Jan 2012 18:22:39 +0100 |
The alignment field is now set to the value that is promised to the guest,
rather than required by the host. The next patches will make QEMU aware
of the host-provided values, so make this clear.
Signed-off-by: Paolo Bonzini <address@hidden>
---
block.c | 10 +++++-----
block.h | 2 +-
block/raw-posix.c | 2 +-
block_int.h | 4 ++--
hw/ide/core.c | 2 +-
hw/scsi-disk.c | 2 +-
hw/scsi-generic.c | 2 +-
hw/virtio-blk.c | 2 +-
8 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/block.c b/block.c
index afc327e..2e1ebeb 100644
--- a/block.c
+++ b/block.c
@@ -590,7 +590,7 @@ static int bdrv_open_common(BlockDriverState *bs, const
char *filename,
bs->valid_key = 0;
bs->sg = 0;
bs->growable = 0;
- bs->buffer_alignment = 512;
+ bs->guest_block_size = 512;
assert(bs->copy_on_read == 0); /* bdrv_new() and bdrv_close() make it so */
if ((flags & BDRV_O_RDWR) && (flags & BDRV_O_COPY_ON_READ)) {
@@ -920,7 +920,7 @@ void bdrv_detach_dev(BlockDriverState *bs, void *dev)
bs->dev = NULL;
bs->dev_ops = NULL;
bs->dev_opaque = NULL;
- bs->buffer_alignment = 512;
+ bs->guest_block_size = 512;
}
/* TODO change to return DeviceState * when all users are qdevified */
@@ -3604,14 +3604,14 @@ BlockDriverAIOCB *bdrv_aio_ioctl(BlockDriverState *bs,
return NULL;
}
-void bdrv_set_buffer_alignment(BlockDriverState *bs, int align)
+void bdrv_set_guest_block_size(BlockDriverState *bs, int align)
{
- bs->buffer_alignment = align;
+ bs->guest_block_size = align;
}
void *qemu_blockalign(BlockDriverState *bs, size_t size)
{
- return qemu_memalign((bs && bs->buffer_alignment) ? bs->buffer_alignment :
512, size);
+ return qemu_memalign((bs && bs->guest_block_size) ? bs->guest_block_size :
512, size);
}
void bdrv_set_dirty_tracking(BlockDriverState *bs, int enable)
diff --git a/block.h b/block.h
index cae289b..34dc925 100644
--- a/block.h
+++ b/block.h
@@ -307,7 +307,7 @@ int bdrv_img_create(const char *filename, const char *fmt,
const char *base_filename, const char *base_fmt,
char *options, uint64_t img_size, int flags);
-void bdrv_set_buffer_alignment(BlockDriverState *bs, int align);
+void bdrv_set_guest_block_size(BlockDriverState *bs, int align);
void *qemu_blockalign(BlockDriverState *bs, size_t size);
#define BDRV_SECTORS_PER_DIRTY_CHUNK 2048
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 007d1d3..49a8c21 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -287,7 +287,7 @@ static int qiov_is_aligned(BlockDriverState *bs,
QEMUIOVector *qiov)
int i;
for (i = 0; i < qiov->niov; i++) {
- if ((uintptr_t) qiov->iov[i].iov_base % bs->buffer_alignment) {
+ if ((uintptr_t) qiov->iov[i].iov_base % bs->guest_block_size) {
return 0;
}
}
diff --git a/block_int.h b/block_int.h
index 6f23d4a..dfde061 100644
--- a/block_int.h
+++ b/block_int.h
@@ -273,8 +273,8 @@ struct BlockDriverState {
uint64_t total_time_ns[BDRV_MAX_IOTYPE];
uint64_t wr_highest_sector;
- /* the memory alignment required for the buffers handled by this driver */
- int buffer_alignment;
+ /* the memory alignment used by the guest for the buffers handled by this
driver */
+ int guest_block_size;
/* NOTE: the following infos are only hints for real hardware
drivers. They are not used by the block driver */
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 56b219b..9eefdf2 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -1852,7 +1852,7 @@ int ide_init_drive(IDEState *s, BlockDriverState *bs,
IDEDriveKind kind,
s->smart_selftest_count = 0;
if (kind == IDE_CD) {
bdrv_set_dev_ops(bs, &ide_cd_block_ops, s);
- bdrv_set_buffer_alignment(bs, 2048);
+ bdrv_set_guest_block_size(bs, 2048);
} else {
if (!bdrv_is_inserted(s->bs)) {
error_report("Device needs media, but drive is empty");
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 11cfe73..4f370a6 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1536,7 +1536,7 @@ static int scsi_initfn(SCSIDevice *dev)
if (s->removable) {
bdrv_set_dev_ops(s->qdev.conf.bs, &scsi_cd_block_ops, s);
}
- bdrv_set_buffer_alignment(s->qdev.conf.bs, s->qdev.blocksize);
+ bdrv_set_guest_block_size(s->qdev.conf.bs, s->qdev.blocksize);
bdrv_iostatus_enable(s->qdev.conf.bs);
add_boot_device_path(s->qdev.conf.bootindex, &dev->qdev, NULL);
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index 0aebcdd..95d3cda 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -184,7 +184,7 @@ static void scsi_read_complete(void * opaque, int ret)
s->blocksize = ldl_be_p(&r->buf[8]);
s->max_lba = ldq_be_p(&r->buf[0]);
}
- bdrv_set_buffer_alignment(s->conf.bs, s->blocksize);
+ bdrv_set_guest_block_size(s->conf.bs, s->blocksize);
scsi_req_data(&r->req, len);
if (!r->req.io_canceled) {
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index a5a4396..7c44a1f 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -614,7 +614,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_dev_ops(s->bs, &virtio_block_ops, s);
- bdrv_set_buffer_alignment(s->bs, conf->logical_block_size);
+ bdrv_set_guest_block_size(s->bs, conf->logical_block_size);
bdrv_iostatus_enable(s->bs);
add_boot_device_path(conf->bootindex, dev, "/address@hidden,0");
--
1.7.7.6
- [Qemu-devel] [PATCH v2 00/18] Support mismatched host and guest logical block sizes, Paolo Bonzini, 2012/01/26
- [Qemu-devel] [PATCH v2 01/18] block: do not rely on open_flags for bdrv_is_snapshot, Paolo Bonzini, 2012/01/26
- [Qemu-devel] [PATCH v2 03/18] block: pass protocol flags up to the format, Paolo Bonzini, 2012/01/26
- [Qemu-devel] [PATCH v2 02/18] block: store actual flags in bs->open_flags, Paolo Bonzini, 2012/01/26
- [Qemu-devel] [PATCH v2 04/18] block: non-raw protocols never cache, Paolo Bonzini, 2012/01/26
- [Qemu-devel] [PATCH v2 05/18] block: remove enable_write_cache, Paolo Bonzini, 2012/01/26
- [Qemu-devel] [PATCH v2 06/18] block: move flag bits together, Paolo Bonzini, 2012/01/26
- [Qemu-devel] [PATCH v2 07/18] raw: remove the aligned_buf, Paolo Bonzini, 2012/01/26
- [Qemu-devel] [PATCH v2 09/18] block: add host_block_size, Paolo Bonzini, 2012/01/26
- [Qemu-devel] [PATCH v2 11/18] iscsi: save host block size, Paolo Bonzini, 2012/01/26
- [Qemu-devel] [PATCH v2 08/18] block: rename buffer_alignment to guest_block_size,
Paolo Bonzini <=
- [Qemu-devel] [PATCH v2 10/18] raw: probe host_block_size, Paolo Bonzini, 2012/01/26
- [Qemu-devel] [PATCH v2 12/18] block: allow waiting only for overlapping writes, Paolo Bonzini, 2012/01/26
- [Qemu-devel] [PATCH v2 14/18] block: protect against "torn reads" for guest_block_size > host_block_size, Paolo Bonzini, 2012/01/26
- [Qemu-devel] [PATCH v2 17/18] block: default min_io_size to host block size when doing rmw, Paolo Bonzini, 2012/01/26
- [Qemu-devel] [PATCH v2 16/18] block: default physical block size to host block size, Paolo Bonzini, 2012/01/26
- [Qemu-devel] [PATCH v2 18/18] qemu-io: add blocksize argument to open, Paolo Bonzini, 2012/01/26
- [Qemu-devel] [PATCH v2 15/18] block: align and serialize I/O when guest_block_size < host_block_size, Paolo Bonzini, 2012/01/26
- [Qemu-devel] [PATCH v2 13/18] block: allow waiting at arbitrary granularity, Paolo Bonzini, 2012/01/26