vhost_net: cleanup recovery
PATCH v3 1/1 vhost_net: cleanup recovery
commit aad4dce934649b3a398396fc2a76f215bb194ea4
vhost_net: start/stop guest notifiers properly
changed the order of calls for guest notifiers, but did not recover in the correct (reverse) order. Fix it up.
--- hw/net/vhost_net.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
hw/net/vhost_net.c +9 -3
@@ -289,7 +289,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,BusState *qbus =BUS (qdev_get_parent_bus (DEVICE (dev)));VirtioBusState *vbus =VIRTIO_BUS (qbus);VirtioBusClass *k =VIRTIO_BUS_GET_CLASS (vbus); -int r, i =0 ; +int r, e, i;if (!vhost_net_device_endian_ok (dev)) {error_report ("vhost-net does not support cross-endian" );
@@ -317,16 +317,22 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, r =vhost_net_start_one (get_vhost_net (ncs[i].peer), dev);if (r <0 ) { - goto err; + goto err_start; } }return 0 ; -err: +err_start:while (--i >=0 ) {vhost_net_stop_one (get_vhost_net (ncs[i].peer), dev); } + e = k->set_guest_notifiers (qbus->parent, total_queues *2 , false); +if (e <0 ) { +fprintf (stderr,"vhost guest notifier cleanup failed: %d\n" , e); +fflush (stderr); + } +err:return r; }
Signature · 1 line
MST
Quoted 54 lines · Michael S. Tsirkin
commit
aad4dce934649b3a398396fc2a76f215bb194ea4
vhost_net: start/stop guest notifiers properlychanged the order of calls for guest notifiers, but did not recover in the correct (reverse) order. Fix it up.
Cc Andrey Korolyov <[email protected]>Cc Jason Wang <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>--- hw/net/vhost_net.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)hw/net/vhost_net.c +9
-4@@ -289,7 +289,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,BusState *qbus =BUS (qdev_get_parent_bus (DEVICE (dev)));VirtioBusState *vbus =VIRTIO_BUS (qbus);VirtioBusClass *k =VIRTIO_BUS_GET_CLASS (vbus); -int r, i =0 ; +int r, e, i;if (!vhost_net_device_endian_ok (dev)) {error_report ("vhost-net does not support cross-endian" );@@ -317,16 +317,22 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, r =vhost_net_start_one (get_vhost_net (ncs[i].peer), dev);if (r <0 ) { - goto err; + goto err_start; } }return 0 ; -err: +err_start:while (--i >=0 ) {vhost_net_stop_one (get_vhost_net (ncs[i].peer), dev); } + e = k->set_guest_notifiers (qbus->parent, total_queues *2 , false); +if (e <0 ) { +fprintf (stderr,"vhost guest notifier cleanup failed: %d\n" , e); +fflush (stderr); + } +err:return r; } --
Quoted 1 line
MST
Except thing that the accel reinitialization takes place now at every reset, everything is OK (problematic tree with just this patch applied):
qemu-system-x86_64: unable to start vhost net: 95: falling back on userspace virtio
qemu-system-x86_64: unable to start vhost net: 95: falling back on userspace virtio
... reset...
qemu-system-x86_64: unable to start vhost net: 95: falling back on userspace virtio
qemu-system-x86_64: unable to start vhost net: 95: falling back on userspace virtio
Quoted 43 lines · Michael S. Tsirkin
commit
aad4dce934649b3a398396fc2a76f215bb194ea4
vhost_net: start/stop guest notifiers properlychanged the order of calls for guest notifiers, but did not recover in the correct (reverse) order. Fix it up.
Cc Andrey Korolyov <[email protected]>Cc Jason Wang <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>--- hw/net/vhost_net.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)hw/net/vhost_net.c +3
-3@@ -289,7 +289,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,BusState *qbus =BUS (qdev_get_parent_bus (DEVICE (dev)));VirtioBusState *vbus =VIRTIO_BUS (qbus);VirtioBusClass *k =VIRTIO_BUS_GET_CLASS (vbus); -int r, i =0 ; +int r, e, i;if (!vhost_net_device_endian_ok (dev)) {error_report ("vhost-net does not support cross-endian" );@@ -317,16 +317,22 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, r =vhost_net_start_one (get_vhost_net (ncs[i].peer), dev);if (r <0 ) { - goto err; + goto err_start; } }return 0 ; -err: +err_start:while (--i >=0 ) {vhost_net_stop_one (get_vhost_net (ncs[i].peer), dev);
hw/net/vhost_net.c int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, · line 338
Quoted 10 lines
hw/net/vhost_net.c +6
-0} + e = k->set_guest_notifiers (qbus->parent, total_queues *2 , false); +if (e <0 ) { +fprintf (stderr,"vhost guest notifier cleanup failed: %d\n" , e); +fflush (stderr); + } +err:return r; }
Quoted 40 lines · Jason Wang
Quoted 39 lines · Michael S. Tsirkin
commit
aad4dce934649b3a398396fc2a76f215bb194ea4
vhost_net: start/stop guest notifiers properlychanged the order of calls for guest notifiers, but did not recover in the correct (reverse) order. Fix it up.
Cc Andrey Korolyov <[email protected]>Cc Jason Wang <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>--- hw/net/vhost_net.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)hw/net/vhost_net.c +2
-2@@ -289,7 +289,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,BusState *qbus =BUS (qdev_get_parent_bus (DEVICE (dev)));VirtioBusState *vbus =VIRTIO_BUS (qbus);VirtioBusClass *k =VIRTIO_BUS_GET_CLASS (vbus); -int r, i =0 ; +int r, e, i;if (!vhost_net_device_endian_ok (dev)) {error_report ("vhost-net does not support cross-endian" );@@ -317,16 +317,22 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, r =vhost_net_start_one (get_vhost_net (ncs[i].peer), dev);if (r <0 ) { - goto err; + goto err_start; } }return 0 ;
Quoted 16 lines
Quoted 4 lines
hw/net/vhost_net.c +1
-1-err: +err_start:while (--i >=0 ) {vhost_net_stop_one (get_vhost_net (ncs[i].peer), dev);hw/net/vhost_net.c int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, · line 338
Quoted 10 lines
hw/net/vhost_net.c +6
-0} + e = k->set_guest_notifiers (qbus->parent, total_queues *2 , false); +if (e <0 ) { +fprintf (stderr,"vhost guest notifier cleanup failed: %d\n" , e); +fflush (stderr); + } +err:return r; }Acked-by Jason Wang <[email protected]>
OK I will just roll this up into the original patch.