* [PATCH 0/3] vdpa: Fix SIGSEGV on failed vdpa devices
@ 2021-11-19 10:20 Eugenio Pérez
2021-11-19 10:20 ` [PATCH 1/3] virtio-net: Fix indentation Eugenio Pérez
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Eugenio Pérez @ 2021-11-19 10:20 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Jason Wang, qemu-stable, Cindy Lu,
Michael S. Tsirkin
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.
This is another bersion of the patch proposed in [1], but the subject
didn't match the patch anymore.
[1] https://lists.nongnu.org/archive/html/qemu-devel/2021-11/msg03719.html
Eugenio Pérez (3):
virtio-net: Fix indentation
vdpa: Add dummy receive callbacks
virtio-net: Fix log message
hw/net/virtio-net.c | 13 +++++++------
net/vhost-vdpa.c | 16 ++++++++++++++++
2 files changed, 23 insertions(+), 6 deletions(-)
--
2.27.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] virtio-net: Fix indentation
2021-11-19 10:20 [PATCH 0/3] vdpa: Fix SIGSEGV on failed vdpa devices Eugenio Pérez
@ 2021-11-19 10:20 ` Eugenio Pérez
2021-11-19 10:20 ` [PATCH 2/3] vdpa: Add dummy receive callbacks Eugenio Pérez
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Eugenio Pérez @ 2021-11-19 10:20 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Jason Wang, qemu-stable, Cindy Lu,
Michael S. Tsirkin
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
hw/net/virtio-net.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index f2014d5ea0..004acf858f 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3501,7 +3501,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
nc = qemu_get_queue(n->nic);
nc->rxfilter_notify_enabled = 1;
- if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
+ if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
struct virtio_net_config netcfg = {};
memcpy(&netcfg.mac, &n->nic_conf.macaddr, ETH_ALEN);
vhost_net_set_config(get_vhost_net(nc->peer),
--
2.27.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] vdpa: Add dummy receive callbacks
2021-11-19 10:20 [PATCH 0/3] vdpa: Fix SIGSEGV on failed vdpa devices Eugenio Pérez
2021-11-19 10:20 ` [PATCH 1/3] virtio-net: Fix indentation Eugenio Pérez
@ 2021-11-19 10:20 ` Eugenio Pérez
2021-11-22 3:55 ` Jason Wang
2021-11-19 10:20 ` [PATCH 3/3] virtio-net: Fix log message Eugenio Pérez
2021-11-22 3:56 ` [PATCH 0/3] vdpa: Fix SIGSEGV on failed vdpa devices Jason Wang
3 siblings, 1 reply; 7+ messages in thread
From: Eugenio Pérez @ 2021-11-19 10:20 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Jason Wang, qemu-stable, Cindy Lu,
Michael S. Tsirkin
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.
Fixes: 1e0a84ea49 ("vhost-vdpa: introduce vhost-vdpa net client")
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
net/vhost-vdpa.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 2e3c22a8c7..4c75b78304 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -170,9 +170,25 @@ 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_iov(NetClientState *nc,
+ const struct iovec *iov, int iovcnt)
+{
+ return 0;
+}
+
+/** Dummy receive in case qemu falls back to userland tap networking */
+static ssize_t vhost_vdpa_receive_raw(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_iov = vhost_vdpa_receive_iov,
+ .receive_raw = vhost_vdpa_receive_raw,
.cleanup = vhost_vdpa_cleanup,
.has_vnet_hdr = vhost_vdpa_has_vnet_hdr,
.has_ufo = vhost_vdpa_has_ufo,
--
2.27.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] virtio-net: Fix log message
2021-11-19 10:20 [PATCH 0/3] vdpa: Fix SIGSEGV on failed vdpa devices Eugenio Pérez
2021-11-19 10:20 ` [PATCH 1/3] virtio-net: Fix indentation Eugenio Pérez
2021-11-19 10:20 ` [PATCH 2/3] vdpa: Add dummy receive callbacks Eugenio Pérez
@ 2021-11-19 10:20 ` Eugenio Pérez
2021-11-22 3:56 ` [PATCH 0/3] vdpa: Fix SIGSEGV on failed vdpa devices Jason Wang
3 siblings, 0 replies; 7+ messages in thread
From: Eugenio Pérez @ 2021-11-19 10:20 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Jason Wang, qemu-stable, Cindy Lu,
Michael S. Tsirkin
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 <eperezma@redhat.com>
---
hw/net/virtio-net.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 004acf858f..442082dd8c 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] vdpa: Add dummy receive callbacks
2021-11-19 10:20 ` [PATCH 2/3] vdpa: Add dummy receive callbacks Eugenio Pérez
@ 2021-11-22 3:55 ` Jason Wang
2021-11-22 6:41 ` Eugenio Perez Martin
0 siblings, 1 reply; 7+ messages in thread
From: Jason Wang @ 2021-11-22 3:55 UTC (permalink / raw)
To: Eugenio Pérez
Cc: Laurent Vivier, qemu-stable, qemu-devel, Cindy Lu,
Michael S. Tsirkin
On Fri, Nov 19, 2021 at 6:20 PM Eugenio Pérez <eperezma@redhat.com> wrote:
>
> 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.
>
> Fixes: 1e0a84ea49 ("vhost-vdpa: introduce vhost-vdpa net client")
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> ---
> net/vhost-vdpa.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
> index 2e3c22a8c7..4c75b78304 100644
> --- a/net/vhost-vdpa.c
> +++ b/net/vhost-vdpa.c
> @@ -170,9 +170,25 @@ 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_iov(NetClientState *nc,
> + const struct iovec *iov, int iovcnt)
> +{
> + return 0;
> +}
> +
> +/** Dummy receive in case qemu falls back to userland tap networking */
> +static ssize_t vhost_vdpa_receive_raw(NetClientState *nc, const uint8_t *buf,
> + size_t size)
> +{
> + return 0;
> +}
It looks to me the .receive_raw is not need, in nc_sendv_compat() we had:
=> if (flags & QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) {
ret = nc->info->receive_raw(nc, buffer, offset);
} else {
ret = nc->info->receive(nc, buffer, offset);
}
Thanks
> +
> static NetClientInfo net_vhost_vdpa_info = {
> .type = NET_CLIENT_DRIVER_VHOST_VDPA,
> .size = sizeof(VhostVDPAState),
> + .receive_iov = vhost_vdpa_receive_iov,
> + .receive_raw = vhost_vdpa_receive_raw,
> .cleanup = vhost_vdpa_cleanup,
> .has_vnet_hdr = vhost_vdpa_has_vnet_hdr,
> .has_ufo = vhost_vdpa_has_ufo,
> --
> 2.27.0
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] vdpa: Fix SIGSEGV on failed vdpa devices
2021-11-19 10:20 [PATCH 0/3] vdpa: Fix SIGSEGV on failed vdpa devices Eugenio Pérez
` (2 preceding siblings ...)
2021-11-19 10:20 ` [PATCH 3/3] virtio-net: Fix log message Eugenio Pérez
@ 2021-11-22 3:56 ` Jason Wang
3 siblings, 0 replies; 7+ messages in thread
From: Jason Wang @ 2021-11-22 3:56 UTC (permalink / raw)
To: Eugenio Pérez
Cc: Laurent Vivier, qemu-stable, qemu-devel, Cindy Lu,
Michael S. Tsirkin
On Fri, Nov 19, 2021 at 6:20 PM Eugenio Pérez <eperezma@redhat.com> wrote:
>
> 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.
>
> This is another bersion of the patch proposed in [1], but the subject
> didn't match the patch anymore.
>
> [1] https://lists.nongnu.org/archive/html/qemu-devel/2021-11/msg03719.html
>
As discussed, we need to consider fixing the gRARP transmission issue
on top, any idea on that?
Thanks
> Eugenio Pérez (3):
> virtio-net: Fix indentation
> vdpa: Add dummy receive callbacks
> virtio-net: Fix log message
>
> hw/net/virtio-net.c | 13 +++++++------
> net/vhost-vdpa.c | 16 ++++++++++++++++
> 2 files changed, 23 insertions(+), 6 deletions(-)
>
> --
> 2.27.0
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] vdpa: Add dummy receive callbacks
2021-11-22 3:55 ` Jason Wang
@ 2021-11-22 6:41 ` Eugenio Perez Martin
0 siblings, 0 replies; 7+ messages in thread
From: Eugenio Perez Martin @ 2021-11-22 6:41 UTC (permalink / raw)
To: Jason Wang
Cc: Laurent Vivier, qemu-stable, qemu-devel, Cindy Lu,
Michael S. Tsirkin
On Mon, Nov 22, 2021 at 4:55 AM Jason Wang <jasowang@redhat.com> wrote:
>
> On Fri, Nov 19, 2021 at 6:20 PM Eugenio Pérez <eperezma@redhat.com> wrote:
> >
> > 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.
> >
> > Fixes: 1e0a84ea49 ("vhost-vdpa: introduce vhost-vdpa net client")
> > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> > ---
> > net/vhost-vdpa.c | 16 ++++++++++++++++
> > 1 file changed, 16 insertions(+)
> >
> > diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
> > index 2e3c22a8c7..4c75b78304 100644
> > --- a/net/vhost-vdpa.c
> > +++ b/net/vhost-vdpa.c
> > @@ -170,9 +170,25 @@ 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_iov(NetClientState *nc,
> > + const struct iovec *iov, int iovcnt)
> > +{
> > + return 0;
> > +}
> > +
> > +/** Dummy receive in case qemu falls back to userland tap networking */
> > +static ssize_t vhost_vdpa_receive_raw(NetClientState *nc, const uint8_t *buf,
> > + size_t size)
> > +{
> > + return 0;
> > +}
>
> It looks to me the .receive_raw is not need, in nc_sendv_compat() we had:
>
> => if (flags & QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) {
> ret = nc->info->receive_raw(nc, buffer, offset);
> } else {
> ret = nc->info->receive(nc, buffer, offset);
> }
>
Right, I will delete the _raw part.
Thanks!
> Thanks
>
> > +
> > static NetClientInfo net_vhost_vdpa_info = {
> > .type = NET_CLIENT_DRIVER_VHOST_VDPA,
> > .size = sizeof(VhostVDPAState),
> > + .receive_iov = vhost_vdpa_receive_iov,
> > + .receive_raw = vhost_vdpa_receive_raw,
> > .cleanup = vhost_vdpa_cleanup,
> > .has_vnet_hdr = vhost_vdpa_has_vnet_hdr,
> > .has_ufo = vhost_vdpa_has_ufo,
> > --
> > 2.27.0
> >
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-11-22 6:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-19 10:20 [PATCH 0/3] vdpa: Fix SIGSEGV on failed vdpa devices Eugenio Pérez
2021-11-19 10:20 ` [PATCH 1/3] virtio-net: Fix indentation Eugenio Pérez
2021-11-19 10:20 ` [PATCH 2/3] vdpa: Add dummy receive callbacks Eugenio Pérez
2021-11-22 3:55 ` Jason Wang
2021-11-22 6:41 ` Eugenio Perez Martin
2021-11-19 10:20 ` [PATCH 3/3] virtio-net: Fix log message Eugenio Pérez
2021-11-22 3:56 ` [PATCH 0/3] vdpa: Fix SIGSEGV on failed vdpa devices Jason Wang
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).