Add config.h file that includes config-target.h and config-host.h
Patchworks-ID: 35193
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
If config-host.mak dont' exist, we have exited in the check at
the beginning of the file.
Once here, move the bits to the else part of the test at the beginning of
the file.
Patchworks-ID: 35191
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Use timestamp based appreach to avoid not needed recompilation.
Add it to rules.mak
Many thanks to Paolo Bonzini for helpding the design, and the debug.
Patchworks-ID: 35190
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Include it directly in Makefile.target
Patchworks-ID: 35189
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Some callers test for != 0, some for < 0. Normalize to < 0.
Patchworks-ID: 35171
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
After qdev_init() fails, the device is gone. Failure to check runs a
high risk of use-after-free.
Patchworks-ID: 35166
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Callers don't check the return value anyway.
Patchworks-ID: 35172
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Like qdev_init(), but terminate program via hw_error() instead of
returning an error value.
Use it instead of qdev_init() where terminating the program on failure
is okay, either because it's during machine construction, or because
we know that failure can't happen.
Because relying in the latter is somewhat unclean, and the former is
not always obvious, it would be nice to go back to qdev_init() in the
not-so-obvious cases, only with proper error handling. I'm leaving
that for another day, because it involves making sure that error
values are properly checked by all callers.
Patchworks-ID: 35168
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
But do so only where it may actually fail. Leave the rest for the
next commit.
Patchworks-ID: 35167
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Before, every caller had to do this. Only two actually did.
Patchworks-ID: 35170
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Commit 22f84e73 added a qdev_init() missing on the path through
usb_host_device_open(), but that broke the path through
usb_host_auto_scan(), which already had one. Remove that one.
Patchworks-ID: 35169
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
The arpl implementation in target-i386/translate.c uses cpu_A0
temporary across a brcond op. This patch fixes that issue.
Signed-off-by: Laurent Desnogues <laurent.desnogues@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This remove implicit rules + implicit variables.
Explicit rules like the generation of %.h and %.c from %.hx still works
as expected.
As an added bonus, now the output of make -d is readable.
As another added bonus, time spend on Makefiles is way smaller.
We run make -j3 in a fully compiled tree, and results are:
Before:
$ time make -j3
real 0m1.225s
user 0m1.660s
sys 0m0.253s
After:
$ time make -j3
real 0m0.422s
user 0m0.393s
sys 0m0.248s
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Move comment back next to main_system_bus to avoid confusion.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Making pci device cleanup msix automatically makes pci.c depend on
msix.c, which is IMO messy. Since devices do msix_init it's easy and
natural for them to also do msix_uninit.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
PCI load routine has to be called with size equal to 256 (otherwise it
will crash in weird ways). So assert this, making code clearer.
Also avoid dynamically sized array on stack - good for portability.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Cc: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
The first step in porting -net to QemuOpts. We do not include parameter
descriptions in the QemuOptsList because we use the first parameter to
choose which descriptions validate against.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Rather than overwriting a QemuOpt, just add a new one to the tail and
always do a reverse search for parameters to preserve the same
behaviour. We use this order so that foreach() iterates over the opts
in their original order.
This will allow us handle options where multiple values for the same
parameter is allowed - e.g. -net user,hostfwd=
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Several qemu command line options have a parameter whose value affects
what other parameters are accepted for the option.
In these cases, we can have an empty description table in the
QemuOptsList and once the option has been parsed we can use a suitable
description table to validate the other parameters based on the value of
that parameter.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Rather than making callers explicitly handle empty strings by using
qemu_opts_create(), we can easily have qemu_opts_parse() handle
empty parameter strings.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qemu_opts_parse() gives a suitable error message in all failure cases
so we can remove the error message from the caller.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qemu_opt_set() prints an error message in all failure cases, so
qemu_set_option() doesn't need to print another error.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
The only way qemu_opts_create() can fail is if a QemuOpts with that id
already exists and fail_if_exists=1. In that case, we already print
an error which makes more sense than the one in qemu_opts_set().
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
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>
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>
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>
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>
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>