[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC v1 1/4] net: Introduce qemu_get_peer
From: |
Laurent Vivier |
Subject: |
Re: [RFC v1 1/4] net: Introduce qemu_get_peer |
Date: |
Tue, 21 Apr 2020 17:01:12 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 |
On 20/04/2020 11:32, Cindy Lu wrote:
> This is a small function that can get the peer from given NetClientState and
> queue_index
>
> Signed-off-by: Cindy Lu <address@hidden>
> ---
> hw/net/vhost_net.c | 16 ++++++++++------
> include/net/net.h | 1 +
> net/net.c | 6 ++++++
> 3 files changed, 17 insertions(+), 6 deletions(-)
>
...
> diff --git a/net/net.c b/net/net.c
> index 84aa6d8d00..ac5080dda1 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -324,6 +324,12 @@ void *qemu_get_nic_opaque(NetClientState *nc)
>
> return nic->opaque;
> }
> +NetClientState *qemu_get_peer(NetClientState *nc, int queue_index)
> +{
> + NetClientState *ncs = nc + queue_index;
> + assert(ncs != NULL);
This will not assert if nc is NULL and queue_index != 0.
You should check value of nc and then calculate ncs.
Thanks,
Laurent
- Re: [RFC v1 2/4] vhost-vdpa: introduce vhost-vdpa net client, (continued)
- [RFC v1 3/4] vhost-vdpa: implement vhost-vdpa backend, Cindy Lu, 2020/04/20
- [RFC v1 1/4] net: Introduce qemu_get_peer, Cindy Lu, 2020/04/20
- [RFC v1 4/4] vhost: introduce vhost_set_vring_ready method, Cindy Lu, 2020/04/20
- Re: [RFC v1 0/4] vDPA support in qemu, Jason Wang, 2020/04/21
- Re: [RFC v1 0/4] vDPA support in qemu, Jason Wang, 2020/04/21