sim-card
/
qemu
Archived
10
0
Fork 0
Commit Graph

254 Commits

Author SHA1 Message Date
Juan Quintela a3a766e7b3 slirp: fix !CONFIG_SLIRP compilation
This moves the code that depens on slirp under CONFIG_SLIRP again.

Patchworks-ID: 35372
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-12 09:42:31 -05:00
Mark McLoughlin dc1c9fe8b7 Final net cleanup after conversion to QemuOpts
Now that net_client_init() has no users, kill it off and rename
net_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
the special handling of the 'vmchannel' type there.

Simplify the vl.c code into merely call net_client_parse() for each
-net command line option and then calling net_init_clients() later
to iterate over the options and create the clients.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06 14:36:13 -05:00
Mark McLoughlin 13cf8f2129 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>
2009-10-06 14:36:13 -05:00
Mark McLoughlin 7f1c9d20ea 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 using
qemu_opts_create() when we're not supplied any parameters, but its
cleaner this way.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06 14:36:13 -05:00
Mark McLoughlin 7b3fb25110 Clean up legacy code in net_client_init()
Now that we've ported everything over to QemuOpts, we can kill off
all the cruft in net_client_init().

Note, the 'channel' type requires special handling as it uses a
format that QemuOpts can't parse

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06 14:36:12 -05:00
Mark McLoughlin ed2955c2d6 Port -net dump to QemuOpts
Note, not incrementing nb_host_devs in net_init_dump() is intentional.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06 14:36:12 -05:00
Mark McLoughlin dd51058dfc Port -net vde to QemuOpts
The net_vde_init() change is needed because we now pass NULL pointers
instead of empty strings for group/sock if they're not set.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06 14:36:12 -05:00
Mark McLoughlin 88ce16cafc Port -net socket to QemuOpts
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06 14:36:12 -05:00
Mark McLoughlin 8a1c523551 Port -net tap to QemuOpts
Some parameters are not valid with fd=. Rather than having a separate
parameter description table for validating fd=, it's easir to just
check for those invalid parameters later.

Note, the need to possible lookup a file descriptor name from the
monitor is the reason why all these init functions are passed a Monitor
pointer.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06 14:36:12 -05:00
Mark McLoughlin ec302ffdfd Port -net user to QemuOpts
The handling of guestfwd and hostfwd requires the previous changes
to allow multiple values for each parameter. The only way to access
those multiple values is to use qemu_opt_foreach().

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06 14:36:12 -05:00
Mark McLoughlin f83c6e1085 Port -net none and -net nic to QemuOpts
We use a table of network types to look up the initialization function
and parameter descriptions in net_client_init().

For now, we use QemuOpts for the 'none' and 'nic' types. Subsequent
patches port the other types too and the special casing is removed.

We're not parsing the full -net option string here as the type has
been stripped from the string, so we do not use qemu_opts_parse()
'firstname' facility. This will also be rectified in subsequent
patches.

No functional changes are introduced by this patch.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06 14:36:12 -05:00
Markus Armbruster fb12577c2a Drop config_error(), use qemu_error() instead
Diagnostic output goes to stderr, except when we're in a monitor
command, when it goes to the monitor instead.

config_error() implements this with a monitor argument: if it's
non-null, report there, else to stderr.  This obliges us to pass the
monitor down various call chains, to make it available to
config_error().

The recently created qemu_error() doesn't need a monitor argument to
route output.  Use it.

There's one user-visible difference: config_error() prepended "qemu: "
to a message bound for stderr.  qemu_error() doesn't, which means the
prefix goes away with this commit.  If such a prefix is desired for
stderr, then I figure it should be slapped on all error messages, not
just the ones that used to go through config_error().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06 14:36:11 -05:00
Markus Armbruster 0752706de2 Don't exit() in config_error()
Propagating errors up the call chain is tedious.  In startup code, we
can 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
program unless its mon parameter tells it it's working for the
monitor.

Its users need to return status anyway (unless passing a null mon
argument, which none do), which their users need to check.  So this
automatic exit buys us exactly nothing useful.  Only the dangerous
delusion that we can get away without returning status.  Some of its
users fell for that.  Their callers continue executing after failure
when working for the monitor.

This bites monitor command host_net_add in two places:

* net_slirp_init() continues after slirp_hostfwd(), slirp_guestfwd(),
  or slirp_smb() failed, and may end up reporting success.  This
  happens for "host_net_add user guestfwd=foo": it complains about the
  invalid guest forwarding rule, then happily creates the user network
  without guest forwarding.

* net_client_init() can't detect slirp_guestfwd() failure, and gets
  fooled by net_slirp_init() lying about success.  Suppresses its
  "Could not initialize device" message.

Add the missing error reporting, make sure errors are checked, and
drop the exit() from config_error().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06 14:36:10 -05:00
Markus Armbruster 3a179c6614 Make net_client_init() consume slirp_configs even on error
net_slirp_init() walks slirp_configs, and stops when it encounters one
that doesn't work.  Instead of consuming slirp_configs members there,
consume them in the sole caller.  This makes sure all are consumed.
Before, the tail starting with the non-working one was left in place,
where it made the next net_slirp_init() fail again.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06 14:36:10 -05:00
Mark McLoughlin 02374aa02a Use qemu_strdup() for VLANClientState string fields
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06 14:36:10 -05:00
Mark McLoughlin d2cffe303e Move memset() from net_client_uninit() to net_client_init()
zeroing a structure before using it is more common than zeroing after
using it. Also makes the setting of nd->used more obvious.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06 14:36:10 -05:00
Mark McLoughlin 9203f5202b Make NICInfo string fields non-const
We now only assign strdup()ed strings to these fields, never static
strings.

aliguori: fix build for ppc_prep and mips_jazz

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06 14:36:10 -05:00
Mark McLoughlin 32a8e14a0b Use qemu_strdup() for NICInfo string fields
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06 14:36:10 -05:00
Markus Armbruster 07caea315a Fix pci_add nic not to exit on bad model
Monitor command "pci_add ADDR nic model=MODEL" uses pci_nic_init() to
create the NIC.  When MODEL is unknown or "?", this prints to stderr
and terminates the program.

Change pci_nic_init() not to treat "?" specially, and to return NULL
on failure.  Switch uses during startup to new convenience wrapper
pci_nic_init_nofail(), which behaves just like pci_nic_init() used to
do.

Bonus bug fix: we now check for qdev_init() failing there.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05 09:32:53 -05:00
Markus Armbruster 9ee05825d9 Make it obvious that pci_nic_init() can't fail
Before this patch, pci_nic_init() returns NULL when it can't find the
model in pci_nic_models[].  Except this can't happen, because
qemu_check_nic_model_list() just searched for model in
pci_nic_models[], and terminated the program on failure.

Repeating the search here is pointless.  Instead, change
qemu_check_nic_model_list() to return the model's array index.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05 09:32:53 -05:00
Glauber Costa a979670344 Correctly free nd structure
When we "free" a NICInfo structure, we can leak pointers, since we don't do
much more than setting used = 0.

We free() the model parameter, but we don't set it to NULL. This means that
a new user of this structure will see garbage in there. It was not noticed
before because reusing a NICInfo is not that common, but it can be, for
users of device pci hotplug.

A user hit it, described at https://bugzilla.redhat.com/show_bug.cgi?id=524022

This patch memset's the whole structure, guaranteeing that anyone reusing it
will see a fresh NICinfo. Also, we free some other strings that are currently
leaking.

This codebase is quite old, so this patch should feed all stable trees.

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05 09:32:44 -05:00
Michael S. Tsirkin acedcfbf7a net: fix coding style nit
Put space between = and - assigning a negative number
to 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>
2009-09-30 18:56:44 +00:00
Blue Swirl 72cf2d4f0e Fix sys-queue.h conflict for good
Problem: Our file sys-queue.h is a copy of the BSD file, but there are
some additions and it's not entirely compatible. Because of that, there have
been conflicts with system headers on BSD systems. Some hacks have been
introduced in the commits 15cc923584,
f40d753718,
96555a96d7 and
3990d09adf but the fixes were fragile.

Solution: Avoid the conflict entirely by renaming the functions and the
file. Revert the previous hacks.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-12 07:36:22 +00:00
Juan Quintela 6ee093c907 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>
2009-09-11 10:19:52 -05:00
Blue Swirl f40d753718 Include sys-queue.h early to override system queue definitions on BSD
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-04 17:47:09 +00:00
Luiz Capitulino 1d4daa91ff monitor: Port handler_3 to use QDict
This commit ports command handlers that receive three arguments to use
the new monitor's dictionary.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-04 09:37:31 -05:00
Luiz Capitulino f18c16de4a monitor: Port handler_2 to use QDict
This commit ports command handlers that receive two arguments to use
the new monitor's dictionary.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-04 09:37:31 -05:00
Jan Kiszka 9da4318706 net: Fix send queue ordering
Ensure that packets enqueued for delayed delivery are dequeued in FIFO
order. At least one simplistic guest TCP/IP stack became unhappy due to
sporadically reordered packet streams.

At this chance, switch the send queue implementation to TAILQ.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-04 09:37:27 -05:00
Stefan Weil 7dc3fa0913 Add missing linefeed in error message
The error message for an unknown network device given to
monitor command set_link looks better with a terminating
linefeed.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-24 08:01:40 -05:00
Luiz Capitulino c3cf0d3f96 net: Fix do_set_link() return type
do_set_link() returns int, but Monitor handler functions should
always return void.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Message-Id:
2009-08-10 13:05:48 -05:00
Juan Quintela 71e72a19ba rename HOST_BSD to CONFIG_BSD
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-27 14:09:20 -05:00
Filip Navara 8fde6546fb 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>
2009-07-27 14:09:15 -05:00
Jan Kiszka bb53fc5394 slirp: Fix guestfwd for incoming data
Unless a virtual server address was explicitly defined (which is
impossible with the legacy -net channel format), guestfwd did not
properly forwarded host->guest packets. This patch fixes it.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-27 14:08:23 -05:00
Mark McLoughlin c1d6eed7e8 Add support for fd=name to tap and socket networking
This allows a program to initialize a host networking device using a
file descriptor passed over a unix monitor socket.

The program must first pass the file descriptor using SCM_RIGHTS
ancillary data with the getfd monitor command. It then may do
"host_net_add tap fd=name" to use the named file descriptor.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-27 08:39:28 -05:00
Gerd Hoffmann eb54b6dcb8 qdev: add id= support for pci nics.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-16 17:28:53 -05:00
Anthony Liguori 8389e7f4e1 slirp: Fix default netmask to 255.255.255.0
This got broken between a13a4126c8 and c92ef6a22d: old slirp code used
255.255.255.0.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-16 08:28:12 -05:00
Mark McLoughlin d026fb6dab Don't abort if TUNSETSNDBUF fails where no sndbuf= arg is supplied
If no tap,sndbuf= arg is supplied, we use a default value. If
TUNSETSNDBUF fails in this case, we should not abort.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-09 16:58:07 -05:00
Mark McLoughlin fc5b81d1f6 net: set a default value for sndbuf=
On reflection, perhaps it does make sense to set a default value for
the sndbuf= tap parameter.

For best effect, sndbuf= should be set to just below the capacity of
the physical NIC.

Setting it higher will cause packets to be dropped before the limit
is hit. Setting it much lower will not cause any problems unless
you set it low enough such that the guest cannot queue up new packets
before the NIC has emptied its queue.

In Linux, txqueuelen=1000 by default for ethernet NICs. Given a 1500
byte MTU, 1Mb is a good choice for sndbuf.

If it turns out that txqueuelen is actually much lower than this, then
sndbuf is essentially disabled. In the event that txqueuelen is much
higher, it's unlikely that the NIC will be able to empty a 1Mb queue.

Thanks to Herbert Xu for this logic.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Cc: Herbert Xu <herbert.xu@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-09 16:06:37 -05:00
Blue Swirl 3da6abd472 Use pstrcpy and pstrcat to avoid OpenBSD linker warning
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-07-01 20:29:39 +00:00
Jan Kiszka fc57bc5780 slirp: Basic VLAN client info_str
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:51 -05:00
Jan Kiszka f13b572cb3 slirp: Make hostfwd_add/remove multi-instance-aware
Extend the syntax of hostfwd_add/remove to optionally take a tuple of
VLAN ID and slirp stack name. If those are omitted, the commands will
continue to work on the first registered slirp stack.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:50 -05:00
Jan Kiszka 1a60952027 net: Provide VLAN client lookup helper
Introduce qemu_find_vlan_client_by_name for VLANClientState lookup based
on VLAN ID and client name. This is useful for monitor commands.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:50 -05:00
Jan Kiszka 28432466f3 slirp: Enable multi-instance support for the smb service
Push the smb state, smb_dir, into SlirpState and construct it in a way
that allows multiple smb instances (one per slirp stack). Remove the smb
directory on slirp cleanup instead of qemu termination. As VLAN clients
are also cleaned up on process termination, no feature is lost.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:50 -05:00
Jan Kiszka 492efabd47 slirp: Improve error handling in slirp_smb
Make sure for invocations from the monitor that slirp_smb properly
reports errors and doesn't terminate qemu.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:50 -05:00
Jan Kiszka 09c1892576 slirp: Use shell to erase smb directory
Instead of open-coding this, we can use the power of the shell to remove
the smb_dir on exit.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:50 -05:00
Jan Kiszka b1c99fcdf5 slirp: Enable multiple instances
Once again this was a long journey to reach the destination: Allow to
instantiate slirp multiple times. But as in the past, the journey was
worthwhile, cleaning up, fixing and enhancing various parts of the user
space network stack along the way.

What is this particular change good for? Multiple slirps instances
allow separated user space networks for guests with multiple NICs. This
is already possible, but without any slirp support for the second
network, ie. without a chance to talk to that network from the host via
IP. We have a legacy guest system here that benefits from this slirp
enhancement, allowing us to run both of its NICs purely over
unprivileged user space IP stacks.

Another benefit of this patch is that it simply removes an artificial
restriction of the configuration space qemu is providing, avoiding
another source of surprises that users may face when playing with
possible setups.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:50 -05:00
Jan Kiszka ad0d8c4c32 slirp: Allocate/free stack instance dynamically
Allocate the internal slirp state dynamically and provide and call
slirp_cleanup to properly release it after use. This patch finally
unbreaks slirp release and re-instantiation via host_net_* monitor
commands.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:49 -05:00
Jan Kiszka 9f8bd0421d 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 service
invocations. Additionally provide an opaque value interface for the
callbacks from slirp into the qemu core.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:49 -05:00
Jan Kiszka d6cf84e1de slirp: Drop redundant checks from slirp_output
Slirp doesn't invoke slirp[_can]_output before it is initialized. The
motivation for these checks (3b7f5d479c) no longer applies. So drop
them.

Note: slirp_vc will become invalid if the slirp stack is removed during
runtime. But this is no new bug and will be fixed later.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:49 -05:00
Jan Kiszka d918f23efa slirp: Kill slirp_is_inited
Avoid the need for slirp_is_inited by refactoring the protected
slirp_select_* functions. This also avoids the clearing of all fd sets
on select errors.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:49 -05:00
Jan Kiszka 0fe6a7f284 slirp: Drop statistic code
As agreed on the mailing list, there is no interest in keeping the
usually disabled slirp statistics in the tree. So this patch removes
them.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:46 -05:00
Jan Kiszka 6dbe553fe9 slirp: Add info usernet for dumping connection states
Break out sockstats from the slirp statistics and present them under the
new info category "usernet". This patch also improves the current output
/wrt proper reporting connection source and destination.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:46 -05:00
Jan Kiszka 9c12a6f24d slirp: Do not allow to remove non-hostfwd sockets
Prevent that the users accidentally shoots down dynamic sockets. This
allows to remove looping for removals as there can now only be one
match.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:46 -05:00
Jan Kiszka 3c6a05803c slirp: Bind support for host forwarding rules
Extend the hostfwd rule format so that the user can specify on which
host interface qemu should listen for incoming connections. If omitted,
binding will takes place against all interfaces.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:45 -05:00
Jan Kiszka f3546deb07 slirp: Rework monitor commands for host forwarding
Improve the monitor interface for adding and removing host forwarding
rules by splitting it up in two commands and rename them to hostfwd_add
and hostfwd_remove. Also split up the paths taken for legacy -redir
support and the monitor add command as the latter will be extended later
on.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:45 -05:00
Jan Kiszka c92ef6a22d slirp: Rework external configuration interface
With the internal IP configuration made more flexible, we can now
enhance the user interface. This patch adds a number of new options to
"-net user": net (address and mask), host, dhcpstart, dns and smbserver.
It also renames "redir" to "hostfwd" and "channel" to "guestfwd" in
order to (hopefully) clarify their meanings. The format of guestfwd is
extended so that the user can define not only the port but also the
virtual server's IP address the forwarding starts from.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:45 -05:00
Jan Kiszka ad196a9d0c slirp: Move smb, redir, tftp and bootp parameters and -net channel
So far a couple of slirp-related parameters were expressed via
stand-alone command line options. This it inconsistent and unintuitive.
Moreover, it prevents both dynamically reconfigured (host_net_add/
delete) and multi-instance slirp.

This patch refactors the configuration by turning -smb, -redir, -tftp
and -bootp as well as -net channel into options of "-net user". The old
stand-alone command line options are still processed, but no longer
advertised. This allows smooth migration of management applications to
to the new syntax and also the extension of that syntax later in this
series.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:44 -05:00
Jan Kiszka e15f4a992c Revert "User networking: Show active connections"
This reverts commit 1c6ed9f337.

It's redundant to slirp statistics, which are going to be split up /
reworked later on.

Conflicts:

	monitor.c
	net.c

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29 08:52:44 -05:00
Michael S. Tsirkin ffe6370c9f 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. This
can also be used to disable MSI-X, for compatibility with old qemu. This
option currently only affects virtio cards.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-24 09:09:15 -05:00
Mark McLoughlin 783527a9ef net: add packet length to NetPacketSent callback
virtio-net needs this - for the same purpose that it currently uses the
return value from qemu_sendv_packet().

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-22 10:15:30 -05:00
Mark McLoughlin 0df0ff6de7 net: add '-net tap,sndbuf=nbytes'
2.6.30 adds a new TUNSETSNDBUF ioctl() which allows a send buffer limit
for the tap device to be specified. When this limit is reached, a tap
write() will return EAGAIN and poll() will indicate the fd isn't
writable.

This allows people to tune their setups so as to avoid e.g. UDP packet
loss when the sending application in the guest out-runs the NIC in the
host.

There is no obviously sensible default setting - a suitable value
depends mostly on the capabilities of the physical NIC through which the
packets are being sent.

Also, note that when using a bridge with netfilter enabled, we currently
never get EAGAIN because netfilter causes the packet to be immediately
orphaned. Set /proc/sys/net/bridge/bridge nf-call-iptables to zero to
disable this behaviour.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-22 10:15:30 -05:00
Mark McLoughlin 4a77b25e2a net: return TAPState from net_tap_init()
net_tap_fd_init() already returns TAPState, so this is a sensible
cleanup in its own right.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-22 10:15:30 -05:00
Mark McLoughlin 1f7babf6d5 net: handle EAGAIN from tapfd write()
If a write() on tapfd returns EAGAIN, return zero so that the packet
gets queued (in the case of async send) and enable polling tapfd for
writing.

When tapfd becomes writable, disable write polling and flush any queued
packets.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-22 10:15:30 -05:00
Mark McLoughlin b664e3673c 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 too
and enable/disable both types of polling independently.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-22 10:15:30 -05:00
Mark McLoughlin b9adce2c83 net: purge queued packets in tap_cleanup()
If tap has any packets queued at host_net_remove time, it needs to purge
them in order to prevent a sent callback being invoked for it.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-22 10:15:30 -05:00
Mark McLoughlin 8cad55161c net: add qemu_purge_queued_packets()
If net client sends packets asynchronously, it needs to purge its queued
packets in cleanup() so as to prevent sent callbacks being invoked with
a freed client.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-22 10:15:30 -05:00
Markus Armbruster 5607c38820 Support addr=... in option argument of -net nic
Make net_client_init() accept addr=, put the value into struct
NICinfo.  Use it in pci_nic_init(), and remove arguments bus and
devfn.

Don't support addr= in third argument of monitor command pci_add,
because that clashes with its first argument.  Admittedly unelegant.

Machines "malta" and "r2d" have a default NIC with a well-known PCI
address.  Deal with that the same way as the NIC model: make
pci_nic_init() take an optional default to be used when the user
doesn't specify one.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-22 10:15:29 -05:00
Filip Navara 024431b3d8 Add O_BINARY to open call in net_dump_init.
Fix the pcap dumps on Win32 and other systems where O_BINARY is required.

Signed-off-by: Filip Navara <filip.navara@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-22 10:10:50 -05:00
Glauber Costa 406c8df3a9 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 loading
code that linux_boot and vga are already using.

This patch introduces a "bootable" state in NICInfo structure,
that we can use to keep track of whether or not a given nic should
be bootable, avoiding the introduction of yet another global state.

With that in hands, we move the code in vl.c to hw/pc.c, and use
the already existing infra structure to load those option roms.

Error checking code suggested by Mark McLoughlin

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-22 10:10:50 -05:00
Stefan Weil 705032644f Win32: Don't remove const attribute in type casts.
Type casts removing the const attribute are bad because
they 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>
2009-06-13 14:22:03 +03:00
Blue Swirl c5b76b3810 Fix mingw32 build warnings
Work around buffer and ioctlsocket argument type signedness problems
Suppress a prototype which is unused on mingw32
Expand a macro to avoid warnings from some GCC versions

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-06-13 08:44:31 +00:00
Anthony Liguori 068daedd7d Fix build breakage when using VDE introduced by 4f1c942
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-10 20:24:44 -05:00
Mark McLoughlin e19eb22486 net: make use of async packet sending API in tap client
If a packet is queued by qemu_send_packet(), remove I/O
handler for the tap fd until we get notification that the
packet has been sent.

A not insignificant side effect of this is we can now
drain the tap send queue in one go without fear of packets
being dropped.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:50 +01:00
Mark McLoughlin f3b6c7fcf8 net: add qemu_send_packet_async()
Add a qemu_send_packet() variant which will queue up the packet
if it cannot be sent when all client queues are full. It later
invokes the supplied callback when the packet has been sent.

If qemu_send_packet_async() returns zero, the caller is expected
to not send any more packets until the queued packet has been
sent.

Packets are queued iff a receive() handler returns zero (indicating
queue full) and the caller has provided a sent notification callback
(indicating it will stop and start its own queue).

We need the packet sending API to support queueing because:

  - a sending client should process all available packets in one go
    (e.g. virtio-net emptying its tx ring)

  - a receiving client may not be able to handle the packet
    (e.g. -EAGAIN from write() to tapfd)

  - the sending client could detect this condition in advance
    (e.g. by select() for writable on tapfd)

  - that's too much overhead (e.g. a select() call per packet)

  - therefore the sending client must handle the condition by
    dropping the packet or queueing it

  - dropping packets is poor form; we should queue.

However, we don't want queueing to be completely transparent. We
want the sending client to stop sending packets as soon as a
packet is queued. This allows the sending client to be throttled
by the receiver.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:50 +01:00
Mark McLoughlin e94667b91c net: split out packet queueing and flushing into separate functions
We'll be doing more packet queueing in later commits.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:50 +01:00
Mark McLoughlin 3e021d40b7 net: return status from qemu_deliver_packet()
Will allow qemu_send_packet() handle queue full condition.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:50 +01:00
Mark McLoughlin 4f1c942b7f net: add return value to packet receive handler
This allows us to handle queue full conditions rather than dropping
the packet on the floor.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:49 +01:00
Mark McLoughlin e3f5ec2b5e net: pass VLANClientState* as first arg to receive handlers
Give static type checking a chance to catch errors.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:49 +01:00
Mark McLoughlin cda9046ba7 net: re-name vc->fd_read() to vc->receive()
VLANClientState's fd_read() handler doesn't read from file
descriptors, it adds a buffer to the client's receive queue.

Re-name the handlers to make things a little less confusing.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:49 +01:00
Mark McLoughlin 463af5349a net: add fd_readv() handler to qemu_new_vlan_client() args
This, apparently, is the style we prefer - all VLANClientState
should be an argument to qemu_new_vlan_client().

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:49 +01:00
Mark McLoughlin 3471b757d0 net: only read from tapfd when we can send
Reduce the number of packets dropped under heavy network
traffic by only reading a packet from the tapfd when a
client can actually handle it.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:49 +01:00
Mark McLoughlin 2e1e064110 net: vlan clients with no fd_can_read() can always receive
If a vlan client has no fd_can_read(), that means it can
always receive packets. The current code assumes it can *never*
receive packets.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:49 +01:00
Mark McLoughlin 5b01e886d9 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 qemu
anyway, so merge it in advance of GSO support.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:49 +01:00
Mark McLoughlin 5a6d881574 net: factor tap_read_packet() out of tap_send()
Move portability clutter out into its own function.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:49 +01:00
Jan Kiszka b8e8af38ee slirp: Reorder initialization
This patch reorders the initialization of slirp itself as well as its
associated features smb and redirection. So far the first reference to
slirp triggered the initialization, independent of the actual -net user
option which may carry additional parameters. Now we save any request to
add a smb export or some redirections until the actual initialization of
the stack. This also allows to move a few parameters that were passed
via global variable into the argument list of net_slirp_init.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:49 +01:00
Jan Kiszka 10ae5a7a98 net: Improve parameter error reporting
As host network devices can also be instantiated via the monitor, errors
should then be reported to the related monitor instead of stderr. This
requires larger refactoring, so this patch starts small with introducing
a helper to catch both cases and convert net_client_init as well as
net_slirp_redir.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:49 +01:00
Mark McLoughlin c8decae2e1 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'

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:49 +01:00
Jan Kiszka 0aa7a205c8 net: Real fix for check_params users
OK, last try: 8e4416af45 broke -net socket, ffad4116b9 tried to fix it
but broke error reporting of invalid parameters. So this patch widely
reverts ffad4116b9 again and intead fixes those callers of check_params
that originally suffered from overwritten buffers by using separate
ones.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:49 +01:00
Mark McLoughlin cda94b2782 Revert "Fix output of uninitialized strings"
This reverts commit 8cf07dcbe7.

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

fixed the problem but introduced another problem which
this commit:

  8cf07dcbe7 Fix output of uninitialized strings

fixed that final problem, but causing us to lose some
error reporting information in the process.

Meanwhile Jan posted a patch to mostly re-do ffad4116b9
in a way that fixes the original issue, but without
losing the error reporting information. So, let's revert
8cf07dcbe7 and apply Jan's patch.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:49 +01:00
Jan Kiszka 7c3370d4fe slirp: Avoid zombie processes after fork_exec
Slirp uses fork_exec for spawning service processes, and QEMU uses this
for running smbd. As SIGCHLD is not handled, these processes become
zombies on termination. Fix this by installing a proper signal handler,
but also make sure we disable the signal while waiting on forked network
setup/shutdown scripts.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:49 +01:00
Jan Kiszka c27ff60871 net: Fix and improved ordered packet delivery
Fix a race in qemu_send_packet when delivering deferred packets and
add proper deferring also to qemu_sendv_packet.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09 11:38:48 +01:00
Jan Kiszka c8aa237c64 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>
2009-06-09 11:38:48 +01:00
Alexander Graf 1c6ed9f337 User networking: Show active connections
In case you're wondering what connections exactly you have open
or maybe redir'ed in the past, you can't really find out from qemu
right now.

This patch enables you to see all current connections the host
only networking holds open, so you can kill them using the previous
patch.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-28 02:14:56 -05:00
Alexander Graf c1261d8d16 User Networking: Enable removal of redirections
Using the new host_net_redir command you can easily create redirections
on the fly while your VM is running.

While that's great, it's missing the removal of redirections, in case you
want to have a port closed again at a later point in time.

This patch adds support for removal of redirections.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-27 09:46:12 -05:00
Kevin Wolf 8cf07dcbe7 Fix output of uninitialized strings
Commit ffad4116b9 removed the "scratch buffer"
from check_params, but didn't care for the error messages which actually
included this string to tell the user which option was wrong. Now this string
is uninitialized, so this patch removes it from the message.

This means that the user is only told the whole parameter string and has to
pick the wrong option by himself as the callers of check_params can't know this
value any more. An alternative approach would be to revert that commit and do
whatever is needed to fix the original problem without changing check_params.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-27 09:44:51 -05:00
Jan Kiszka 37cb6fc37b net: Fix dump time stamps
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2009-05-22 10:50:36 -05:00
Paul Brook cc63bb0faa Suppress type mismatch warnings in VDE code.
Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-05-03 22:40:54 +01:00
Jan Kiszka ffad4116b9 net: Fix -net socket parameter checks
My commit ea053add70 broke -net socket by
overwriting an intermediate buffer in the added check_param. Fix this
by switching check_param to automatic buffer allocation and release, ie.
callers no longer have to worry about providing a scratch buffer.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-01 09:44:11 -05:00
Jan Kiszka 206ab6e090 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 the
> code base.

Valid remark, fix below.

Thanks,
Jan

-------->

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-01 09:44:10 -05:00
Robert Reif 8d316b0011 fix net.c compile warning
Fix net.c compile warning:

CC net.o
net.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>
2009-04-27 17:11:36 +00:00
aliguori 8d6249a73a net: Prevent multiple slirp instances (Jan Kiszka)
The slirp stack is full of global variables which prevents instantiating
it more than once. Catch this during net_slirp_init to prevent more harm
later on.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7208 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-21 20:49:11 +00:00
aliguori d4ebe1934a slirp: Enhance host-guest redirection setup (Jan Kiszka)
Allow to establish a TCP/UDP connection redirection also via a monitor
command 'host_net_redir'. Moreover, assume TCP as connection type if
that parameter is omitted.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7204 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-21 19:56:44 +00:00
aliguori 764a4d1deb net: Untangle nested qemu_send_packet (Jan Kiszka)
Queue packets that are send during an ongoing packet delivery. This
ensures that packets will always arrive in their logical order at each
client of a VLAN. Currently, slirp generates such immediate relies, and
e.g. packet-sniffing clients on the same VLAN may get confused.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7203 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-21 19:56:41 +00:00
aliguori 5c8be678a9 monitor: Improve host_net_add (Jan Kiszka)
Fix the documentation of the host_net_add monitor command and allow the
user to pass no options at all. Moreover, inform the user on the
monitor terminal if a request failed.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7201 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-21 19:56:32 +00:00
aliguori bb9ea79e7a net: Add support for capturing VLANs (Jan Kiszka)
This patch is derived from Tristan Gingold's patch. It adds a new VLAN
client type that writes all traffic on the VLAN it is attached to into a
pcap file. Such a file can then be analyzed offline with Wireshark or
tcpdump.

Besides rebasing and some minor cleanups, the major differences to the
original version are:
 - support for enabling/disabling via the monitor (host_net_add/remove)
 - no special ordering of VLAN client list, qemu_send_packet now takes
   care of properly ordered packets
 - 64k default capturing limit (I hate tcpdump's default)

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7200 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-21 19:56:28 +00:00
aliguori 8e4416af45 net: Add parameter checks for VLAN clients (Jan Kiszka)
This aims at helping the user to find typos or other mistakes in
parameter lists passed for VLAN client initialization. The existing
parsing infrastructure does not allow a leaner approach, but this is
better than nothing IMHO.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7197 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-21 19:56:15 +00:00
aliguori ea053add70 net: Fix -net socket,listen (Jan Kiszka)
In case no symbolic name is provided when requesting VLAN connection via
listening TCP socket ('-net socket,listen=...'), qemu crashes. This
fixes the cause.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7196 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-21 19:56:11 +00:00
aliguori e8f1f9db87 net: Check device passed to host_net_remove (Jan Kiszka)
Make sure that we do not delete guest NICs via host_net_remove.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7195 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-21 19:56:08 +00:00
aliguori dad354198e Free VLANClientState using qemu_free() (Mark McLoughlin)
It's allocated using qemu_mallocz(), so ...

The name and model strings are strdup() allocated, so free()
is still appropriate for them.

Reported-by: Jan Kiszka <jan.kiszka@siemens.com>
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@7151 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 17:11:12 +00:00
aliguori b946a15332 Introduce VLANClientState::cleanup() (Mark McLoughlin)
We're currently leaking memory and file descriptors on device
hot-unplug.

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@7150 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 17:11:08 +00:00
aliguori 9036de1a8a Remove some useless malloc() checking (Mark McLoughlin)
Now that we abort() on malloc, neither qemu_find_vlan() nor
net_tap_fd_init() can fail.

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@7146 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 17:10:51 +00:00
aliguori 771f133989 Fix error handling in net_client_init() (Mark McLoughlin)
We weren't freeing the name string everywhere.

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@7144 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 17:10:43 +00:00
aliguori efb816c9a8 struct iovec is now universally available (Mark McLoughlin)
struct iovec is now defined in qemu-common.h if needed, so we don't need
the tap code to handle !defined(HAVE_IOVEC).

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@7143 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 17:10:39 +00:00
blueswir1 3f4cb3d37f Fix OpenSolaris gcc4 warnings: iovec type mismatches, missing 'static'
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7103 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-13 16:31:01 +00:00
blueswir1 b9e82a5946 Fix some win32 compile warnings
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6984 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-05 18:03:31 +00:00
aliguori 7cd0874c7a host_device_remove: remove incorrect check for device name (Eduardo Habkost)
There is no need to check for valid prefixes on the the device name
when removing it. If the device name is found on the vlan client list,
it can be removed, regardless of the prefix used on its name.

To reproduce the bug, just run this on the monitor:

 (qemu) host_net_add user name=foobar
 (qemu) host_net_remove 0 foobar
 invalid host network device foobar
 (qemu)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6891 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-28 15:58:58 +00:00
aliguori 49dc768d4c Fix windows build and clean up use of <windows.h>
We want to globally define WIN_LEAN_AND_MEAN and WINVER to particular values so
let's do it in OS_CFLAGS.

Then, we can pepper in windows.h includes where using #includes that require it.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6783 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-08 16:26:59 +00:00
blueswir1 179a2c1971 Rename _BSD to HOST_BSD so that it's more obvious that it's defined by configure
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6775 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-08 08:23:32 +00:00
blueswir1 c5e97233e8 Support for DragonFly BSD (Hasso Tepper)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6746 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-07 20:06:23 +00:00
blueswir1 d40cdb1002 Fix BSD breakage from r6736
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6742 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-07 16:52:02 +00:00
blueswir1 511d2b140f Sparse fixes: NULL use, header order, ANSI prototypes, static
Fix Sparse warnings:
 * use NULL instead of plain 0
 * rearrange header include order to avoid redefining types accidentally
 * ANSIfy SLIRP
 * avoid "restrict" keyword
 * add static



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6736 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-07 15:32:56 +00:00
aliguori 376253ece4 monitor: Rework API (Jan Kiszka)
Refactor the monitor API and prepare it for decoupled terminals:
term_print functions are renamed to monitor_* and all monitor services
gain a new parameter (mon) that will once refer to the monitor instance
the output is supposed to appear on. However, the argument remains
unused for now. All monitor command callbacks are also extended by a mon
parameter so that command handlers are able to pass an appropriate
reference to monitor output services.

For the case that monitor outputs so far happen without clearly
identifiable context, the global variable cur_mon is introduced that
shall once provide a pointer either to the current active monitor (while
processing commands) or to the default one. On the mid or long term,
those use case will be obsoleted so that this variable can be removed
again.

Due to the broad usage of the monitor interface, this patch mostly deals
with converting users of the monitor API. A few of them are already
extended to pass 'mon' from the command handler further down to internal
functions that invoke monitor_printf.

At this chance, monitor-related prototypes are moved from console.h to
a new monitor.h. The same is done for the readline API.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6711 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-05 23:01:23 +00:00
aliguori abcd2baab1 net socket verify packet size (Dustin Kirkland)
net socket oversized packet

This is a patch being carried by Ubuntu against kvm/qemu.

Verify packet size before performing memcpy().

Signed-off-by: Dustin Kirkland <kirkland@canonical.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6647 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-27 19:54:01 +00:00
aliguori 8ca9217d04 specify vmchannel as a net option (Gleb Natapov)
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6623 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-16 15:34:18 +00:00
aliguori 6f338c3469 qemu: PCI device, disk and host network hot-add / hot-remove (Marcelo Tosatti)
Add monitor command to hot-add PCI devices (nic and storage).
    
Syntax is:
    
pci_add pci_addr=[[<domain>:]<bus>:]<slot> nic|storage params
    
It returns the domain, bus and slot for the newly added device on success.
    
It is possible to attach a disk to a device after PCI initialization via
the drive_add command. If so, a manual scan of the SCSI bus on the guest
is necessary.
    
Save QEMUMachine necessary for drive_init.
    
Add monitor command to hot-remove devices, remove device data on _EJ0 notification.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6610 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-11 15:21:54 +00:00
aliguori 8b13c4a794 qemu: add net_client_uninit / qemu_find_vlan_client (Marcelo Tosatti)
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6600 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-11 15:20:51 +00:00
aliguori 4d73cd3b3f qemu: net/drive add/remove tweaks (Marcelo Tosatti)
Export net/drive add/remove functions for device hotplug usage.

Return the table index on add.

Return failure instead of exiting if limit has been reached
on drive_add.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6599 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-11 15:20:46 +00:00
aliguori 7697079b73 qemu: dynamic nic info index allocation (Marcelo Tosatti)
Dynamically allocate nic info index, so to reuse indexes when devices are
removed.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6595 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-11 15:20:03 +00:00
aliguori 1eec614b36 toplevel: remove error handling from qemu_malloc() callers (Avi Kivity)
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6531 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-05 22:06:18 +00:00
aliguori e0e7877a0a Handle link status in qemu_sendv_packet() (Mark McLoughlin)
If link is down, pretend that the packet has been successfully sent.

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@6444 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-26 15:37:44 +00:00
aliguori 973cbd37ce Fix tap downscript argument (Mark McLoughlin)
Kill off the hack that parses info_str for the tap interface
name to pass as the argument to the downscript and, instead,
just explicitly keep a copy of the string for later.

As reported by John Wong, this commit:

  Add qemu_format_nic_info_str()

changed the invocation of downscript from e.g.

  /path/kvm-ifdown "tap0"

to:

  /path/kvm-ifdown "tap0,script=/path/kvm-ifup,downscript=/path/kvm-ifdown"

This fix restores the original behavior.

Reported-by: John Wong <johnw@wonghome.net>
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@6285 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-13 19:15:55 +00:00
aliguori d07f22c530 Add qemu_check_nic_model() and qemu_check_nic_model_list() (Mark McLoughlin)
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@6281 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-13 19:03:57 +00:00
edgar_igl dd5de373b7 Make the set_link cmd handle multiple nics.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6256 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-09 00:48:28 +00:00
aliguori 34b25ca74e Allow devices be notified of link status change (Mark McLoughlin)
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@6248 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-08 19:45:03 +00:00
aliguori 436e5e53c9 Add 'set_link' monitor command (Mark McLoughlin)
Add a monitor command to setting a given network device's link status
to 'up' or 'down'.

Allows simulation of network cable disconnect.

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@6247 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-08 19:44:06 +00:00
aliguori 49ec9b4054 Add "restrict" and "ip" option to "user" net option (Gleb Natapov)
Expose new slirp capabilities to user through a command line options.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6242 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-08 19:26:22 +00:00
aliguori a9ba3a856d Add slirp_restrict option (Gleb Natapov)
Add "slirp firewall" to permit connection only to vmchannel addresses.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6241 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-08 19:24:00 +00:00
aliguori 4dda406337 Add model field to nic info (Mark McLoughlin)
The model type used to be printed as part of the nic info.  It was removed when
the name type was added.  This adds back a model field for those that were
using it previously.

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@6239 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-08 19:01:37 +00:00
aliguori 7a9f6e4a8d Add a -net name=foo parameter (Mark McLoughlin)
Allow the user to supply a vlan client name on the command line.

This is probably only useful for management tools so that they can
use their own names rather than parsing the output of 'info network'.

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@6220 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-07 17:48:51 +00:00
aliguori 7cb7434b1e Add qemu_format_nic_info_str() (Mark McLoughlin)
Factor out a simple little function for formatting a NIC's
info_str and make all NICs use it.

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@6218 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-07 17:46:21 +00:00
aliguori 676cff2940 Assign a name to each VLAN client (Mark McLoughlin)
Automatically assign a name to each vlan client based on its model,
e.g. e1000.0, tap.3 or vde.1.

This name is intended to be used by the forthcoming 'set_link'
monitor command.

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@6217 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-07 17:43:44 +00:00
aliguori bf38c1a0e1 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
2009-01-07 17:42:25 +00:00
aurel32 f54825cc24 consolidate definition for tap script and smb support
Since the introduction of net.c in r5581 there had been 2 places where
the location of the TAP helper scripts and SMB daemon are defined.

The following patch move those definitions to net.h so they are accessible
for net.c and vl.c but defined only once

(Carlo Marcelo Arenas Belon)

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6093 c046a42c-6fe2-441c-8c8c-71466251a162
2008-12-18 22:43:48 +00:00
aliguori b535b7b2f7 Add support for tap vectored send
This is adapted from kvm-userspace.  It allows readv to be used with tap when
the host supports it.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6074 c046a42c-6fe2-441c-8c8c-71466251a162
2008-12-17 19:17:17 +00:00
aliguori fbe78f4f55 virtio-net support
This adds virtio-net support.  This is based on the virtio-net driver 
that exists in kvm-userspace.  This also adds a new qemu_sendv_packet 
which virtio-net requires.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6073 c046a42c-6fe2-441c-8c8c-71466251a162
2008-12-17 19:13:11 +00:00
blueswir1 69d6451c3e Fix some new warnings introduced after r5022
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5933 c046a42c-6fe2-441c-8c8c-71466251a162
2008-12-07 19:30:18 +00:00
blueswir1 47398b9c36 Use qemu_isfoobar and qemu_towombat versions, based on patch by Christoph Egger
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5774 c046a42c-6fe2-441c-8c8c-71466251a162
2008-11-22 20:04:24 +00:00
malc b29fe3ed48 Preliminary AIX support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5732 c046a42c-6fe2-441c-8c8c-71466251a162
2008-11-18 01:42:22 +00:00
blueswir1 cd390083ad Attached patch fixes a series of this warning
when compiling on NetBSD:

warning: array subscript has type 'char'

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5727 c046a42c-6fe2-441c-8c8c-71466251a162
2008-11-16 13:53:32 +00:00
aliguori 559b90fbbf Move the things that aren't target specific to libqemu_common.a.
This will improve the build time.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5699 c046a42c-6fe2-441c-8c8c-71466251a162
2008-11-11 21:20:14 +00:00