@@ -588,6 +588,7 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename,
bs->open_flags = open_flags;
bs->growable = 0;
bs->guest_block_size = 512;
+ bs->host_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)) {
@@ -612,6 +613,7 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename,
} else {
ret = bdrv_file_open(&bs->file, filename, open_flags);
bs->open_flags = bs->file->open_flags;
+ bs->host_block_size = bs->file->host_block_size;
if (ret >= 0) {
ret = drv->bdrv_open(bs, bs->file->open_flags);
}
@@ -3564,7 +3566,7 @@ void bdrv_set_guest_block_size(BlockDriverState *bs, int align)
void *qemu_blockalign(BlockDriverState *bs, size_t size)
{
- return qemu_memalign((bs && bs->guest_block_size) ? bs->guest_block_size : 512, size);
+ return qemu_memalign(bs ? bs->host_block_size : 512, size);
}
void bdrv_set_dirty_tracking(BlockDriverState *bs, int enable)
@@ -243,6 +243,9 @@ struct BlockDriverState {
/* the memory alignment used by the guest for the buffers handled by this driver */
int guest_block_size;
+ /* the memory alignment required by the device for the buffers handled by this driver */
+ int host_block_size;
+
/* NOTE: the following infos are only hints for real hardware
drivers. They are not used by the block driver */
int cyls, heads, secs, translation;
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- block.c | 4 +++- block_int.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletions(-)