* [Qemu-devel] [6216] Add a model string to VLANClientState (Mark McLoughlin)
@ 2009-01-07 17:42 Anthony Liguori
2009-01-07 19:23 ` Stefan Weil
0 siblings, 1 reply; 12+ messages in thread
From: Anthony Liguori @ 2009-01-07 17:42 UTC (permalink / raw)
To: qemu-devel
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 <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
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);
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [6216] Add a model string to VLANClientState (Mark McLoughlin)
2009-01-07 17:42 [Qemu-devel] [6216] Add a model string to VLANClientState (Mark McLoughlin) Anthony Liguori
@ 2009-01-07 19:23 ` Stefan Weil
2009-01-08 14:45 ` Mark McLoughlin
0 siblings, 1 reply; 12+ messages in thread
From: Stefan Weil @ 2009-01-07 19:23 UTC (permalink / raw)
To: qemu-devel
Anthony Liguori schrieb:
> 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 <markmc@redhat.com>
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
>
> 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/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);
>
Some targets don't force a value for model, so it can be NULL.
This raises a SIGSEGV crash. Should targets set model, or is
it better to catch this case here?
> 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
>
>
Regards
Stefan Weil
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [6216] Add a model string to VLANClientState (Mark McLoughlin)
2009-01-07 19:23 ` Stefan Weil
@ 2009-01-08 14:45 ` Mark McLoughlin
2009-01-08 14:47 ` [Qemu-devel] [PATCH 1/4] Add qemu_check_nic_model() and qemu_check_nic_model_list() Mark McLoughlin
0 siblings, 1 reply; 12+ messages in thread
From: Mark McLoughlin @ 2009-01-08 14:45 UTC (permalink / raw)
To: qemu-devel
On Wed, 2009-01-07 at 20:23 +0100, Stefan Weil wrote:
> Anthony Liguori schrieb:
> > 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 <markmc@redhat.com>
> > Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
...
> > 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);
> >
>
> Some targets don't force a value for model, so it can be NULL.
> This raises a SIGSEGV crash. Should targets set model, or is
> it better to catch this case here?
Ouch.
It'd be much nicer to make sure we always get a model string here rather
than having names default to e.g. "nic.1".
So, I went and fixed up all the targets to make sure that nd->model is
always set.
That sucked, though, so I went through a couple of iterations of
cleaning all this stuff up and settled on the patches that follow this
mail.
Cheers,
Mark.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 1/4] Add qemu_check_nic_model() and qemu_check_nic_model_list()
2009-01-08 14:45 ` Mark McLoughlin
@ 2009-01-08 14:47 ` Mark McLoughlin
2009-01-08 14:47 ` [Qemu-devel] [PATCH 2/4] Check NIC model in some NIC init functions Mark McLoughlin
2009-01-13 19:25 ` [Qemu-devel] [PATCH 1/3] Check NIC model in some NIC init functions Mark McLoughlin
0 siblings, 2 replies; 12+ messages in thread
From: Mark McLoughlin @ 2009-01-08 14:47 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel, Mark McLoughlin
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
net.c | 34 ++++++++++++++++++++++++++++++++++
net.h | 3 +++
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/net.c b/net.c
index 15f9153..4609be2 100644
--- a/net.c
+++ b/net.c
@@ -1491,6 +1491,40 @@ VLANState *qemu_find_vlan(int id)
return vlan;
}
+void qemu_check_nic_model(NICInfo *nd, const char *model)
+{
+ const char *models[2];
+
+ models[0] = model;
+ models[1] = NULL;
+
+ qemu_check_nic_model_list(nd, models, model);
+}
+
+void qemu_check_nic_model_list(NICInfo *nd, const char * const *models,
+ const char *default_model)
+{
+ int i, exit_status = 0;
+
+ if (!nd->model)
+ nd->model = strdup(default_model);
+
+ if (strcmp(nd->model, "?") != 0) {
+ for (i = 0 ; models[i]; i++)
+ if (strcmp(nd->model, models[i]) == 0)
+ return;
+
+ fprintf(stderr, "qemu: Unsupported NIC model: %s\n", nd->model);
+ exit_status = 1;
+ }
+
+ fprintf(stderr, "qemu: Supported NIC models: ");
+ for (i = 0 ; models[i]; i++)
+ fprintf(stderr, "%s%c", models[i], models[i+1] ? ',' : '\n');
+
+ exit(exit_status);
+}
+
int net_client_init(const char *device, const char *p)
{
char buf[1024];
diff --git a/net.h b/net.h
index b89d165..19ab649 100644
--- a/net.h
+++ b/net.h
@@ -43,6 +43,9 @@ ssize_t qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov,
int iovcnt);
void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size);
void qemu_format_nic_info_str(VLANClientState *vc, uint8_t macaddr[6]);
+void qemu_check_nic_model(NICInfo *nd, const char *model);
+void qemu_check_nic_model_list(NICInfo *nd, const char * const *models,
+ const char *default_model);
void qemu_handler_true(void *opaque);
void do_info_network(void);
--
1.6.0.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 2/4] Check NIC model in some NIC init functions
2009-01-08 14:47 ` [Qemu-devel] [PATCH 1/4] Add qemu_check_nic_model() and qemu_check_nic_model_list() Mark McLoughlin
@ 2009-01-08 14:47 ` Mark McLoughlin
2009-01-08 14:47 ` [Qemu-devel] [PATCH 3/4] Make virtio_net_init() return void Mark McLoughlin
2009-01-13 19:25 ` [Qemu-devel] [PATCH 1/3] Check NIC model in some NIC init functions Mark McLoughlin
1 sibling, 1 reply; 12+ messages in thread
From: Mark McLoughlin @ 2009-01-08 14:47 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel, Mark McLoughlin
Some NIC init functions are only called when that model is
the only valid model. In that case, it makes sense to use
qemu_check_nic_model() from the NIC init function itself.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
hw/axis_dev88.c | 5 +----
hw/etraxfs.c | 5 +----
hw/etraxfs_eth.c | 2 ++
hw/integratorcp.c | 14 ++------------
hw/mcf5208.c | 14 ++------------
hw/mcf_fec.c | 2 ++
hw/mips_mipssim.c | 16 +++-------------
hw/mips_r4k.c | 14 ++------------
hw/mipsnet.c | 2 ++
hw/musicpal.c | 2 ++
hw/ne2000.c | 2 ++
hw/pcnet.c | 2 ++
hw/realview.c | 8 +++++---
hw/smc91c111.c | 2 ++
hw/stellaris.c | 4 +---
hw/stellaris_enet.c | 2 ++
hw/sun4m.c | 33 +++------------------------------
hw/versatilepb.c | 8 +++++---
18 files changed, 41 insertions(+), 96 deletions(-)
diff --git a/hw/axis_dev88.c b/hw/axis_dev88.c
index f7bdd14..3f90fa5 100644
--- a/hw/axis_dev88.c
+++ b/hw/axis_dev88.c
@@ -303,12 +303,9 @@ void axisdev88_init (ram_addr_t ram_size, int vga_ram_size,
}
/* Add the two ethernet blocks. */
- nd_table[0].model = nd_table[0].model ? nd_table[0].model : "fseth";
eth[0] = etraxfs_eth_init(&nd_table[0], env, pic->irq + 25, 0x30034000);
- if (nb_nics > 1) {
- nd_table[1].model = nd_table[1].model ? nd_table[1].model : "fseth";
+ if (nb_nics > 1)
eth[1] = etraxfs_eth_init(&nd_table[1], env, pic->irq + 26, 0x30036000);
- }
/* The DMA Connector block is missing, hardwire things for now. */
etraxfs_dmac_connect_client(etraxfs_dmac, 0, eth[0]);
diff --git a/hw/etraxfs.c b/hw/etraxfs.c
index 01b5a6e..5cd56f3 100644
--- a/hw/etraxfs.c
+++ b/hw/etraxfs.c
@@ -94,12 +94,9 @@ void bareetraxfs_init (ram_addr_t ram_size, int vga_ram_size,
}
/* Add the two ethernet blocks. */
- nd_table[0].model = nd_table[0].model ? nd_table[0].model : "fseth";
eth[0] = etraxfs_eth_init(&nd_table[0], env, pic->irq + 25, 0x30034000);
- if (nb_nics > 1) {
- nd_table[1].model = nd_table[1].model ? nd_table[1].model : "fseth";
+ if (nb_nics > 1)
eth[1] = etraxfs_eth_init(&nd_table[1], env, pic->irq + 26, 0x30036000);
- }
/* The DMA Connector block is missing, hardwire things for now. */
etraxfs_dmac_connect_client(etraxfs_dmac, 0, eth[0]);
diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c
index 239e0d8..23026ca 100644
--- a/hw/etraxfs_eth.c
+++ b/hw/etraxfs_eth.c
@@ -546,6 +546,8 @@ void *etraxfs_eth_init(NICInfo *nd, CPUState *env,
struct etraxfs_dma_client *dma = NULL;
struct fs_eth *eth = NULL;
+ qemu_check_nic_model(nd, "fseth");
+
dma = qemu_mallocz(sizeof *dma * 2);
if (!dma)
return NULL;
diff --git a/hw/integratorcp.c b/hw/integratorcp.c
index a2d3d43..fdbfe20 100644
--- a/hw/integratorcp.c
+++ b/hw/integratorcp.c
@@ -497,18 +497,8 @@ static void integratorcp_init(ram_addr_t ram_size, int vga_ram_size,
exit(1);
}
pl181_init(0x1c000000, drives_table[sd].bdrv, pic[23], pic[24]);
- if (nd_table[0].vlan) {
- if (nd_table[0].model == NULL
- || strcmp(nd_table[0].model, "smc91c111") == 0) {
- smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
- } else if (strcmp(nd_table[0].model, "?") == 0) {
- fprintf(stderr, "qemu: Supported NICs: smc91c111\n");
- exit (1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
- exit (1);
- }
- }
+ if (nd_table[0].vlan)
+ smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
pl110_init(ds, 0xc0000000, pic[22], 0);
integrator_binfo.ram_size = ram_size;
diff --git a/hw/mcf5208.c b/hw/mcf5208.c
index 71ba3fb..f06c25a 100644
--- a/hw/mcf5208.c
+++ b/hw/mcf5208.c
@@ -241,18 +241,8 @@ static void mcf5208evb_init(ram_addr_t ram_size, int vga_ram_size,
fprintf(stderr, "Too many NICs\n");
exit(1);
}
- if (nd_table[0].vlan) {
- if (nd_table[0].model == NULL
- || strcmp(nd_table[0].model, "mcf_fec") == 0) {
- mcf_fec_init(&nd_table[0], 0xfc030000, pic + 36);
- } else if (strcmp(nd_table[0].model, "?") == 0) {
- fprintf(stderr, "qemu: Supported NICs: mcf_fec\n");
- exit (1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
- exit (1);
- }
- }
+ if (nd_table[0].vlan)
+ mcf_fec_init(&nd_table[0], 0xfc030000, pic + 36);
/* 0xfc000000 SCM. */
/* 0xfc004000 XBS. */
diff --git a/hw/mcf_fec.c b/hw/mcf_fec.c
index 49ae69b..413c569 100644
--- a/hw/mcf_fec.c
+++ b/hw/mcf_fec.c
@@ -446,6 +446,8 @@ void mcf_fec_init(NICInfo *nd, target_phys_addr_t base, qemu_irq *irq)
mcf_fec_state *s;
int iomemtype;
+ qemu_check_nic_model(nd, "mcf_fec");
+
s = (mcf_fec_state *)qemu_mallocz(sizeof(mcf_fec_state));
s->irq = irq;
iomemtype = cpu_register_io_memory(0, mcf_fec_readfn,
diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c
index dc62f69..83f1a63 100644
--- a/hw/mips_mipssim.c
+++ b/hw/mips_mipssim.c
@@ -175,19 +175,9 @@ mips_mipssim_init (ram_addr_t ram_size, int vga_ram_size,
if (serial_hds[0])
serial_init(0x3f8, env->irq[4], 115200, serial_hds[0]);
- if (nd_table[0].vlan) {
- if (nd_table[0].model == NULL
- || strcmp(nd_table[0].model, "mipsnet") == 0) {
- /* MIPSnet uses the MIPS CPU INT0, which is interrupt 2. */
- mipsnet_init(0x4200, env->irq[2], &nd_table[0]);
- } else if (strcmp(nd_table[0].model, "?") == 0) {
- fprintf(stderr, "qemu: Supported NICs: mipsnet\n");
- exit (1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
- exit (1);
- }
- }
+ if (nd_table[0].vlan)
+ /* MIPSnet uses the MIPS CPU INT0, which is interrupt 2. */
+ mipsnet_init(0x4200, env->irq[2], &nd_table[0]);
}
QEMUMachine mips_mipssim_machine = {
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index 6551b02..c12ab54 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -247,18 +247,8 @@ void mips_r4k_init (ram_addr_t ram_size, int vga_ram_size,
isa_vga_init(ds, phys_ram_base + ram_size, ram_size,
vga_ram_size);
- if (nd_table[0].vlan) {
- if (nd_table[0].model == NULL
- || strcmp(nd_table[0].model, "ne2k_isa") == 0) {
- isa_ne2000_init(0x300, i8259[9], &nd_table[0]);
- } else if (strcmp(nd_table[0].model, "?") == 0) {
- fprintf(stderr, "qemu: Supported NICs: ne2k_isa\n");
- exit (1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
- exit (1);
- }
- }
+ if (nd_table[0].vlan)
+ isa_ne2000_init(0x300, i8259[9], &nd_table[0]);
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
diff --git a/hw/mipsnet.c b/hw/mipsnet.c
index 0eb4c1e..04ce322 100644
--- a/hw/mipsnet.c
+++ b/hw/mipsnet.c
@@ -236,6 +236,8 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd)
{
MIPSnetState *s;
+ qemu_check_nic_model(nd, "mipsnet");
+
s = qemu_mallocz(sizeof(MIPSnetState));
if (!s)
return;
diff --git a/hw/musicpal.c b/hw/musicpal.c
index 1c932ec..f64bb1c 100644
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -714,6 +714,8 @@ static void mv88w8618_eth_init(NICInfo *nd, uint32_t base, qemu_irq irq)
mv88w8618_eth_state *s;
int iomemtype;
+ qemu_check_nic_model(nd, "mv88w8618");
+
s = qemu_mallocz(sizeof(mv88w8618_eth_state));
if (!s)
return;
diff --git a/hw/ne2000.c b/hw/ne2000.c
index 200db90..a85730f 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -722,6 +722,8 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd)
{
NE2000State *s;
+ qemu_check_nic_model(nd, "ne2k_isa");
+
s = qemu_mallocz(sizeof(NE2000State));
if (!s)
return;
diff --git a/hw/pcnet.c b/hw/pcnet.c
index 102166e..6198968 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -2087,6 +2087,8 @@ void lance_init(NICInfo *nd, target_phys_addr_t leaddr, void *dma_opaque,
PCNetState *d;
int lance_io_memory;
+ qemu_check_nic_model(nd, "lance");
+
d = qemu_mallocz(sizeof(PCNetState));
if (!d)
return;
diff --git a/hw/realview.c b/hw/realview.c
index a9d20ed..5abbc16 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -121,11 +121,13 @@ static void realview_init(ram_addr_t ram_size, int vga_ram_size,
}
for(n = 0; n < nb_nics; n++) {
nd = &nd_table[n];
- if (!nd->model)
- nd->model = done_smc ? "rtl8139" : "smc91c111";
- if (strcmp(nd->model, "smc91c111") == 0) {
+
+ if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) {
smc91c111_init(nd, 0x4e000000, pic[28]);
+ done_smc = 1;
} else {
+ if (!nd->model)
+ nd->model = "rtl8139";
pci_nic_init(pci_bus, nd, -1);
}
}
diff --git a/hw/smc91c111.c b/hw/smc91c111.c
index 27a3158..f5b29a7 100644
--- a/hw/smc91c111.c
+++ b/hw/smc91c111.c
@@ -695,6 +695,8 @@ void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq)
smc91c111_state *s;
int iomemtype;
+ qemu_check_nic_model(nd, "smc91c111");
+
s = (smc91c111_state *)qemu_mallocz(sizeof(smc91c111_state));
iomemtype = cpu_register_io_memory(0, smc91c111_readfn,
smc91c111_writefn, s);
diff --git a/hw/stellaris.c b/hw/stellaris.c
index 703ef7e..7069518 100644
--- a/hw/stellaris.c
+++ b/hw/stellaris.c
@@ -1361,10 +1361,8 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model,
pl022_init(0x40008000, pic[7], NULL, NULL);
}
}
- if (board->dc4 & (1 << 28)) {
- /* FIXME: Obey network model. */
+ if (board->dc4 & (1 << 28))
stellaris_enet_init(&nd_table[0], 0x40048000, pic[42]);
- }
if (board->peripherals & BP_GAMEPAD) {
qemu_irq gpad_irq[5];
static const int gpad_keycode[5] = { 0xc8, 0xd0, 0xcb, 0xcd, 0x1d };
diff --git a/hw/stellaris_enet.c b/hw/stellaris_enet.c
index a5cd163..88c5620 100644
--- a/hw/stellaris_enet.c
+++ b/hw/stellaris_enet.c
@@ -389,6 +389,8 @@ void stellaris_enet_init(NICInfo *nd, uint32_t base, qemu_irq irq)
stellaris_enet_state *s;
int iomemtype;
+ qemu_check_nic_model(nd, "stellaris");
+
s = (stellaris_enet_state *)qemu_mallocz(sizeof(stellaris_enet_state));
iomemtype = cpu_register_io_memory(0, stellaris_enet_readfn,
stellaris_enet_writefn, s);
diff --git a/hw/sun4m.c b/hw/sun4m.c
index e6a538a..c99ee1a 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -533,16 +533,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
tcx_init(ds, hwdef->tcx_base, phys_ram_base + tcx_offset, tcx_offset,
hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
- if (nd_table[0].model == NULL
- || strcmp(nd_table[0].model, "lance") == 0) {
- lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
- } else if (strcmp(nd_table[0].model, "?") == 0) {
- fprintf(stderr, "qemu: Supported NICs: lance\n");
- exit (1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
- exit (1);
- }
+ lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0,
hwdef->nvram_size, 8);
@@ -1325,16 +1316,7 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
tcx_init(ds, hwdef->tcx_base, phys_ram_base + tcx_offset, tcx_offset,
hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
- if (nd_table[0].model == NULL
- || strcmp(nd_table[0].model, "lance") == 0) {
- lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
- } else if (strcmp(nd_table[0].model, "?") == 0) {
- fprintf(stderr, "qemu: Supported NICs: lance\n");
- exit (1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
- exit (1);
- }
+ lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
nvram = m48t59_init(sbi_irq[0], hwdef->nvram_base, 0,
hwdef->nvram_size, 8);
@@ -1540,16 +1522,7 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
tcx_init(ds, hwdef->tcx_base, phys_ram_base + tcx_offset, tcx_offset,
hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
- if (nd_table[0].model == NULL
- || strcmp(nd_table[0].model, "lance") == 0) {
- lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
- } else if (strcmp(nd_table[0].model, "?") == 0) {
- fprintf(stderr, "qemu: Supported NICs: lance\n");
- exit (1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
- exit (1);
- }
+ lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0,
hwdef->nvram_size, 2);
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index e5d02f2..38c040d 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -194,11 +194,13 @@ static void versatile_init(ram_addr_t ram_size, int vga_ram_size,
so many of the qemu PCI devices are not useable. */
for(n = 0; n < nb_nics; n++) {
nd = &nd_table[n];
- if (!nd->model)
- nd->model = done_smc ? "rtl8139" : "smc91c111";
- if (strcmp(nd->model, "smc91c111") == 0) {
+
+ if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) {
smc91c111_init(nd, 0x10010000, sic[25]);
+ done_smc = 1;
} else {
+ if (!nd->model)
+ nd->model = "rtl8139";
pci_nic_init(pci_bus, nd, -1);
}
}
--
1.6.0.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 3/4] Make virtio_net_init() return void
2009-01-08 14:47 ` [Qemu-devel] [PATCH 2/4] Check NIC model in some NIC init functions Mark McLoughlin
@ 2009-01-08 14:47 ` Mark McLoughlin
2009-01-08 14:47 ` [Qemu-devel] [PATCH 4/4] Make pci_nic_init() use qemu_setup_nic_model() Mark McLoughlin
0 siblings, 1 reply; 12+ messages in thread
From: Mark McLoughlin @ 2009-01-08 14:47 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel, Mark McLoughlin
All PCI NIC init functions return void and nothing uses the
return value from virtio_net_init().
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
hw/virtio-net.c | 6 ++----
hw/virtio-net.h | 2 +-
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index de1f7ce..43fde20 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -299,7 +299,7 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
-PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
+void virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
{
VirtIONet *n;
static int virtio_net_id;
@@ -309,7 +309,7 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
0x02, 0x00, 0x00,
6, sizeof(VirtIONet));
if (!n)
- return NULL;
+ return;
n->vdev.get_config = virtio_net_update_config;
n->vdev.get_features = virtio_net_get_features;
@@ -328,6 +328,4 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
register_savevm("virtio-net", virtio_net_id++, 2,
virtio_net_save, virtio_net_load, n);
-
- return (PCIDevice *)n;
}
diff --git a/hw/virtio-net.h b/hw/virtio-net.h
index 0d9f71b..7446b11 100644
--- a/hw/virtio-net.h
+++ b/hw/virtio-net.h
@@ -75,6 +75,6 @@ struct virtio_net_hdr_mrg_rxbuf
uint16_t num_buffers; /* Number of merged rx buffers */
};
-PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn);
+void virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn);
#endif
--
1.6.0.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 4/4] Make pci_nic_init() use qemu_setup_nic_model()
2009-01-08 14:47 ` [Qemu-devel] [PATCH 3/4] Make virtio_net_init() return void Mark McLoughlin
@ 2009-01-08 14:47 ` Mark McLoughlin
0 siblings, 0 replies; 12+ messages in thread
From: Mark McLoughlin @ 2009-01-08 14:47 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel, Mark McLoughlin
Add a table of PCI NIC models to pass to qemu_setup_nic_model().
While we're at it, also add a corresponding table of NIC init
functions.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
hw/mips_malta.c | 17 ++++++--------
hw/pc.c | 26 ++++------------------
hw/pci.c | 60 ++++++++++++++++++++++++++++++---------------------
hw/pci.h | 3 +-
hw/ppc440_bamboo.c | 11 ++-------
hw/ppc_chrp.c | 8 ++----
hw/ppc_oldworld.c | 7 +----
hw/ppc_prep.c | 2 +-
hw/r2d.c | 4 +-
hw/realview.c | 4 +--
hw/sun4u.c | 7 +----
hw/versatilepb.c | 4 +--
12 files changed, 64 insertions(+), 89 deletions(-)
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 972c71c..3ca036b 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -487,19 +487,16 @@ static void audio_init (PCIBus *pci_bus)
static void network_init (PCIBus *pci_bus)
{
int i;
- NICInfo *nd;
for(i = 0; i < nb_nics; i++) {
- nd = &nd_table[i];
- if (!nd->model) {
- nd->model = "pcnet";
- }
- if (i == 0 && strcmp(nd->model, "pcnet") == 0) {
+ NICInfo *nd = &nd_table[i];
+ int devfn = -1;
+
+ if (i == 0 && (!nd->model || strcmp(nd->model, "pcnet") == 0))
/* The malta board has a PCNet card using PCI SLOT 11 */
- pci_nic_init(pci_bus, nd, 88);
- } else {
- pci_nic_init(pci_bus, nd, -1);
- }
+ devfn = 88;
+
+ pci_nic_init(pci_bus, nd, devfn, "pcnet");
}
}
diff --git a/hw/pc.c b/hw/pc.c
index 64c08a4..6a1c8ec 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -764,7 +764,6 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
PCIBus *pci_bus;
int piix3_devfn = -1;
CPUState *env;
- NICInfo *nd;
qemu_irq *cpu_irq;
qemu_irq *i8259;
int index;
@@ -1000,27 +999,12 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
}
for(i = 0; i < nb_nics; i++) {
- nd = &nd_table[i];
- if (!nd->model) {
- if (pci_enabled) {
- nd->model = "ne2k_pci";
- } else {
- nd->model = "ne2k_isa";
- }
- }
- if (strcmp(nd->model, "ne2k_isa") == 0) {
+ NICInfo *nd = &nd_table[i];
+
+ if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0))
pc_init_ne2k_isa(nd, i8259);
- } else if (pci_enabled) {
- if (strcmp(nd->model, "?") == 0)
- fprintf(stderr, "qemu: Supported ISA NICs: ne2k_isa\n");
- pci_nic_init(pci_bus, nd, -1);
- } else if (strcmp(nd->model, "?") == 0) {
- fprintf(stderr, "qemu: Supported ISA NICs: ne2k_isa\n");
- exit(1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
- exit(1);
- }
+ else
+ pci_nic_init(pci_bus, nd, -1, "ne2k_pci");
}
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
diff --git a/hw/pci.c b/hw/pci.c
index 8252d21..bba50d0 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -652,33 +652,43 @@ void pci_info(void)
pci_for_each_device(0, pci_info_device);
}
+static const char * const pci_nic_models[] = {
+ "ne2k_pci",
+ "i82551",
+ "i82557b",
+ "i82559er",
+ "rtl8139",
+ "e1000",
+ "pcnet",
+ "virtio",
+ NULL
+};
+
+typedef void (*PCINICInitFn)(PCIBus *, NICInfo *, int);
+
+static PCINICInitFn pci_nic_init_fns[] = {
+ pci_ne2000_init,
+ pci_i82551_init,
+ pci_i82557b_init,
+ pci_i82559er_init,
+ pci_rtl8139_init,
+ pci_e1000_init,
+ pci_pcnet_init,
+ virtio_net_init,
+ NULL
+};
+
/* Initialize a PCI NIC. */
-void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn)
+void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn,
+ const char *default_model)
{
- if (strcmp(nd->model, "ne2k_pci") == 0) {
- pci_ne2000_init(bus, nd, devfn);
- } else if (strcmp(nd->model, "i82551") == 0) {
- pci_i82551_init(bus, nd, devfn);
- } else if (strcmp(nd->model, "i82557b") == 0) {
- pci_i82557b_init(bus, nd, devfn);
- } else if (strcmp(nd->model, "i82559er") == 0) {
- pci_i82559er_init(bus, nd, devfn);
- } else if (strcmp(nd->model, "rtl8139") == 0) {
- pci_rtl8139_init(bus, nd, devfn);
- } else if (strcmp(nd->model, "e1000") == 0) {
- pci_e1000_init(bus, nd, devfn);
- } else if (strcmp(nd->model, "pcnet") == 0) {
- pci_pcnet_init(bus, nd, devfn);
- } else if (strcmp(nd->model, "virtio") == 0) {
- virtio_net_init(bus, nd, devfn);
- } else if (strcmp(nd->model, "?") == 0) {
- fprintf(stderr, "qemu: Supported PCI NICs: i82551 i82557b i82559er"
- " ne2k_pci pcnet rtl8139 e1000 virtio\n");
- exit (1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
- exit (1);
- }
+ int i;
+
+ qemu_check_nic_model_list(nd, pci_nic_models, default_model);
+
+ for (i = 0; pci_nic_models[i]; i++)
+ if (strcmp(nd->model, pci_nic_models[i]) == 0)
+ pci_nic_init_fns[i](bus, nd, devfn);
}
typedef struct {
diff --git a/hw/pci.h b/hw/pci.h
index 3b1caf5..77a2a63 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -118,7 +118,8 @@ typedef int (*pci_map_irq_fn)(PCIDevice *pci_dev, int irq_num);
PCIBus *pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
qemu_irq *pic, int devfn_min, int nirq);
-void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn);
+void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn,
+ const char *default_model);
void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len);
uint32_t pci_data_read(void *opaque, uint32_t addr, int len);
int pci_bus_num(PCIBus *s);
diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
index a6fc758..bc8a47b 100644
--- a/hw/ppc440_bamboo.c
+++ b/hw/ppc440_bamboo.c
@@ -90,7 +90,6 @@ static void bamboo_init(ram_addr_t ram_size, int vga_ram_size,
const char *cpu_model)
{
unsigned int pci_irq_nrs[4] = { 28, 27, 26, 25 };
- NICInfo *nd;
PCIBus *pcibus;
CPUState *env;
uint64_t elf_entry;
@@ -118,13 +117,9 @@ static void bamboo_init(ram_addr_t ram_size, int vga_ram_size,
/* Register network interfaces. */
for (i = 0; i < nb_nics; i++) {
- nd = &nd_table[i];
- if (!nd->model) {
- /* There are no PCI NICs on the Bamboo board, but there are
- * PCI slots, so we can pick model whatever we want. */
- nd->model = "e1000";
- }
- pci_nic_init(pcibus, nd, -1);
+ /* There are no PCI NICs on the Bamboo board, but there are
+ * PCI slots, so we can pick whatever default model we want. */
+ pci_nic_init(pcibus, &nd_table[i], -1, "e1000");
}
}
diff --git a/hw/ppc_chrp.c b/hw/ppc_chrp.c
index 5bdb805..dae5a1a 100644
--- a/hw/ppc_chrp.c
+++ b/hw/ppc_chrp.c
@@ -264,11 +264,9 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size,
/* XXX: use Mac Serial port */
serial_init(0x3f8, dummy_irq[4], 115200, serial_hds[0]);
- for(i = 0; i < nb_nics; i++) {
- if (!nd_table[i].model)
- nd_table[i].model = "ne2k_pci";
- pci_nic_init(pci_bus, &nd_table[i], -1);
- }
+ for(i = 0; i < nb_nics; i++)
+ pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
+
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index 1d5e9d6..4a9f832 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -305,11 +305,8 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size,
/* XXX: use Mac Serial port */
serial_init(0x3f8, dummy_irq[4], 115200, serial_hds[0]);
- for(i = 0; i < nb_nics; i++) {
- if (!nd_table[i].model)
- nd_table[i].model = "ne2k_pci";
- pci_nic_init(pci_bus, &nd_table[i], -1);
- }
+ for(i = 0; i < nb_nics; i++)
+ pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
/* First IDE channel is a CMD646 on the PCI bus */
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 571c48e..308b7af 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -675,7 +675,7 @@ static void ppc_prep_init (ram_addr_t ram_size, int vga_ram_size,
|| strcmp(nd_table[i].model, "ne2k_isa") == 0) {
isa_ne2000_init(ne2000_io[i], i8259[ne2000_irq[i]], &nd_table[i]);
} else {
- pci_nic_init(pci_bus, &nd_table[i], -1);
+ pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
}
}
diff --git a/hw/r2d.c b/hw/r2d.c
index 5d5eb1e..88853e7 100644
--- a/hw/r2d.c
+++ b/hw/r2d.c
@@ -230,9 +230,9 @@ static void r2d_init(ram_addr_t ram_size, int vga_ram_size,
drives_table[drive_get_index(IF_IDE, 0, 0)].bdrv, NULL);
/* NIC: rtl8139 on-board, and 2 slots. */
- pci_rtl8139_init(pci, &nd_table[0], 2 << 3);
+ pci_nic_init(pci, &nd_table[0], 2 << 3, "rtl8139");
for (i = 1; i < nb_nics; i++)
- pci_nic_init(pci, &nd_table[i], -1);
+ pci_nic_init(pci, &nd_table[i], -1, "ne2k_pci");
/* Todo: register on board registers */
{
diff --git a/hw/realview.c b/hw/realview.c
index 5abbc16..e285338 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -126,9 +126,7 @@ static void realview_init(ram_addr_t ram_size, int vga_ram_size,
smc91c111_init(nd, 0x4e000000, pic[28]);
done_smc = 1;
} else {
- if (!nd->model)
- nd->model = "rtl8139";
- pci_nic_init(pci_bus, nd, -1);
+ pci_nic_init(pci_bus, nd, -1, "rtl8139");
}
}
diff --git a/hw/sun4u.c b/hw/sun4u.c
index b3ecc1e..9a6de32 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -488,11 +488,8 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size,
}
}
- for(i = 0; i < nb_nics; i++) {
- if (!nd_table[i].model)
- nd_table[i].model = "ne2k_pci";
- pci_nic_init(pci_bus, &nd_table[i], -1);
- }
+ for(i = 0; i < nb_nics; i++)
+ pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
irq = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS);
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index 38c040d..267aa42 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -199,9 +199,7 @@ static void versatile_init(ram_addr_t ram_size, int vga_ram_size,
smc91c111_init(nd, 0x10010000, sic[25]);
done_smc = 1;
} else {
- if (!nd->model)
- nd->model = "rtl8139";
- pci_nic_init(pci_bus, nd, -1);
+ pci_nic_init(pci_bus, nd, -1, "rtl8139");
}
}
if (usb_enabled) {
--
1.6.0.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 1/3] Check NIC model in some NIC init functions
2009-01-08 14:47 ` [Qemu-devel] [PATCH 1/4] Add qemu_check_nic_model() and qemu_check_nic_model_list() Mark McLoughlin
2009-01-08 14:47 ` [Qemu-devel] [PATCH 2/4] Check NIC model in some NIC init functions Mark McLoughlin
@ 2009-01-13 19:25 ` Mark McLoughlin
2009-01-13 19:25 ` [Qemu-devel] [PATCH 2/3] Make virtio_net_init() return void Mark McLoughlin
2009-01-13 19:47 ` [Qemu-devel] Re: [PATCH 1/3] Check NIC model in some NIC init functions Anthony Liguori
1 sibling, 2 replies; 12+ messages in thread
From: Mark McLoughlin @ 2009-01-13 19:25 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Mark McLoughlin, qemu-devel
Some NIC init functions are only called when that model is
the only valid model. In that case, it makes sense to use
qemu_check_nic_model() from the NIC init function itself.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
hw/axis_dev88.c | 5 +----
hw/etraxfs.c | 5 +----
hw/etraxfs_eth.c | 2 ++
hw/integratorcp.c | 14 ++------------
hw/mcf5208.c | 14 ++------------
hw/mcf_fec.c | 2 ++
hw/mips_mipssim.c | 16 +++-------------
hw/mips_r4k.c | 16 ++--------------
hw/mipsnet.c | 2 ++
hw/musicpal.c | 2 ++
hw/ne2000.c | 2 ++
hw/pcnet.c | 2 ++
hw/realview.c | 8 +++++---
hw/smc91c111.c | 2 ++
hw/stellaris.c | 4 +---
hw/stellaris_enet.c | 2 ++
hw/sun4m.c | 36 +++---------------------------------
hw/versatilepb.c | 8 +++++---
18 files changed, 41 insertions(+), 101 deletions(-)
diff --git a/hw/axis_dev88.c b/hw/axis_dev88.c
index c20524b..066b969 100644
--- a/hw/axis_dev88.c
+++ b/hw/axis_dev88.c
@@ -303,13 +303,10 @@ void axisdev88_init (ram_addr_t ram_size, int vga_ram_size,
}
/* Add the two ethernet blocks. */
- nd_table[0].model = nd_table[0].model ? nd_table[0].model : "fseth";
eth[0] = etraxfs_eth_init(&nd_table[0], env, pic->irq + 25, 0x30034000, 1);
- if (nb_nics > 1) {
- nd_table[1].model = nd_table[1].model ? nd_table[1].model : "fseth";
+ if (nb_nics > 1)
eth[1] = etraxfs_eth_init(&nd_table[1], env,
pic->irq + 26, 0x30036000, 2);
- }
/* The DMA Connector block is missing, hardwire things for now. */
etraxfs_dmac_connect_client(etraxfs_dmac, 0, eth[0]);
diff --git a/hw/etraxfs.c b/hw/etraxfs.c
index 01569bc..e409a94 100644
--- a/hw/etraxfs.c
+++ b/hw/etraxfs.c
@@ -94,13 +94,10 @@ void bareetraxfs_init (ram_addr_t ram_size, int vga_ram_size,
}
/* Add the two ethernet blocks. */
- nd_table[0].model = nd_table[0].model ? nd_table[0].model : "fseth";
eth[0] = etraxfs_eth_init(&nd_table[0], env, pic->irq + 25, 0x30034000, 1);
- if (nb_nics > 1) {
- nd_table[1].model = nd_table[1].model ? nd_table[1].model : "fseth";
+ if (nb_nics > 1)
eth[1] = etraxfs_eth_init(&nd_table[1], env,
pic->irq + 26, 0x30036000, 2);
- }
/* The DMA Connector block is missing, hardwire things for now. */
etraxfs_dmac_connect_client(etraxfs_dmac, 0, eth[0]);
diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c
index 4ae97b1..cce8917 100644
--- a/hw/etraxfs_eth.c
+++ b/hw/etraxfs_eth.c
@@ -561,6 +561,8 @@ void *etraxfs_eth_init(NICInfo *nd, CPUState *env,
struct etraxfs_dma_client *dma = NULL;
struct fs_eth *eth = NULL;
+ qemu_check_nic_model(nd, "fseth");
+
dma = qemu_mallocz(sizeof *dma * 2);
if (!dma)
return NULL;
diff --git a/hw/integratorcp.c b/hw/integratorcp.c
index a2d3d43..fdbfe20 100644
--- a/hw/integratorcp.c
+++ b/hw/integratorcp.c
@@ -497,18 +497,8 @@ static void integratorcp_init(ram_addr_t ram_size, int vga_ram_size,
exit(1);
}
pl181_init(0x1c000000, drives_table[sd].bdrv, pic[23], pic[24]);
- if (nd_table[0].vlan) {
- if (nd_table[0].model == NULL
- || strcmp(nd_table[0].model, "smc91c111") == 0) {
- smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
- } else if (strcmp(nd_table[0].model, "?") == 0) {
- fprintf(stderr, "qemu: Supported NICs: smc91c111\n");
- exit (1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
- exit (1);
- }
- }
+ if (nd_table[0].vlan)
+ smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
pl110_init(ds, 0xc0000000, pic[22], 0);
integrator_binfo.ram_size = ram_size;
diff --git a/hw/mcf5208.c b/hw/mcf5208.c
index 71ba3fb..f06c25a 100644
--- a/hw/mcf5208.c
+++ b/hw/mcf5208.c
@@ -241,18 +241,8 @@ static void mcf5208evb_init(ram_addr_t ram_size, int vga_ram_size,
fprintf(stderr, "Too many NICs\n");
exit(1);
}
- if (nd_table[0].vlan) {
- if (nd_table[0].model == NULL
- || strcmp(nd_table[0].model, "mcf_fec") == 0) {
- mcf_fec_init(&nd_table[0], 0xfc030000, pic + 36);
- } else if (strcmp(nd_table[0].model, "?") == 0) {
- fprintf(stderr, "qemu: Supported NICs: mcf_fec\n");
- exit (1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
- exit (1);
- }
- }
+ if (nd_table[0].vlan)
+ mcf_fec_init(&nd_table[0], 0xfc030000, pic + 36);
/* 0xfc000000 SCM. */
/* 0xfc004000 XBS. */
diff --git a/hw/mcf_fec.c b/hw/mcf_fec.c
index 49ae69b..413c569 100644
--- a/hw/mcf_fec.c
+++ b/hw/mcf_fec.c
@@ -446,6 +446,8 @@ void mcf_fec_init(NICInfo *nd, target_phys_addr_t base, qemu_irq *irq)
mcf_fec_state *s;
int iomemtype;
+ qemu_check_nic_model(nd, "mcf_fec");
+
s = (mcf_fec_state *)qemu_mallocz(sizeof(mcf_fec_state));
s->irq = irq;
iomemtype = cpu_register_io_memory(0, mcf_fec_readfn,
diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c
index dc62f69..83f1a63 100644
--- a/hw/mips_mipssim.c
+++ b/hw/mips_mipssim.c
@@ -175,19 +175,9 @@ mips_mipssim_init (ram_addr_t ram_size, int vga_ram_size,
if (serial_hds[0])
serial_init(0x3f8, env->irq[4], 115200, serial_hds[0]);
- if (nd_table[0].vlan) {
- if (nd_table[0].model == NULL
- || strcmp(nd_table[0].model, "mipsnet") == 0) {
- /* MIPSnet uses the MIPS CPU INT0, which is interrupt 2. */
- mipsnet_init(0x4200, env->irq[2], &nd_table[0]);
- } else if (strcmp(nd_table[0].model, "?") == 0) {
- fprintf(stderr, "qemu: Supported NICs: mipsnet\n");
- exit (1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
- exit (1);
- }
- }
+ if (nd_table[0].vlan)
+ /* MIPSnet uses the MIPS CPU INT0, which is interrupt 2. */
+ mipsnet_init(0x4200, env->irq[2], &nd_table[0]);
}
QEMUMachine mips_mipssim_machine = {
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index 56a1719..c12ab54 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -247,20 +247,8 @@ void mips_r4k_init (ram_addr_t ram_size, int vga_ram_size,
isa_vga_init(ds, phys_ram_base + ram_size, ram_size,
vga_ram_size);
- if (nd_table[0].vlan) {
- if (nd_table[i].model == NULL) {
- nd_table[i].model = "ne2k_isa";
- }
- if (strcmp(nd_table[0].model, "ne2k_isa") == 0) {
- isa_ne2000_init(0x300, i8259[9], &nd_table[0]);
- } else if (strcmp(nd_table[0].model, "?") == 0) {
- fprintf(stderr, "qemu: Supported NICs: ne2k_isa\n");
- exit (1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
- exit (1);
- }
- }
+ if (nd_table[0].vlan)
+ isa_ne2000_init(0x300, i8259[9], &nd_table[0]);
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
diff --git a/hw/mipsnet.c b/hw/mipsnet.c
index 0eb4c1e..04ce322 100644
--- a/hw/mipsnet.c
+++ b/hw/mipsnet.c
@@ -236,6 +236,8 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd)
{
MIPSnetState *s;
+ qemu_check_nic_model(nd, "mipsnet");
+
s = qemu_mallocz(sizeof(MIPSnetState));
if (!s)
return;
diff --git a/hw/musicpal.c b/hw/musicpal.c
index 1c932ec..f64bb1c 100644
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -714,6 +714,8 @@ static void mv88w8618_eth_init(NICInfo *nd, uint32_t base, qemu_irq irq)
mv88w8618_eth_state *s;
int iomemtype;
+ qemu_check_nic_model(nd, "mv88w8618");
+
s = qemu_mallocz(sizeof(mv88w8618_eth_state));
if (!s)
return;
diff --git a/hw/ne2000.c b/hw/ne2000.c
index 200db90..a85730f 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -722,6 +722,8 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd)
{
NE2000State *s;
+ qemu_check_nic_model(nd, "ne2k_isa");
+
s = qemu_mallocz(sizeof(NE2000State));
if (!s)
return;
diff --git a/hw/pcnet.c b/hw/pcnet.c
index 102166e..6198968 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -2087,6 +2087,8 @@ void lance_init(NICInfo *nd, target_phys_addr_t leaddr, void *dma_opaque,
PCNetState *d;
int lance_io_memory;
+ qemu_check_nic_model(nd, "lance");
+
d = qemu_mallocz(sizeof(PCNetState));
if (!d)
return;
diff --git a/hw/realview.c b/hw/realview.c
index a9d20ed..5abbc16 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -121,11 +121,13 @@ static void realview_init(ram_addr_t ram_size, int vga_ram_size,
}
for(n = 0; n < nb_nics; n++) {
nd = &nd_table[n];
- if (!nd->model)
- nd->model = done_smc ? "rtl8139" : "smc91c111";
- if (strcmp(nd->model, "smc91c111") == 0) {
+
+ if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) {
smc91c111_init(nd, 0x4e000000, pic[28]);
+ done_smc = 1;
} else {
+ if (!nd->model)
+ nd->model = "rtl8139";
pci_nic_init(pci_bus, nd, -1);
}
}
diff --git a/hw/smc91c111.c b/hw/smc91c111.c
index 27a3158..f5b29a7 100644
--- a/hw/smc91c111.c
+++ b/hw/smc91c111.c
@@ -695,6 +695,8 @@ void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq)
smc91c111_state *s;
int iomemtype;
+ qemu_check_nic_model(nd, "smc91c111");
+
s = (smc91c111_state *)qemu_mallocz(sizeof(smc91c111_state));
iomemtype = cpu_register_io_memory(0, smc91c111_readfn,
smc91c111_writefn, s);
diff --git a/hw/stellaris.c b/hw/stellaris.c
index 703ef7e..7069518 100644
--- a/hw/stellaris.c
+++ b/hw/stellaris.c
@@ -1361,10 +1361,8 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model,
pl022_init(0x40008000, pic[7], NULL, NULL);
}
}
- if (board->dc4 & (1 << 28)) {
- /* FIXME: Obey network model. */
+ if (board->dc4 & (1 << 28))
stellaris_enet_init(&nd_table[0], 0x40048000, pic[42]);
- }
if (board->peripherals & BP_GAMEPAD) {
qemu_irq gpad_irq[5];
static const int gpad_keycode[5] = { 0xc8, 0xd0, 0xcb, 0xcd, 0x1d };
diff --git a/hw/stellaris_enet.c b/hw/stellaris_enet.c
index a5cd163..88c5620 100644
--- a/hw/stellaris_enet.c
+++ b/hw/stellaris_enet.c
@@ -389,6 +389,8 @@ void stellaris_enet_init(NICInfo *nd, uint32_t base, qemu_irq irq)
stellaris_enet_state *s;
int iomemtype;
+ qemu_check_nic_model(nd, "stellaris");
+
s = (stellaris_enet_state *)qemu_mallocz(sizeof(stellaris_enet_state));
iomemtype = cpu_register_io_memory(0, stellaris_enet_readfn,
stellaris_enet_writefn, s);
diff --git a/hw/sun4m.c b/hw/sun4m.c
index fffd173..1679a1d 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -536,17 +536,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
tcx_init(ds, hwdef->tcx_base, phys_ram_base + tcx_offset, tcx_offset,
hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
- if (nd_table[0].model == NULL)
- nd_table[0].model = "lance";
- if (strcmp(nd_table[0].model, "lance") == 0) {
- lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
- } else if (strcmp(nd_table[0].model, "?") == 0) {
- fprintf(stderr, "qemu: Supported NICs: lance\n");
- exit (1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
- exit (1);
- }
+ lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0,
hwdef->nvram_size, 8);
@@ -1329,17 +1319,7 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
tcx_init(ds, hwdef->tcx_base, phys_ram_base + tcx_offset, tcx_offset,
hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
- if (nd_table[0].model == NULL)
- nd_table[0].model = "lance";
- if (strcmp(nd_table[0].model, "lance") == 0) {
- lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
- } else if (strcmp(nd_table[0].model, "?") == 0) {
- fprintf(stderr, "qemu: Supported NICs: lance\n");
- exit (1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
- exit (1);
- }
+ lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
nvram = m48t59_init(sbi_irq[0], hwdef->nvram_base, 0,
hwdef->nvram_size, 8);
@@ -1545,17 +1525,7 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
tcx_init(ds, hwdef->tcx_base, phys_ram_base + tcx_offset, tcx_offset,
hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
- if (nd_table[0].model == NULL)
- nd_table[0].model = "lance";
- if (strcmp(nd_table[0].model, "lance") == 0) {
- lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
- } else if (strcmp(nd_table[0].model, "?") == 0) {
- fprintf(stderr, "qemu: Supported NICs: lance\n");
- exit (1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
- exit (1);
- }
+ lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0,
hwdef->nvram_size, 2);
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index e5d02f2..38c040d 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -194,11 +194,13 @@ static void versatile_init(ram_addr_t ram_size, int vga_ram_size,
so many of the qemu PCI devices are not useable. */
for(n = 0; n < nb_nics; n++) {
nd = &nd_table[n];
- if (!nd->model)
- nd->model = done_smc ? "rtl8139" : "smc91c111";
- if (strcmp(nd->model, "smc91c111") == 0) {
+
+ if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) {
smc91c111_init(nd, 0x10010000, sic[25]);
+ done_smc = 1;
} else {
+ if (!nd->model)
+ nd->model = "rtl8139";
pci_nic_init(pci_bus, nd, -1);
}
}
--
1.6.0.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 2/3] Make virtio_net_init() return void
2009-01-13 19:25 ` [Qemu-devel] [PATCH 1/3] Check NIC model in some NIC init functions Mark McLoughlin
@ 2009-01-13 19:25 ` Mark McLoughlin
2009-01-13 19:25 ` [Qemu-devel] [PATCH 3/3] Make pci_nic_init() use qemu_setup_nic_model() Mark McLoughlin
2009-01-13 19:47 ` [Qemu-devel] Re: [PATCH 1/3] Check NIC model in some NIC init functions Anthony Liguori
1 sibling, 1 reply; 12+ messages in thread
From: Mark McLoughlin @ 2009-01-13 19:25 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Mark McLoughlin, qemu-devel
All PCI NIC init functions return void and nothing uses the
return value from virtio_net_init().
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
hw/virtio-net.c | 6 ++----
hw/virtio-net.h | 2 +-
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 5eca19c..54c0030 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -315,7 +315,7 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
-PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
+void virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
{
VirtIONet *n;
static int virtio_net_id;
@@ -326,7 +326,7 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
sizeof(struct virtio_net_config),
sizeof(VirtIONet));
if (!n)
- return NULL;
+ return;
n->vdev.get_config = virtio_net_update_config;
n->vdev.get_features = virtio_net_get_features;
@@ -347,6 +347,4 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
register_savevm("virtio-net", virtio_net_id++, 2,
virtio_net_save, virtio_net_load, n);
-
- return (PCIDevice *)n;
}
diff --git a/hw/virtio-net.h b/hw/virtio-net.h
index 9ac9e34..148ec47 100644
--- a/hw/virtio-net.h
+++ b/hw/virtio-net.h
@@ -80,6 +80,6 @@ struct virtio_net_hdr_mrg_rxbuf
uint16_t num_buffers; /* Number of merged rx buffers */
};
-PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn);
+void virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn);
#endif
--
1.6.0.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 3/3] Make pci_nic_init() use qemu_setup_nic_model()
2009-01-13 19:25 ` [Qemu-devel] [PATCH 2/3] Make virtio_net_init() return void Mark McLoughlin
@ 2009-01-13 19:25 ` Mark McLoughlin
0 siblings, 0 replies; 12+ messages in thread
From: Mark McLoughlin @ 2009-01-13 19:25 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Mark McLoughlin, qemu-devel
Add a table of PCI NIC models to pass to qemu_setup_nic_model().
While we're at it, also add a corresponding table of NIC init
functions.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
hw/mips_malta.c | 17 ++++++--------
hw/pc.c | 26 ++++------------------
hw/pci.c | 60 ++++++++++++++++++++++++++++++---------------------
hw/pci.h | 3 +-
hw/ppc440_bamboo.c | 11 ++-------
hw/ppc_chrp.c | 9 +++----
hw/ppc_oldworld.c | 7 +----
hw/ppc_prep.c | 2 +-
hw/r2d.c | 4 +-
hw/realview.c | 4 +--
hw/sun4u.c | 7 +----
hw/versatilepb.c | 4 +--
12 files changed, 65 insertions(+), 89 deletions(-)
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 972c71c..3ca036b 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -487,19 +487,16 @@ static void audio_init (PCIBus *pci_bus)
static void network_init (PCIBus *pci_bus)
{
int i;
- NICInfo *nd;
for(i = 0; i < nb_nics; i++) {
- nd = &nd_table[i];
- if (!nd->model) {
- nd->model = "pcnet";
- }
- if (i == 0 && strcmp(nd->model, "pcnet") == 0) {
+ NICInfo *nd = &nd_table[i];
+ int devfn = -1;
+
+ if (i == 0 && (!nd->model || strcmp(nd->model, "pcnet") == 0))
/* The malta board has a PCNet card using PCI SLOT 11 */
- pci_nic_init(pci_bus, nd, 88);
- } else {
- pci_nic_init(pci_bus, nd, -1);
- }
+ devfn = 88;
+
+ pci_nic_init(pci_bus, nd, devfn, "pcnet");
}
}
diff --git a/hw/pc.c b/hw/pc.c
index 64c08a4..6a1c8ec 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -764,7 +764,6 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
PCIBus *pci_bus;
int piix3_devfn = -1;
CPUState *env;
- NICInfo *nd;
qemu_irq *cpu_irq;
qemu_irq *i8259;
int index;
@@ -1000,27 +999,12 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
}
for(i = 0; i < nb_nics; i++) {
- nd = &nd_table[i];
- if (!nd->model) {
- if (pci_enabled) {
- nd->model = "ne2k_pci";
- } else {
- nd->model = "ne2k_isa";
- }
- }
- if (strcmp(nd->model, "ne2k_isa") == 0) {
+ NICInfo *nd = &nd_table[i];
+
+ if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0))
pc_init_ne2k_isa(nd, i8259);
- } else if (pci_enabled) {
- if (strcmp(nd->model, "?") == 0)
- fprintf(stderr, "qemu: Supported ISA NICs: ne2k_isa\n");
- pci_nic_init(pci_bus, nd, -1);
- } else if (strcmp(nd->model, "?") == 0) {
- fprintf(stderr, "qemu: Supported ISA NICs: ne2k_isa\n");
- exit(1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
- exit(1);
- }
+ else
+ pci_nic_init(pci_bus, nd, -1, "ne2k_pci");
}
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
diff --git a/hw/pci.c b/hw/pci.c
index 8252d21..bba50d0 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -652,33 +652,43 @@ void pci_info(void)
pci_for_each_device(0, pci_info_device);
}
+static const char * const pci_nic_models[] = {
+ "ne2k_pci",
+ "i82551",
+ "i82557b",
+ "i82559er",
+ "rtl8139",
+ "e1000",
+ "pcnet",
+ "virtio",
+ NULL
+};
+
+typedef void (*PCINICInitFn)(PCIBus *, NICInfo *, int);
+
+static PCINICInitFn pci_nic_init_fns[] = {
+ pci_ne2000_init,
+ pci_i82551_init,
+ pci_i82557b_init,
+ pci_i82559er_init,
+ pci_rtl8139_init,
+ pci_e1000_init,
+ pci_pcnet_init,
+ virtio_net_init,
+ NULL
+};
+
/* Initialize a PCI NIC. */
-void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn)
+void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn,
+ const char *default_model)
{
- if (strcmp(nd->model, "ne2k_pci") == 0) {
- pci_ne2000_init(bus, nd, devfn);
- } else if (strcmp(nd->model, "i82551") == 0) {
- pci_i82551_init(bus, nd, devfn);
- } else if (strcmp(nd->model, "i82557b") == 0) {
- pci_i82557b_init(bus, nd, devfn);
- } else if (strcmp(nd->model, "i82559er") == 0) {
- pci_i82559er_init(bus, nd, devfn);
- } else if (strcmp(nd->model, "rtl8139") == 0) {
- pci_rtl8139_init(bus, nd, devfn);
- } else if (strcmp(nd->model, "e1000") == 0) {
- pci_e1000_init(bus, nd, devfn);
- } else if (strcmp(nd->model, "pcnet") == 0) {
- pci_pcnet_init(bus, nd, devfn);
- } else if (strcmp(nd->model, "virtio") == 0) {
- virtio_net_init(bus, nd, devfn);
- } else if (strcmp(nd->model, "?") == 0) {
- fprintf(stderr, "qemu: Supported PCI NICs: i82551 i82557b i82559er"
- " ne2k_pci pcnet rtl8139 e1000 virtio\n");
- exit (1);
- } else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
- exit (1);
- }
+ int i;
+
+ qemu_check_nic_model_list(nd, pci_nic_models, default_model);
+
+ for (i = 0; pci_nic_models[i]; i++)
+ if (strcmp(nd->model, pci_nic_models[i]) == 0)
+ pci_nic_init_fns[i](bus, nd, devfn);
}
typedef struct {
diff --git a/hw/pci.h b/hw/pci.h
index d34f618..76f4474 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -118,7 +118,8 @@ typedef int (*pci_map_irq_fn)(PCIDevice *pci_dev, int irq_num);
PCIBus *pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
qemu_irq *pic, int devfn_min, int nirq);
-void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn);
+void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn,
+ const char *default_model);
void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len);
uint32_t pci_data_read(void *opaque, uint32_t addr, int len);
int pci_bus_num(PCIBus *s);
diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
index a6fc758..bc8a47b 100644
--- a/hw/ppc440_bamboo.c
+++ b/hw/ppc440_bamboo.c
@@ -90,7 +90,6 @@ static void bamboo_init(ram_addr_t ram_size, int vga_ram_size,
const char *cpu_model)
{
unsigned int pci_irq_nrs[4] = { 28, 27, 26, 25 };
- NICInfo *nd;
PCIBus *pcibus;
CPUState *env;
uint64_t elf_entry;
@@ -118,13 +117,9 @@ static void bamboo_init(ram_addr_t ram_size, int vga_ram_size,
/* Register network interfaces. */
for (i = 0; i < nb_nics; i++) {
- nd = &nd_table[i];
- if (!nd->model) {
- /* There are no PCI NICs on the Bamboo board, but there are
- * PCI slots, so we can pick model whatever we want. */
- nd->model = "e1000";
- }
- pci_nic_init(pcibus, nd, -1);
+ /* There are no PCI NICs on the Bamboo board, but there are
+ * PCI slots, so we can pick whatever default model we want. */
+ pci_nic_init(pcibus, &nd_table[i], -1, "e1000");
}
}
diff --git a/hw/ppc_chrp.c b/hw/ppc_chrp.c
index d57e286..7625cd1 100644
--- a/hw/ppc_chrp.c
+++ b/hw/ppc_chrp.c
@@ -265,11 +265,10 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size,
escc_mem_index = escc_init(0x80013000, dummy_irq[4], serial_hds[0],
serial_hds[1], ESCC_CLOCK, 4);
- for(i = 0; i < nb_nics; i++) {
- if (!nd_table[i].model)
- nd_table[i].model = "ne2k_pci";
- pci_nic_init(pci_bus, &nd_table[i], -1);
- }
+
+ for(i = 0; i < nb_nics; i++)
+ pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
+
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index 7ae555d..cf8b24f 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -307,11 +307,8 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size,
escc_mem_index = escc_init(0x80013000, pic[0x10], serial_hds[0],
serial_hds[1], ESCC_CLOCK, 4);
- for(i = 0; i < nb_nics; i++) {
- if (!nd_table[i].model)
- nd_table[i].model = "ne2k_pci";
- pci_nic_init(pci_bus, &nd_table[i], -1);
- }
+ for(i = 0; i < nb_nics; i++)
+ pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
/* First IDE channel is a CMD646 on the PCI bus */
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index d602399..6c0d8fe 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -677,7 +677,7 @@ static void ppc_prep_init (ram_addr_t ram_size, int vga_ram_size,
if (strcmp(nd_table[i].model, "ne2k_isa") == 0) {
isa_ne2000_init(ne2000_io[i], i8259[ne2000_irq[i]], &nd_table[i]);
} else {
- pci_nic_init(pci_bus, &nd_table[i], -1);
+ pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
}
}
diff --git a/hw/r2d.c b/hw/r2d.c
index 5d5eb1e..88853e7 100644
--- a/hw/r2d.c
+++ b/hw/r2d.c
@@ -230,9 +230,9 @@ static void r2d_init(ram_addr_t ram_size, int vga_ram_size,
drives_table[drive_get_index(IF_IDE, 0, 0)].bdrv, NULL);
/* NIC: rtl8139 on-board, and 2 slots. */
- pci_rtl8139_init(pci, &nd_table[0], 2 << 3);
+ pci_nic_init(pci, &nd_table[0], 2 << 3, "rtl8139");
for (i = 1; i < nb_nics; i++)
- pci_nic_init(pci, &nd_table[i], -1);
+ pci_nic_init(pci, &nd_table[i], -1, "ne2k_pci");
/* Todo: register on board registers */
{
diff --git a/hw/realview.c b/hw/realview.c
index 5abbc16..e285338 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -126,9 +126,7 @@ static void realview_init(ram_addr_t ram_size, int vga_ram_size,
smc91c111_init(nd, 0x4e000000, pic[28]);
done_smc = 1;
} else {
- if (!nd->model)
- nd->model = "rtl8139";
- pci_nic_init(pci_bus, nd, -1);
+ pci_nic_init(pci_bus, nd, -1, "rtl8139");
}
}
diff --git a/hw/sun4u.c b/hw/sun4u.c
index 35f299c..91e7538 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -535,11 +535,8 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size,
}
}
- for(i = 0; i < nb_nics; i++) {
- if (!nd_table[i].model)
- nd_table[i].model = "ne2k_pci";
- pci_nic_init(pci_bus, &nd_table[i], -1);
- }
+ for(i = 0; i < nb_nics; i++)
+ pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
irq = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS);
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index 38c040d..267aa42 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -199,9 +199,7 @@ static void versatile_init(ram_addr_t ram_size, int vga_ram_size,
smc91c111_init(nd, 0x10010000, sic[25]);
done_smc = 1;
} else {
- if (!nd->model)
- nd->model = "rtl8139";
- pci_nic_init(pci_bus, nd, -1);
+ pci_nic_init(pci_bus, nd, -1, "rtl8139");
}
}
if (usb_enabled) {
--
1.6.0.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] Re: [PATCH 1/3] Check NIC model in some NIC init functions
2009-01-13 19:25 ` [Qemu-devel] [PATCH 1/3] Check NIC model in some NIC init functions Mark McLoughlin
2009-01-13 19:25 ` [Qemu-devel] [PATCH 2/3] Make virtio_net_init() return void Mark McLoughlin
@ 2009-01-13 19:47 ` Anthony Liguori
2009-01-13 20:59 ` Sylvain Petreolle
1 sibling, 1 reply; 12+ messages in thread
From: Anthony Liguori @ 2009-01-13 19:47 UTC (permalink / raw)
To: Mark McLoughlin; +Cc: qemu-devel
Mark McLoughlin wrote:
> Some NIC init functions are only called when that model is
> the only valid model. In that case, it makes sense to use
> qemu_check_nic_model() from the NIC init function itself.
>
> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
>
Applied all 4. Thanks.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Qemu-devel] Re: [PATCH 1/3] Check NIC model in some NIC init functions
2009-01-13 19:47 ` [Qemu-devel] Re: [PATCH 1/3] Check NIC model in some NIC init functions Anthony Liguori
@ 2009-01-13 20:59 ` Sylvain Petreolle
0 siblings, 0 replies; 12+ messages in thread
From: Sylvain Petreolle @ 2009-01-13 20:59 UTC (permalink / raw)
To: Mark McLoughlin, Anthony Liguori
----- Message d'origine ----
> De : Anthony Liguori <anthony@codemonkey.ws>
> À : Mark McLoughlin <markmc@redhat.com>
> Cc : qemu-devel@nongnu.org
> Envoyé le : Mardi, 13 Janvier 2009, 20h47mn 19s
> Objet : [Qemu-devel] Re: [PATCH 1/3] Check NIC model in some NIC init functions
>
> Mark McLoughlin wrote:
> > Some NIC init functions are only called when that model is
> > the only valid model. In that case, it makes sense to use
> > qemu_check_nic_model() from the NIC init function itself.
> >
> > Signed-off-by: Mark McLoughlin
> >
>
> Applied all 4. Thanks.
>
> Regards,
>
> Anthony Liguori
It seems the virtio part of these 4 hasn't been applied.
Kind regards,
Sylvain Petreolle
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2009-01-13 20:59 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-07 17:42 [Qemu-devel] [6216] Add a model string to VLANClientState (Mark McLoughlin) Anthony Liguori
2009-01-07 19:23 ` Stefan Weil
2009-01-08 14:45 ` Mark McLoughlin
2009-01-08 14:47 ` [Qemu-devel] [PATCH 1/4] Add qemu_check_nic_model() and qemu_check_nic_model_list() Mark McLoughlin
2009-01-08 14:47 ` [Qemu-devel] [PATCH 2/4] Check NIC model in some NIC init functions Mark McLoughlin
2009-01-08 14:47 ` [Qemu-devel] [PATCH 3/4] Make virtio_net_init() return void Mark McLoughlin
2009-01-08 14:47 ` [Qemu-devel] [PATCH 4/4] Make pci_nic_init() use qemu_setup_nic_model() Mark McLoughlin
2009-01-13 19:25 ` [Qemu-devel] [PATCH 1/3] Check NIC model in some NIC init functions Mark McLoughlin
2009-01-13 19:25 ` [Qemu-devel] [PATCH 2/3] Make virtio_net_init() return void Mark McLoughlin
2009-01-13 19:25 ` [Qemu-devel] [PATCH 3/3] Make pci_nic_init() use qemu_setup_nic_model() Mark McLoughlin
2009-01-13 19:47 ` [Qemu-devel] Re: [PATCH 1/3] Check NIC model in some NIC init functions Anthony Liguori
2009-01-13 20:59 ` Sylvain Petreolle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).