* [Qemu-devel] [PATCH for-1.6] virtio: clear signalled_used_valid when switching from dataplane
@ 2013-08-12 9:08 Stefan Hajnoczi
2013-08-12 9:18 ` Michael S. Tsirkin
2013-08-12 9:52 ` Kevin Wolf
0 siblings, 2 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2013-08-12 9:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Michael S. Tsirkin
When the dataplane thread stops, its vring.c implementation synchronizes
vring state back to virtio.c so we can continue emulating the virtio
device.
This patch ensures that virtio.c's signalled_used_valid flag is reset so
that we do not suppress guest notifications due to stale signalled_used
values.
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/virtio/dataplane/vring.c | 1 +
hw/virtio/virtio.c | 5 +++++
include/hw/virtio/virtio.h | 1 +
3 files changed, 7 insertions(+)
diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c
index 82cc151..351a343 100644
--- a/hw/virtio/dataplane/vring.c
+++ b/hw/virtio/dataplane/vring.c
@@ -52,6 +52,7 @@ bool vring_setup(Vring *vring, VirtIODevice *vdev, int n)
void vring_teardown(Vring *vring, VirtIODevice *vdev, int n)
{
virtio_queue_set_last_avail_idx(vdev, n, vring->last_avail_idx);
+ virtio_queue_invalidate_signalled_used(vdev, n);
hostmem_finalize(&vring->hostmem);
}
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 09f62c6..706bdf4 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1059,6 +1059,11 @@ void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx)
vdev->vq[n].last_avail_idx = idx;
}
+void virtio_queue_invalidate_signalled_used(VirtIODevice *vdev, int n)
+{
+ vdev->vq[n].signalled_used_valid = false;
+}
+
VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n)
{
return vdev->vq + n;
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index d7e9e0f..a90522d 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -237,6 +237,7 @@ hwaddr virtio_queue_get_used_size(VirtIODevice *vdev, int n);
hwaddr virtio_queue_get_ring_size(VirtIODevice *vdev, int n);
uint16_t virtio_queue_get_last_avail_idx(VirtIODevice *vdev, int n);
void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx);
+void virtio_queue_invalidate_signalled_used(VirtIODevice *vdev, int n);
VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n);
uint16_t virtio_get_queue_index(VirtQueue *vq);
int virtio_queue_get_id(VirtQueue *vq);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.6] virtio: clear signalled_used_valid when switching from dataplane
2013-08-12 9:08 [Qemu-devel] [PATCH for-1.6] virtio: clear signalled_used_valid when switching from dataplane Stefan Hajnoczi
@ 2013-08-12 9:18 ` Michael S. Tsirkin
2013-08-12 13:39 ` Stefan Hajnoczi
2013-08-12 9:52 ` Kevin Wolf
1 sibling, 1 reply; 7+ messages in thread
From: Michael S. Tsirkin @ 2013-08-12 9:18 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Kevin Wolf, qemu-devel
On Mon, Aug 12, 2013 at 11:08:09AM +0200, Stefan Hajnoczi wrote:
> When the dataplane thread stops, its vring.c implementation synchronizes
> vring state back to virtio.c so we can continue emulating the virtio
> device.
>
> This patch ensures that virtio.c's signalled_used_valid flag is reset so
> that we do not suppress guest notifications due to stale signalled_used
> values.
>
> Suggested-by: Kevin Wolf <kwolf@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Good point
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
and we also need this for vhost.c right?
> ---
> hw/virtio/dataplane/vring.c | 1 +
> hw/virtio/virtio.c | 5 +++++
> include/hw/virtio/virtio.h | 1 +
> 3 files changed, 7 insertions(+)
>
> diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c
> index 82cc151..351a343 100644
> --- a/hw/virtio/dataplane/vring.c
> +++ b/hw/virtio/dataplane/vring.c
> @@ -52,6 +52,7 @@ bool vring_setup(Vring *vring, VirtIODevice *vdev, int n)
> void vring_teardown(Vring *vring, VirtIODevice *vdev, int n)
> {
> virtio_queue_set_last_avail_idx(vdev, n, vring->last_avail_idx);
> + virtio_queue_invalidate_signalled_used(vdev, n);
>
> hostmem_finalize(&vring->hostmem);
> }
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 09f62c6..706bdf4 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -1059,6 +1059,11 @@ void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx)
> vdev->vq[n].last_avail_idx = idx;
> }
>
> +void virtio_queue_invalidate_signalled_used(VirtIODevice *vdev, int n)
> +{
> + vdev->vq[n].signalled_used_valid = false;
> +}
> +
> VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n)
> {
> return vdev->vq + n;
> diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
> index d7e9e0f..a90522d 100644
> --- a/include/hw/virtio/virtio.h
> +++ b/include/hw/virtio/virtio.h
> @@ -237,6 +237,7 @@ hwaddr virtio_queue_get_used_size(VirtIODevice *vdev, int n);
> hwaddr virtio_queue_get_ring_size(VirtIODevice *vdev, int n);
> uint16_t virtio_queue_get_last_avail_idx(VirtIODevice *vdev, int n);
> void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx);
> +void virtio_queue_invalidate_signalled_used(VirtIODevice *vdev, int n);
> VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n);
> uint16_t virtio_get_queue_index(VirtQueue *vq);
> int virtio_queue_get_id(VirtQueue *vq);
> --
> 1.8.3.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.6] virtio: clear signalled_used_valid when switching from dataplane
2013-08-12 9:08 [Qemu-devel] [PATCH for-1.6] virtio: clear signalled_used_valid when switching from dataplane Stefan Hajnoczi
2013-08-12 9:18 ` Michael S. Tsirkin
@ 2013-08-12 9:52 ` Kevin Wolf
1 sibling, 0 replies; 7+ messages in thread
From: Kevin Wolf @ 2013-08-12 9:52 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-devel, Michael S. Tsirkin
Am 12.08.2013 um 11:08 hat Stefan Hajnoczi geschrieben:
> When the dataplane thread stops, its vring.c implementation synchronizes
> vring state back to virtio.c so we can continue emulating the virtio
> device.
>
> This patch ensures that virtio.c's signalled_used_valid flag is reset so
> that we do not suppress guest notifications due to stale signalled_used
> values.
>
> Suggested-by: Kevin Wolf <kwolf@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.6] virtio: clear signalled_used_valid when switching from dataplane
2013-08-12 9:18 ` Michael S. Tsirkin
@ 2013-08-12 13:39 ` Stefan Hajnoczi
2013-08-12 14:10 ` Michael S. Tsirkin
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Hajnoczi @ 2013-08-12 13:39 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Kevin Wolf, qemu-devel, Stefan Hajnoczi
On Mon, Aug 12, 2013 at 11:18 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
> On Mon, Aug 12, 2013 at 11:08:09AM +0200, Stefan Hajnoczi wrote:
>> When the dataplane thread stops, its vring.c implementation synchronizes
>> vring state back to virtio.c so we can continue emulating the virtio
>> device.
>>
>> This patch ensures that virtio.c's signalled_used_valid flag is reset so
>> that we do not suppress guest notifications due to stale signalled_used
>> values.
>>
>> Suggested-by: Kevin Wolf <kwolf@redhat.com>
>> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
>
> Good point
>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
>
> and we also need this for vhost.c right?
I think vhost is not affected by this because virtio.c clears the
signalled_used_valid flag when the device is reset. Since vhost_net
does not transition back and forth between userspace virtio and vhost
(without a device reset), there is no need to reset the flag.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.6] virtio: clear signalled_used_valid when switching from dataplane
2013-08-12 13:39 ` Stefan Hajnoczi
@ 2013-08-12 14:10 ` Michael S. Tsirkin
2013-08-13 8:14 ` Stefan Hajnoczi
0 siblings, 1 reply; 7+ messages in thread
From: Michael S. Tsirkin @ 2013-08-12 14:10 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Kevin Wolf, qemu-devel, Stefan Hajnoczi
On Mon, Aug 12, 2013 at 03:39:23PM +0200, Stefan Hajnoczi wrote:
> On Mon, Aug 12, 2013 at 11:18 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
> > On Mon, Aug 12, 2013 at 11:08:09AM +0200, Stefan Hajnoczi wrote:
> >> When the dataplane thread stops, its vring.c implementation synchronizes
> >> vring state back to virtio.c so we can continue emulating the virtio
> >> device.
> >>
> >> This patch ensures that virtio.c's signalled_used_valid flag is reset so
> >> that we do not suppress guest notifications due to stale signalled_used
> >> values.
> >>
> >> Suggested-by: Kevin Wolf <kwolf@redhat.com>
> >> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> >
> > Good point
> >
> > Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> >
> > and we also need this for vhost.c right?
>
> I think vhost is not affected by this because virtio.c clears the
> signalled_used_valid flag when the device is reset. Since vhost_net
> does not transition back and forth between userspace virtio and vhost
> (without a device reset), there is no need to reset the flag.
>
> Stefan
Yes it does transition on vm stop/start.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.6] virtio: clear signalled_used_valid when switching from dataplane
2013-08-12 14:10 ` Michael S. Tsirkin
@ 2013-08-13 8:14 ` Stefan Hajnoczi
2013-08-13 9:27 ` Michael S. Tsirkin
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Hajnoczi @ 2013-08-13 8:14 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Kevin Wolf, Stefan Hajnoczi, qemu-devel
On Mon, Aug 12, 2013 at 05:10:11PM +0300, Michael S. Tsirkin wrote:
> On Mon, Aug 12, 2013 at 03:39:23PM +0200, Stefan Hajnoczi wrote:
> > On Mon, Aug 12, 2013 at 11:18 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
> > > On Mon, Aug 12, 2013 at 11:08:09AM +0200, Stefan Hajnoczi wrote:
> > >> When the dataplane thread stops, its vring.c implementation synchronizes
> > >> vring state back to virtio.c so we can continue emulating the virtio
> > >> device.
> > >>
> > >> This patch ensures that virtio.c's signalled_used_valid flag is reset so
> > >> that we do not suppress guest notifications due to stale signalled_used
> > >> values.
> > >>
> > >> Suggested-by: Kevin Wolf <kwolf@redhat.com>
> > >> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > >
> > > Good point
> > >
> > > Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> > >
> > > and we also need this for vhost.c right?
> >
> > I think vhost is not affected by this because virtio.c clears the
> > signalled_used_valid flag when the device is reset. Since vhost_net
> > does not transition back and forth between userspace virtio and vhost
> > (without a device reset), there is no need to reset the flag.
> >
> > Stefan
>
> Yes it does transition on vm stop/start.
I see. Come to think of it maybe dataplane could use virtio.c's vm
change state handler instead of registering its own. Anyway, thanks for
pointing this out.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.6] virtio: clear signalled_used_valid when switching from dataplane
2013-08-13 8:14 ` Stefan Hajnoczi
@ 2013-08-13 9:27 ` Michael S. Tsirkin
0 siblings, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2013-08-13 9:27 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Kevin Wolf, Stefan Hajnoczi, qemu-devel
On Tue, Aug 13, 2013 at 10:14:11AM +0200, Stefan Hajnoczi wrote:
> On Mon, Aug 12, 2013 at 05:10:11PM +0300, Michael S. Tsirkin wrote:
> > On Mon, Aug 12, 2013 at 03:39:23PM +0200, Stefan Hajnoczi wrote:
> > > On Mon, Aug 12, 2013 at 11:18 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
> > > > On Mon, Aug 12, 2013 at 11:08:09AM +0200, Stefan Hajnoczi wrote:
> > > >> When the dataplane thread stops, its vring.c implementation synchronizes
> > > >> vring state back to virtio.c so we can continue emulating the virtio
> > > >> device.
> > > >>
> > > >> This patch ensures that virtio.c's signalled_used_valid flag is reset so
> > > >> that we do not suppress guest notifications due to stale signalled_used
> > > >> values.
> > > >>
> > > >> Suggested-by: Kevin Wolf <kwolf@redhat.com>
> > > >> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > > >
> > > > Good point
> > > >
> > > > Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> > > >
> > > > and we also need this for vhost.c right?
> > >
> > > I think vhost is not affected by this because virtio.c clears the
> > > signalled_used_valid flag when the device is reset. Since vhost_net
> > > does not transition back and forth between userspace virtio and vhost
> > > (without a device reset), there is no need to reset the flag.
> > >
> > > Stefan
> >
> > Yes it does transition on vm stop/start.
>
> I see. Come to think of it maybe dataplane could use virtio.c's vm
> change state handler instead of registering its own. Anyway, thanks for
> pointing this out.
>
> Stefan
It probably should esp if you have a handler for virtio status:
this is the only way to guarantee they are called in a sane order.
--
MST
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-08-13 9:26 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-12 9:08 [Qemu-devel] [PATCH for-1.6] virtio: clear signalled_used_valid when switching from dataplane Stefan Hajnoczi
2013-08-12 9:18 ` Michael S. Tsirkin
2013-08-12 13:39 ` Stefan Hajnoczi
2013-08-12 14:10 ` Michael S. Tsirkin
2013-08-13 8:14 ` Stefan Hajnoczi
2013-08-13 9:27 ` Michael S. Tsirkin
2013-08-12 9:52 ` Kevin Wolf
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).