qemu-devel
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]