[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [6216] Add a model string to VLANClientState (Mark McLoughl
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [6216] Add a model string to VLANClientState (Mark McLoughlin) |
Date: |
Wed, 07 Jan 2009 17:42:26 +0000 |
Revision: 6216
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6216
Author: aliguori
Date: 2009-01-07 17:42:25 +0000 (Wed, 07 Jan 2009)
Log Message:
-----------
Add a model string to VLANClientState (Mark McLoughlin)
Don't lose track of what type/model a vlan client is so that we can
e.g. assign a global per-model id to clients.
The entire patch is basically a tedious excercise in making sure the
type/model string gets propagated down to qemu_new_vlan_client().
Signed-off-by: Mark McLoughlin <address@hidden>
Signed-off-by: Anthony Liguori <address@hidden>
Modified Paths:
--------------
trunk/hw/e1000.c
trunk/hw/eepro100.c
trunk/hw/etraxfs_eth.c
trunk/hw/mcf_fec.c
trunk/hw/mipsnet.c
trunk/hw/musicpal.c
trunk/hw/ne2000.c
trunk/hw/pcnet.c
trunk/hw/rtl8139.c
trunk/hw/smc91c111.c
trunk/hw/stellaris_enet.c
trunk/hw/usb-net.c
trunk/hw/virtio-net.c
trunk/net.c
trunk/net.h
trunk/sysemu.h
trunk/tap-win32.c
Modified: trunk/hw/e1000.c
===================================================================
--- trunk/hw/e1000.c 2009-01-07 17:40:15 UTC (rev 6215)
+++ trunk/hw/e1000.c 2009-01-07 17:42:25 UTC (rev 6216)
@@ -1071,8 +1071,8 @@
d->rxbuf_min_shift = 1;
memset(&d->tx, 0, sizeof d->tx);
- d->vc = qemu_new_vlan_client(nd->vlan, e1000_receive,
- e1000_can_receive, d);
+ d->vc = qemu_new_vlan_client(nd->vlan, nd->model,
+ e1000_receive, e1000_can_receive, d);
snprintf(d->vc->info_str, sizeof(d->vc->info_str),
"%s macaddr=%02x:%02x:%02x:%02x:%02x:%02x", info_str,
Modified: trunk/hw/eepro100.c
===================================================================
--- trunk/hw/eepro100.c 2009-01-07 17:40:15 UTC (rev 6215)
+++ trunk/hw/eepro100.c 2009-01-07 17:42:25 UTC (rev 6216)
@@ -1776,7 +1776,8 @@
nic_reset(s);
- s->vc = qemu_new_vlan_client(nd->vlan, nic_receive, nic_can_receive, s);
+ s->vc = qemu_new_vlan_client(nd->vlan, nd->model,
+ nic_receive, nic_can_receive, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str),
"eepro100 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
Modified: trunk/hw/etraxfs_eth.c
===================================================================
--- trunk/hw/etraxfs_eth.c 2009-01-07 17:40:15 UTC (rev 6215)
+++ trunk/hw/etraxfs_eth.c 2009-01-07 17:42:25 UTC (rev 6216)
@@ -572,7 +572,7 @@
eth->ethregs = cpu_register_io_memory(0, eth_read, eth_write, eth);
cpu_register_physical_memory (base, 0x5c, eth->ethregs);
- eth->vc = qemu_new_vlan_client(nd->vlan,
+ eth->vc = qemu_new_vlan_client(nd->vlan, nd->model,
eth_receive, eth_can_receive, eth);
return dma;
Modified: trunk/hw/mcf_fec.c
===================================================================
--- trunk/hw/mcf_fec.c 2009-01-07 17:40:15 UTC (rev 6215)
+++ trunk/hw/mcf_fec.c 2009-01-07 17:42:25 UTC (rev 6216)
@@ -452,7 +452,7 @@
mcf_fec_writefn, s);
cpu_register_physical_memory(base, 0x400, iomemtype);
- s->vc = qemu_new_vlan_client(nd->vlan, mcf_fec_receive,
- mcf_fec_can_receive, s);
+ s->vc = qemu_new_vlan_client(nd->vlan, nd->model,
+ mcf_fec_receive, mcf_fec_can_receive, s);
memcpy(s->macaddr, nd->macaddr, 6);
}
Modified: trunk/hw/mipsnet.c
===================================================================
--- trunk/hw/mipsnet.c 2009-01-07 17:40:15 UTC (rev 6215)
+++ trunk/hw/mipsnet.c 2009-01-07 17:42:25 UTC (rev 6216)
@@ -250,8 +250,8 @@
s->irq = irq;
s->nd = nd;
if (nd && nd->vlan) {
- s->vc = qemu_new_vlan_client(nd->vlan, mipsnet_receive,
- mipsnet_can_receive, s);
+ s->vc = qemu_new_vlan_client(nd->vlan, nd->model,
+ mipsnet_receive, mipsnet_can_receive, s);
} else {
s->vc = NULL;
}
Modified: trunk/hw/musicpal.c
===================================================================
--- trunk/hw/musicpal.c 2009-01-07 17:40:15 UTC (rev 6215)
+++ trunk/hw/musicpal.c 2009-01-07 17:42:25 UTC (rev 6216)
@@ -718,7 +718,8 @@
if (!s)
return;
s->irq = irq;
- s->vc = qemu_new_vlan_client(nd->vlan, eth_receive, eth_can_receive, s);
+ s->vc = qemu_new_vlan_client(nd->vlan, nd->model,
+ eth_receive, eth_can_receive, s);
iomemtype = cpu_register_io_memory(0, mv88w8618_eth_readfn,
mv88w8618_eth_writefn, s);
cpu_register_physical_memory(base, MP_ETH_SIZE, iomemtype);
Modified: trunk/hw/ne2000.c
===================================================================
--- trunk/hw/ne2000.c 2009-01-07 17:40:15 UTC (rev 6215)
+++ trunk/hw/ne2000.c 2009-01-07 17:42:25 UTC (rev 6216)
@@ -741,8 +741,8 @@
ne2000_reset(s);
- s->vc = qemu_new_vlan_client(nd->vlan, ne2000_receive,
- ne2000_can_receive, s);
+ s->vc = qemu_new_vlan_client(nd->vlan, nd->model,
+ ne2000_receive, ne2000_can_receive, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str),
"ne2000 macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
@@ -811,8 +811,8 @@
s->pci_dev = (PCIDevice *)d;
memcpy(s->macaddr, nd->macaddr, 6);
ne2000_reset(s);
- s->vc = qemu_new_vlan_client(nd->vlan, ne2000_receive,
- ne2000_can_receive, s);
+ s->vc = qemu_new_vlan_client(nd->vlan, nd->model,
+ ne2000_receive, ne2000_can_receive, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str),
"ne2000 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
Modified: trunk/hw/pcnet.c
===================================================================
--- trunk/hw/pcnet.c 2009-01-07 17:40:15 UTC (rev 6215)
+++ trunk/hw/pcnet.c 2009-01-07 17:42:25 UTC (rev 6216)
@@ -1936,8 +1936,8 @@
d->nd = nd;
if (nd && nd->vlan) {
- d->vc = qemu_new_vlan_client(nd->vlan, pcnet_receive,
- pcnet_can_receive, d);
+ d->vc = qemu_new_vlan_client(nd->vlan, nd->model,
+ pcnet_receive, pcnet_can_receive, d);
snprintf(d->vc->info_str, sizeof(d->vc->info_str),
"pcnet macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
Modified: trunk/hw/rtl8139.c
===================================================================
--- trunk/hw/rtl8139.c 2009-01-07 17:40:15 UTC (rev 6215)
+++ trunk/hw/rtl8139.c 2009-01-07 17:42:25 UTC (rev 6216)
@@ -3438,8 +3438,8 @@
s->pci_dev = (PCIDevice *)d;
memcpy(s->macaddr, nd->macaddr, 6);
rtl8139_reset(s);
- s->vc = qemu_new_vlan_client(nd->vlan, rtl8139_receive,
- rtl8139_can_receive, s);
+ s->vc = qemu_new_vlan_client(nd->vlan, nd->model,
+ rtl8139_receive, rtl8139_can_receive, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str),
"rtl8139 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
Modified: trunk/hw/smc91c111.c
===================================================================
--- trunk/hw/smc91c111.c 2009-01-07 17:40:15 UTC (rev 6215)
+++ trunk/hw/smc91c111.c 2009-01-07 17:42:25 UTC (rev 6216)
@@ -704,7 +704,7 @@
smc91c111_reset(s);
- s->vc = qemu_new_vlan_client(nd->vlan, smc91c111_receive,
- smc91c111_can_receive, s);
+ s->vc = qemu_new_vlan_client(nd->vlan, nd->model,
+ smc91c111_receive, smc91c111_can_receive, s);
/* ??? Save/restore. */
}
Modified: trunk/hw/stellaris_enet.c
===================================================================
--- trunk/hw/stellaris_enet.c 2009-01-07 17:40:15 UTC (rev 6215)
+++ trunk/hw/stellaris_enet.c 2009-01-07 17:42:25 UTC (rev 6216)
@@ -397,8 +397,8 @@
memcpy(s->macaddr, nd->macaddr, 6);
if (nd->vlan)
- s->vc = qemu_new_vlan_client(nd->vlan, stellaris_enet_receive,
- stellaris_enet_can_receive, s);
+ s->vc = qemu_new_vlan_client(nd->vlan, nd->model,
+ stellaris_enet_receive,
stellaris_enet_can_receive, s);
stellaris_enet_reset(s);
register_savevm("stellaris_enet", -1, 1,
Modified: trunk/hw/usb-net.c
===================================================================
--- trunk/hw/usb-net.c 2009-01-07 17:40:15 UTC (rev 6215)
+++ trunk/hw/usb-net.c 2009-01-07 17:42:25 UTC (rev 6216)
@@ -1453,7 +1453,7 @@
pstrcpy(s->dev.devname, sizeof(s->dev.devname),
"QEMU USB Network Interface");
- s->vc = qemu_new_vlan_client(nd->vlan,
+ s->vc = qemu_new_vlan_client(nd->vlan, nd->model,
usbnet_receive, usbnet_can_receive, s);
snprintf(s->usbstring_mac, sizeof(s->usbstring_mac),
Modified: trunk/hw/virtio-net.c
===================================================================
--- trunk/hw/virtio-net.c 2009-01-07 17:40:15 UTC (rev 6215)
+++ trunk/hw/virtio-net.c 2009-01-07 17:42:25 UTC (rev 6216)
@@ -315,8 +315,8 @@
n->rx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_rx);
n->tx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_tx);
memcpy(n->mac, nd->macaddr, 6);
- n->vc = qemu_new_vlan_client(nd->vlan, virtio_net_receive,
- virtio_net_can_receive, n);
+ n->vc = qemu_new_vlan_client(nd->vlan, nd->model,
+ virtio_net_receive, virtio_net_can_receive,
n);
n->tx_timer = qemu_new_timer(vm_clock, virtio_net_tx_timer, n);
n->tx_timer_active = 0;
Modified: trunk/net.c
===================================================================
--- trunk/net.c 2009-01-07 17:40:15 UTC (rev 6215)
+++ trunk/net.c 2009-01-07 17:42:25 UTC (rev 6216)
@@ -297,6 +297,7 @@
#endif
VLANClientState *qemu_new_vlan_client(VLANState *vlan,
+ const char *model,
IOReadHandler *fd_read,
IOCanRWHandler *fd_can_read,
void *opaque)
@@ -305,6 +306,7 @@
vc = qemu_mallocz(sizeof(VLANClientState));
if (!vc)
return NULL;
+ vc->model = strdup(model);
vc->fd_read = fd_read;
vc->fd_can_read = fd_can_read;
vc->opaque = opaque;
@@ -325,6 +327,7 @@
while (*pvc != NULL)
if (*pvc == vc) {
*pvc = vc->next;
+ free(vc->model);
free(vc);
break;
} else
@@ -442,13 +445,13 @@
slirp_input(buf, size);
}
-static int net_slirp_init(VLANState *vlan)
+static int net_slirp_init(VLANState *vlan, const char *model)
{
if (!slirp_inited) {
slirp_inited = 1;
slirp_init();
}
- slirp_vc = qemu_new_vlan_client(vlan,
+ slirp_vc = qemu_new_vlan_client(vlan, model,
slirp_receive, NULL, NULL);
snprintf(slirp_vc->info_str, sizeof(slirp_vc->info_str), "user
redirector");
return 0;
@@ -662,7 +665,7 @@
/* fd support */
-static TAPState *net_tap_fd_init(VLANState *vlan, int fd)
+static TAPState *net_tap_fd_init(VLANState *vlan, const char *model, int fd)
{
TAPState *s;
@@ -670,7 +673,7 @@
if (!s)
return NULL;
s->fd = fd;
- s->vc = qemu_new_vlan_client(vlan, tap_receive, NULL, s);
+ s->vc = qemu_new_vlan_client(vlan, model, tap_receive, NULL, s);
#ifdef HAVE_IOVEC
s->vc->fd_readv = tap_receive_iov;
#endif
@@ -905,7 +908,7 @@
return 0;
}
-static int net_tap_init(VLANState *vlan, const char *ifname1,
+static int net_tap_init(VLANState *vlan, const char *model, const char
*ifname1,
const char *setup_script, const char *down_script)
{
TAPState *s;
@@ -926,7 +929,7 @@
if (launch_script(setup_script, ifname, fd))
return -1;
}
- s = net_tap_fd_init(vlan, fd);
+ s = net_tap_fd_init(vlan, model, fd);
if (!s)
return -1;
snprintf(s->vc->info_str, sizeof(s->vc->info_str),
@@ -969,8 +972,8 @@
}
}
-static int net_vde_init(VLANState *vlan, const char *sock, int port,
- const char *group, int mode)
+static int net_vde_init(VLANState *vlan, const char *model, const char *sock,
+ int port, const char *group, int mode)
{
VDEState *s;
char *init_group = strlen(group) ? (char *)group : NULL;
@@ -990,7 +993,7 @@
free(s);
return -1;
}
- s->vc = qemu_new_vlan_client(vlan, vde_from_qemu, NULL, s);
+ s->vc = qemu_new_vlan_client(vlan, model, vde_from_qemu, NULL, s);
qemu_set_fd_handler(vde_datafd(s->vde), vde_to_qemu, NULL, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str), "vde: sock=%s fd=%d",
sock, vde_datafd(s->vde));
@@ -1011,6 +1014,7 @@
typedef struct NetSocketListenState {
VLANState *vlan;
+ char *model;
int fd;
} NetSocketListenState;
@@ -1164,8 +1168,8 @@
return -1;
}
-static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, int fd,
- int is_connected)
+static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, const char
*model,
+ int fd, int is_connected)
{
struct sockaddr_in saddr;
int newfd;
@@ -1208,7 +1212,7 @@
return NULL;
s->fd = fd;
- s->vc = qemu_new_vlan_client(vlan, net_socket_receive_dgram, NULL, s);
+ s->vc = qemu_new_vlan_client(vlan, model, net_socket_receive_dgram, NULL,
s);
qemu_set_fd_handler(s->fd, net_socket_send_dgram, NULL, s);
/* mcast: save bound address as dst */
@@ -1227,15 +1231,15 @@
qemu_set_fd_handler(s->fd, net_socket_send, NULL, s);
}
-static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, int fd,
- int is_connected)
+static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, const char
*model,
+ int fd, int is_connected)
{
NetSocketState *s;
s = qemu_mallocz(sizeof(NetSocketState));
if (!s)
return NULL;
s->fd = fd;
- s->vc = qemu_new_vlan_client(vlan,
+ s->vc = qemu_new_vlan_client(vlan, model,
net_socket_receive, NULL, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str),
"socket: fd=%d", fd);
@@ -1247,8 +1251,8 @@
return s;
}
-static NetSocketState *net_socket_fd_init(VLANState *vlan, int fd,
- int is_connected)
+static NetSocketState *net_socket_fd_init(VLANState *vlan, const char *model,
+ int fd, int is_connected)
{
int so_type=-1, optlen=sizeof(so_type);
@@ -1259,13 +1263,13 @@
}
switch(so_type) {
case SOCK_DGRAM:
- return net_socket_fd_init_dgram(vlan, fd, is_connected);
+ return net_socket_fd_init_dgram(vlan, model, fd, is_connected);
case SOCK_STREAM:
- return net_socket_fd_init_stream(vlan, fd, is_connected);
+ return net_socket_fd_init_stream(vlan, model, fd, is_connected);
default:
/* who knows ... this could be a eg. a pty, do warn and continue as
stream */
fprintf(stderr, "qemu: warning: socket type=%d for fd=%d is not
SOCK_DGRAM or SOCK_STREAM\n", so_type, fd);
- return net_socket_fd_init_stream(vlan, fd, is_connected);
+ return net_socket_fd_init_stream(vlan, model, fd, is_connected);
}
return NULL;
}
@@ -1287,7 +1291,7 @@
break;
}
}
- s1 = net_socket_fd_init(s->vlan, fd, 1);
+ s1 = net_socket_fd_init(s->vlan, s->model, fd, 1);
if (!s1) {
closesocket(fd);
} else {
@@ -1297,7 +1301,8 @@
}
}
-static int net_socket_listen_init(VLANState *vlan, const char *host_str)
+static int net_socket_listen_init(VLANState *vlan, const char *model,
+ const char *host_str)
{
NetSocketListenState *s;
int fd, val, ret;
@@ -1332,12 +1337,14 @@
return -1;
}
s->vlan = vlan;
+ s->model = strdup(model);
s->fd = fd;
qemu_set_fd_handler(fd, net_socket_accept, NULL, s);
return 0;
}
-static int net_socket_connect_init(VLANState *vlan, const char *host_str)
+static int net_socket_connect_init(VLANState *vlan, const char *model,
+ const char *host_str)
{
NetSocketState *s;
int fd, connected, ret, err;
@@ -1375,7 +1382,7 @@
break;
}
}
- s = net_socket_fd_init(vlan, fd, connected);
+ s = net_socket_fd_init(vlan, model, fd, connected);
if (!s)
return -1;
snprintf(s->vc->info_str, sizeof(s->vc->info_str),
@@ -1384,7 +1391,8 @@
return 0;
}
-static int net_socket_mcast_init(VLANState *vlan, const char *host_str)
+static int net_socket_mcast_init(VLANState *vlan, const char *model,
+ const char *host_str)
{
NetSocketState *s;
int fd;
@@ -1398,7 +1406,7 @@
if (fd < 0)
return -1;
- s = net_socket_fd_init(vlan, fd, 0);
+ s = net_socket_fd_init(vlan, model, fd, 0);
if (!s)
return -1;
@@ -1488,7 +1496,7 @@
pstrcpy(slirp_hostname, sizeof(slirp_hostname), buf);
}
vlan->nb_host_devs++;
- ret = net_slirp_init(vlan);
+ ret = net_slirp_init(vlan, device);
} else
#endif
#ifdef _WIN32
@@ -1499,7 +1507,7 @@
return -1;
}
vlan->nb_host_devs++;
- ret = tap_win32_init(vlan, ifname);
+ ret = tap_win32_init(vlan, device, ifname);
} else
#elif defined (_AIX)
#else
@@ -1512,7 +1520,7 @@
fd = strtol(buf, NULL, 0);
fcntl(fd, F_SETFL, O_NONBLOCK);
ret = -1;
- if (net_tap_fd_init(vlan, fd))
+ if (net_tap_fd_init(vlan, device, fd))
ret = 0;
} else {
if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) {
@@ -1524,7 +1532,7 @@
if (get_param_value(down_script, sizeof(down_script),
"downscript", p) == 0) {
pstrcpy(down_script, sizeof(down_script),
DEFAULT_NETWORK_DOWN_SCRIPT);
}
- ret = net_tap_init(vlan, ifname, setup_script, down_script);
+ ret = net_tap_init(vlan, device, ifname, setup_script,
down_script);
}
} else
#endif
@@ -1533,14 +1541,14 @@
int fd;
fd = strtol(buf, NULL, 0);
ret = -1;
- if (net_socket_fd_init(vlan, fd, 1))
+ if (net_socket_fd_init(vlan, device, fd, 1))
ret = 0;
} else if (get_param_value(buf, sizeof(buf), "listen", p) > 0) {
- ret = net_socket_listen_init(vlan, buf);
+ ret = net_socket_listen_init(vlan, device, buf);
} else if (get_param_value(buf, sizeof(buf), "connect", p) > 0) {
- ret = net_socket_connect_init(vlan, buf);
+ ret = net_socket_connect_init(vlan, device, buf);
} else if (get_param_value(buf, sizeof(buf), "mcast", p) > 0) {
- ret = net_socket_mcast_init(vlan, buf);
+ ret = net_socket_mcast_init(vlan, device, buf);
} else {
fprintf(stderr, "Unknown socket options: %s\n", p);
return -1;
@@ -1568,7 +1576,7 @@
} else {
vde_mode = 0700;
}
- ret = net_vde_init(vlan, vde_sock, vde_port, vde_group, vde_mode);
+ ret = net_vde_init(vlan, device, vde_sock, vde_port, vde_group,
vde_mode);
} else
#endif
{
Modified: trunk/net.h
===================================================================
--- trunk/net.h 2009-01-07 17:40:15 UTC (rev 6215)
+++ trunk/net.h 2009-01-07 17:42:25 UTC (rev 6216)
@@ -18,6 +18,7 @@
void *opaque;
struct VLANClientState *next;
struct VLANState *vlan;
+ char *model;
char info_str[256];
};
@@ -30,6 +31,7 @@
VLANState *qemu_find_vlan(int id);
VLANClientState *qemu_new_vlan_client(VLANState *vlan,
+ const char *model,
IOReadHandler *fd_read,
IOCanRWHandler *fd_can_read,
void *opaque);
Modified: trunk/sysemu.h
===================================================================
--- trunk/sysemu.h 2009-01-07 17:40:15 UTC (rev 6215)
+++ trunk/sysemu.h 2009-01-07 17:42:25 UTC (rev 6216)
@@ -75,7 +75,7 @@
#endif
/* TAP win32 */
-int tap_win32_init(VLANState *vlan, const char *ifname);
+int tap_win32_init(VLANState *vlan, const char *model, const char *ifname);
/* SLIRP */
void do_info_slirp(void);
Modified: trunk/tap-win32.c
===================================================================
--- trunk/tap-win32.c 2009-01-07 17:40:15 UTC (rev 6215)
+++ trunk/tap-win32.c 2009-01-07 17:42:25 UTC (rev 6216)
@@ -660,7 +660,7 @@
}
}
-int tap_win32_init(VLANState *vlan, const char *ifname)
+int tap_win32_init(VLANState *vlan, const char *model, const char *ifname)
{
TAPState *s;
@@ -672,7 +672,7 @@
return -1;
}
- s->vc = qemu_new_vlan_client(vlan, tap_receive, NULL, s);
+ s->vc = qemu_new_vlan_client(vlan, model, tap_receive, NULL, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str),
"tap: ifname=%s", ifname);