vdpa: Fix SIGSEGV on failed vdpa devices
v2 cover vdpa: Fix SIGSEGV on failed vdpa devices
Qemu falls back on userland handlers even if vhost-user and vhost-vdpa cases. These assumes a tap device can handle the packets.
If a vdpa device fail to start, it can trigger a sigsegv because of that. Add dummy receivers that return no progress so it can keep running.
Tested with a modified version of vp_vdpa to fail negotiation.
v2:
* Replace dummy receive_{iov,raw} with receive callback.
* Delete fix indentation commit, we don't touch that code anymore.
Eugenio Pérez (2):
vdpa: Add dummy receive callback
virtio-net: Fix log message
hw/net/virtio-net.c | 11 ++++++----- net/vhost-vdpa.c | 8 ++++++++ 2 files changed, 14 insertions(+), 5 deletions(-)
Signature · 1 line
2.27.0
PATCH v2 1/2 vdpa: Add dummy receive callback
Qemu falls back on userland handlers even if vhost-user and vhost-vdpa cases. These assumes a tap device can handle the packets.
If a vdpa device fail to start, it can trigger a sigsegv because of that. Add dummy receiver that returns no progress so it can keep running.
--- net/vhost-vdpa.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/vhost-vdpa.c +8 -0
@@ -170,9 +170,17 @@ static bool vhost_vdpa_check_peer_type(NetClientState *nc, ObjectClass *oc,return true; } +/** Dummy receive in case qemu falls back to userland tap networking */ +static ssize_t vhost_vdpa_receive (NetClientState *nc,const uint8_t *buf, +size_t size) +{ +return 0 ; +} +static NetClientInfo net_vhost_vdpa_info = { .type =NET_CLIENT_DRIVER_VHOST_VDPA , .size =sizeof (VhostVDPAState), + .receive = vhost_vdpa_receive, .cleanup = vhost_vdpa_cleanup, .has_vnet_hdr = vhost_vdpa_has_vnet_hdr, .has_ufo = vhost_vdpa_has_ufo,
Signature · 1 line
2.27.0
Re: [PATCH v2 1/2] vdpa: Add dummy receive callback
Quoted 10 lines · Eugenio Pérez
Qemu falls back on userland handlers even if vhost-user and vhost-vdpa cases. These assumes a tap device can handle the packets.
If a vdpa device fail to start, it can trigger a sigsegv because of that. Add dummy receiver that returns no progress so it can keep running.
Fixes 1e0a84ea49 ("vhost-vdpa: introduce vhost-vdpa net client")Signed-off-by Eugenio Pérez <[email protected]>
Quoted 29 lines
--- net/vhost-vdpa.c | 8 ++++++++ 1 file changed, 8 insertions(+)net/vhost-vdpa.c +8
-1@@ -170,9 +170,17 @@ static bool vhost_vdpa_check_peer_type(NetClientState *nc, ObjectClass *oc,return true; } +/** Dummy receive in case qemu falls back to userland tap networking */ +static ssize_t vhost_vdpa_receive (NetClientState *nc,const uint8_t *buf, +size_t size) +{ +return 0 ; +} +static NetClientInfo net_vhost_vdpa_info = { .type =NET_CLIENT_DRIVER_VHOST_VDPA , .size =sizeof (VhostVDPAState), + .receive = vhost_vdpa_receive, .cleanup = vhost_vdpa_cleanup, .has_vnet_hdr = vhost_vdpa_has_vnet_hdr, .has_ufo = vhost_vdpa_has_ufo, --2.27.0
PATCH v2 2/2 virtio-net: Fix log message
In reply to Eugenio PérezThe message has never been true in the case of non tap networking, so only tell that userland networking will be used if possible.
--- hw/net/virtio-net.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
hw/net/virtio-net.c +6 -5
@@ -245,6 +245,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)NetClientState *nc =qemu_get_queue (n->nic);int queue_pairs = n->multiqueue ? n->max_queue_pairs :1 ;int cvq = n->max_ncs - n->max_queue_pairs; +bool tap_backend = nc->peer->info->type ==NET_CLIENT_DRIVER_TAP ;if (!get_vhost_net (nc->peer)) {return ;
@@ -258,9 +259,9 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)int r, i;if (n->needs_vnet_hdr_swap) { -error_report ("backend does not support %s vnet headers; " -"falling back on userspace virtio" , -virtio_is_big_endian (vdev) ?"BE" :"LE" ); +error_report ("backend does not support %s vnet headers%s" , +virtio_is_big_endian (vdev) ?"BE" :"LE" , + tap_backend ?"; falling back on userspace virtio" :"" );return ; }
@@ -288,8 +289,8 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status) n->vhost_started =1 ; r =vhost_net_start (vdev, n->nic->ncs, queue_pairs, cvq);if (r <0 ) { -error_report ("unable to start vhost net: %d: " -"falling back on userspace virtio" , -r); +error_report ("unable to start vhost net: %d%s" , -r, + tap_backend ?" falling back on userspace virtio" :"" ); n->vhost_started =0 ; } }else {
Signature · 1 line
2.27.0
Re: [PATCH v2 2/2] virtio-net: Fix log message
Quoted 5 lines · Eugenio Pérez
The message has never been true in the case of non tap networking, so only tell that userland networking will be used if possible.
Signed-off-by Eugenio Pérez <[email protected]>
Quoted 43 lines
--- hw/net/virtio-net.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)hw/net/virtio-net.c +6
-6@@ -245,6 +245,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)NetClientState *nc =qemu_get_queue (n->nic);int queue_pairs = n->multiqueue ? n->max_queue_pairs :1 ;int cvq = n->max_ncs - n->max_queue_pairs; +bool tap_backend = nc->peer->info->type ==NET_CLIENT_DRIVER_TAP ;if (!get_vhost_net (nc->peer)) {return ;@@ -258,9 +259,9 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)int r, i;if (n->needs_vnet_hdr_swap) { -error_report ("backend does not support %s vnet headers; " -"falling back on userspace virtio" , -virtio_is_big_endian (vdev) ?"BE" :"LE" ); +error_report ("backend does not support %s vnet headers%s" , +virtio_is_big_endian (vdev) ?"BE" :"LE" , + tap_backend ?"; falling back on userspace virtio" :"" );return ; }@@ -288,8 +289,8 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status) n->vhost_started =1 ; r =vhost_net_start (vdev, n->nic->ncs, queue_pairs, cvq);if (r <0 ) { -error_report ("unable to start vhost net: %d: " -"falling back on userspace virtio" , -r); +error_report ("unable to start vhost net: %d%s" , -r, + tap_backend ?" falling back on userspace virtio" :"" ); n->vhost_started =0 ; } }else { --2.27.0
Re: [PATCH v2 2/2] virtio-net: Fix log message
Quoted 8 lines · Jason Wang
Quoted 5 lines · Eugenio Pérez
The message has never been true in the case of non tap networking, so only tell that userland networking will be used if possible.
Signed-off-by Eugenio Pérez <[email protected]>Acked-by Jason Wang <[email protected]>
Breaks make check. I suspect it's called without a peer or something.
Dropped for 6.2.
Quoted 43 lines
Quoted 43 lines
--- hw/net/virtio-net.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)hw/net/virtio-net.c +6
-6@@ -245,6 +245,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)NetClientState *nc =qemu_get_queue (n->nic);int queue_pairs = n->multiqueue ? n->max_queue_pairs :1 ;int cvq = n->max_ncs - n->max_queue_pairs; +bool tap_backend = nc->peer->info->type ==NET_CLIENT_DRIVER_TAP ;if (!get_vhost_net (nc->peer)) {return ;@@ -258,9 +259,9 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)int r, i;if (n->needs_vnet_hdr_swap) { -error_report ("backend does not support %s vnet headers; " -"falling back on userspace virtio" , -virtio_is_big_endian (vdev) ?"BE" :"LE" ); +error_report ("backend does not support %s vnet headers%s" , +virtio_is_big_endian (vdev) ?"BE" :"LE" , + tap_backend ?"; falling back on userspace virtio" :"" );return ; }@@ -288,8 +289,8 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status) n->vhost_started =1 ; r =vhost_net_start (vdev, n->nic->ncs, queue_pairs, cvq);if (r <0 ) { -error_report ("unable to start vhost net: %d: " -"falling back on userspace virtio" , -r); +error_report ("unable to start vhost net: %d%s" , -r, + tap_backend ?" falling back on userspace virtio" :"" ); n->vhost_started =0 ; } }else { --2.27.0
Re: [PATCH v2 2/2] virtio-net: Fix log message
Quoted 4 lines · Michael S. Tsirkin
Quoted 2 lines · Jason Wang
Quoted 1 line · Eugenio Pérez
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
The message has never been true in the case of non tap networking, so only tell that userland networking will be used if possible.
Signed-off-by Eugenio Pérez <[email protected]>Acked-by Jason Wang <[email protected]>Breaks make check. I suspect it's called without a peer or something.
You're right, sending it as a separate patch since I saw the other one made it into the pull request.
Thanks!
Quoted 46 lines
Dropped for 6.2.
Quoted 43 lines
Quoted 43 lines
--- hw/net/virtio-net.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)hw/net/virtio-net.c +6
-6@@ -245,6 +245,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)NetClientState *nc =qemu_get_queue (n->nic);int queue_pairs = n->multiqueue ? n->max_queue_pairs :1 ;int cvq = n->max_ncs - n->max_queue_pairs; +bool tap_backend = nc->peer->info->type ==NET_CLIENT_DRIVER_TAP ;if (!get_vhost_net (nc->peer)) {return ;@@ -258,9 +259,9 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)int r, i;if (n->needs_vnet_hdr_swap) { -error_report ("backend does not support %s vnet headers; " -"falling back on userspace virtio" , -virtio_is_big_endian (vdev) ?"BE" :"LE" ); +error_report ("backend does not support %s vnet headers%s" , +virtio_is_big_endian (vdev) ?"BE" :"LE" , + tap_backend ?"; falling back on userspace virtio" :"" );return ; }@@ -288,8 +289,8 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status) n->vhost_started =1 ; r =vhost_net_start (vdev, n->nic->ncs, queue_pairs, cvq);if (r <0 ) { -error_report ("unable to start vhost net: %d: " -"falling back on userspace virtio" , -r); +error_report ("unable to start vhost net: %d%s" , -r, + tap_backend ?" falling back on userspace virtio" :"" ); n->vhost_started =0 ; } }else { --2.27.0