[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/3] vdpa: Add dummy receive callbacks
From: |
Jason Wang |
Subject: |
Re: [PATCH 2/3] vdpa: Add dummy receive callbacks |
Date: |
Mon, 22 Nov 2021 11:55:30 +0800 |
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
>