From patchwork Tue Oct 7 11:59:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 397246 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4EDE51400B2 for ; Tue, 7 Oct 2014 23:02:51 +1100 (EST) Received: from localhost ([::1]:57972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XbTTd-0002Bs-Ez for incoming@patchwork.ozlabs.org; Tue, 07 Oct 2014 08:02:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XbTQg-0006FU-MT for qemu-devel@nongnu.org; Tue, 07 Oct 2014 07:59:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XbTQX-0002YM-VJ for qemu-devel@nongnu.org; Tue, 07 Oct 2014 07:59:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12111) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XbTQX-0002YC-NT for qemu-devel@nongnu.org; Tue, 07 Oct 2014 07:59:37 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s97BxZlG013623 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 7 Oct 2014 07:59:35 -0400 Received: from blackfin.pond.sub.org (ovpn-116-51.ams2.redhat.com [10.36.116.51]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s97BxVsH021440 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 7 Oct 2014 07:59:33 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5DD93304604C; Tue, 7 Oct 2014 13:59:27 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 7 Oct 2014 13:59:16 +0200 Message-Id: <1412683166-4934-15-git-send-email-armbru@redhat.com> In-Reply-To: <1412683166-4934-1-git-send-email-armbru@redhat.com> References: <1412683166-4934-1-git-send-email-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id s97BxZlG013623 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, benoit.canet@nodalink.com, stefanha@redhat.com, mreitz@redhat.com Subject: [Qemu-devel] [PATCH v6 14/24] virtio-blk: Drop redundant VirtIOBlock member conf 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 Commit 12c5674 turned it into a pointer to member blk.conf. Signed-off-by: Markus Armbruster Reviewed-by: BenoƮt Canet Reviewed-by: Max Reitz Reviewed-by: Kevin Wolf --- hw/block/virtio-blk.c | 28 ++++++++++++++-------------- include/hw/virtio/virtio-blk.h | 1 - 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 45e0c8f..5dc1b29 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -296,7 +296,7 @@ static bool virtio_blk_sect_range_ok(VirtIOBlock *dev, if (sector & dev->sector_mask) { return false; } - if (size % dev->conf->logical_block_size) { + if (size % dev->blk.conf.logical_block_size) { return false; } bdrv_get_geometry(dev->bs, &total_sectors); @@ -513,19 +513,20 @@ static void virtio_blk_reset(VirtIODevice *vdev) static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config) { VirtIOBlock *s = VIRTIO_BLK(vdev); + BlockConf *conf = &s->blk.conf; struct virtio_blk_config blkcfg; uint64_t capacity; - int blk_size = s->conf->logical_block_size; + int blk_size = conf->logical_block_size; bdrv_get_geometry(s->bs, &capacity); memset(&blkcfg, 0, sizeof(blkcfg)); virtio_stq_p(vdev, &blkcfg.capacity, capacity); virtio_stl_p(vdev, &blkcfg.seg_max, 128 - 2); - virtio_stw_p(vdev, &blkcfg.cylinders, s->conf->cyls); + virtio_stw_p(vdev, &blkcfg.cylinders, conf->cyls); virtio_stl_p(vdev, &blkcfg.blk_size, blk_size); - virtio_stw_p(vdev, &blkcfg.min_io_size, s->conf->min_io_size / blk_size); - virtio_stw_p(vdev, &blkcfg.opt_io_size, s->conf->opt_io_size / blk_size); - blkcfg.heads = s->conf->heads; + virtio_stw_p(vdev, &blkcfg.min_io_size, conf->min_io_size / blk_size); + virtio_stw_p(vdev, &blkcfg.opt_io_size, conf->opt_io_size / blk_size); + blkcfg.heads = conf->heads; /* * We must ensure that the block device capacity is a multiple of * the logical block size. If that is not the case, let's use @@ -537,13 +538,13 @@ static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config) * divided by 512 - instead it is the amount of blk_size blocks * per track (cylinder). */ - if (bdrv_getlength(s->bs) / s->conf->heads / s->conf->secs % blk_size) { - blkcfg.sectors = s->conf->secs & ~s->sector_mask; + if (bdrv_getlength(s->bs) / conf->heads / conf->secs % blk_size) { + blkcfg.sectors = conf->secs & ~s->sector_mask; } else { - blkcfg.sectors = s->conf->secs; + blkcfg.sectors = conf->secs; } blkcfg.size_max = 0; - blkcfg.physical_block_exp = get_physical_block_exp(s->conf); + blkcfg.physical_block_exp = get_physical_block_exp(conf); blkcfg.alignment_offset = 0; blkcfg.wce = bdrv_enable_write_cache(s->bs); memcpy(config, &blkcfg, sizeof(struct virtio_blk_config)); @@ -746,9 +747,8 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp) sizeof(struct virtio_blk_config)); s->bs = blk->conf.bs; - s->conf = &blk->conf; s->rq = NULL; - s->sector_mask = (s->conf->logical_block_size / BDRV_SECTOR_SIZE) - 1; + s->sector_mask = (s->blk.conf.logical_block_size / BDRV_SECTOR_SIZE) - 1; s->vq = virtio_add_queue(vdev, 128, virtio_blk_handle_output); s->complete_request = virtio_blk_complete_request; @@ -765,11 +765,11 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp) 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_guest_block_size(s->bs, s->conf->logical_block_size); + bdrv_set_guest_block_size(s->bs, s->blk.conf.logical_block_size); bdrv_iostatus_enable(s->bs); - add_boot_device_path(s->conf->bootindex, dev, "/disk@0,0"); + add_boot_device_path(s->blk.conf.bootindex, dev, "/disk@0,0"); } static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp) diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index f3853f2..0f4323d 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -125,7 +125,6 @@ typedef struct VirtIOBlock { VirtQueue *vq; void *rq; QEMUBH *bh; - BlockConf *conf; VirtIOBlkConf blk; unsigned short sector_mask; bool original_wce;