From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqT2n-0004Li-Sk for qemu-devel@nongnu.org; Thu, 26 Jan 2012 12:23:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RqT2h-0003Of-S7 for qemu-devel@nongnu.org; Thu, 26 Jan 2012 12:23:29 -0500 Received: from mail-gx0-f173.google.com ([209.85.161.173]:59379) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqT2h-0003Mz-JL for qemu-devel@nongnu.org; Thu, 26 Jan 2012 12:23:23 -0500 Received: by mail-gx0-f173.google.com with SMTP id h1so470472ggn.4 for ; Thu, 26 Jan 2012 09:23:23 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 26 Jan 2012 18:22:40 +0100 Message-Id: <1327598569-5199-10-git-send-email-pbonzini@redhat.com> In-Reply-To: <1327598569-5199-1-git-send-email-pbonzini@redhat.com> References: <1327598569-5199-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v2 09/18] block: add host_block_size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com Signed-off-by: Paolo Bonzini --- block.c | 4 +++- block_int.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/block.c b/block.c index 2e1ebeb..af41fb3 100644 --- a/block.c +++ b/block.c @@ -591,6 +591,7 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename, bs->sg = 0; 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)) { @@ -616,6 +617,7 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename, ret = bdrv_file_open(&bs->file, filename, bs->open_flags); if (ret >= 0) { bs->open_flags = bs->file->open_flags; + bs->host_block_size = bs->file->host_block_size; ret = drv->bdrv_open(bs, bs->open_flags); } } @@ -3611,7 +3613,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) diff --git a/block_int.h b/block_int.h index dfde061..06e5d35 100644 --- a/block_int.h +++ b/block_int.h @@ -276,6 +276,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; -- 1.7.7.6