From patchwork Tue Dec 13 12:37:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 131093 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1AC511007D3 for ; Wed, 14 Dec 2011 00:53:47 +1100 (EST) Received: from localhost ([::1]:33502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaRcw-0006Lr-LL for incoming@patchwork.ozlabs.org; Tue, 13 Dec 2011 07:38:34 -0500 Received: from eggs.gnu.org ([140.186.70.92]:44678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaRcD-0004SH-FW for qemu-devel@nongnu.org; Tue, 13 Dec 2011 07:37:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RaRcA-0004IH-NN for qemu-devel@nongnu.org; Tue, 13 Dec 2011 07:37:48 -0500 Received: from mail-yw0-f45.google.com ([209.85.213.45]:63177) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaRcA-0004Es-Kb for qemu-devel@nongnu.org; Tue, 13 Dec 2011 07:37:46 -0500 Received: by mail-yw0-f45.google.com with SMTP id g71so370792yhg.4 for ; Tue, 13 Dec 2011 04:37:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=cGmmgsL1Ucy1eSangncquFW8NsEN9GNKnH92TJrnYLQ=; b=AZn2qBZCmXyObj9V5z9x/tiVWYjigF7Pd+pEZK1B9pOwHrMVRw+EXbO0X8IDo1/7Wf LQ85PiJqDEZRqQGf89BN8a2s/U8mabQxD71Jo2uyvS5K53r4LVxbx/9liuD7DhBRTvGj hL99Z/HXtFlUl5beArJlcN7BgyiH5QLOCFTPE= Received: by 10.236.127.144 with SMTP id d16mr3274937yhi.51.1323779866448; Tue, 13 Dec 2011 04:37:46 -0800 (PST) Received: from localhost.localdomain (93-34-178-147.ip50.fastwebnet.it. [93.34.178.147]) by mx.google.com with ESMTPS id i50sm35972917yhk.11.2011.12.13.04.37.44 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 13 Dec 2011 04:37:45 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 13 Dec 2011 13:37:12 +0100 Message-Id: <1323779840-4235-10-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.7.1 In-Reply-To: <1323779840-4235-1-git-send-email-pbonzini@redhat.com> References: <1323779840-4235-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.213.45 Subject: [Qemu-devel] [PATCH 09/17] block: add host_block_size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 9e8ffb8..91622db 100644 --- a/block.c +++ b/block.c @@ -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) diff --git a/block_int.h b/block_int.h index 99f29e2..30393a0 100644 --- a/block_int.h +++ b/block_int.h @@ -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;