Commit bf38c1a0e1d7ebbe0930d8926dbc499b88a2d7db
1 parent
f7b4a940
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> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6216 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
17 changed files
with
74 additions
and
62 deletions
hw/e1000.c
| ... | ... | @@ -1071,8 +1071,8 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) |
| 1071 | 1071 | d->rxbuf_min_shift = 1; |
| 1072 | 1072 | memset(&d->tx, 0, sizeof d->tx); |
| 1073 | 1073 | |
| 1074 | - d->vc = qemu_new_vlan_client(nd->vlan, e1000_receive, | |
| 1075 | - e1000_can_receive, d); | |
| 1074 | + d->vc = qemu_new_vlan_client(nd->vlan, nd->model, | |
| 1075 | + e1000_receive, e1000_can_receive, d); | |
| 1076 | 1076 | |
| 1077 | 1077 | snprintf(d->vc->info_str, sizeof(d->vc->info_str), |
| 1078 | 1078 | "%s macaddr=%02x:%02x:%02x:%02x:%02x:%02x", info_str, | ... | ... |
hw/eepro100.c
| ... | ... | @@ -1776,7 +1776,8 @@ static void nic_init(PCIBus * bus, NICInfo * nd, |
| 1776 | 1776 | |
| 1777 | 1777 | nic_reset(s); |
| 1778 | 1778 | |
| 1779 | - s->vc = qemu_new_vlan_client(nd->vlan, nic_receive, nic_can_receive, s); | |
| 1779 | + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, | |
| 1780 | + nic_receive, nic_can_receive, s); | |
| 1780 | 1781 | |
| 1781 | 1782 | snprintf(s->vc->info_str, sizeof(s->vc->info_str), |
| 1782 | 1783 | "eepro100 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x", | ... | ... |
hw/etraxfs_eth.c
| ... | ... | @@ -572,7 +572,7 @@ void *etraxfs_eth_init(NICInfo *nd, CPUState *env, |
| 572 | 572 | eth->ethregs = cpu_register_io_memory(0, eth_read, eth_write, eth); |
| 573 | 573 | cpu_register_physical_memory (base, 0x5c, eth->ethregs); |
| 574 | 574 | |
| 575 | - eth->vc = qemu_new_vlan_client(nd->vlan, | |
| 575 | + eth->vc = qemu_new_vlan_client(nd->vlan, nd->model, | |
| 576 | 576 | eth_receive, eth_can_receive, eth); |
| 577 | 577 | |
| 578 | 578 | return dma; | ... | ... |
hw/mcf_fec.c
| ... | ... | @@ -452,7 +452,7 @@ void mcf_fec_init(NICInfo *nd, target_phys_addr_t base, qemu_irq *irq) |
| 452 | 452 | mcf_fec_writefn, s); |
| 453 | 453 | cpu_register_physical_memory(base, 0x400, iomemtype); |
| 454 | 454 | |
| 455 | - s->vc = qemu_new_vlan_client(nd->vlan, mcf_fec_receive, | |
| 456 | - mcf_fec_can_receive, s); | |
| 455 | + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, | |
| 456 | + mcf_fec_receive, mcf_fec_can_receive, s); | |
| 457 | 457 | memcpy(s->macaddr, nd->macaddr, 6); |
| 458 | 458 | } | ... | ... |
hw/mipsnet.c
| ... | ... | @@ -250,8 +250,8 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd) |
| 250 | 250 | s->irq = irq; |
| 251 | 251 | s->nd = nd; |
| 252 | 252 | if (nd && nd->vlan) { |
| 253 | - s->vc = qemu_new_vlan_client(nd->vlan, mipsnet_receive, | |
| 254 | - mipsnet_can_receive, s); | |
| 253 | + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, | |
| 254 | + mipsnet_receive, mipsnet_can_receive, s); | |
| 255 | 255 | } else { |
| 256 | 256 | s->vc = NULL; |
| 257 | 257 | } | ... | ... |
hw/musicpal.c
| ... | ... | @@ -718,7 +718,8 @@ static void mv88w8618_eth_init(NICInfo *nd, uint32_t base, qemu_irq irq) |
| 718 | 718 | if (!s) |
| 719 | 719 | return; |
| 720 | 720 | s->irq = irq; |
| 721 | - s->vc = qemu_new_vlan_client(nd->vlan, eth_receive, eth_can_receive, s); | |
| 721 | + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, | |
| 722 | + eth_receive, eth_can_receive, s); | |
| 722 | 723 | iomemtype = cpu_register_io_memory(0, mv88w8618_eth_readfn, |
| 723 | 724 | mv88w8618_eth_writefn, s); |
| 724 | 725 | cpu_register_physical_memory(base, MP_ETH_SIZE, iomemtype); | ... | ... |
hw/ne2000.c
| ... | ... | @@ -741,8 +741,8 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd) |
| 741 | 741 | |
| 742 | 742 | ne2000_reset(s); |
| 743 | 743 | |
| 744 | - s->vc = qemu_new_vlan_client(nd->vlan, ne2000_receive, | |
| 745 | - ne2000_can_receive, s); | |
| 744 | + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, | |
| 745 | + ne2000_receive, ne2000_can_receive, s); | |
| 746 | 746 | |
| 747 | 747 | snprintf(s->vc->info_str, sizeof(s->vc->info_str), |
| 748 | 748 | "ne2000 macaddr=%02x:%02x:%02x:%02x:%02x:%02x", |
| ... | ... | @@ -811,8 +811,8 @@ void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn) |
| 811 | 811 | s->pci_dev = (PCIDevice *)d; |
| 812 | 812 | memcpy(s->macaddr, nd->macaddr, 6); |
| 813 | 813 | ne2000_reset(s); |
| 814 | - s->vc = qemu_new_vlan_client(nd->vlan, ne2000_receive, | |
| 815 | - ne2000_can_receive, s); | |
| 814 | + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, | |
| 815 | + ne2000_receive, ne2000_can_receive, s); | |
| 816 | 816 | |
| 817 | 817 | snprintf(s->vc->info_str, sizeof(s->vc->info_str), |
| 818 | 818 | "ne2000 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x", | ... | ... |
hw/pcnet.c
| ... | ... | @@ -1936,8 +1936,8 @@ static void pcnet_common_init(PCNetState *d, NICInfo *nd, const char *info_str) |
| 1936 | 1936 | d->nd = nd; |
| 1937 | 1937 | |
| 1938 | 1938 | if (nd && nd->vlan) { |
| 1939 | - d->vc = qemu_new_vlan_client(nd->vlan, pcnet_receive, | |
| 1940 | - pcnet_can_receive, d); | |
| 1939 | + d->vc = qemu_new_vlan_client(nd->vlan, nd->model, | |
| 1940 | + pcnet_receive, pcnet_can_receive, d); | |
| 1941 | 1941 | |
| 1942 | 1942 | snprintf(d->vc->info_str, sizeof(d->vc->info_str), |
| 1943 | 1943 | "pcnet macaddr=%02x:%02x:%02x:%02x:%02x:%02x", | ... | ... |
hw/rtl8139.c
| ... | ... | @@ -3438,8 +3438,8 @@ void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn) |
| 3438 | 3438 | s->pci_dev = (PCIDevice *)d; |
| 3439 | 3439 | memcpy(s->macaddr, nd->macaddr, 6); |
| 3440 | 3440 | rtl8139_reset(s); |
| 3441 | - s->vc = qemu_new_vlan_client(nd->vlan, rtl8139_receive, | |
| 3442 | - rtl8139_can_receive, s); | |
| 3441 | + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, | |
| 3442 | + rtl8139_receive, rtl8139_can_receive, s); | |
| 3443 | 3443 | |
| 3444 | 3444 | snprintf(s->vc->info_str, sizeof(s->vc->info_str), |
| 3445 | 3445 | "rtl8139 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x", | ... | ... |
hw/smc91c111.c
| ... | ... | @@ -704,7 +704,7 @@ void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq) |
| 704 | 704 | |
| 705 | 705 | smc91c111_reset(s); |
| 706 | 706 | |
| 707 | - s->vc = qemu_new_vlan_client(nd->vlan, smc91c111_receive, | |
| 708 | - smc91c111_can_receive, s); | |
| 707 | + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, | |
| 708 | + smc91c111_receive, smc91c111_can_receive, s); | |
| 709 | 709 | /* ??? Save/restore. */ |
| 710 | 710 | } | ... | ... |
hw/stellaris_enet.c
| ... | ... | @@ -397,8 +397,8 @@ void stellaris_enet_init(NICInfo *nd, uint32_t base, qemu_irq irq) |
| 397 | 397 | memcpy(s->macaddr, nd->macaddr, 6); |
| 398 | 398 | |
| 399 | 399 | if (nd->vlan) |
| 400 | - s->vc = qemu_new_vlan_client(nd->vlan, stellaris_enet_receive, | |
| 401 | - stellaris_enet_can_receive, s); | |
| 400 | + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, | |
| 401 | + stellaris_enet_receive, stellaris_enet_can_receive, s); | |
| 402 | 402 | |
| 403 | 403 | stellaris_enet_reset(s); |
| 404 | 404 | register_savevm("stellaris_enet", -1, 1, | ... | ... |
hw/usb-net.c
| ... | ... | @@ -1453,7 +1453,7 @@ USBDevice *usb_net_init(NICInfo *nd) |
| 1453 | 1453 | |
| 1454 | 1454 | pstrcpy(s->dev.devname, sizeof(s->dev.devname), |
| 1455 | 1455 | "QEMU USB Network Interface"); |
| 1456 | - s->vc = qemu_new_vlan_client(nd->vlan, | |
| 1456 | + s->vc = qemu_new_vlan_client(nd->vlan, nd->model, | |
| 1457 | 1457 | usbnet_receive, usbnet_can_receive, s); |
| 1458 | 1458 | |
| 1459 | 1459 | snprintf(s->usbstring_mac, sizeof(s->usbstring_mac), | ... | ... |
hw/virtio-net.c
| ... | ... | @@ -315,8 +315,8 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) |
| 315 | 315 | n->rx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_rx); |
| 316 | 316 | n->tx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_tx); |
| 317 | 317 | memcpy(n->mac, nd->macaddr, 6); |
| 318 | - n->vc = qemu_new_vlan_client(nd->vlan, virtio_net_receive, | |
| 319 | - virtio_net_can_receive, n); | |
| 318 | + n->vc = qemu_new_vlan_client(nd->vlan, nd->model, | |
| 319 | + virtio_net_receive, virtio_net_can_receive, n); | |
| 320 | 320 | |
| 321 | 321 | n->tx_timer = qemu_new_timer(vm_clock, virtio_net_tx_timer, n); |
| 322 | 322 | n->tx_timer_active = 0; | ... | ... |
net.c
| ... | ... | @@ -297,6 +297,7 @@ static int parse_unix_path(struct sockaddr_un *uaddr, const char *str) |
| 297 | 297 | #endif |
| 298 | 298 | |
| 299 | 299 | VLANClientState *qemu_new_vlan_client(VLANState *vlan, |
| 300 | + const char *model, | |
| 300 | 301 | IOReadHandler *fd_read, |
| 301 | 302 | IOCanRWHandler *fd_can_read, |
| 302 | 303 | void *opaque) |
| ... | ... | @@ -305,6 +306,7 @@ VLANClientState *qemu_new_vlan_client(VLANState *vlan, |
| 305 | 306 | vc = qemu_mallocz(sizeof(VLANClientState)); |
| 306 | 307 | if (!vc) |
| 307 | 308 | return NULL; |
| 309 | + vc->model = strdup(model); | |
| 308 | 310 | vc->fd_read = fd_read; |
| 309 | 311 | vc->fd_can_read = fd_can_read; |
| 310 | 312 | vc->opaque = opaque; |
| ... | ... | @@ -325,6 +327,7 @@ void qemu_del_vlan_client(VLANClientState *vc) |
| 325 | 327 | while (*pvc != NULL) |
| 326 | 328 | if (*pvc == vc) { |
| 327 | 329 | *pvc = vc->next; |
| 330 | + free(vc->model); | |
| 328 | 331 | free(vc); |
| 329 | 332 | break; |
| 330 | 333 | } else |
| ... | ... | @@ -442,13 +445,13 @@ static void slirp_receive(void *opaque, const uint8_t *buf, int size) |
| 442 | 445 | slirp_input(buf, size); |
| 443 | 446 | } |
| 444 | 447 | |
| 445 | -static int net_slirp_init(VLANState *vlan) | |
| 448 | +static int net_slirp_init(VLANState *vlan, const char *model) | |
| 446 | 449 | { |
| 447 | 450 | if (!slirp_inited) { |
| 448 | 451 | slirp_inited = 1; |
| 449 | 452 | slirp_init(); |
| 450 | 453 | } |
| 451 | - slirp_vc = qemu_new_vlan_client(vlan, | |
| 454 | + slirp_vc = qemu_new_vlan_client(vlan, model, | |
| 452 | 455 | slirp_receive, NULL, NULL); |
| 453 | 456 | snprintf(slirp_vc->info_str, sizeof(slirp_vc->info_str), "user redirector"); |
| 454 | 457 | return 0; |
| ... | ... | @@ -662,7 +665,7 @@ static void tap_send(void *opaque) |
| 662 | 665 | |
| 663 | 666 | /* fd support */ |
| 664 | 667 | |
| 665 | -static TAPState *net_tap_fd_init(VLANState *vlan, int fd) | |
| 668 | +static TAPState *net_tap_fd_init(VLANState *vlan, const char *model, int fd) | |
| 666 | 669 | { |
| 667 | 670 | TAPState *s; |
| 668 | 671 | |
| ... | ... | @@ -670,7 +673,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan, int fd) |
| 670 | 673 | if (!s) |
| 671 | 674 | return NULL; |
| 672 | 675 | s->fd = fd; |
| 673 | - s->vc = qemu_new_vlan_client(vlan, tap_receive, NULL, s); | |
| 676 | + s->vc = qemu_new_vlan_client(vlan, model, tap_receive, NULL, s); | |
| 674 | 677 | #ifdef HAVE_IOVEC |
| 675 | 678 | s->vc->fd_readv = tap_receive_iov; |
| 676 | 679 | #endif |
| ... | ... | @@ -905,7 +908,7 @@ static int launch_script(const char *setup_script, const char *ifname, int fd) |
| 905 | 908 | return 0; |
| 906 | 909 | } |
| 907 | 910 | |
| 908 | -static int net_tap_init(VLANState *vlan, const char *ifname1, | |
| 911 | +static int net_tap_init(VLANState *vlan, const char *model, const char *ifname1, | |
| 909 | 912 | const char *setup_script, const char *down_script) |
| 910 | 913 | { |
| 911 | 914 | TAPState *s; |
| ... | ... | @@ -926,7 +929,7 @@ static int net_tap_init(VLANState *vlan, const char *ifname1, |
| 926 | 929 | if (launch_script(setup_script, ifname, fd)) |
| 927 | 930 | return -1; |
| 928 | 931 | } |
| 929 | - s = net_tap_fd_init(vlan, fd); | |
| 932 | + s = net_tap_fd_init(vlan, model, fd); | |
| 930 | 933 | if (!s) |
| 931 | 934 | return -1; |
| 932 | 935 | snprintf(s->vc->info_str, sizeof(s->vc->info_str), |
| ... | ... | @@ -969,8 +972,8 @@ static void vde_from_qemu(void *opaque, const uint8_t *buf, int size) |
| 969 | 972 | } |
| 970 | 973 | } |
| 971 | 974 | |
| 972 | -static int net_vde_init(VLANState *vlan, const char *sock, int port, | |
| 973 | - const char *group, int mode) | |
| 975 | +static int net_vde_init(VLANState *vlan, const char *model, const char *sock, | |
| 976 | + int port, const char *group, int mode) | |
| 974 | 977 | { |
| 975 | 978 | VDEState *s; |
| 976 | 979 | char *init_group = strlen(group) ? (char *)group : NULL; |
| ... | ... | @@ -990,7 +993,7 @@ static int net_vde_init(VLANState *vlan, const char *sock, int port, |
| 990 | 993 | free(s); |
| 991 | 994 | return -1; |
| 992 | 995 | } |
| 993 | - s->vc = qemu_new_vlan_client(vlan, vde_from_qemu, NULL, s); | |
| 996 | + s->vc = qemu_new_vlan_client(vlan, model, vde_from_qemu, NULL, s); | |
| 994 | 997 | qemu_set_fd_handler(vde_datafd(s->vde), vde_to_qemu, NULL, s); |
| 995 | 998 | snprintf(s->vc->info_str, sizeof(s->vc->info_str), "vde: sock=%s fd=%d", |
| 996 | 999 | sock, vde_datafd(s->vde)); |
| ... | ... | @@ -1011,6 +1014,7 @@ typedef struct NetSocketState { |
| 1011 | 1014 | |
| 1012 | 1015 | typedef struct NetSocketListenState { |
| 1013 | 1016 | VLANState *vlan; |
| 1017 | + char *model; | |
| 1014 | 1018 | int fd; |
| 1015 | 1019 | } NetSocketListenState; |
| 1016 | 1020 | |
| ... | ... | @@ -1164,8 +1168,8 @@ fail: |
| 1164 | 1168 | return -1; |
| 1165 | 1169 | } |
| 1166 | 1170 | |
| 1167 | -static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, int fd, | |
| 1168 | - int is_connected) | |
| 1171 | +static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, const char *model, | |
| 1172 | + int fd, int is_connected) | |
| 1169 | 1173 | { |
| 1170 | 1174 | struct sockaddr_in saddr; |
| 1171 | 1175 | int newfd; |
| ... | ... | @@ -1208,7 +1212,7 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, int fd, |
| 1208 | 1212 | return NULL; |
| 1209 | 1213 | s->fd = fd; |
| 1210 | 1214 | |
| 1211 | - s->vc = qemu_new_vlan_client(vlan, net_socket_receive_dgram, NULL, s); | |
| 1215 | + s->vc = qemu_new_vlan_client(vlan, model, net_socket_receive_dgram, NULL, s); | |
| 1212 | 1216 | qemu_set_fd_handler(s->fd, net_socket_send_dgram, NULL, s); |
| 1213 | 1217 | |
| 1214 | 1218 | /* mcast: save bound address as dst */ |
| ... | ... | @@ -1227,15 +1231,15 @@ static void net_socket_connect(void *opaque) |
| 1227 | 1231 | qemu_set_fd_handler(s->fd, net_socket_send, NULL, s); |
| 1228 | 1232 | } |
| 1229 | 1233 | |
| 1230 | -static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, int fd, | |
| 1231 | - int is_connected) | |
| 1234 | +static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, const char *model, | |
| 1235 | + int fd, int is_connected) | |
| 1232 | 1236 | { |
| 1233 | 1237 | NetSocketState *s; |
| 1234 | 1238 | s = qemu_mallocz(sizeof(NetSocketState)); |
| 1235 | 1239 | if (!s) |
| 1236 | 1240 | return NULL; |
| 1237 | 1241 | s->fd = fd; |
| 1238 | - s->vc = qemu_new_vlan_client(vlan, | |
| 1242 | + s->vc = qemu_new_vlan_client(vlan, model, | |
| 1239 | 1243 | net_socket_receive, NULL, s); |
| 1240 | 1244 | snprintf(s->vc->info_str, sizeof(s->vc->info_str), |
| 1241 | 1245 | "socket: fd=%d", fd); |
| ... | ... | @@ -1247,8 +1251,8 @@ static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, int fd, |
| 1247 | 1251 | return s; |
| 1248 | 1252 | } |
| 1249 | 1253 | |
| 1250 | -static NetSocketState *net_socket_fd_init(VLANState *vlan, int fd, | |
| 1251 | - int is_connected) | |
| 1254 | +static NetSocketState *net_socket_fd_init(VLANState *vlan, const char *model, | |
| 1255 | + int fd, int is_connected) | |
| 1252 | 1256 | { |
| 1253 | 1257 | int so_type=-1, optlen=sizeof(so_type); |
| 1254 | 1258 | |
| ... | ... | @@ -1259,13 +1263,13 @@ static NetSocketState *net_socket_fd_init(VLANState *vlan, int fd, |
| 1259 | 1263 | } |
| 1260 | 1264 | switch(so_type) { |
| 1261 | 1265 | case SOCK_DGRAM: |
| 1262 | - return net_socket_fd_init_dgram(vlan, fd, is_connected); | |
| 1266 | + return net_socket_fd_init_dgram(vlan, model, fd, is_connected); | |
| 1263 | 1267 | case SOCK_STREAM: |
| 1264 | - return net_socket_fd_init_stream(vlan, fd, is_connected); | |
| 1268 | + return net_socket_fd_init_stream(vlan, model, fd, is_connected); | |
| 1265 | 1269 | default: |
| 1266 | 1270 | /* who knows ... this could be a eg. a pty, do warn and continue as stream */ |
| 1267 | 1271 | fprintf(stderr, "qemu: warning: socket type=%d for fd=%d is not SOCK_DGRAM or SOCK_STREAM\n", so_type, fd); |
| 1268 | - return net_socket_fd_init_stream(vlan, fd, is_connected); | |
| 1272 | + return net_socket_fd_init_stream(vlan, model, fd, is_connected); | |
| 1269 | 1273 | } |
| 1270 | 1274 | return NULL; |
| 1271 | 1275 | } |
| ... | ... | @@ -1287,7 +1291,7 @@ static void net_socket_accept(void *opaque) |
| 1287 | 1291 | break; |
| 1288 | 1292 | } |
| 1289 | 1293 | } |
| 1290 | - s1 = net_socket_fd_init(s->vlan, fd, 1); | |
| 1294 | + s1 = net_socket_fd_init(s->vlan, s->model, fd, 1); | |
| 1291 | 1295 | if (!s1) { |
| 1292 | 1296 | closesocket(fd); |
| 1293 | 1297 | } else { |
| ... | ... | @@ -1297,7 +1301,8 @@ static void net_socket_accept(void *opaque) |
| 1297 | 1301 | } |
| 1298 | 1302 | } |
| 1299 | 1303 | |
| 1300 | -static int net_socket_listen_init(VLANState *vlan, const char *host_str) | |
| 1304 | +static int net_socket_listen_init(VLANState *vlan, const char *model, | |
| 1305 | + const char *host_str) | |
| 1301 | 1306 | { |
| 1302 | 1307 | NetSocketListenState *s; |
| 1303 | 1308 | int fd, val, ret; |
| ... | ... | @@ -1332,12 +1337,14 @@ static int net_socket_listen_init(VLANState *vlan, const char *host_str) |
| 1332 | 1337 | return -1; |
| 1333 | 1338 | } |
| 1334 | 1339 | s->vlan = vlan; |
| 1340 | + s->model = strdup(model); | |
| 1335 | 1341 | s->fd = fd; |
| 1336 | 1342 | qemu_set_fd_handler(fd, net_socket_accept, NULL, s); |
| 1337 | 1343 | return 0; |
| 1338 | 1344 | } |
| 1339 | 1345 | |
| 1340 | -static int net_socket_connect_init(VLANState *vlan, const char *host_str) | |
| 1346 | +static int net_socket_connect_init(VLANState *vlan, const char *model, | |
| 1347 | + const char *host_str) | |
| 1341 | 1348 | { |
| 1342 | 1349 | NetSocketState *s; |
| 1343 | 1350 | int fd, connected, ret, err; |
| ... | ... | @@ -1375,7 +1382,7 @@ static int net_socket_connect_init(VLANState *vlan, const char *host_str) |
| 1375 | 1382 | break; |
| 1376 | 1383 | } |
| 1377 | 1384 | } |
| 1378 | - s = net_socket_fd_init(vlan, fd, connected); | |
| 1385 | + s = net_socket_fd_init(vlan, model, fd, connected); | |
| 1379 | 1386 | if (!s) |
| 1380 | 1387 | return -1; |
| 1381 | 1388 | snprintf(s->vc->info_str, sizeof(s->vc->info_str), |
| ... | ... | @@ -1384,7 +1391,8 @@ static int net_socket_connect_init(VLANState *vlan, const char *host_str) |
| 1384 | 1391 | return 0; |
| 1385 | 1392 | } |
| 1386 | 1393 | |
| 1387 | -static int net_socket_mcast_init(VLANState *vlan, const char *host_str) | |
| 1394 | +static int net_socket_mcast_init(VLANState *vlan, const char *model, | |
| 1395 | + const char *host_str) | |
| 1388 | 1396 | { |
| 1389 | 1397 | NetSocketState *s; |
| 1390 | 1398 | int fd; |
| ... | ... | @@ -1398,7 +1406,7 @@ static int net_socket_mcast_init(VLANState *vlan, const char *host_str) |
| 1398 | 1406 | if (fd < 0) |
| 1399 | 1407 | return -1; |
| 1400 | 1408 | |
| 1401 | - s = net_socket_fd_init(vlan, fd, 0); | |
| 1409 | + s = net_socket_fd_init(vlan, model, fd, 0); | |
| 1402 | 1410 | if (!s) |
| 1403 | 1411 | return -1; |
| 1404 | 1412 | |
| ... | ... | @@ -1488,7 +1496,7 @@ int net_client_init(const char *device, const char *p) |
| 1488 | 1496 | pstrcpy(slirp_hostname, sizeof(slirp_hostname), buf); |
| 1489 | 1497 | } |
| 1490 | 1498 | vlan->nb_host_devs++; |
| 1491 | - ret = net_slirp_init(vlan); | |
| 1499 | + ret = net_slirp_init(vlan, device); | |
| 1492 | 1500 | } else |
| 1493 | 1501 | #endif |
| 1494 | 1502 | #ifdef _WIN32 |
| ... | ... | @@ -1499,7 +1507,7 @@ int net_client_init(const char *device, const char *p) |
| 1499 | 1507 | return -1; |
| 1500 | 1508 | } |
| 1501 | 1509 | vlan->nb_host_devs++; |
| 1502 | - ret = tap_win32_init(vlan, ifname); | |
| 1510 | + ret = tap_win32_init(vlan, device, ifname); | |
| 1503 | 1511 | } else |
| 1504 | 1512 | #elif defined (_AIX) |
| 1505 | 1513 | #else |
| ... | ... | @@ -1512,7 +1520,7 @@ int net_client_init(const char *device, const char *p) |
| 1512 | 1520 | fd = strtol(buf, NULL, 0); |
| 1513 | 1521 | fcntl(fd, F_SETFL, O_NONBLOCK); |
| 1514 | 1522 | ret = -1; |
| 1515 | - if (net_tap_fd_init(vlan, fd)) | |
| 1523 | + if (net_tap_fd_init(vlan, device, fd)) | |
| 1516 | 1524 | ret = 0; |
| 1517 | 1525 | } else { |
| 1518 | 1526 | if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) { |
| ... | ... | @@ -1524,7 +1532,7 @@ int net_client_init(const char *device, const char *p) |
| 1524 | 1532 | if (get_param_value(down_script, sizeof(down_script), "downscript", p) == 0) { |
| 1525 | 1533 | pstrcpy(down_script, sizeof(down_script), DEFAULT_NETWORK_DOWN_SCRIPT); |
| 1526 | 1534 | } |
| 1527 | - ret = net_tap_init(vlan, ifname, setup_script, down_script); | |
| 1535 | + ret = net_tap_init(vlan, device, ifname, setup_script, down_script); | |
| 1528 | 1536 | } |
| 1529 | 1537 | } else |
| 1530 | 1538 | #endif |
| ... | ... | @@ -1533,14 +1541,14 @@ int net_client_init(const char *device, const char *p) |
| 1533 | 1541 | int fd; |
| 1534 | 1542 | fd = strtol(buf, NULL, 0); |
| 1535 | 1543 | ret = -1; |
| 1536 | - if (net_socket_fd_init(vlan, fd, 1)) | |
| 1544 | + if (net_socket_fd_init(vlan, device, fd, 1)) | |
| 1537 | 1545 | ret = 0; |
| 1538 | 1546 | } else if (get_param_value(buf, sizeof(buf), "listen", p) > 0) { |
| 1539 | - ret = net_socket_listen_init(vlan, buf); | |
| 1547 | + ret = net_socket_listen_init(vlan, device, buf); | |
| 1540 | 1548 | } else if (get_param_value(buf, sizeof(buf), "connect", p) > 0) { |
| 1541 | - ret = net_socket_connect_init(vlan, buf); | |
| 1549 | + ret = net_socket_connect_init(vlan, device, buf); | |
| 1542 | 1550 | } else if (get_param_value(buf, sizeof(buf), "mcast", p) > 0) { |
| 1543 | - ret = net_socket_mcast_init(vlan, buf); | |
| 1551 | + ret = net_socket_mcast_init(vlan, device, buf); | |
| 1544 | 1552 | } else { |
| 1545 | 1553 | fprintf(stderr, "Unknown socket options: %s\n", p); |
| 1546 | 1554 | return -1; |
| ... | ... | @@ -1568,7 +1576,7 @@ int net_client_init(const char *device, const char *p) |
| 1568 | 1576 | } else { |
| 1569 | 1577 | vde_mode = 0700; |
| 1570 | 1578 | } |
| 1571 | - ret = net_vde_init(vlan, vde_sock, vde_port, vde_group, vde_mode); | |
| 1579 | + ret = net_vde_init(vlan, device, vde_sock, vde_port, vde_group, vde_mode); | |
| 1572 | 1580 | } else |
| 1573 | 1581 | #endif |
| 1574 | 1582 | { | ... | ... |
net.h
| ... | ... | @@ -18,6 +18,7 @@ struct VLANClientState { |
| 18 | 18 | void *opaque; |
| 19 | 19 | struct VLANClientState *next; |
| 20 | 20 | struct VLANState *vlan; |
| 21 | + char *model; | |
| 21 | 22 | char info_str[256]; |
| 22 | 23 | }; |
| 23 | 24 | |
| ... | ... | @@ -30,6 +31,7 @@ struct VLANState { |
| 30 | 31 | |
| 31 | 32 | VLANState *qemu_find_vlan(int id); |
| 32 | 33 | VLANClientState *qemu_new_vlan_client(VLANState *vlan, |
| 34 | + const char *model, | |
| 33 | 35 | IOReadHandler *fd_read, |
| 34 | 36 | IOCanRWHandler *fd_can_read, |
| 35 | 37 | void *opaque); | ... | ... |
sysemu.h
| ... | ... | @@ -75,7 +75,7 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); |
| 75 | 75 | #endif |
| 76 | 76 | |
| 77 | 77 | /* TAP win32 */ |
| 78 | -int tap_win32_init(VLANState *vlan, const char *ifname); | |
| 78 | +int tap_win32_init(VLANState *vlan, const char *model, const char *ifname); | |
| 79 | 79 | |
| 80 | 80 | /* SLIRP */ |
| 81 | 81 | void do_info_slirp(void); | ... | ... |
tap-win32.c
| ... | ... | @@ -660,7 +660,7 @@ static void tap_win32_send(void *opaque) |
| 660 | 660 | } |
| 661 | 661 | } |
| 662 | 662 | |
| 663 | -int tap_win32_init(VLANState *vlan, const char *ifname) | |
| 663 | +int tap_win32_init(VLANState *vlan, const char *model, const char *ifname) | |
| 664 | 664 | { |
| 665 | 665 | TAPState *s; |
| 666 | 666 | |
| ... | ... | @@ -672,7 +672,7 @@ int tap_win32_init(VLANState *vlan, const char *ifname) |
| 672 | 672 | return -1; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | - s->vc = qemu_new_vlan_client(vlan, tap_receive, NULL, s); | |
| 675 | + s->vc = qemu_new_vlan_client(vlan, model, tap_receive, NULL, s); | |
| 676 | 676 | |
| 677 | 677 | snprintf(s->vc->info_str, sizeof(s->vc->info_str), |
| 678 | 678 | "tap: ifname=%s", ifname); | ... | ... |