提交 ebef2c09 编写于 作者: M Mark McLoughlin 提交者: Anthony Liguori

net: introduce NICState and qemu_new_nic()

Common state for all NICs.

The opaque member will replace the opaque member in VLANClientState
since only NICs need it.

The conf member will allow us to iterate over NICs, access the MAC
addr for the NIC and send a packet from each NIC in qemu_announce_self().
Signed-off-by: NMark McLoughlin <markmc@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 731d5856
......@@ -293,6 +293,27 @@ VLANClientState *qemu_new_net_client(NetClientInfo *info,
return vc;
}
NICState *qemu_new_nic(NetClientInfo *info,
NICConf *conf,
const char *model,
const char *name,
void *opaque)
{
VLANClientState *nc;
NICState *nic;
assert(info->type == NET_CLIENT_TYPE_NIC);
assert(info->size >= sizeof(NICState));
nc = qemu_new_net_client(info, conf->vlan, conf->peer, model, name);
nic = DO_UPCAST(NICState, nc, nc);
nic->conf = conf;
nic->opaque = opaque;
return nic;
}
VLANClientState *qemu_new_vlan_client(net_client_type type,
VLANState *vlan,
VLANClientState *peer,
......
......@@ -75,6 +75,12 @@ struct VLANClientState {
unsigned receive_disabled : 1;
};
typedef struct NICState {
VLANClientState nc;
NICConf *conf;
void *opaque;
} NICState;
struct VLANState {
int id;
QTAILQ_HEAD(, VLANClientState) clients;
......@@ -90,6 +96,11 @@ VLANClientState *qemu_new_net_client(NetClientInfo *info,
VLANClientState *peer,
const char *model,
const char *name);
NICState *qemu_new_nic(NetClientInfo *info,
NICConf *conf,
const char *model,
const char *name,
void *opaque);
VLANClientState *qemu_new_vlan_client(net_client_type type,
VLANState *vlan,
VLANClientState *peer,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册