mirror of https://github.com/proxmox/mirror_qemu
virtio-blk: add num-queues device property
Multiqueue virtio-blk can be enabled as follows: qemu -device virtio-blk-pci,num-queues=8 Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-id: 1466511196-12612-8-git-send-email-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>master
parent
51b04ac5c6
commit
2f2705908f
|
@ -710,6 +710,7 @@ static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)
|
||||||
blkcfg.physical_block_exp = get_physical_block_exp(conf);
|
blkcfg.physical_block_exp = get_physical_block_exp(conf);
|
||||||
blkcfg.alignment_offset = 0;
|
blkcfg.alignment_offset = 0;
|
||||||
blkcfg.wce = blk_enable_write_cache(s->blk);
|
blkcfg.wce = blk_enable_write_cache(s->blk);
|
||||||
|
virtio_stw_p(vdev, &blkcfg.num_queues, s->conf.num_queues);
|
||||||
memcpy(config, &blkcfg, sizeof(struct virtio_blk_config));
|
memcpy(config, &blkcfg, sizeof(struct virtio_blk_config));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -753,6 +754,9 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features,
|
||||||
if (blk_is_read_only(s->blk)) {
|
if (blk_is_read_only(s->blk)) {
|
||||||
virtio_add_feature(&features, VIRTIO_BLK_F_RO);
|
virtio_add_feature(&features, VIRTIO_BLK_F_RO);
|
||||||
}
|
}
|
||||||
|
if (s->conf.num_queues > 1) {
|
||||||
|
virtio_add_feature(&features, VIRTIO_BLK_F_MQ);
|
||||||
|
}
|
||||||
|
|
||||||
return features;
|
return features;
|
||||||
}
|
}
|
||||||
|
@ -877,6 +881,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
|
||||||
VirtIOBlkConf *conf = &s->conf;
|
VirtIOBlkConf *conf = &s->conf;
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
static int virtio_blk_id;
|
static int virtio_blk_id;
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
if (!conf->conf.blk) {
|
if (!conf->conf.blk) {
|
||||||
error_setg(errp, "drive property not set");
|
error_setg(errp, "drive property not set");
|
||||||
|
@ -886,6 +891,10 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
|
||||||
error_setg(errp, "Device needs media, but drive is empty");
|
error_setg(errp, "Device needs media, but drive is empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!conf->num_queues) {
|
||||||
|
error_setg(errp, "num-queues property must be larger than 0");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
blkconf_serial(&conf->conf, &conf->serial);
|
blkconf_serial(&conf->conf, &conf->serial);
|
||||||
s->original_wce = blk_enable_write_cache(conf->conf.blk);
|
s->original_wce = blk_enable_write_cache(conf->conf.blk);
|
||||||
|
@ -903,8 +912,9 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
|
||||||
s->rq = NULL;
|
s->rq = NULL;
|
||||||
s->sector_mask = (s->conf.conf.logical_block_size / BDRV_SECTOR_SIZE) - 1;
|
s->sector_mask = (s->conf.conf.logical_block_size / BDRV_SECTOR_SIZE) - 1;
|
||||||
|
|
||||||
conf->num_queues = 1;
|
for (i = 0; i < conf->num_queues; i++) {
|
||||||
s->vq = virtio_add_queue(vdev, 128, virtio_blk_handle_output);
|
virtio_add_queue(vdev, 128, virtio_blk_handle_output);
|
||||||
|
}
|
||||||
virtio_blk_data_plane_create(vdev, conf, &s->dataplane, &err);
|
virtio_blk_data_plane_create(vdev, conf, &s->dataplane, &err);
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
error_propagate(errp, err);
|
error_propagate(errp, err);
|
||||||
|
@ -957,6 +967,7 @@ static Property virtio_blk_properties[] = {
|
||||||
#endif
|
#endif
|
||||||
DEFINE_PROP_BIT("request-merging", VirtIOBlock, conf.request_merging, 0,
|
DEFINE_PROP_BIT("request-merging", VirtIOBlock, conf.request_merging, 0,
|
||||||
true),
|
true),
|
||||||
|
DEFINE_PROP_UINT16("num-queues", VirtIOBlock, conf.num_queues, 1),
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,6 @@ struct VirtIOBlockReq;
|
||||||
typedef struct VirtIOBlock {
|
typedef struct VirtIOBlock {
|
||||||
VirtIODevice parent_obj;
|
VirtIODevice parent_obj;
|
||||||
BlockBackend *blk;
|
BlockBackend *blk;
|
||||||
VirtQueue *vq;
|
|
||||||
void *rq;
|
void *rq;
|
||||||
QEMUBH *bh;
|
QEMUBH *bh;
|
||||||
VirtIOBlkConf conf;
|
VirtIOBlkConf conf;
|
||||||
|
|
Loading…
Reference in New Issue