hw: move headers to include/
Many of these should be cleaned up with proper qdev-/QOM-ification.Right now there are many catch-all headers in include/hw/ARCH dependingon cpu.h, and this makes it necessary to compile these files per-target.However, fixing this does not belong in these patches....
qemu-char: Call fe_claim / fe_release when not using qdev chr properties
chardev-frontends need to explictly check, increase and decrement theavail_connections "property" of the chardev when they are not using aqdev-chardev-property for the chardev.
This fixes things like:...
oslib-posix: rename socket_set_nonblock() to qemu_set_nonblock()
The fcntl(fd, F_SETFL, O_NONBLOCK) flag is not specific to sockets.Rename to qemu_set_nonblock() just like qemu_set_cloexec().
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>...
net: ensure "socket" backend uses non-blocking fds
There are several code paths in net_init_socket() depending on how thesocket is created: file descriptor passing, UDP multicast, TCP, or UDP.Some of these support both listen and connect.
Not all code paths set the socket to non-blocking. This patch addresses...
net: increase buffer size to accommodate Jumbo frame pkts
Socket buffer sizes were hard-coded to 4K for VDE and socket netdevs. Bump thisup to 68K (ala tap netdev) to handle maximum GSO packet size (64k) plus plentyof room for the ethernet and virtio_net headers....
net: iovec checksum calculator
Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>Signed-off-by: Yan Vugenfirer <yan@daynix.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Common definitions for VMWARE devices
net: use socket_set_nodelay() for -netdev socket
Reduce -netdev socket latency by disabling the Nagle algorithm onSOCK_STREAM sockets in net/socket.c. Since we are tunelling Ethernetover TCP we shouldn't artificially delay outgoing packets, let the guest...
Checksum-related utility functions
net_checksum_add_cont()checksum calculation for scattered data with odd chunk sizes
net_raw_checksum()checksum calculation for a buffer
Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>Signed-off-by: Yan Vugenfirer <yan@daynix.com>...
Fix typos and misspellings
Fix various typos and misspellings. The bulk of these were found withcodespell.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Reviewed-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
MinGW: Replace setsockopt by qemu_setsocketopt
Instead of adding missing type casts which are needed by MinGW for the4th argument, the patch uses qemu_setsockopt which was invented for thispurpose.
Signed-off-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
tap: forbid creating multiqueue tap when hub is used
Obviously, hub does not support multiqueue tap. So this patch forbids creatingmultiple queue tap when hub is used to prevent the crash when command line suchas "-net tap,queues=2" is used.
Cc: qemu-stable@nongnu.org...
tap: set IFF_ONE_QUEUE per default
historically the kernel queues packets two times. onceat the device and second in qdisc. this is believed to causeinterface stalls if one of these queues overruns.
setting IFF_ONE_QUEUE is the default in kernels >= 3.8. the...
net: reduce the unnecessary memory allocation of multiqueue
Edivaldo reports a problem that the array of NetClientState in NICState is toolarge - MAX_QUEUE_NUM(1024) which will wastes memory even if multiqueue is notused.
Instead of static arrays, solving this issue by allocating the queues on demand...
net: fix unbounded NetQueue
In the current implementation of qemu, running without a networkbackend will cause the queue to grow unbounded when the guest istransmitting traffic.
This patch fixes the problem by implementing bounded size NetQueue,used with an arbitrary limit of 10000 packets, and dropping packets...
net: fix qemu_flush_queued_packets() in presence of a hub
When frontend and backend are connected through a hub as below(showing only one direction), and the frontend (or in general, alloutput ports of the hub) cannot accept more traffic, the backendqueues packets in queue-A....
net: Avoid NULL function pointer dereference on cleanup
The pSeries machine and some other devices don't supply a cleanupcallback. Revert part of 1ceef9f27359cbe92ef124bf74de6f792e71f6fb thatstarted calling it unconditionally.
Cc: Jason Wang <jasowang@redhat.com>...
net: fix infinite loop on exit
1ceef9f27359cbe92ef124bf74de6f792e71f6fb added handling for cleaningup multiple queues in qemu_del_nic() for cases where multiqueue is inuse. To determine the number of queues it looks at nic->conf->queues,then iterates through all the queues to cleanup the associated...
tap: unbreak -netdev tap,fd=X
The multiqueue patch series broke -netdev tap,fd=X which manifestsas libvirt not being able to start a guest. This was because itpassed NULL for the netdev name which results in an anonymous netdevdevice regardless of what the user specified....
tap: support enabling or disabling a queue
This patch introduce a new bit - enabled in TAPState which tracks whether aspecific queue/fd is enabled. The tap/fd is enabled during initialization andcould be enabled/disabled by tap_enalbe() and tap_disable() which calls platform...
tap: introduce a helper to get the name of an interface
This patch introduces a helper tap_get_ifname() to get the device name of tapdevice. This is needed when ifname is unspecified in the command line and qemuwere asked to create tap device by itself. In this situation, the name were...
tap: multiqueue support
Recently, linux support multiqueue tap which could let userspace call TUNSETIFFfor a signle device many times to create multiple file descriptors asindependent queues. User could also enable/disabe a specific queue throughTUNSETQUEUE....
net: intorduce qemu_del_nic()
To support multiqueue nic, this patch separate the nic destructor fromqemu_del_net_client() to a new helper qemu_del_nic() since the mapping bettweenNiCState and NetClientState were not 1:1 in multiqueue. The following patches...
net: introduce qemu_find_net_clients_except()
In multiqueue, all NetClientState that belongs to the same netdev or nic has thesame id. So this patches introduces an helper qemu_find_net_clients_except()which finds all NetClientState with the same id. This will be used by multiqueue...
net: introduce qemu_net_client_setup()
This patch separates the setup of NetClientState from its allocation, this willallow allocating an arrays of NetClientState and does the initialization one byone which is what multiqueue needs.
Signed-off-by: Jason Wang <jasowang@redhat.com>...
net: introduce NetClientState destructor
To allow allocating an array of NetClientState and free it once, this patchintroduces destructor of NetClientState. Which could do type specific free,which could be used by multiqueue to free the array once.
net: multiqueue support
This patch adds basic multiqueue support for qemu. The idea is simple, an arrayof NetClientStates were introduced in NICState, parse_netdev() were extended tofind and match all NetClientStates belongs to the backend and place their...
tap: import linux multiqueue constants
Import multiqueue constants from if_tun.h from 3.8-rc3. A new ifr flagIFF_MULTI_QUEUE were introduced to create a multiqueue backend by callingTUNSETIFF with the this flag and with the same interface name many times....
tap: factor out common tap initialization
This patch factors out the common initialization of tap into a new helpernet_init_tap_one(). This will be used by multiqueue tap patches.
Signed-off-by: Jason Wang <jasowang@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
tap: add Linux multiqueue support
This patch add basic multiqueue support for Linux. When multiqueue is needed, wewill first check whether kernel support multiqueue tap before creating morequeues. Two new functions tap_fd_enable() and tap_fd_disable() were introduced...
net: introduce qemu_get_nic()
To support multiqueue, this patch introduces a helper qemu_get_nic() to getNICState from a NetClientState. The following patches would refactor this helperto support multiqueue.
net: introduce qemu_get_queue()
To support multiqueue, the patch introduce a helper qemu_get_queue()which is used to get the NetClientState of a device. The following patches wouldrefactor this helper to support multiqueue.
net: tap: using bool instead of bitfield
net: tap: use abort() instead of assert(0)
g_strdup(NULL) returns NULL; simplify
Signed-off-by: Markus Armbruster <armbru@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
HMP: add QDict to info callback handler
This patch change all info call back function to takeadditional QDict * parameter, which allow those commandtake parameter. Now it is set to NULL at default case.
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>...
qemu-option: move standard option definitions out of qemu-config.c
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
net: add missing include file
To fix building error:
CC net/vde.onet/vde.c: In function ‘vde_cleanup’:net/vde.c:65:5: error: implicit declaration of function ‘qemu_set_fd_handler’ [-Werror=implicit-function-declaration]net/vde.c:65:5: error: nested extern declaration of ‘qemu_set_fd_handler’ [-Werror=nested-externs]...
net: Add missing include statement (fix compiler warnings for MinGW)
These and some more compiler warnings were caused by a recent commit:
net/tap-win32.c:724: warning: no previous prototype for ‘tap_has_ufo’net/tap-win32.c:729: warning: no previous prototype for ‘tap_has_vnet_hdr’...
Merge remote-tracking branch 'bonzini/header-dirs' into staging
softmmu: move remaining include files to include/ subdirectories
softmmu: move include files to include/sysemu/
misc: move include files to include/qemu/
monitor: move include files to include/monitor/
qapi: move include files to include/qobject/
net: reorganize headers
Move public headers to include/net, and leave private headers in net/.Put the virtio headers in include/net/tap.h, removing the multiple copiesthat existed. Leave include/net/tap.h as the interface for NICs, andnet/tap_int.h as the interface for OS-specific parts of the tap backend....
janitor: do not include qemu-char everywhere
Touching char/char.h basically causes the whole of QEMU tobe rebuilt. Avoid this, it is usually unnecessary.
net: move net.c to net/
net, hub: fix the indent in the comments
Remove some redundant blanks in the comments ofnet_hub_id_for_client().
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
tap: reset vnet header size on open
For tap, we currently assume the vnet header size is 10(the default value) but that might not be the caseif tap is persistent and has been used by qemu previously.To fix, set vnet header size correctly on open.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Fix spelling (prefered -> preferred)
For tap, we currently assume the vnet header size is 10(the default value) but that might not be the caseif tap is persistent and has been used by qemu previously.To fix, set host header size in tap device on open....
slirp: Add domain-search option to slirp's DHCP server
This patch will allow the user to include the domain-search option inreplies from the built-in DHCP server. The domain suffixes can bespecified by adding dnssearch= entries to the "-net user" parameter....
net: use "socket" model name for UDP sockets
Fix the problem that can not delete the udp socket.It's caused by passing "udp" model to net_socket_udp_init,but we do not have "udp" model in our model list.Pass the right model "socket" to init function....
tap-win32: stubs to fix win32 build
Add missing stubs to win32 to fix link failure.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>Reported-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
net/tap-win32: Fix compiler warning caused by missing include statement
The include file for net_init_tap was missing:
net/tap-win32.c:703: warning: no previous prototype for ‘net_init_tap’
net: consolidate NetClientState header files into one
This patch doesn't seem much useful alone, I must admit. However,it makes sense as part of the upcoming directory reorganization,where I want to have include/net/tap.h as the net<->hw interfacefor tap. Then having both net/tap.h and include/net/tap.h does...
net/socket: Fix compiler warning (regression for MinGW)
Commit 213fd5087e2e4e2da10ad266df0ba950cf7618bf removed a type castwhich is needed for MinGW:
net/socket.c:136: warning: pointer targets in passing argument 2 of ‘sendto’ differ in signedness/usr/lib/gcc/amd64-mingw32msvc/4.4.4/../../../../amd64-mingw32msvc/include/winsock2.h:1313: note:...
net: broadcast hub packets if at least one port can receive
In commit 60c07d933c66c4b30a83b7ccbc8a0cb3df1b2d0e ("net: fixqemu_can_send_packet logic") the "VLAN" broadcast behavior was changedto queue packets if any net client cannot receive. It turns out that...
net: asynchronous send/receive infrastructure for net/socket.c
The net/socket.c net client is not truly asynchronous. This patchborrows the qemu_set_fd_handler2() code from net/tap.c as the basis forproper asynchronous send/receive.
Only read packets from the socket when the peer is able to receive....
net: EAGAIN handling for net/socket.c UDP
Implement asynchronous send for UDP (or other SOCK_DGRAM) sockets. Ifsend fails with EAGAIN we wait for the socket to become writable again.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
net: EAGAIN handling for net/socket.c TCP
Replace spinning send_all() with a proper non-blocking send. When thesocket write buffer limit is reached, we should stop trying to send andwait for the socket to become writable again.
Non-blocking TCP sockets can return in two different ways when the write...
net: do not report queued packets as sent
Net send functions have a return value where 0 means the packet has notbeen sent and will be queued. A non-zero value means the packet wassent or an error caused the packet to be dropped.
This patch fixes two instances where packets are queued but we return...
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...
qapi: avoid reserved keywords
Clang compiler complained about use of reserved word 'restrict' in SLIRPand QAPI.
Prefix C keywords with "q_", adjust SLIRP accordingly.
Reviewed-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
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: determine if packets can be sent before net queue deliver packets
hub: add the support for hub own flow control
Only when all other hub port's peer .can_receive() all return 1,the source hub port .can_receive() return 1.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>...
net: fix the coding style
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: add the support for -netdev socket, listen
The -net socket,listen option does not work with the newer -netdevsyntax: http://lists.gnu.org/archive/html/qemu-devel/2011-11/msg01508.html
This patch makes it work now.
For the case where one vlan has multiple listenning sockets,...
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: 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
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>
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: Convert qdev_prop_vlan to peer with hub
Instead of using VLANState use net/hub.h to support the vlan qdevproperty. The vlan qdev property becomes an alias for the peer qdevproperty but is represented as a VLAN ID number. When a VLAN ID isselected the device will really peer with a hub port....
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_dump() to NetClientOptions
v1->v2:- NetdevDumpOptions::len is of type 'size', whose C type was changed to uint64_t. Adapt the printf() format specifier macro.
convert net_init_slirp() to NetClientOptions
convert net_init_socket() to NetClientOptions
I "reverse engineered" the following permissions between the -socketsub-options:
fd listen connect mcast udp | localaddr fd x . . . . | . listen . x . . . | ....
convert net_init_vde() to NetClientOptions
v1->v2:- NetdevVdeOptions::port and ::mode are of type uint16. Remove superfluous range checks.
convert net_init_tap() to NetClientOptions
convert net_init_bridge() to NetClientOptions
remove unused QemuOpts parameter from net init functions
v1->v2:- unchanged
v2->v3:- keep "qemu-option.h" included in "net/slirp.h"
slirp: Improve error reporting of inaccessible smb directories
Instead of guessing, print the error code returned by access.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
slirp: Enforce host-side user of smb share
Windows 7 (and possibly other versions) cannot connect to the sambashare if the exported host directory is not world-readable. This can beresolved by forcing the username used for access checks to the oneunder which QEMU and smbd are running....
slirp: add 'cmd:' target for guestfwd
When using guestfwd=, Qemu only connects the virtual server's TCP portto a single chardev. This is useless in most cases, as we usually wantto have more than a single connection from the guest to the outside world....
slirp: Ensure smbd and shared directory exist when enable smb
Users may pass the following parameters to qemu: $ qemu-kvm -net nic -net user,smb= ... $ qemu-kvm -net nic -net user,smb ... $ qemu-kvm -net nic -net user,smb=bad_directory ...
In these cases, qemu started successfully while samba server...
qmp: include monitor.h when needed
This is needed to get file descriptors from SCM_RIGHTS.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
do not include <libutil.h> needlessly or if it doesn't exist
<libutil.h> and <util.h> on *BSD (some have one, some another)were #included just for openpty() declaration. The only filewhere this function is actually used is qemu-char.c.
In vl.c and net/tap-bsd.c, none of functions declared in libutil.h...
build: move net/ objects to nested Makefile.objs
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>
slirp: don't use "smb ports = 0" option
The "smb ports = 0" option causes recent samba versions to crash. It wasintroduced in commit 157777ef3e with log message "Samba 3 support".However, a value of 0 has never been officially supported by smb and isalso not necessary: if stdin is a socket, smb does not try to listen on...
Declare state directory in smb.conf
The smb.conf generated by the userspace networking does not include a state directorydirective. Samba therefore falls back to the default value. Since the user generallydoes not have write access to this path, smbd immediately crashes....