summaryrefslogtreecommitdiffstats
path: root/net.c
Commit message (Collapse)AuthorAgeFilesLines
* Strip trailing '\n' from error_report()'s first argumentMarkus Armbruster2011-06-241-1/+1
| | | | | | | | | error_report() prepends location, and appends a newline. The message constructed from the arguments should not contain a newline. Fix the obvious offenders. Signed-off-by: Markus Armbruster <[email protected]> Signed-off-by: Stefan Hajnoczi <[email protected]>
* net: Warn about "-net nic" options which were ignoredPeter Maydell2011-06-221-0/+15
| | | | | | | | | | | Diagnose the case where the user asked for a NIC via "-net nic" but the board didn't instantiate that NIC (for example where the user asked for two NICs but the board only supports one). Note that this diagnostic doesn't apply to NICs created through -device, because those are always instantiated. Signed-off-by: Peter Maydell <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* net: Don't warn about the default network setupPeter Maydell2011-06-221-0/+12
| | | | | | | | | | | | | Don't warn about the default network setup that you get if no command line -net options are specified. There are two cases that we would otherwise complain about: (1) board doesn't support a NIC but the implicit "-net nic" requested one (2) CONFIG_SLIRP not set, so the implicit "-net nic" sets up a nic that isn't connected to anything Signed-off-by: Peter Maydell <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* Revert "net: Improve the warnings for dubious command line option combinations"Peter Maydell2011-06-221-31/+0
| | | | | | | | | | This reverts commit f68b9d672b90dedc79aeb9b44607f484dbe46a6b. That attempt at diagnosing unused -net nic options failed to account for NICs created via -device; back it out cleanly in preparation for implementing in a different manner. Signed-off-by: Peter Maydell <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* Remove unused sysemu.h include directivesBlue Swirl2011-04-151-1/+0
| | | | | | | Remove unused sysemu.h include directives to speed up build with the following patches. Signed-off-by: Blue Swirl <[email protected]>
* net: Improve the warnings for dubious command line option combinationsPeter Maydell2011-04-011-0/+31
| | | | | | | | | | | | | | Improve the warnings we give if the user specified a combination of -net options which don't make much sense: * Don't warn about anything if the config is the implicit default "-net user -net nic" rather than one specified by the user (this will only kick in for boards with no NIC or if CONFIG_SLIRP is not set) * Diagnose the case where the user asked for NICs which the board didn't instantiate (for example where the user asked for two NICs but the board only supports one) Signed-off-by: Peter Maydell <[email protected]> Signed-off-by: Aurelien Jarno <[email protected]>
* Fix net_check_clients warnings: make it per vlan.Tristan Gingold2011-04-011-1/+2
| | | | | | Signed-off-by: Tristan Gingold <[email protected]> Reviewed-by: Markus Armbruster <[email protected]> Signed-off-by: Aurelien Jarno <[email protected]>
* net: Add the missing option declaration of "vhostforce"Jason Wang2011-03-061-1/+5
| | | | | | Signed-off-by: Jason Wang <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Aurelien Jarno <[email protected]>
* net: remove parse_host_src_port() functionJuan Quintela2011-03-061-41/+0
| | | | | | | It was deprecated, and it has no users. Signed-off-by: Juan Quintela <[email protected]> Signed-off-by: Aurelien Jarno <[email protected]>
* net: Use iov helper functionsBenjamin Poirier2011-03-061-22/+6
| | | | | | | Signed-off-by: Benjamin Poirier <[email protected]> Reviewed-by: Stefan Hajnoczi <[email protected]> Acked-by: Jason Wang <[email protected]> Signed-off-by: Aurelien Jarno <[email protected]>
* net: fix qemu_can_send_packet logicVincent Palatin2011-03-051-3/+3
| | | | | | | | | | | | | | | | | | | | If any of the clients is not ready to receive (ie it has a can_receive callback and can_receive() returns false), we don't want to start sending, else this client may miss/discard the packet. I got this behaviour with the following setup : the emulated machine is using an USB-ethernet adapter, it is connected to the network using SLIRP and I'm dumping the traffic in a .pcap file. As per the following command line : -net nic,model=usb,vlan=1 -net user,vlan=1 -net dump,vlan=1,file=/tmp/pkt.pcap Every time that two packets are coming in a row from the host, the usb-net code will receive the first one, then returns 0 to can_receive call since it has a 1 packet long queue. But as the dump code is always ready to receive, qemu_can_send_packet will return true and the next packet will discard the previous one in the usb-net code. Signed-off-by: Vincent Palatin <[email protected]> Signed-off-by: Blue Swirl <[email protected]>
* net: notify peer about link status changeMichael S. Tsirkin2011-02-201-0/+11
| | | | | | | | | | | | | | | | | | | | | | qemu makes it possible to disable link at tap which is not communicated to the guest but causes all packets to be dropped. This works for virtio userspace, as qemu stops giving it packets, but not for virtio-net connected to vhost-net as that does not get notified about this change. Notify peer when this happens, which will then be used by the follow-up patch to stop/start vhost-net. Note: it might be a good idea to make peer link status match tap in this case, so the guest gets an event and updates the carrier state. For now stay bug for bug compatible with what we used to have in userspace. Signed-off-by: Michael S. Tsirkin <[email protected]> Reported-by: pradeep <[email protected]> Acked-by: Alex Williamson <[email protected]> Acked-by: Jason Wang <[email protected]> Signed-off-by: Aurelien Jarno <[email protected]>
* net/sock: option to specify local addressMike Ryan2010-12-091-0/+4
| | | | | | | | | | | | | Add an option to specify the host IP to send multicast packets from, when using a multicast socket for networking. The option takes an IP address and sets the IP_MULTICAST_IF socket option, which causes the packets to use that IP's interface as an egress. This is useful if the host machine has several interfaces with several virtual networks across disparate interfaces. Signed-off-by: Mike Ryan <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
* net: properly handle illegal fd/vhostfd from command lineJason Wang2010-10-271-5/+11
| | | | | | | | | | | | | When hanlding fd/vhostfd form command line through net_handle_fd_param(), we need to check mon and return value of strtol() otherwise we could get segmentation fault or invalid fd when user type an illegal fd/vhostfd. This patch is based on the suggestions from Luiz Capitulino <[email protected]>. Signed-off-by: Jason Wang <[email protected]> Reviewed-by: Luiz Capitulino <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
* net: delay freeing peer host deviceMichael S. Tsirkin2010-10-061-7/+42
| | | | | | | | | | | | | | | | | | | | | | | | | With -netdev, virtio devices present offload features to guest, depending on the backend used. Thus, removing host netdev peer while guest is active leads to guest-visible inconsistency and/or crashes. As a solution, while guest (NIC) peer device exists, we prevent the host peer from being deleted. This patch does this by adding peer_deleted flag in nic state: if host device is going away while guest device is around, set this flag and keep a shell of the host device around for as long as guest device exists. The link is put down so all packets will get discarded. At the moment, management can detect that device deletion is delayed by doing info net. As a next step, we shall add commands that control hotplug/unplug without removing the device, and an event to report that guest has responded to the hotplug event. Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Alex Williamson <[email protected]>
* QemuOpts: make most qemu_*_opts staticGerd Hoffmann2010-08-221-7/+9
| | | | | | | | Switch tree to lookup-by-name using qemu_find_opts(). Also hook up virtfs options so qemu_find_opts works for them too. Signed-off-by: Gerd Hoffmann <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* net: delete QemuOpts when net_client_init() fails.Yoshiaki Tamura2010-07-011-0/+4
| | | | | | | | | | | | | | | | | This fixes the following scenario using QMP. First, put a bogus argument "foo" to "type", which results in an error. {"execute": "netdev_add", "arguments": { "type": "foo", "id": "netdev1" } } Then, call it again with correct argument "user". {"execute": "netdev_add", "arguments": { "type": "user", "id": "netdev1" } } This results in "DuplicatedId" error. Because the first command was invalid, it should be able to reuse the same "id", and the second command should work. Reported-by: Luiz Capitulino <[email protected]> Signed-off-by: Yoshiaki Tamura <[email protected]> Signed-off-by: Luiz Capitulino <[email protected]>
* net: Fix VM start with '-net none'Amit Shah2010-06-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Commit 50e32ea8f31035877decc10f1075aa0e619e09cb changed the behaviour for the return type of net_client_init() when a nic type with no init method was specified. 'none' is one such nic type. Instead of returning 0, which gets interpreted as an index into the nd_table[] array, we switched to returning -1, which signifies an error as well. That broke VM start with '-net none'. Testing was only done with the monitor command 'pci_add', which doesn't fail. The correct fix would still be to return 0+ values from net_client_init() only when the return value can be used as an index to refer to an entry in nd_table[]. With the current code, callers can erroneously poke into nd_table[0] when -net nic is used, which can lead to badness. However, this commit just returns to the previous behaviour before the offending commit. Signed-off-by: Amit Shah <[email protected]> Signed-off-by: Aurelien Jarno <[email protected]>
* Make netdev_del delete the netdev even when it's in useMarkus Armbruster2010-06-141-4/+0
| | | | | | | | | | | | | | | | | | | | | To hot-unplug guest and host part of a network device, you do: device_del NIC-ID netdev_del NETDEV-ID For PCI devices, device_del merely tells ACPI to unplug the device. The device goes away for real only after the guest processed the ACPI unplug event. You have to wait until then (e.g. by polling info pci) before you can unplug the netdev. Not good. Fix by removing the "in use" check from do_netdev_del(). Deleting a netdev while it's in use is safe; packets simply get routed to the bit bucket. Signed-off-by: Markus Armbruster <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* Merge remote branch 'mst/for_anthony' into stagingAnthony Liguori2010-06-101-2/+5
|\
| * net: Fix hotplug with pci_addAmit Shah2010-06-091-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The correct model type wasn't getting added when hotplugging nics with pci_add. Testcase: start VM with default nic type. In the qemu_monitor: (qemu) pci_add auto nic model=virtio This results in a nic hot-plug of the same nic type as the default. This was broken in 5294e2c774f120e10b44652ac143abda356f44eb Also changes the behaviour where no .init is defined for a net_client_type. Previously, 0 was returned, which indicated the init was successful and that 0 was the index into the nd_tables[] array. Return -1, indicating unsuccessful init, in such a case. Signed-off-by: Amit Shah <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
* | Monitor: Drop QMP documentation from codeLuiz Capitulino2010-06-011-22/+0
|/ | | | | | | | | | | | | Previous commit added QMP documentation to the qemu-monitor.hx file, it's is a copy of this information. While it's good to keep it near code, maintaining two copies of the same information is too hard and has little benefit as we don't expect client writers to consult the code to find how to use a QMP command. Signed-off-by: Luiz Capitulino <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* monitor: Convert do_set_link() to QObject, QErrorMarkus Armbruster2010-04-181-3/+4
| | | | | Signed-off-by: Markus Armbruster <[email protected]> Signed-off-by: Luiz Capitulino <[email protected]>
* monitor: Use argument type 'b' for set_linkMarkus Armbruster2010-04-181-8/+2
| | | | | | | Second argument is now "on" or "off" instead of "up" or "down". Signed-off-by: Markus Armbruster <[email protected]> Signed-off-by: Luiz Capitulino <[email protected]>
* monitor: New commands netdev_add, netdev_delMarkus Armbruster2010-04-181-0/+55
| | | | | | | Monitor commands to go with -netdev. Signed-off-by: Markus Armbruster <[email protected]> Signed-off-by: Luiz Capitulino <[email protected]>
* error: Convert net_client_init() to QErrorMarkus Armbruster2010-04-181-20/+18
| | | | | | | | | The conversion is shallow: client type init() methods aren't converted. Converting them is a big job for relatively little practical benefit, so leave it for later. Signed-off-by: Markus Armbruster <[email protected]> Signed-off-by: Luiz Capitulino <[email protected]>
* error: Drop extra messages after qemu_opts_set() and qemu_opts_parse()Markus Armbruster2010-04-181-2/+0
| | | | | | | | Both functions report errors nicely enough now, no need for additional messages. Signed-off-by: Markus Armbruster <[email protected]> Signed-off-by: Luiz Capitulino <[email protected]>
* net: remove broken net_set_boot_mask() boot device validationEduardo Habkost2010-04-101-19/+0
| | | | | | | | | | | | | | | | | | | | | | | | There are many problems with net_set_boot_mask(): 1) It is broken when using the device model instead of "-net nic". Example: $ qemu-system-x86_64 -device rtl8139,vlan=0,id=net0,mac=52:54:00:82:41:fd,bus=pci.0,addr=0x4 -net user,vlan=0,name=hostnet0 -vnc 0.0.0.0:0 -boot n Cannot boot from non-existent NIC $ 2) The mask was previously used to set which boot ROMs were supposed to be loaded, but this was changed long time ago. Now all ROM images are loaded, and SeaBIOS takes care of jumping to the right boot entry point depending on the boot settings. 3) Interpretation and validation of the boot parameter letters is done on the machine type code. Examples: PC accepts only a,b,c,d,n as valid boot device letters. mac99 accepts only a,b,c,d,e,f. As a side-effect of this change, qemu-kvm won't abort anymore if using "-boot n" on a machine with no network devices. Checking if the requested boot device is valid is now a task for the BIOS or the machine-type code. Signed-off-by: Eduardo Habkost <[email protected]> Acked-by: Juan Quintela <[email protected]> Signed-off-by: Aurelien Jarno <[email protected]>
* net: remove NICInfo.bootable fieldEduardo Habkost2010-04-101-1/+0
| | | | | | | | | It is just set by net_set_boot_mask() and never used. The logic for rom loading changed a lot since this field was introduced. It is not needed anymore. Signed-off-by: Eduardo Habkost <[email protected]> Acked-by: Juan Quintela <[email protected]> Signed-off-by: Aurelien Jarno <[email protected]>
* tap: add vhost/vhostfd optionsMichael S. Tsirkin2010-04-011-0/+8
| | | | | | | | | | | | This adds vhost binary option to tap, to enable vhost net accelerator. Default is off for now, we'll be able to make default on long term when we know it's stable. vhostfd option can be used by management, to pass in the fd. Assigning vhostfd implies vhost=on. Signed-off-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* qemu-option: Move the implied first name into QemuOptsListMarkus Armbruster2010-03-161-2/+2
| | | | | | | | | | | We sometimes permit omitting the first option name, for example -device foo is short for -device driver=foo. The name to use ("driver" in the example) is passed as argument to qemu_opts_parse(). For each QemuOptsList, we use at most one such name. Move the name into QemuOptsList, and pass whether to permit the abbreviation. This ensures continued consistency, and simplifies the commit after next in this series.
* error: Replace qemu_error() by error_report()Markus Armbruster2010-03-161-14/+14
| | | | | | | | | | | | | error_report() terminates the message with a newline. Strip it it from its arguments. This fixes a few error messages lacking a newline: net_handle_fd_param()'s "No file descriptor named %s found", and tap_open()'s "vnet_hdr=1 requested, but no kernel support for IFF_VNET_HDR available" (all three versions). There's one place that passes arguments without newlines intentionally: load_vmstate(). Fix it up.
* qdev: Catch attempt to attach more than one device to a netdevMarkus Armbruster2010-03-091-0/+1
| | | | | | | | | | | | | | | | | | Guest device and host netdev are peers, i.e. it's a 1:1 relation. However, we fail to enforce that: $ qemu -nodefaults --nographic -netdev user,id=net0 -device e1000,netdev=net0 -device virtio-net-pci,netdev=net0 -monitor stdio QEMU 0.12.50 monitor - type 'help' for more information (qemu) info network Devices not on any VLAN: net0: net=10.0.2.0, restricted=n peer=virtio-net-pci.0 e1000.0: model=e1000,macaddr=52:54:00:12:34:56 peer=net0 virtio-net-pci.0: model=virtio-net-pci,macaddr=52:54:00:12:34:57 peer=net0 It's all downhill from there. Signed-off-by: Markus Armbruster <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* qdev: Add a DEV_NVECTORS_UNSPECIFIED enum for unspecified nr of MSI vectorsAmit Shah2010-03-081-2/+4
| | | | | | | | | net.c used a constant to signify no MSI vectors were specified. Extend that to all qdev devices. Signed-off-by: Amit Shah <[email protected]> Reported-by: "Michael S. Tsirkin" <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* Allow const QemuOptDescBlue Swirl2010-02-211-1/+1
| | | | Signed-off-by: Blue Swirl <[email protected]>
* Fix warning on OpenBSDBlue Swirl2010-02-201-1/+1
| | | | | | | | /src/qemu/net.c: In function `net_check_clients': /src/qemu/net.c:1287: warning: `has_nic' might be used uninitialized in this function /src/qemu/net.c:1287: warning: `has_host_dev' might be used uninitialized in this function Signed-off-by: Blue Swirl <[email protected]>
* net: Monitor command set_link finds only VLAN clients, fixMarkus Armbruster2010-02-191-0/+1
| | | | | | | Clients not associated with a VLAN exist since commit d80b9fc6. Signed-off-by: Markus Armbruster <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* net: info network shows only VLAN clients, fixMarkus Armbruster2010-02-191-2/+9
| | | | | | | Clients not associated with a VLAN exist since commit d80b9fc6. Signed-off-by: Markus Armbruster <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* net: net_check_clients() checks only VLAN clients, fixMarkus Armbruster2010-02-191-0/+7
| | | | | | | Clients not associated with a VLAN exist since commit d80b9fc6. Signed-off-by: Markus Armbruster <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* net: Fix bogus "Warning: vlan 0 with no nics" with -deviceMarkus Armbruster2010-02-191-7/+18
| | | | | | | | | | | | net_check_clients() prints this when an VLAN has host devices, but no guest devices. It uses VLANState members nb_guest_devs and nb_host_devs to keep track of these devices. However, -device does not update nb_guest_devs, only net_init_nic() does that, for -net nic. Check the VLAN clients directly, and remove the counters. Signed-off-by: Markus Armbruster <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* net: net_check_clients() runs too early to see -device, fixMarkus Armbruster2010-02-191-3/+1
| | | | | | | Call it right after -device devices get created. Signed-off-by: Markus Armbruster <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* net: Remove unused net_client_uninit()Markus Armbruster2010-02-191-14/+0
| | | | | | | Unused since commit 9ad4531e. Signed-off-by: Markus Armbruster <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* don't dereference NULL after failed strdupJim Meyering2010-02-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most of these are obvious NULL-deref bug fixes, for example, the ones in these files: block/curl.c net.c slirp/misc.c and the first one in block/vvfat.c. The others in block/vvfat.c may not lead to an immediate segfault, but I traced the two schedule_rename(..., strdup(path)) uses, and a failed strdup would appear to trigger this assertion in handle_renames_and_mkdirs: assert(commit->path); The conversion to use qemu_strdup in envlist_to_environ is not technically needed, but does avoid a theoretical leak in the caller when strdup fails for one value, but later succeeds in allocating another buffer(plausible, if one string length is much larger than the others). The caller does not know the length of the returned list, and as such can only free pointers until it hits the first NULL. If there are non-NULL pointers beyond the first, their buffers would be leaked. This one is admittedly far-fetched. The two in linux-user/main.c are worth fixing to ensure that an OOM error is diagnosed up front, rather than letting it provoke some harder-to-diagnose secondary error, in case of exec failure, or worse, in case the exec succeeds but with an invalid list of command line options. However, considering how unlikely it is to encounter a failed strdup early in main, this isn't a big deal. Note that adding the required uses of qemu_strdup here and in envlist.c induce link failures because qemu_strdup is not currently in any library they're linked with. So for now, I've omitted those changes, as well as the fixes in target-i386/helper.c and target-sparc/helper.c. If you'd like to see the above discussion (or anything else) in the commit log, just let me know and I'll be happy to adjust. >From 9af42864fd1ea666bd25e2cecfdfae74c20aa8c7 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Mon, 8 Feb 2010 18:29:29 +0100 Subject: [PATCH] don't dereference NULL after failed strdup Handle failing strdup by replacing each use with qemu_strdup, so as not to dereference NULL or trigger a failing assertion. * block/curl.c (curl_open): s/\bstrdup\b/qemu_strdup/ * block/vvfat.c (init_directories): Likewise. (get_cluster_count_for_direntry, check_directory_consistency): Likewise. * net.c (parse_host_src_port): Likewise. * slirp/misc.c (fork_exec): Likewise. Signed-off-by: Anthony Liguori <[email protected]>
* default devices: networkGerd Hoffmann2009-12-121-1/+4
| | | | | | | | | Add a default_net variable which specified whenever a default network should be created. It is cleared in case any -net option is specified and it is also added to the new -nodefaults switch. Signed-off-by: Gerd Hoffmann <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* net: print correct error for '-netdev ""'Mark McLoughlin2009-12-031-5/+11
| | | | | | Reported-by: Markus Armbruster <[email protected]> Signed-off-by: Mark McLoughlin <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* net: add qemu_foreach_nic()Mark McLoughlin2009-12-031-0/+20
| | | | | Signed-off-by: Mark McLoughlin <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* net: remove VLANClientState members now in NetClientInfoMark McLoughlin2009-12-031-25/+20
| | | | | | | | Add a NetClientInfo pointer to VLANClientState and use that for the typecode and function pointers. Signed-off-by: Mark McLoughlin <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* net: remove qemu_new_vlan_client()Mark McLoughlin2009-12-031-44/+0
| | | | | | | | | ... and VLANClientState::opaque and qemu_find_vlan_client(). All of these are now unused Signed-off-by: Mark McLoughlin <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* net: move parse_macaddr() to net/util.[ch]Mark McLoughlin2009-12-031-33/+2
| | | | | Signed-off-by: Mark McLoughlin <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
* net: introduce NICState and qemu_new_nic()Mark McLoughlin2009-12-031-0/+21
| | | | | | | | | | | | | Common state for all NICs. The opaque member will replace the opaque member in VLANClientState since only NICs need it. The conf member will allow us to iterate over NICs, access the MAC addr for the NIC and send a packet from each NIC in qemu_announce_self(). Signed-off-by: Mark McLoughlin <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>