From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Jia He <hejianet@gmail.com>, Jia He <jia.he@hxt-semitech.com>
Subject: [Qemu-devel] [PULL 07/13] vhost: avoid to start/stop virtqueue which is not ready
Date: Thu, 1 Mar 2018 18:46:02 +0200 [thread overview]
Message-ID: <1519922735-29054-8-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1519922735-29054-1-git-send-email-mst@redhat.com>
From: Jia He <hejianet@gmail.com>
In our Armv8a server, we try to configure the vhost scsi but fail
to boot up the guest (-machine virt-2.10). The guest's boot failure
is very early, even earlier than grub.
There are 3 virtqueues (ctrl, event and cmd) for virtio scsi device,
but ovmf and seabios will only set the physical address for the 3rd
one (cmd). Then in vhost_virtqueue_start(), virtio_queue_get_desc_addr
will be 0 for ctrl and event vq when qemu negotiates with ovmf. So
vhost_memory_map fails with ENOMEM.
This patch just fixs it by early quitting the virtqueue start/stop
when virtio_queue_get_desc_addr is 0.
Btw, after guest kernel starts, all the 3 queues will be initialized
and set address correctly.
Already tested on Arm64 and X86_64 qemu.
Signed-off-by: Jia He <jia.he@hxt-semitech.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/vhost.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 4a583a3..d02d12a 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -345,6 +345,10 @@ static int vhost_verify_ring_mappings(struct vhost_dev *dev,
for (i = 0; i < dev->nvqs; ++i) {
struct vhost_virtqueue *vq = dev->vqs + i;
+ if (vq->desc_phys == 0) {
+ continue;
+ }
+
j = 0;
r = vhost_verify_ring_part_mapping(
vq->desc, vq->desc_phys, vq->desc_size,
@@ -881,6 +885,11 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
};
struct VirtQueue *vvq = virtio_get_queue(vdev, idx);
+ a = virtio_queue_get_desc_addr(vdev, idx);
+ if (a == 0) {
+ /* Queue might not be ready for start */
+ return 0;
+ }
vq->num = state.num = virtio_queue_get_num(vdev, idx);
r = dev->vhost_ops->vhost_set_vring_num(dev, &state);
@@ -906,7 +915,7 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
}
vq->desc_size = s = l = virtio_queue_get_desc_size(vdev, idx);
- vq->desc_phys = a = virtio_queue_get_desc_addr(vdev, idx);
+ vq->desc_phys = a;
vq->desc = vhost_memory_map(dev, a, &l, 0);
if (!vq->desc || l != s) {
r = -ENOMEM;
@@ -989,6 +998,13 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev,
.index = vhost_vq_index,
};
int r;
+ int a;
+
+ a = virtio_queue_get_desc_addr(vdev, idx);
+ if (a == 0) {
+ /* Don't stop the virtqueue which might have not been started */
+ return;
+ }
r = dev->vhost_ops->vhost_get_vring_base(dev, &state);
if (r < 0) {
--
MST
next prev parent reply other threads:[~2018-03-01 16:46 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-01 16:45 [Qemu-devel] [PULL 00/13] virtio, vhost, pci, pc: features, fixes and cleanups Michael S. Tsirkin
2018-03-01 16:45 ` [Qemu-devel] [PULL 01/13] vhost-user: fix memory leak Michael S. Tsirkin
2018-03-01 16:45 ` [Qemu-devel] [PULL 02/13] virtio-pci: trivial fixes in error message Michael S. Tsirkin
2018-03-01 16:45 ` [Qemu-devel] [PULL 03/13] intel-iommu: Accept 64-bit writes to FEADDR Michael S. Tsirkin
2018-03-01 16:45 ` [Qemu-devel] [PULL 04/13] docs: document virtio-balloon stats Michael S. Tsirkin
2018-03-01 16:45 ` [Qemu-devel] [PULL 05/13] docs: pcie: Spell out machine type needs for PCIe features Michael S. Tsirkin
2018-03-01 16:46 ` Michael S. Tsirkin [this message]
2018-03-01 16:46 ` [Qemu-devel] [PULL 06/13] vhost: fix memslot limit check Michael S. Tsirkin
2018-03-01 16:46 ` [Qemu-devel] [PULL 09/13] docs/vmcoreinfo: detail unsupported host format behaviour Michael S. Tsirkin
2018-03-01 16:46 ` [Qemu-devel] [PULL 08/13] vhost: fix incorrect check in vhost_verify_ring_mappings Michael S. Tsirkin
2018-03-01 16:46 ` [Qemu-devel] [PULL 10/13] cryptodev: add vhost-user as a new cryptodev backend Michael S. Tsirkin
2018-04-27 16:15 ` Peter Maydell
2018-04-28 0:59 ` Zhoujian (jay)
2018-03-01 16:46 ` [Qemu-devel] [PULL 11/13] cryptodev: add vhost support Michael S. Tsirkin
2018-03-01 16:46 ` [Qemu-devel] [PULL 12/13] cryptodev-vhost-user: add crypto session handler Michael S. Tsirkin
2018-03-01 16:46 ` [Qemu-devel] [PULL 13/13] cryptodev-vhost-user: set the key length Michael S. Tsirkin
2018-03-01 17:17 ` [Qemu-devel] [PULL 00/13] virtio, vhost, pci, pc: features, fixes and cleanups no-reply
2018-03-01 17:21 ` no-reply
2018-03-02 11:17 ` Peter Maydell
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=1519922735-29054-8-git-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=hejianet@gmail.com \
--cc=jia.he@hxt-semitech.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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).