Skip to content

Commit 0165daa

Browse files
lulu-github-namemstsirkin
authored andcommitted
net: introduce qemu_get_peer
This is a small function that can get the peer from given NetClientState and queue_index Signed-off-by: Cindy Lu <[email protected]> Message-Id: <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]>
1 parent 8bc43f3 commit 0165daa

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

include/net/net.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ void hmp_info_network(Monitor *mon, const QDict *qdict);
176176
void net_socket_rs_init(SocketReadState *rs,
177177
SocketReadStateFinalize *finalize,
178178
bool vnet_hdr);
179+
NetClientState *qemu_get_peer(NetClientState *nc, int queue_index);
179180

180181
/* NIC info */
181182

net/net.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,13 @@ void *qemu_get_nic_opaque(NetClientState *nc)
325325
return nic->opaque;
326326
}
327327

328+
NetClientState *qemu_get_peer(NetClientState *nc, int queue_index)
329+
{
330+
assert(nc != NULL);
331+
NetClientState *ncs = nc + queue_index;
332+
return ncs->peer;
333+
}
334+
328335
static void qemu_cleanup_net_client(NetClientState *nc)
329336
{
330337
QTAILQ_REMOVE(&net_clients, nc, next);

0 commit comments

Comments
 (0)