[RFC v3 1/8] net: introduce qemu_get_peer

Cindy Lu posted 8 patches 5 years, 8 months ago
Maintainers: Eric Blake <eblake@redhat.com>, Jason Wang <jasowang@redhat.com>, Markus Armbruster <armbru@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>
There is a newer version of this series
[RFC v3 1/8] net: introduce qemu_get_peer
Posted by Cindy Lu 5 years, 8 months ago
This is a small function that can get the peer from given NetClientState and queue_index

Signed-off-by: Cindy Lu <lulu@redhat.com>
---
 include/net/net.h | 1 +
 net/net.c         | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/include/net/net.h b/include/net/net.h
index 39085d9444..e7ef42d62b 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -176,6 +176,7 @@ void hmp_info_network(Monitor *mon, const QDict *qdict);
 void net_socket_rs_init(SocketReadState *rs,
                         SocketReadStateFinalize *finalize,
                         bool vnet_hdr);
+NetClientState *qemu_get_peer(NetClientState *nc, int queue_index);
 
 /* NIC info */
 
diff --git a/net/net.c b/net/net.c
index 38778e831d..599fb61028 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)
+{
+    assert(nc != NULL);
+    NetClientState *ncs = nc + queue_index;
+    return ncs->peer;
+}
 
 static void qemu_cleanup_net_client(NetClientState *nc)
 {
-- 
2.21.1


Re: [RFC v3 1/8] net: introduce qemu_get_peer
Posted by Laurent Vivier 5 years, 8 months ago
On 29/05/2020 16:06, Cindy Lu wrote:
> This is a small function that can get the peer from given NetClientState and queue_index
> 
> Signed-off-by: Cindy Lu <lulu@redhat.com>
> ---
>  include/net/net.h | 1 +
>  net/net.c         | 6 ++++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/include/net/net.h b/include/net/net.h
> index 39085d9444..e7ef42d62b 100644
> --- a/include/net/net.h
> +++ b/include/net/net.h
> @@ -176,6 +176,7 @@ void hmp_info_network(Monitor *mon, const QDict *qdict);
>  void net_socket_rs_init(SocketReadState *rs,
>                          SocketReadStateFinalize *finalize,
>                          bool vnet_hdr);
> +NetClientState *qemu_get_peer(NetClientState *nc, int queue_index);
>  
>  /* NIC info */
>  
> diff --git a/net/net.c b/net/net.c
> index 38778e831d..599fb61028 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -324,6 +324,12 @@ void *qemu_get_nic_opaque(NetClientState *nc)
>  
>      return nic->opaque;
>  }

To be consistent with the style of the file, you should add a blank line
here.

> +NetClientState *qemu_get_peer(NetClientState *nc, int queue_index)
> +{
> +    assert(nc != NULL);
> +    NetClientState *ncs = nc + queue_index;
> +    return ncs->peer;
> +}
>  
>  static void qemu_cleanup_net_client(NetClientState *nc)
>  {
> 

Thanks,
Laurent


Re: [RFC v3 1/8] net: introduce qemu_get_peer
Posted by Cindy Lu 5 years, 8 months ago
On Thu, Jun 11, 2020 at 5:08 PM Laurent Vivier <lvivier@redhat.com> wrote:
>
> On 29/05/2020 16:06, Cindy Lu wrote:
> > This is a small function that can get the peer from given NetClientState and queue_index
> >
> > Signed-off-by: Cindy Lu <lulu@redhat.com>
> > ---
> >  include/net/net.h | 1 +
> >  net/net.c         | 6 ++++++
> >  2 files changed, 7 insertions(+)
> >
> > diff --git a/include/net/net.h b/include/net/net.h
> > index 39085d9444..e7ef42d62b 100644
> > --- a/include/net/net.h
> > +++ b/include/net/net.h
> > @@ -176,6 +176,7 @@ void hmp_info_network(Monitor *mon, const QDict *qdict);
> >  void net_socket_rs_init(SocketReadState *rs,
> >                          SocketReadStateFinalize *finalize,
> >                          bool vnet_hdr);
> > +NetClientState *qemu_get_peer(NetClientState *nc, int queue_index);
> >
> >  /* NIC info */
> >
> > diff --git a/net/net.c b/net/net.c
> > index 38778e831d..599fb61028 100644
> > --- a/net/net.c
> > +++ b/net/net.c
> > @@ -324,6 +324,12 @@ void *qemu_get_nic_opaque(NetClientState *nc)
> >
> >      return nic->opaque;
> >  }
>
> To be consistent with the style of the file, you should add a blank line
> here.
>
Thanks Laurent, I will fix this
> > +NetClientState *qemu_get_peer(NetClientState *nc, int queue_index)
> > +{
> > +    assert(nc != NULL);
> > +    NetClientState *ncs = nc + queue_index;
> > +    return ncs->peer;
> > +}
> >
> >  static void qemu_cleanup_net_client(NetClientState *nc)
> >  {
> >
>
> Thanks,
> Laurent
>