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

169 Commits

Author SHA1 Message Date
Gerd Hoffmann 2ef924b416 qdev: add netdev property
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27 12:28:37 -05:00
Gerd Hoffmann 76d32cba7e net: add macaddr type.
Add new type for mac addresses.

Add function which sets the qemu default mac address if it finds the mac
address uninitialized (i.e. all zeros).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27 12:28:36 -05:00
Mark McLoughlin c1671a0876 net: fix multiple NICs causing net opts process to stop
For NICs, net_init_client() returns the index into the NICInfo table.

qemu_opts_foreach() interprets non-zero as an error return an stops
iterating over the options.

So, if you have more than one '-net nic' on the command line, subsequent
'-net' options do not get processed.

Fix this by making net_client_init() only return non-zero if
net_init_client() returns an error.

Reported-by: Peter Lieven <pl@dlh.net>
Patchworks-ID: 35736
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15 09:32:03 -05:00
Mark McLoughlin 9a6ecb308b net: add queue for peer-to-peer packet forwarding
Now that we have re-factored the packet queue code, we can re-use
it for peer-to-peer also.

Patchworks-ID: 35520
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15 09:32:03 -05:00
Mark McLoughlin f710584399 net: refactor packet queueing code
The packet queue code is fairly standalone, has some complex details and
easily reusable. It makes sense to split it out on its own. This patch
doesn't contain any functional changes.

Patchworks-ID: 35511
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15 09:32:03 -05:00
Mark McLoughlin 283c7c63f5 net: allow NICs to be connected to netdevs
Introduce a 'peer' member to VLANClientState as an alternative
to a vlan. The idea being that packets are transfered directly
from peer clients rather than going through a vlan.

Patchworks-ID: 35516
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15 09:32:02 -05:00
Mark McLoughlin 5869c4d515 net: add -net nic,netdev= option
Patchworks-ID: 35515
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15 09:32:02 -05:00
Mark McLoughlin 577c4af937 net: maintain a list of vlan-less clients
Allows them to be cleaned up at shutdown.

This is pretty lame, but will eventually go away as we make vlans
the special case.

Patchworks-ID: 35518
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15 09:32:02 -05:00
Mark McLoughlin f6b134ac30 net: handle -netdevice options
Same as for -net except for:

- only tap, user, vde and socket types are supported
- the vlan parameter is not allowed
- the name parameter is not allowed but the id parameter is
required

Patchworks-ID: 35517
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15 09:32:01 -05:00
Mark McLoughlin 7f161aaea6 net: add QemuOptsList arg to net_client_parse()
Patchworks-ID: 35505
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15 09:32:01 -05:00
Mark McLoughlin d80b9fc628 net: allow clients not associated with a vlan
Allow net clients to be created which are not connected to any vlan.

This is needed by Gerd in order to allow adding -device nic, where
the absence of a vlan parameter will not imply vlan=0. Also needed
to allow adding a -netdevice option which doesn't connect the backend
to a vlan.

Patchworks-ID: 35513
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15 09:32:01 -05:00
Mark McLoughlin 5610c3aaf4 net: use qtailq for vlan and client lists
Patchworks-ID: 35507
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15 09:32:00 -05:00
Mark McLoughlin dea7b3b95a net: remove id field from NICInfo
Just use the name field instead since we now use the id paramater as
the name, if supplied. Only implication with this change is that if
id is not supplied, the value of the name paramater is used as an
id.

Patchworks-ID: 35512
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15 09:32:00 -05:00
Mark McLoughlin 6d952ebedd net: handle id= parameter for -net
Use id= in the same was as the current name= parameter; if both are
specified, id= is used.

Patchworks-ID: 35514
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15 09:32:00 -05:00
Mark McLoughlin 8b077c9f97 net: pass monitor handle to client init functions
Needed for e.g. looking up a file descriptor name using
monitor_get_fd() in net_init_tap()

Patchworks-ID: 35509
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15 09:32:00 -05:00
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