History | View | Annotate | Download (26.1 kB)
net: add receive_disabled logic to iov delivery path
This patch adds the missing NetClient->receive_disabled logic in thesendv delivery code path. It seems that commit893379efd0e1b84ceb0c42a713293f3dbd27b1bd ("net: disable receiving ifclient returns zero") only added the logic to qemu_deliver_packet() and...
net: notify iothread after flushing queue
virtio-net has code to flush the queue and notify the iothreadwhenever new receive buffers are added by the guest. That isfine, and indeed we need to do the same in all other drivers.However, notifying the iothread should be work for the network...
monitor: Rename+move net_handle_fd_param -> monitor_handle_fd_param
This patch renames+moves the net_handle_fd_param() caller used toobtain a file descriptor from either qemu_parse_fd() (the normal case)or from monitor_get_fd() (migration case) into a generically prefixed...
Merge remote-tracking branch 'stefanha/net' into staging
Support 'help' as a synonym for '?' in command line options
For command line options which permit '?' meaning 'please list thepermitted values', add support for 'help' as a synonym, by abstractingthe check out into a helper function.
This change means that in some cases where we were being lazy in...
net: Make "info network" output more readable info
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Reviewed-by: Laszlo Ersek <lersek@redhat.com>
net: cleanup deliver/deliver_iov func pointers
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Reviewed-by: Laszlo Ersek <lersek@redhat.com>
net: Rename non_vlan_clients to net_clients
There is no longer a distinction between vlan clients and non-vlanclients in the net core. The net core only knows about point-to-pointclients which are connected to a peer. It's time to rename the globallist of net clients since it no longer refers to vlans at all....
net: Rename VLANClientState to NetClientState
The vlan feature is no longer part of net core. Rename VLANClientStateto NetClientState because net clients are not explicitly associated witha vlan at all, instead they have a peer net client to which they are...
net: Rename vc local variables to nc
Now that VLANClientState has been renamed to NetClientState all 'vc'local variables should be 'nc'. Much of the code already used 'nc' butthere are places where 'vc' needs to be renamed.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
net: Rename qemu_del_vlan_client() to qemu_del_net_client()
Another step in moving the vlan feature out of net core. Users onlydeal with NetClientState and therefore qemu_del_vlan_client() should benamed qemu_del_net_client().
net: Remove VLANState
VLANState is no longer used and can be removed.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>Reviewed-by: Laszlo Ersek <lersek@redhat.com>
net: Add a hub net client
The vlan feature can be implemented in terms of hubs. By introducing ahub net client it becomes possible to remove the special case vlan codefrom net.c and push the vlan feature out of generic networking code.
net: Use hubs for the vlan feature
Stop using the special-case vlan code in net.c. Instead use the hub netclient to implement the vlan feature. The next patch will remove vlancode from net.c completely.
net: Look up 'vlan' net clients using hubs
hub: Check that hubs are configured correctly
Checks can be performed to make sure that hubs have at least one NIC andone host device, warning the user if this is not the case.Configurations which do not meet this rule tend to be broken but justemit a warning. This patch preserves compatibility with the checks...
net: Drop vlan argument to qemu_new_net_client()
Since hubs are now used to implement the 'vlan' feature and the vlanargument is always NULL, remove the argument entirely and update all netclients that use qemu_new_net_client().
net: Remove vlan code from net.c
The vlan implementation in net.c has been replaced by hubs so we canremove the code.
hw, net: "net_client_type" -> "NetClientOptionsKind" (qapi-generated)
NET_CLIENT_TYPE_ -> NET_CLIENT_OPTIONS_KIND_
Signed-off-by: Laszlo Ersek <lersek@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
convert net_client_init() to OptsVisitor
The net_client_init() prototype is kept intact.
Based on "is_netdev", the QemuOpts-rooted QemuOpt-list is parsed as aNetdev or a NetLegacy. The original meat of net_client_init() is moved toand simplified in net_client_init1():...
convert net_init_nic() to NetClientOptions
v1->v2:- NetLegacyNicOptions::vectors is of type uint32
remove unused QemuOpts parameter from net init functions
v1->v2:- unchanged
v2->v3:- keep "qemu-option.h" included in "net/slirp.h"
change iov_* function prototypes to be more appropriate
Reorder arguments to be more natural, readable andconsistent with other iov_* functions, and changeargument names, from: iov_from_buf(iov, iov_cnt, buf, iov_off, size)to iov_from_buf(iov, iov_cnt, offset, buf, bytes)...
net: purge the monitor object from all init functions
The only backend that really uses it is the socket one, which callsmonitor_get_fd(). But it can use 'cur_mon' instead.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-By: Laszlo Ersek <lersek@redhat.com>
net: net_client_init(): use error_set()
Callers are changed to use qerror_report_err() to keep their QErrorsemantics.
qapi: convert netdev_add
This is not a full QAPI conversion, but an intermediate step.
In essence, do_netdev_add() is split into three functions:
1. netdev_add(): performs the actual work. This function is fully converted to Error (thus, it's "qapi-friendly")...
qapi: convert netdev_del
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-By: Laszlo Ersek <lersek@redhat.com>
qemu-option: qemu_opts_validate(): use error_set()
net_client_init() propagates the error up by calling qerror_report_err(),because its users expect QError semantics.
qemu-option: qemu_opts_from_qdict(): use error_set()
do_device_add() and do_netdev_add() call qerror_report_err() to maintaintheir QError semantics.
net: move compute_mcast_idx() to net.h
Reduce duplicated codes.
Signed-off-by: Jason Wang <jasowang@redhat.com>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
w32: Fix build with new net bridge code
Commit a7c36ee4920ea3acc227a0248dd161693f207357 added code for a netbridge and explicitly said that "this is very Linux centric".
Indeed, compilation failed for w32, so the bridge code is nowconditional. Hosts which don't support it can simply remove the...
Add support for net bridge
The most common use of -net tap is to connect a tap device to a bridge. Thisrequires the use of a script and running qemu as root in order to allocate atap device to pass to the script.
This model is great for portability and flexibility but it's incredibly...
Support for UDP unicast network backend
Signed-off-by: Benjamin MARSILI <mlspirat42@gmail.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qapi: Convert set_link
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Move filedescriptor parsing code from net.c into qemu_parse_fd()
Move the parsing of a filedescriptor into a common functionqemu_parse_fd() so others can use it as well. Have net.c call thisfunction.
v2: - moving qemu_parse_fd into cutils.c
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>...
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Merge remote-tracking branch 'mst/for_anthony' into staging
net: Improve layout of 'info network'
Improve the layout when listing non-vlan clients via 'info network'. Theresult looks like this:
(qemu) info networkDevices not on any VLAN: orphan: net=10.0.2.0, restricted=n virtio-net-pci.0: model=virtio-net-pci,macaddr=52:54:00:12:34:56...
net: Refactor net_client_types
Position entries of net_client_types according to the correspondingvalues of NET_CLIENT_TYPE_*. The array size is now defined byNET_CLIENT_TYPE_MAX. This will allow to obtain entries based on typevalue in later patches....
net: Dump client type 'info network'
Include the client type name into the output of 'info network'. Theresult looks like this:
(qemu) info networkVLAN 0 devices: rtl8139.0: type=nic,model=rtl8139,macaddr=52:54:00:12:34:57Devices not on any VLAN: virtio-net-pci.0: type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:56...
net: Consistently use qemu_macaddr_default_if_unset
Drop the open-coded MAC assignment from net_init_nic and replace it withstandard qemu_macaddr_default_if_unset which is also used by qdev. Thatavoid creating colliding MACs when instantiating NICs via different...
Fix automatically assigned network names for netdev
If a network client doesn't have a name, we make one up, withassign_name(). assign_name() creates a name MODEL.NUM, where MODEL isthe client's model, and NUM is the number of MODELs that alreadyexist....
Fix netdev name lookup in -device, device_add, netdev_del
qemu_find_netdev() looks up members of non_vlan_clients by name. Ithappily returns the first match. Trouble is the names need not beunique.
non_vlan_clients contains host parts (netdevs) and guest parts (NICs)....
Strip trailing '\n' from error_report()'s first argument
error_report() prepends location, and appends a newline. The messageconstructed from the arguments should not contain a newline. Fix theobvious offenders.
Signed-off-by: Markus Armbruster <armbru@redhat.com>...
net: Warn about "-net nic" options which were ignored
Diagnose the case where the user asked for a NIC via "-net nic" but the board didn't instantiate that NIC (for example where theuser asked for two NICs but the board only supports one). Notethat this diagnostic doesn't apply to NICs created through -device,...
Revert "net: Improve the warnings for dubious command line option combinations"
This reverts commit f68b9d672b90dedc79aeb9b44607f484dbe46a6b.That attempt at diagnosing unused -net nic options failed to accountfor NICs created via -device; back it out cleanly in preparation...
net: Don't warn about the default network setup
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 otherwisecomplain about:
(1) board doesn't support a NIC but the implicit "-net nic" requested one...
Remove unused sysemu.h include directives
Remove unused sysemu.h include directives to speed up buildwith the following patches.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
net: Improve the warnings for dubious command line option combinations
Improve the warnings we give if the user specified a combination of -netoptions 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...
Fix net_check_clients warnings: make it per vlan.
Signed-off-by: Tristan Gingold <gingold@adacore.com>Reviewed-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
net: Add the missing option declaration of "vhostforce"
Signed-off-by: Jason Wang <jasowang@redhat.com>Acked-by: Michael S. Tsirkin <mst@redhat.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
net: remove parse_host_src_port() function
It was deprecated, and it has no users.
Signed-off-by: Juan Quintela <quintela@redhat.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
net: Use iov helper functions
Signed-off-by: Benjamin Poirier <benjamin.poirier@gmail.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Acked-by: Jason Wang <jasowang@redhat.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
net: fix qemu_can_send_packet logic
If any of the clients is not ready to receive (ie it has a can_receivecallback and can_receive() returns false), we don't want to startsending, else this client may miss/discard the packet.
I got this behaviour with the following setup :...
net: notify peer about link status change
qemu makes it possible to disable link at tap which is not communicatedto the guest but causes all packets to be dropped.
This works for virtio userspace, as qemu stops giving it packets, butnot for virtio-net connected to vhost-net as that does not get notified...
net/sock: option to specify local address
Add an option to specify the host IP to send multicast packets from,when using a multicast socket for networking. The option takes an IPaddress and sets the IP_MULTICAST_IF socket option, which causes thepackets to use that IP's interface as an egress....
net: properly handle illegal fd/vhostfd from command line
When hanlding fd/vhostfd form command line through net_handle_fd_param(),we need to check mon and return value of strtol() otherwise we couldget segmentation fault or invalid fd when user type an illegal fd/vhostfd....
net: delay freeing peer host device
With -netdev, virtio devices present offloadfeatures to guest, depending on the backend used.Thus, removing host netdev peer while guest isactive leads to guest-visible inconsistency and/or crashes.
As a solution, while guest (NIC) peer device exists,...
QemuOpts: make most qemu_*_opts static
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 <kraxel@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net: delete QemuOpts when net_client_init() fails.
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"....
net: Fix VM start with '-net none'
Commit 50e32ea8f31035877decc10f1075aa0e619e09cb changed the behaviourfor the return type of net_client_init() when a nic type with no initmethod was specified. 'none' is one such nic type. Instead of returning0, which gets interpreted as an index into the nd_table[] array, we...
Make netdev_del delete the netdev even when it's in use
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...
Merge remote branch 'mst/for_anthony' into staging
net: Fix hotplug with pci_add
The correct model type wasn't getting added when hotplugging nics withpci_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....
Monitor: Drop QMP documentation from code
Previous commit added QMP documentation to the qemu-monitor.hxfile, it's is a copy of this information.
While it's good to keep it near code, maintaining two copies ofthe same information is too hard and has little benefit as we...
monitor: Use argument type 'b' for set_link
Second argument is now "on" or "off" instead of "up" or "down".
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
monitor: Convert do_set_link() to QObject, QError
monitor: New commands netdev_add, netdev_del
Monitor commands to go with -netdev.
error: Drop extra messages after qemu_opts_set() and qemu_opts_parse()
Both functions report errors nicely enough now, no need for additionalmessages.
error: Convert net_client_init() to QError
The conversion is shallow: client type init() methods aren'tconverted. Converting them is a big job for relatively littlepractical benefit, so leave it for later.
net: remove broken net_set_boot_mask() boot device validation
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...
net: remove NICInfo.bootable field
It is just set by net_set_boot_mask() and never used. The logic for rom loadingchanged a lot since this field was introduced. It is not needed anymore.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>Acked-by: Juan Quintela <quintela@redhat.com>...
tap: add vhost/vhostfd options
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 termwhen we know it's stable.
vhostfd option can be used by management, to pass in the fd. Assigning...
qemu-option: Move the implied first name into QemuOptsList
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()....
error: Replace qemu_error() by error_report()
error_report() terminates the message with a newline. Strip it itfrom its arguments.
This fixes a few error messages lacking a newline:net_handle_fd_param()'s "No file descriptor named %s found", andtap_open()'s "vnet_hdr=1 requested, but no kernel support for...
qdev: Catch attempt to attach more than one device to a netdev
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...
qdev: Add a DEV_NVECTORS_UNSPECIFIED enum for unspecified nr of MSI vectors
net.c used a constant to signify no MSI vectors were specified. Extendthat to all qdev devices.
Signed-off-by: Amit Shah <amit.shah@redhat.com>Reported-by: "Michael S. Tsirkin" <mst@redhat.com>...
Allow const QemuOptDesc
Fix warning on OpenBSD
/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
net: net_check_clients() checks only VLAN clients, fix
Clients not associated with a VLAN exist since commit d80b9fc6.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net: info network shows only VLAN clients, fix
net: Monitor command set_link finds only VLAN clients, fix
net: Remove unused net_client_uninit()
Unused since commit 9ad4531e.
net: net_check_clients() runs too early to see -device, fix
Call it right after -device devices get created.
net: Fix bogus "Warning: vlan 0 with no nics" with -device
net_check_clients() prints this when an VLAN has host devices, but noguest devices. It uses VLANState members nb_guest_devs andnb_host_devs to keep track of these devices. However, -device does...
don't dereference NULL after failed strdup
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...
default devices: network
Add a default_net variable which specified whenever a default networkshould be created. It is cleared in case any -net option is specifiedand it is also added to the new -nodefaults switch.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>...
net: add qemu_foreach_nic()
Signed-off-by: Mark McLoughlin <markmc@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net: print correct error for '-netdev ""'
Reported-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Mark McLoughlin <markmc@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net: move parse_macaddr() to net/util.[ch]
net: remove qemu_new_vlan_client()
... and VLANClientState::opaque and qemu_find_vlan_client().
All of these are now unused
net: remove VLANClientState members now in NetClientInfo
Add a NetClientInfo pointer to VLANClientState and use thatfor the typecode and function pointers.
net: introduce NICState and qemu_new_nic()
Common state for all NICs.
The opaque member will replace the opaque member in VLANClientStatesince only NICs need it.
The conf member will allow us to iterate over NICs, access the MACaddr for the NIC and send a packet from each NIC in qemu_announce_self()....
net: introduce qemu_new_net_client()
A replacement for qemu_new_vlan_client(), using NetClientInfo toreplace most arguments.
net: move vde code from net.c to net/vde.c
net: move socket backend code from net.c to net/socket.c
net: move dump backend code from net.c to net/dump.c
net: clean up includes in net.c
This is probably a little drastic, but the includes in this file arenow totally out of control when compared with what includes areactually needed.
This may break the build on e.g. *BSD, but it will be easily fixed byre-instating an include....
net: move slirp code from net.c to net/slirp.c
Add support for GNU/kFreeBSD
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>