[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/44] net: introduce qemu_new_net_client()
From: |
Mark McLoughlin |
Subject: |
[Qemu-devel] [PATCH 09/44] net: introduce qemu_new_net_client() |
Date: |
Wed, 25 Nov 2009 18:49:02 +0000 |
A replacement for qemu_new_vlan_client(), using NetClientInfo to
replace most arguments.
Signed-off-by: Mark McLoughlin <address@hidden>
---
net.c | 70 +++++++++++++++++++++++++++++++++++++++++++++-------------------
net.h | 5 ++++
2 files changed, 54 insertions(+), 21 deletions(-)
diff --git a/net.c b/net.c
index 599e5b0..355eb87 100644
--- a/net.c
+++ b/net.c
@@ -248,34 +248,31 @@ static ssize_t qemu_deliver_packet_iov(VLANClientState
*sender,
int iovcnt,
void *opaque);
-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 *qemu_new_net_client(NetClientInfo *info,
+ VLANState *vlan,
+ VLANClientState *peer,
+ const char *model,
+ const char *name)
{
VLANClientState *vc;
- vc = qemu_mallocz(sizeof(VLANClientState));
+ assert(info->size >= sizeof(VLANClientState));
+
+ vc = qemu_mallocz(info->size);
- vc->type = type;
+ vc->type = info->type;
vc->model = qemu_strdup(model);
- if (name)
+ if (name) {
vc->name = qemu_strdup(name);
- else
+ } else {
vc->name = assign_name(vc, model);
- vc->can_receive = can_receive;
- vc->receive = receive;
- vc->receive_raw = receive_raw;
- vc->receive_iov = receive_iov;
- vc->cleanup = cleanup;
- vc->opaque = opaque;
+ }
+ vc->can_receive = info->can_receive;
+ vc->receive = info->receive;
+ vc->receive_raw = info->receive_raw;
+ vc->receive_iov = info->receive_iov;
+ vc->cleanup = info->cleanup;
+ vc->link_status_changed = info->link_status_changed;
if (vlan) {
assert(!peer);
@@ -296,6 +293,37 @@ VLANClientState *qemu_new_vlan_client(net_client_type type,
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)
{
if (vc->vlan) {
diff --git a/net.h b/net.h
index 56c5849..71a9a44 100644
--- a/net.h
+++ b/net.h
@@ -85,6 +85,11 @@ struct VLANState {
VLANState *qemu_find_vlan(int id, int allocate);
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,
VLANState *vlan,
VLANClientState *peer,
--
1.6.5.2
- [Qemu-devel] [PATCH 00/44] Fix announce_self(), misc net fixes and cleanups, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 03/44] net: move socket backend code from net.c to net/socket.c, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 01/44] net: move slirp code from net.c to net/slirp.c, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 02/44] net: move vde code from net.c to net/vde.c, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 04/44] net: move dump backend code from net.c to net/dump.c, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 09/44] net: introduce qemu_new_net_client(),
Mark McLoughlin <=
- [Qemu-devel] [PATCH 06/44] net: remove NICInfo::vc, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 10/44] qdev: move DO_UPCAST() into osdep.h, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 11/44] net: convert tap to NetClientInfo, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 28/44] net: convert mipsnet to NICState, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 17/44] net: introduce NICState and qemu_new_nic(), Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 34/44] net: move parse_macaddr() to net/util.[ch], Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 35/44] net: convert xen to NICState, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 22/44] net: convert pcnet to NICState, Mark McLoughlin, 2009/11/25