diff mbox

[PULL,3/6] virtio: don't call device on !vm_running

Message ID 1409848699-28374-4-git-send-email-stefanha@redhat.com
State New
Headers show

Commit Message

Stefan Hajnoczi Sept. 4, 2014, 4:38 p.m. UTC
From: "Michael S. Tsirkin" <mst@redhat.com>

On vm stop, virtio changes vm_running state
too soon, so callbacks can get envoked with
vm_running = false;

Cc: qemu-stable@nongnu.org
Cc: Jason Wang <jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/virtio/virtio.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Christian Borntraeger Sept. 11, 2014, 12:19 p.m. UTC | #1
On 04/09/14 18:38, Stefan Hajnoczi wrote:
> From: "Michael S. Tsirkin" <mst@redhat.com>
> 
> On vm stop, virtio changes vm_running state
> too soon, so callbacks can get envoked with
> vm_running = false;
> 
> Cc: qemu-stable@nongnu.org
> Cc: Jason Wang <jasowang@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  hw/virtio/virtio.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 5c98180..ac22238 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -1108,7 +1108,10 @@ static void virtio_vmstate_change(void *opaque, int running, RunState state)
>      BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
>      VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
>      bool backend_run = running && (vdev->status & VIRTIO_CONFIG_S_DRIVER_OK);
> -    vdev->vm_running = running;
> +
> +    if (running) {
> +        vdev->vm_running = running;
> +    }
> 
>      if (backend_run) {
>          virtio_set_status(vdev, vdev->status);
> @@ -1121,6 +1124,10 @@ static void virtio_vmstate_change(void *opaque, int running, RunState state)
>      if (!backend_run) {
>          virtio_set_status(vdev, vdev->status);
>      }
> +
> +    if (!running) {
> +        vdev->vm_running = running;
> +    }
>  }
> 
>  void virtio_init(VirtIODevice *vdev, const char *name,
> 


This broke managedsave on s390x:
qemu-system-s390x: hw/net/virtio-net.c:1348: virtio_net_save: Assertion `!n->vhost_started' failed.
reverting that commit makes it working again.
Any ideas?

Christian
Michael S. Tsirkin Sept. 11, 2014, 12:38 p.m. UTC | #2
On Thu, Sep 11, 2014 at 02:19:42PM +0200, Christian Borntraeger wrote:
> On 04/09/14 18:38, Stefan Hajnoczi wrote:
> > From: "Michael S. Tsirkin" <mst@redhat.com>
> > 
> > On vm stop, virtio changes vm_running state
> > too soon, so callbacks can get envoked with
> > vm_running = false;
> > 
> > Cc: qemu-stable@nongnu.org
> > Cc: Jason Wang <jasowang@redhat.com>
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > ---
> >  hw/virtio/virtio.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> > index 5c98180..ac22238 100644
> > --- a/hw/virtio/virtio.c
> > +++ b/hw/virtio/virtio.c
> > @@ -1108,7 +1108,10 @@ static void virtio_vmstate_change(void *opaque, int running, RunState state)
> >      BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
> >      VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
> >      bool backend_run = running && (vdev->status & VIRTIO_CONFIG_S_DRIVER_OK);
> > -    vdev->vm_running = running;
> > +
> > +    if (running) {
> > +        vdev->vm_running = running;
> > +    }
> > 
> >      if (backend_run) {
> >          virtio_set_status(vdev, vdev->status);
> > @@ -1121,6 +1124,10 @@ static void virtio_vmstate_change(void *opaque, int running, RunState state)
> >      if (!backend_run) {
> >          virtio_set_status(vdev, vdev->status);
> >      }
> > +
> > +    if (!running) {
> > +        vdev->vm_running = running;
> > +    }
> >  }
> > 
> >  void virtio_init(VirtIODevice *vdev, const char *name,
> > 
> 
> 
> This broke managedsave on s390x:
> qemu-system-s390x: hw/net/virtio-net.c:1348: virtio_net_save: Assertion `!n->vhost_started' failed.
> reverting that commit makes it working again.
> Any ideas?
> 
> Christian


Does it help if you apply
[PULL v2 09/16] vhost_net: cleanup start/stop condition
on top?
Christian Borntraeger Sept. 11, 2014, 12:41 p.m. UTC | #3
On 11/09/14 14:38, Michael S. Tsirkin wrote:
>> > 
>> > This broke managedsave on s390x:
>> > qemu-system-s390x: hw/net/virtio-net.c:1348: virtio_net_save: Assertion `!n->vhost_started' failed.
>> > reverting that commit makes it working again.
>> > Any ideas?
>> > 
>> > Christian
> 
> Does it help if you apply
> [PULL v2 09/16] vhost_net: cleanup start/stop condition
> on top?
> 

This patch is part of my tree (I am testing qemu/master + some s390 specific patches)

Christian
diff mbox

Patch

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 5c98180..ac22238 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1108,7 +1108,10 @@  static void virtio_vmstate_change(void *opaque, int running, RunState state)
     BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
     bool backend_run = running && (vdev->status & VIRTIO_CONFIG_S_DRIVER_OK);
-    vdev->vm_running = running;
+
+    if (running) {
+        vdev->vm_running = running;
+    }
 
     if (backend_run) {
         virtio_set_status(vdev, vdev->status);
@@ -1121,6 +1124,10 @@  static void virtio_vmstate_change(void *opaque, int running, RunState state)
     if (!backend_run) {
         virtio_set_status(vdev, vdev->status);
     }
+
+    if (!running) {
+        vdev->vm_running = running;
+    }
 }
 
 void virtio_init(VirtIODevice *vdev, const char *name,