History | View | Annotate | Download (84.5 kB)
Port host_net_add monitor command to QemuOpts
Here is where we rely on qemu_opts_parse() to handle an empty string.We could alternatively explicitly handle this here by usingqemu_opts_create() when we're not supplied any parameters, but itscleaner this way....
Port usb net to QemuOpts
We need net_client_init_from_opts() exported for this
Signed-off-by: Mark McLoughlin <markmc@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Final net cleanup after conversion to QemuOpts
Now that net_client_init() has no users, kill it off and renamenet_client_init_from_opts().
There is no further need for the old code in net_client_parse() either.We use qemu_opts_parse() 'firstname' facitity for that. Instead, move...
Port -net none and -net nic to QemuOpts
We use a table of network types to look up the initialization functionand parameter descriptions in net_client_init().
For now, we use QemuOpts for the 'none' and 'nic' types. Subsequentpatches port the other types too and the special casing is removed....
Port -net user to QemuOpts
The handling of guestfwd and hostfwd requires the previous changesto allow multiple values for each parameter. The only way to accessthose multiple values is to use qemu_opt_foreach().
Signed-off-by: Mark McLoughlin <markmc@redhat.com>...
Port -net tap to QemuOpts
Some parameters are not valid with fd=. Rather than having a separateparameter description table for validating fd=, it's easir to justcheck for those invalid parameters later.
Note, the need to possible lookup a file descriptor name from the...
Port -net socket to QemuOpts
Port -net vde to QemuOpts
The net_vde_init() change is needed because we now pass NULL pointersinstead of empty strings for group/sock if they're not set.
Port -net dump to QemuOpts
Note, not incrementing nb_host_devs in net_init_dump() is intentional.
Clean up legacy code in net_client_init()
Now that we've ported everything over to QemuOpts, we can kill offall the cruft in net_client_init().
Note, the 'channel' type requires special handling as it uses aformat that QemuOpts can't parse
Drop config_error(), use qemu_error() instead
Diagnostic output goes to stderr, except when we're in a monitorcommand, when it goes to the monitor instead.
config_error() implements this with a monitor argument: if it'snon-null, report there, else to stderr. This obliges us to pass the...
Use qemu_strdup() for NICInfo string fields
Make NICInfo string fields non-const
We now only assign strdup()ed strings to these fields, never staticstrings.
aliguori: fix build for ppc_prep and mips_jazz
Move memset() from net_client_uninit() to net_client_init()
zeroing a structure before using it is more common than zeroing afterusing it. Also makes the setting of nd->used more obvious.
Use qemu_strdup() for VLANClientState string fields
Make net_client_init() consume slirp_configs even on error
net_slirp_init() walks slirp_configs, and stops when it encounters onethat doesn't work. Instead of consuming slirp_configs members there,consume them in the sole caller. This makes sure all are consumed....
Don't exit() in config_error()
Propagating errors up the call chain is tedious. In startup code, wecan take a shortcut: terminate the program. This is wrong elsewhere,the monitor in particular.
config_error() tries to cater for both customers: it terminates the...
Make it obvious that pci_nic_init() can't fail
Before this patch, pci_nic_init() returns NULL when it can't find themodel in pci_nic_models[]. Except this can't happen, becauseqemu_check_nic_model_list() just searched for model inpci_nic_models[], and terminated the program on failure....
Fix pci_add nic not to exit on bad model
Monitor command "pci_add ADDR nic model=MODEL" uses pci_nic_init() tocreate the NIC. When MODEL is unknown or "?", this prints to stderrand terminates the program.
Change pci_nic_init() not to treat "?" specially, and to return NULL...
Correctly free nd structure
When we "free" a NICInfo structure, we can leak pointers, since we don't domuch more than setting used = 0.
We free() the model parameter, but we don't set it to NULL. This means thata new user of this structure will see garbage in there. It was not noticed...
net: fix coding style nit
Put space between = and - assigning a negative numberto avoid confusion with old-style "-=" (which we also have, and need to be fixed).
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Fix sys-queue.h conflict for good
Problem: Our file sys-queue.h is a copy of the BSD file, but there aresome additions and it's not entirely compatible. Because of that, there havebeen conflicts with system headers on BSD systems. Some hacks have beenintroduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896,...
Unexport ticks_per_sec variable. Create get_ticks_per_sec() function
Signed-off-by: Juan Quintela <quintela@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Include sys-queue.h early to override system queue definitions on BSD
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
monitor: Port handler_2 to use QDict
This commit ports command handlers that receive two arguments to usethe new monitor's dictionary.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
monitor: Port handler_3 to use QDict
This commit ports command handlers that receive three arguments to usethe new monitor's dictionary.
net: Fix send queue ordering
Ensure that packets enqueued for delayed delivery are dequeued in FIFOorder. At least one simplistic guest TCP/IP stack became unhappy due tosporadically reordered packet streams.
At this chance, switch the send queue implementation to TAILQ....
Add missing linefeed in error message
The error message for an unknown network device given tomonitor command set_link looks better with a terminatinglinefeed.
Signed-off-by: Stefan Weil <weil@mail.berlios.de>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net: Fix do_set_link() return type
do_set_link() returns int, but Monitor handler functions shouldalways return void.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>Message-Id:
rename HOST_BSD to CONFIG_BSD
Remove useless Win32 include files and unused function in net.c.
Signed-off-by: Filip Navara <filip.navara@gmail.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
slirp: Fix guestfwd for incoming data
Unless a virtual server address was explicitly defined (which isimpossible with the legacy net channel format), guestfwd did notproperly forwarded host>guest packets. This patch fixes it.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>...
Add support for fd=name to tap and socket networking
This allows a program to initialize a host networking device using afile descriptor passed over a unix monitor socket.
The program must first pass the file descriptor using SCM_RIGHTSancillary data with the getfd monitor command. It then may do...
qdev: add id= support for pci nics.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
slirp: Fix default netmask to 255.255.255.0
This got broken between a13a4126c8 and c92ef6a22d: old slirp code used255.255.255.0.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Don't abort if TUNSETSNDBUF fails where no sndbuf= arg is supplied
If no tap,sndbuf= arg is supplied, we use a default value. IfTUNSETSNDBUF fails in this case, we should not abort.
net: set a default value for sndbuf=
On reflection, perhaps it does make sense to set a default value forthe sndbuf= tap parameter.
For best effect, sndbuf= should be set to just below the capacity ofthe physical NIC.
Setting it higher will cause packets to be dropped before the limit...
Use pstrcpy and pstrcat to avoid OpenBSD linker warning
slirp: Basic VLAN client info_str
slirp: Enable multiple instances
Once again this was a long journey to reach the destination: Allow toinstantiate slirp multiple times. But as in the past, the journey wasworthwhile, cleaning up, fixing and enhancing various parts of the userspace network stack along the way....
slirp: Use shell to erase smb directory
Instead of open-coding this, we can use the power of the shell to removethe smb_dir on exit.
slirp: Improve error handling in slirp_smb
Make sure for invocations from the monitor that slirp_smb properlyreports errors and doesn't terminate qemu.
slirp: Enable multi-instance support for the smb service
Push the smb state, smb_dir, into SlirpState and construct it in a waythat allows multiple smb instances (one per slirp stack). Remove the smbdirectory on slirp cleanup instead of qemu termination. As VLAN clients...
net: Provide VLAN client lookup helper
Introduce qemu_find_vlan_client_by_name for VLANClientState lookup basedon VLAN ID and client name. This is useful for monitor commands.
slirp: Make hostfwd_add/remove multi-instance-aware
Extend the syntax of hostfwd_add/remove to optionally take a tuple ofVLAN ID and slirp stack name. If those are omitted, the commands willcontinue to work on the first registered slirp stack.
slirp: Kill slirp_is_inited
Avoid the need for slirp_is_inited by refactoring the protectedslirp_select_* functions. This also avoids the clearing of all fd setson select errors.
slirp: Drop redundant checks from slirp_output
Slirp doesn't invoke slirp[_can]_output before it is initialized. Themotivation for these checks (3b7f5d479c) no longer applies. So dropthem.
Note: slirp_vc will become invalid if the slirp stack is removed during...
slirp: Use internal state in interface
This now also exports the internal state to the slirp users in qemu,returning it from slirp_init and expecting it along with serviceinvocations. Additionally provide an opaque value interface for thecallbacks from slirp into the qemu core....
slirp: Allocate/free stack instance dynamically
Allocate the internal slirp state dynamically and provide and callslirp_cleanup to properly release it after use. This patch finallyunbreaks slirp release and re-instantiation via host_net_* monitorcommands....
slirp: Do not allow to remove non-hostfwd sockets
Prevent that the users accidentally shoots down dynamic sockets. Thisallows to remove looping for removals as there can now only be onematch.
slirp: Add info usernet for dumping connection states
Break out sockstats from the slirp statistics and present them under thenew info category "usernet". This patch also improves the current output/wrt proper reporting connection source and destination....
slirp: Drop statistic code
As agreed on the mailing list, there is no interest in keeping theusually disabled slirp statistics in the tree. So this patch removesthem.
slirp: Rework external configuration interface
With the internal IP configuration made more flexible, we can nowenhance the user interface. This patch adds a number of new options to"-net user": net (address and mask), host, dhcpstart, dns and smbserver....
slirp: Rework monitor commands for host forwarding
Improve the monitor interface for adding and removing host forwardingrules by splitting it up in two commands and rename them to hostfwd_addand hostfwd_remove. Also split up the paths taken for legacy -redir...
slirp: Bind support for host forwarding rules
Extend the hostfwd rule format so that the user can specify on whichhost interface qemu should listen for incoming connections. If omitted,binding will takes place against all interfaces.
Revert "User networking: Show active connections"
This reverts commit 1c6ed9f3379faac83da0ed3e95cbd49003ac0dd1.
It's redundant to slirp statistics, which are going to be split up /reworked later on.
Conflicts:
monitor.c net.c
slirp: Move smb, redir, tftp and bootp parameters and -net channel
So far a couple of slirp-related parameters were expressed viastand-alone command line options. This it inconsistent and unintuitive.Moreover, it prevents both dynamically reconfigured (host_net_add/...
qemu/net: flag to control the number of vectors a nic has
Add an option to specify the number of MSI-X vectors for PCI NIC cards. Thiscan also be used to disable MSI-X, for compatibility with old qemu. Thisoption currently only affects virtio cards.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>...
net: add qemu_purge_queued_packets()
If net client sends packets asynchronously, it needs to purge its queuedpackets in cleanup() so as to prevent sent callbacks being invoked witha freed client.
net: purge queued packets in tap_cleanup()
If tap has any packets queued at host_net_remove time, it needs to purgethem in order to prevent a sent callback being invoked for it.
net: add tap_read_poll() helper
Add a helper to enable/disable the read polling on tapfd.
We need this, because we want to start write polling on the tapfd tooand enable/disable both types of polling independently.
net: handle EAGAIN from tapfd write()
If a write() on tapfd returns EAGAIN, return zero so that the packetgets queued (in the case of async send) and enable polling tapfd forwriting.
When tapfd becomes writable, disable write polling and flush any queued...
net: return TAPState from net_tap_init()
net_tap_fd_init() already returns TAPState, so this is a sensiblecleanup in its own right.
net: add '-net tap,sndbuf=nbytes'
2.6.30 adds a new TUNSETSNDBUF ioctl() which allows a send buffer limitfor the tap device to be specified. When this limit is reached, a tapwrite() will return EAGAIN and poll() will indicate the fd isn'twritable.
This allows people to tune their setups so as to avoid e.g. UDP packet...
net: add packet length to NetPacketSent callback
virtio-net needs this - for the same purpose that it currently uses thereturn value from qemu_sendv_packet().
Support addr=... in option argument of -net nic
Make net_client_init() accept addr=, put the value into structNICinfo. Use it in pci_nic_init(), and remove arguments bus anddevfn.
Don't support addr= in third argument of monitor command pci_add,because that clashes with its first argument. Admittedly unelegant....
Make nic option rom loading less painful.
The code how it is today, is totally painful to read and keep.To begin with, the code is duplicated with the option rom loadingcode that linux_boot and vga are already using.
This patch introduces a "bootable" state in NICInfo structure,...
Add O_BINARY to open call in net_dump_init.
Fix the pcap dumps on Win32 and other systems where O_BINARY is required.
Win32: Don't remove const attribute in type casts.
Type casts removing the const attribute are bad becausethey hide the fact that the argument remains const.
They also result in a compiler warning (at least with MS-C).
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Fix mingw32 build warnings
Work around buffer and ioctlsocket argument type signedness problemsSuppress a prototype which is unused on mingw32Expand a macro to avoid warnings from some GCC versions
Fix build breakage when using VDE introduced by 4f1c942
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net: return status from qemu_deliver_packet()
Will allow qemu_send_packet() handle queue full condition.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
net: split out packet queueing and flushing into separate functions
We'll be doing more packet queueing in later commits.
net: add qemu_send_packet_async()
Add a qemu_send_packet() variant which will queue up the packetif it cannot be sent when all client queues are full. It laterinvokes the supplied callback when the packet has been sent.
If qemu_send_packet_async() returns zero, the caller is expected...
net: make use of async packet sending API in tap client
If a packet is queued by qemu_send_packet(), remove I/Ohandler for the tap fd until we get notification that thepacket has been sent.
A not insignificant side effect of this is we can nowdrain the tap send queue in one go without fear of packets...
slirp: Avoid zombie processes after fork_exec
Slirp uses fork_exec for spawning service processes, and QEMU uses thisfor running smbd. As SIGCHLD is not handled, these processes becomezombies on termination. Fix this by installing a proper signal handler,...
Revert "Fix output of uninitialized strings"
This reverts commit 8cf07dcbe7691dbe4f47563058659dba6ef66b05.
This is a sorry saga.
This commit:
8e4416af45 net: Add parameter checks for VLAN clients
broken '-net socket' and this commit:
ffad4116b9 net: Fix -net socket parameter checks...
net: Real fix for check_params users
OK, last try: 8e4416af45 broke -net socket, ffad4116b9 tried to fix itbut broke error reporting of invalid parameters. So this patch widelyreverts ffad4116b9 again and intead fixes those callers of check_paramsthat originally suffered from overwritten buffers by using separate...
net: fix error reporting for some net parameter checks
A small bit of confusion between buffers is causing errors like:
qemu: invalid parameter '10' in 'script=/etc/qemu-ifup,fd=10'
instead of:
qemu: invalid parameter 'script' in 'script=/etc/qemu-ifup,fd=10'...
net: Improve parameter error reporting
As host network devices can also be instantiated via the monitor, errorsshould then be reported to the related monitor instead of stderr. Thisrequires larger refactoring, so this patch starts small with introducing...
slirp: Reorder initialization
This patch reorders the initialization of slirp itself as well as itsassociated features smb and redirection. So far the first reference toslirp triggered the initialization, independent of the actual -net useroption which may carry additional parameters. Now we save any request to...
net: factor tap_read_packet() out of tap_send()
Move portability clutter out into its own function.
net: move the tap buffer into TAPState
KVM uses a 64k buffer for reading from tapfd (for GSO support)and allocates the buffer with TAPState rather than on the stack.
Not allocating it on the stack probably makes sense for qemuanyway, so merge it in advance of GSO support....
net: vlan clients with no fd_can_read() can always receive
If a vlan client has no fd_can_read(), that means it canalways receive packets. The current code assumes it can neverreceive packets.
net: only read from tapfd when we can send
Reduce the number of packets dropped under heavy networktraffic by only reading a packet from the tapfd when aclient can actually handle it.
net: add fd_readv() handler to qemu_new_vlan_client() args
This, apparently, is the style we prefer - all VLANClientStateshould be an argument to qemu_new_vlan_client().
net: re-name vc->fd_read() to vc->receive()
VLANClientState's fd_read() handler doesn't read from filedescriptors, it adds a buffer to the client's receive queue.
Re-name the handlers to make things a little less confusing.
net: pass VLANClientState* as first arg to receive handlers
Give static type checking a chance to catch errors.
net: add return value to packet receive handler
This allows us to handle queue full conditions rather than droppingthe packet on the floor.
net: Don't deliver to disabled interfaces in qemu_sendv_packet
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Mark McLoughlin <markmc@redhat.com>
net: Fix and improved ordered packet delivery
Fix a race in qemu_send_packet when delivering deferred packets andadd proper deferring also to qemu_sendv_packet.
User networking: Show active connections
In case you're wondering what connections exactly you have openor maybe redir'ed in the past, you can't really find out from qemuright now.
This patch enables you to see all current connections the hostonly networking holds open, so you can kill them using the previous...
User Networking: Enable removal of redirections
Using the new host_net_redir command you can easily create redirectionson the fly while your VM is running.
While that's great, it's missing the removal of redirections, in case youwant to have a port closed again at a later point in time....
Fix output of uninitialized strings
Commit ffad4116b96e29e0fbe892806f97c0a6c903d30d removed the "scratch buffer" from check_params, but didn't care for the error messages which actuallyincluded this string to tell the user which option was wrong. Now this string...
net: Fix dump time stamps
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Suppress type mismatch warnings in VDE code.
Signed-off-by: Paul Brook <paul@codesourcery.com>
net: Fix -net socket parameter checks
My commit ea053add700d8abe203cd79a9ffb082aee4eabc0 broke -net socket byoverwriting an intermediate buffer in the added check_param. Fix thisby switching check_param to automatic buffer allocation and release, ie.callers no longer have to worry about providing a scratch buffer....
net: Avoid gcc'ism in net_host_device_add
+ if (net_client_init(device, opts ? : "") < 0) { Is this a gcc extension? Do we want to introduce this construct to thecode base.
+ if (net_client_init(device, opts ? : "") < 0) {
Is this a gcc extension? Do we want to introduce this construct to thecode base.
Valid remark, fix below.
Thanks,Jan
-------->
fix net.c compile warning
Fix net.c compile warning:
CC net.onet.c: In function net_slirp_redir:net.c:623: warning: format not a string literal and no format arguments
Signed-off-by: Robert Reif <reif@earthlink.net>
net: Prevent multiple slirp instances (Jan Kiszka)
The slirp stack is full of global variables which prevents instantiatingit more than once. Catch this during net_slirp_init to prevent more harmlater on.