From: Stefan Hajnoczi <stefanha@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: mst@redhat.com, qemu-devel@nongnu.org,
Yuri Benditovich <yuri.benditovich@daynix.com>,
Paolo Bonzini <pbonzini@redhat.com>,
qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH for 2.11] virtio-net: don't touch virtqueue if vm is stopped
Date: Thu, 23 Nov 2017 10:59:34 +0000 [thread overview]
Message-ID: <20171123105934.GC26022@stefanha-x1.localdomain> (raw)
In-Reply-To: <1511408266-4139-1-git-send-email-jasowang@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]
On Thu, Nov 23, 2017 at 11:37:46AM +0800, Jason Wang wrote:
> Guest state should not be touched if VM is stopped, unfortunately we
> didn't check running state and tried to drain tx queue unconditionally
> in virtio_net_set_status(). A crash was then noticed as a migration
> destination when user type quit after virtqueue state is loaded but
> before region cache is initialized. In this case,
> virtio_net_drop_tx_queue_data() tries to access the uninitialized
> region cache.
>
> Fix this by only dropping tx queue data when vm is running.
hw/virtio/virtio.c:virtio_load() does the following:
for (i = 0; i < num; i++) {
if (vdev->vq[i].vring.desc) {
uint16_t nheads;
/*
* VIRTIO-1 devices migrate desc, used, and avail ring addresses so
* only the region cache needs to be set up. Legacy devices need
* to calculate used and avail ring addresses based on the desc
* address.
*/
if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
virtio_init_region_cache(vdev, i);
} else {
virtio_queue_update_rings(vdev, i);
}
So the region caches should be initialized after virtqueue state is
loaded.
It's unclear to me which code path triggers this issue. Can you add a
backtrace or an explanation?
Thanks,
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
next prev parent reply other threads:[~2017-11-23 10:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-23 3:37 [Qemu-devel] [PATCH for 2.11] virtio-net: don't touch virtqueue if vm is stopped Jason Wang
2017-11-23 4:09 ` no-reply
2017-11-23 10:59 ` Stefan Hajnoczi [this message]
2017-11-24 2:57 ` Jason Wang
2017-11-24 10:44 ` Stefan Hajnoczi
2017-11-27 3:26 ` Jason Wang
2017-11-27 11:19 ` Stefan Hajnoczi
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=20171123105934.GC26022@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=yuri.benditovich@daynix.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).