From: Denis Plotnikov <dplotnikov@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: den@virtuozzo.com, stefanha@redhat.com, qemu-block@nongnu.org,
mst@redhat.com
Subject: [PATCH v2 1/1] virtio: make seg_max virtqueue size dependent
Date: Fri, 8 Nov 2019 16:42:49 +0300 [thread overview]
Message-ID: <20191108134249.19004-2-dplotnikov@virtuozzo.com> (raw)
In-Reply-To: <20191108134249.19004-1-dplotnikov@virtuozzo.com>
seg_max has a restriction to be less or equal to virtqueue size
according to Virtio 1.0 specification
Although seg_max can't be set directly, it's worth to express this
dependancy directly in the code for sanity purpose.
Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
---
hw/block/virtio-blk.c | 2 +-
hw/scsi/virtio-scsi.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 06e57a4d39..21530304cf 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -903,7 +903,7 @@ static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)
blk_get_geometry(s->blk, &capacity);
memset(&blkcfg, 0, sizeof(blkcfg));
virtio_stq_p(vdev, &blkcfg.capacity, capacity);
- virtio_stl_p(vdev, &blkcfg.seg_max, 128 - 2);
+ virtio_stl_p(vdev, &blkcfg.seg_max, s->conf.queue_size - 2);
virtio_stw_p(vdev, &blkcfg.geometry.cylinders, conf->cyls);
virtio_stl_p(vdev, &blkcfg.blk_size, blk_size);
virtio_stw_p(vdev, &blkcfg.min_io_size, conf->min_io_size / blk_size);
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 839f120256..f7e5533cd5 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -650,7 +650,7 @@ static void virtio_scsi_get_config(VirtIODevice *vdev,
VirtIOSCSICommon *s = VIRTIO_SCSI_COMMON(vdev);
virtio_stl_p(vdev, &scsiconf->num_queues, s->conf.num_queues);
- virtio_stl_p(vdev, &scsiconf->seg_max, 128 - 2);
+ virtio_stl_p(vdev, &scsiconf->seg_max, s->conf.virtqueue_size - 2);
virtio_stl_p(vdev, &scsiconf->max_sectors, s->conf.max_sectors);
virtio_stl_p(vdev, &scsiconf->cmd_per_lun, s->conf.cmd_per_lun);
virtio_stl_p(vdev, &scsiconf->event_info_size, sizeof(VirtIOSCSIEvent));
--
2.17.0
next prev parent reply other threads:[~2019-11-08 13:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-08 13:42 [PATCH v2 0/1] virtio: fix IO request length in virtio SCSI/block Denis Plotnikov
2019-11-08 13:42 ` Denis Plotnikov [this message]
2019-11-08 14:26 ` [PATCH v2 1/1] virtio: make seg_max virtqueue size dependent Michael S. Tsirkin
2019-11-11 11:19 ` Stefan Hajnoczi
2019-11-11 11:20 ` Denis Plotnikov
2019-11-08 19:43 ` [PATCH v2 0/1] virtio: fix IO request length in virtio SCSI/block no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191108134249.19004-2-dplotnikov@virtuozzo.com \
--to=dplotnikov@virtuozzo.com \
--cc=den@virtuozzo.com \
--cc=mst@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).