提交 9752c371 编写于 作者: C Christoph Hellwig 提交者: Anthony Liguori

virtio-blk: add topology support

Export all topology information in the block config structure,
guarded by a new VIRTIO_BLK_F_TOPOLOGY feature flag.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 428c149b
...@@ -26,6 +26,7 @@ typedef struct VirtIOBlock ...@@ -26,6 +26,7 @@ typedef struct VirtIOBlock
VirtQueue *vq; VirtQueue *vq;
void *rq; void *rq;
QEMUBH *bh; QEMUBH *bh;
BlockConf *conf;
} VirtIOBlock; } VirtIOBlock;
static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev) static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev)
...@@ -405,6 +406,10 @@ static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config) ...@@ -405,6 +406,10 @@ static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)
blkcfg.heads = heads; blkcfg.heads = heads;
blkcfg.sectors = secs; blkcfg.sectors = secs;
blkcfg.size_max = 0; 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)); memcpy(config, &blkcfg, sizeof(struct virtio_blk_config));
} }
...@@ -414,6 +419,7 @@ static uint32_t virtio_blk_get_features(VirtIODevice *vdev, uint32_t features) ...@@ -414,6 +419,7 @@ static uint32_t virtio_blk_get_features(VirtIODevice *vdev, uint32_t features)
features |= (1 << VIRTIO_BLK_F_SEG_MAX); features |= (1 << VIRTIO_BLK_F_SEG_MAX);
features |= (1 << VIRTIO_BLK_F_GEOMETRY); features |= (1 << VIRTIO_BLK_F_GEOMETRY);
features |= (1 << VIRTIO_BLK_F_TOPOLOGY);
if (bdrv_enable_write_cache(s->bs)) if (bdrv_enable_write_cache(s->bs))
features |= (1 << VIRTIO_BLK_F_WCACHE); features |= (1 << VIRTIO_BLK_F_WCACHE);
...@@ -471,6 +477,7 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf) ...@@ -471,6 +477,7 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf)
s->vdev.get_features = virtio_blk_get_features; s->vdev.get_features = virtio_blk_get_features;
s->vdev.reset = virtio_blk_reset; s->vdev.reset = virtio_blk_reset;
s->bs = conf->dinfo->bdrv; s->bs = conf->dinfo->bdrv;
s->conf = conf;
s->rq = NULL; s->rq = NULL;
bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs); bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs);
bdrv_set_geometry_hint(s->bs, cylinders, heads, secs); bdrv_set_geometry_hint(s->bs, cylinders, heads, secs);
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */ #define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */
/* #define VIRTIO_BLK_F_IDENTIFY 8 ATA IDENTIFY supported, DEPRECATED */ /* #define VIRTIO_BLK_F_IDENTIFY 8 ATA IDENTIFY supported, DEPRECATED */
#define VIRTIO_BLK_F_WCACHE 9 /* write cache enabled */ #define VIRTIO_BLK_F_WCACHE 9 /* write cache enabled */
#define VIRTIO_BLK_F_TOPOLOGY 10 /* Topology information is available */
struct virtio_blk_config struct virtio_blk_config
{ {
...@@ -42,6 +43,10 @@ struct virtio_blk_config ...@@ -42,6 +43,10 @@ struct virtio_blk_config
uint8_t heads; uint8_t heads;
uint8_t sectors; uint8_t sectors;
uint32_t _blk_size; /* structure pad, currently unused */ 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)); } __attribute__((packed));
/* These two define direction. */ /* These two define direction. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册