From patchwork Wed Feb 10 22:37:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 45063 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D6850B7CE7 for ; Thu, 11 Feb 2010 09:43:16 +1100 (EST) Received: from localhost ([127.0.0.1]:36664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NfLGL-00038s-FT for incoming@patchwork.ozlabs.org; Wed, 10 Feb 2010 17:42:25 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NfLBZ-0001pl-5U for qemu-devel@nongnu.org; Wed, 10 Feb 2010 17:37:29 -0500 Received: from [199.232.76.173] (port=48297 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NfLBY-0001pQ-M6 for qemu-devel@nongnu.org; Wed, 10 Feb 2010 17:37:28 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NfLBX-0007OY-2i for qemu-devel@nongnu.org; Wed, 10 Feb 2010 17:37:28 -0500 Received: from verein.lst.de ([213.95.11.210]:52370) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1NfLBW-0007OK-KE for qemu-devel@nongnu.org; Wed, 10 Feb 2010 17:37:26 -0500 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id o1AMbPWY011452 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Wed, 10 Feb 2010 23:37:25 +0100 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id o1AMbPC2011451; Wed, 10 Feb 2010 23:37:25 +0100 Date: Wed, 10 Feb 2010 23:37:25 +0100 From: Christoph Hellwig To: qemu-devel@nongnu.org, "Martin K. Petersen" Message-ID: <20100210223725.GC11405@lst.de> References: <20100210223649.GA11405@lst.de> Mime-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100210223649.GA11405@lst.de> User-Agent: Mutt/1.3.28i X-Scanned-By: MIMEDefang 2.39 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: Subject: [Qemu-devel] [PATCH 3/5] virtio-blk: add topology support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Export all topology information in the block config structure, guarded by a new VIRTIO_BLK_F_TOPOLOGY feature flag. Signed-off-by: Christoph Hellwig Index: qemu/hw/virtio-blk.c =================================================================== --- qemu.orig/hw/virtio-blk.c 2010-02-10 23:27:55.105016426 +0100 +++ qemu/hw/virtio-blk.c 2010-02-10 23:31:30.927004343 +0100 @@ -26,6 +26,7 @@ typedef struct VirtIOBlock VirtQueue *vq; void *rq; QEMUBH *bh; + BlockConf *conf; } VirtIOBlock; static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev) @@ -405,6 +406,10 @@ static void virtio_blk_update_config(Vir blkcfg.heads = heads; blkcfg.sectors = secs; blkcfg.size_max = 0; + blkcfg.physical_block_exp = get_physical_block_exp(s->conf); + blkcfg.alignment_offset = 0; + blkcfg.min_io_size = s->conf->min_io_size / 512; + blkcfg.opt_io_size = s->conf->opt_io_size / 512; memcpy(config, &blkcfg, sizeof(struct virtio_blk_config)); } @@ -414,6 +419,7 @@ static uint32_t virtio_blk_get_features( features |= (1 << VIRTIO_BLK_F_SEG_MAX); features |= (1 << VIRTIO_BLK_F_GEOMETRY); + features |= (1 << VIRTIO_BLK_F_TOPOLOGY); if (bdrv_enable_write_cache(s->bs)) features |= (1 << VIRTIO_BLK_F_WCACHE); @@ -471,6 +477,7 @@ VirtIODevice *virtio_blk_init(DeviceStat s->vdev.get_features = virtio_blk_get_features; s->vdev.reset = virtio_blk_reset; s->bs = conf->dinfo->bdrv; + s->conf = conf; s->rq = NULL; bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs); bdrv_set_geometry_hint(s->bs, cylinders, heads, secs); Index: qemu/hw/virtio-blk.h =================================================================== --- qemu.orig/hw/virtio-blk.h 2010-02-10 23:27:51.067254307 +0100 +++ qemu/hw/virtio-blk.h 2010-02-10 23:31:30.928004413 +0100 @@ -32,6 +32,7 @@ #define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */ /* #define VIRTIO_BLK_F_IDENTIFY 8 ATA IDENTIFY supported, DEPRECATED */ #define VIRTIO_BLK_F_WCACHE 9 /* write cache enabled */ +#define VIRTIO_BLK_F_TOPOLOGY 10 /* Topology information is available */ struct virtio_blk_config { @@ -42,6 +43,10 @@ struct virtio_blk_config uint8_t heads; uint8_t sectors; uint32_t _blk_size; /* structure pad, currently unused */ + uint8_t physical_block_exp; + uint8_t alignment_offset; + uint16_t min_io_size; + uint32_t opt_io_size; } __attribute__((packed)); /* These two define direction. */