mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 14:53:54 -06:00
net: introduce qemu_get_nic()
To support multiqueue, this patch introduces a helper qemu_get_nic() to get NICState from a NetClientState. The following patches would refactor this helper to support multiqueue. Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
b356f76de3
commit
cc1f0f4542
28 changed files with 92 additions and 78 deletions
20
net/net.c
20
net/net.c
|
@ -227,7 +227,7 @@ NICState *qemu_new_nic(NetClientInfo *info,
|
|||
|
||||
nc = qemu_new_net_client(info, conf->peer, model, name);
|
||||
|
||||
nic = DO_UPCAST(NICState, nc, nc);
|
||||
nic = qemu_get_nic(nc);
|
||||
nic->conf = conf;
|
||||
nic->opaque = opaque;
|
||||
|
||||
|
@ -239,6 +239,18 @@ NetClientState *qemu_get_queue(NICState *nic)
|
|||
return &nic->nc;
|
||||
}
|
||||
|
||||
NICState *qemu_get_nic(NetClientState *nc)
|
||||
{
|
||||
return DO_UPCAST(NICState, nc, nc);
|
||||
}
|
||||
|
||||
void *qemu_get_nic_opaque(NetClientState *nc)
|
||||
{
|
||||
NICState *nic = qemu_get_nic(nc);
|
||||
|
||||
return nic->opaque;
|
||||
}
|
||||
|
||||
static void qemu_cleanup_net_client(NetClientState *nc)
|
||||
{
|
||||
QTAILQ_REMOVE(&net_clients, nc, next);
|
||||
|
@ -265,7 +277,7 @@ void qemu_del_net_client(NetClientState *nc)
|
|||
{
|
||||
/* If there is a peer NIC, delete and cleanup client, but do not free. */
|
||||
if (nc->peer && nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
|
||||
NICState *nic = DO_UPCAST(NICState, nc, nc->peer);
|
||||
NICState *nic = qemu_get_nic(nc->peer);
|
||||
if (nic->peer_deleted) {
|
||||
return;
|
||||
}
|
||||
|
@ -281,7 +293,7 @@ void qemu_del_net_client(NetClientState *nc)
|
|||
|
||||
/* If this is a peer NIC and peer has already been deleted, free it now. */
|
||||
if (nc->peer && nc->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
|
||||
NICState *nic = DO_UPCAST(NICState, nc, nc);
|
||||
NICState *nic = qemu_get_nic(nc);
|
||||
if (nic->peer_deleted) {
|
||||
qemu_free_net_client(nc->peer);
|
||||
}
|
||||
|
@ -297,7 +309,7 @@ void qemu_foreach_nic(qemu_nic_foreach func, void *opaque)
|
|||
|
||||
QTAILQ_FOREACH(nc, &net_clients, next) {
|
||||
if (nc->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
|
||||
func(DO_UPCAST(NICState, nc, nc), opaque);
|
||||
func(qemu_get_nic(nc), opaque);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue