net: introduce qemu_new_net_client()
A replacement for qemu_new_vlan_client(), using NetClientInfo to replace most arguments. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
3ed79cc949
commit
45460d1a53
64
net.c
64
net.c
|
@ -248,34 +248,31 @@ static ssize_t qemu_deliver_packet_iov(VLANClientState *sender,
|
||||||
int iovcnt,
|
int iovcnt,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
|
|
||||||
VLANClientState *qemu_new_vlan_client(net_client_type type,
|
VLANClientState *qemu_new_net_client(NetClientInfo *info,
|
||||||
VLANState *vlan,
|
VLANState *vlan,
|
||||||
VLANClientState *peer,
|
VLANClientState *peer,
|
||||||
const char *model,
|
const char *model,
|
||||||
const char *name,
|
const char *name)
|
||||||
NetCanReceive *can_receive,
|
|
||||||
NetReceive *receive,
|
|
||||||
NetReceive *receive_raw,
|
|
||||||
NetReceiveIOV *receive_iov,
|
|
||||||
NetCleanup *cleanup,
|
|
||||||
void *opaque)
|
|
||||||
{
|
{
|
||||||
VLANClientState *vc;
|
VLANClientState *vc;
|
||||||
|
|
||||||
vc = qemu_mallocz(sizeof(VLANClientState));
|
assert(info->size >= sizeof(VLANClientState));
|
||||||
|
|
||||||
vc->type = type;
|
vc = qemu_mallocz(info->size);
|
||||||
|
|
||||||
|
vc->type = info->type;
|
||||||
vc->model = qemu_strdup(model);
|
vc->model = qemu_strdup(model);
|
||||||
if (name)
|
if (name) {
|
||||||
vc->name = qemu_strdup(name);
|
vc->name = qemu_strdup(name);
|
||||||
else
|
} else {
|
||||||
vc->name = assign_name(vc, model);
|
vc->name = assign_name(vc, model);
|
||||||
vc->can_receive = can_receive;
|
}
|
||||||
vc->receive = receive;
|
vc->can_receive = info->can_receive;
|
||||||
vc->receive_raw = receive_raw;
|
vc->receive = info->receive;
|
||||||
vc->receive_iov = receive_iov;
|
vc->receive_raw = info->receive_raw;
|
||||||
vc->cleanup = cleanup;
|
vc->receive_iov = info->receive_iov;
|
||||||
vc->opaque = opaque;
|
vc->cleanup = info->cleanup;
|
||||||
|
vc->link_status_changed = info->link_status_changed;
|
||||||
|
|
||||||
if (vlan) {
|
if (vlan) {
|
||||||
assert(!peer);
|
assert(!peer);
|
||||||
|
@ -296,6 +293,37 @@ VLANClientState *qemu_new_vlan_client(net_client_type type,
|
||||||
return vc;
|
return vc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VLANClientState *qemu_new_vlan_client(net_client_type type,
|
||||||
|
VLANState *vlan,
|
||||||
|
VLANClientState *peer,
|
||||||
|
const char *model,
|
||||||
|
const char *name,
|
||||||
|
NetCanReceive *can_receive,
|
||||||
|
NetReceive *receive,
|
||||||
|
NetReceive *receive_raw,
|
||||||
|
NetReceiveIOV *receive_iov,
|
||||||
|
NetCleanup *cleanup,
|
||||||
|
void *opaque)
|
||||||
|
{
|
||||||
|
VLANClientState *ret;
|
||||||
|
NetClientInfo info;
|
||||||
|
|
||||||
|
info.type = type;
|
||||||
|
info.size = sizeof(VLANClientState);
|
||||||
|
info.can_receive = can_receive;
|
||||||
|
info.receive = receive;
|
||||||
|
info.receive_raw = receive_raw;
|
||||||
|
info.receive_iov = receive_iov;
|
||||||
|
info.cleanup = cleanup;
|
||||||
|
info.link_status_changed = NULL;
|
||||||
|
|
||||||
|
ret = qemu_new_net_client(&info, vlan, peer, model, name);
|
||||||
|
|
||||||
|
ret->opaque = opaque;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void qemu_del_vlan_client(VLANClientState *vc)
|
void qemu_del_vlan_client(VLANClientState *vc)
|
||||||
{
|
{
|
||||||
if (vc->vlan) {
|
if (vc->vlan) {
|
||||||
|
|
5
net.h
5
net.h
|
@ -85,6 +85,11 @@ struct VLANState {
|
||||||
|
|
||||||
VLANState *qemu_find_vlan(int id, int allocate);
|
VLANState *qemu_find_vlan(int id, int allocate);
|
||||||
VLANClientState *qemu_find_netdev(const char *id);
|
VLANClientState *qemu_find_netdev(const char *id);
|
||||||
|
VLANClientState *qemu_new_net_client(NetClientInfo *info,
|
||||||
|
VLANState *vlan,
|
||||||
|
VLANClientState *peer,
|
||||||
|
const char *model,
|
||||||
|
const char *name);
|
||||||
VLANClientState *qemu_new_vlan_client(net_client_type type,
|
VLANClientState *qemu_new_vlan_client(net_client_type type,
|
||||||
VLANState *vlan,
|
VLANState *vlan,
|
||||||
VLANClientState *peer,
|
VLANClientState *peer,
|
||||||
|
|
Loading…
Reference in a new issue