Commit Graph

43247 Commits

Author SHA1 Message Date
Markus Armbruster 433672b0d5 error: Clean up errors with embedded newlines (again)
The arguments of error_report() should yield a short error string
without newlines.

A few places try to print additional help after the error message by
embedding newlines in the error string.  That's nice, but let's do it
the right way.  Commit 474c213 cleaned up some, but they keep coming
back.  Offenders tracked down with the Coccinelle semantic patch from
commit 312fd5f.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-01-13 15:16:18 +01:00
Markus Armbruster bf89e87427 vhdx: Fix "log that needs to be replayed" error message
The arguments of error_setg_errno() should yield a short error string
without newlines.

Here, we try to append additional help to the error message by
embedding newlines in the error string.  That's nice, but it's doesn't
play nicely with the errno part.  tests/qemu-iotests/070.out shows the
resulting mess:

    can't open device TEST_DIR/iotest-dirtylog-10G-4M.vhdx: VHDX image file 'TEST_DIR/iotest-dirtylog-10G-4M.vhdx' opened read-only, but contains a log that needs to be replayed.  To replay the log, execute:
     qemu-img check -r all 'TEST_DIR/iotest-dirtylog-10G-4M.vhdx': Operation not permitted

Switch to error_setg() and error_append_hint().  Result:

    can't open device TEST_DIR/iotest-dirtylog-10G-4M.vhdx: VHDX image file 'TEST_DIR/iotest-dirtylog-10G-4M.vhdx' opened read-only, but contains a log that needs to be replayed
    To replay the log, run:
    qemu-img check -r all 'TEST_DIR/iotest-dirtylog-10G-4M.vhdx'

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-21-git-send-email-armbru@redhat.com>
2016-01-13 15:16:18 +01:00
Markus Armbruster c3d2d68ad6 pci-assign: Clean up "Failed to assign" error messages
The arguments of error_setg() & friends should yield a short error
string without newlines.

Two places try to append additional help to the error message by
embedding newlines in the error string.  That's nice, but let's do it
the right way, with error_append_hint().

Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-20-git-send-email-armbru@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2016-01-13 15:16:18 +01:00
Markus Armbruster d28d737fb9 vmdk: Clean up "Invalid extent lines" error message
vmdk_parse_extents() reports parse errors like this:

    error_setg(errp, "Invalid extent lines:\n%s", p);

where p points to the beginning of the malformed line in the image
descriptor.  This results in a multi-line error message

    Invalid extent lines:
    <first line that doesn't parse>
    <remaining text that may or may not parse, if any>

Error messages should not have newlines embedded.  Since the remaining
text is not helpful, we can simply report:

    Invalid extent line: <first line that doesn't parse>

Cc: Fam Zheng <famz@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-19-git-send-email-armbru@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
2016-01-13 15:16:18 +01:00
Markus Armbruster e4937694b6 vmdk: Clean up control flow in vmdk_parse_extents() a bit
Factor out loop stepping to turn a while-loop with goto into a
for-loop with continue.

Cc: Fam Zheng <famz@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Message-Id: <1450452927-8346-18-git-send-email-armbru@redhat.com>
2016-01-13 15:16:18 +01:00
Markus Armbruster 9af9e0fed7 error: Strip trailing '\n' from error string arguments (again)
Commit 6daf194d, be62a2eb and 312fd5f got rid of a bunch, but they
keep coming back.  Tracked down with the Coccinelle semantic patch
from commit 312fd5f.

Cc: Fam Zheng <famz@redhat.com>
Cc: Peter Crosthwaite <crosthwaitepeter@gmail.com>
Cc: Bharata B Rao <bharata@linux.vnet.ibm.com>
Cc: Dominik Dingel <dingel@linux.vnet.ibm.com>
Cc: David Hildenbrand <dahi@linux.vnet.ibm.com>
Cc: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Cc: Stefan Berger <stefanb@linux.vnet.ibm.com>
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Changchun Ouyang <changchun.ouyang@intel.com>
Cc: zhanghailiang <zhang.zhanghailiang@huawei.com>
Cc: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Acked-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Acked-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-17-git-send-email-armbru@redhat.com>
2016-01-13 15:16:18 +01:00
Markus Armbruster b988468149 qemu-io qemu-nbd: Use error_report() etc. instead of fprintf()
Just three instances left.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-16-git-send-email-armbru@redhat.com>
2016-01-13 15:16:18 +01:00
Markus Armbruster d410fe1454 migration: Use error_reportf_err() instead of monitor_printf()
Both error_reportf_err() and monitor_printf() print to the same
destination when monitor_printf() is used correctly, i.e. within an
HMP monitor.  Elsewhere, monitor_printf() does nothing, while
error_reportf_err() reports to stderr.

Both changed functions are HMP command handlers.  These should only
run within an HMP monitor.

Unlike monitor_printf(), error_reportf_err() uses the error whole
instead of just its message obtained with error_get_pretty().  This
avoids suppressing its hint (see commit 50b7b00), but I don't think
the errors touched in this commit can come with hints.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-15-git-send-email-armbru@redhat.com>
2016-01-13 15:16:17 +01:00
Markus Armbruster b83baa6025 spapr: Use error_reportf_err()
Not caught by Coccinelle, because we report the error only
conditionally here.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-14-git-send-email-armbru@redhat.com>
2016-01-13 15:16:17 +01:00
Markus Armbruster e43bfd9c87 error: Use error_prepend() where it makes obvious sense
Done with this Coccinelle semantic patch

    @@
    expression FMT, E1, E2;
    expression list ARGS;
    @@
    -    error_setg(E1, FMT, ARGS, error_get_pretty(E2));
    +    error_propagate(E1, E2);/*###*/
    +    error_prepend(E1, FMT/*@@@*/, ARGS);

followed by manual cleanup, first because I can't figure out how to
make Coccinelle transform strings, and second to get rid of now
superfluous error_propagate().

We now use or propagate the original error whole instead of just its
message obtained with error_get_pretty().  This avoids suppressing its
hint (see commit 50b7b00), but I can't see how the errors touched in
this commit could come with hints.  It also improves the message
printed with &error_abort when we screw up (see commit 1e9b65b).

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2016-01-13 15:16:17 +01:00
Markus Armbruster c29b77f955 error: Use error_reportf_err() where it makes obvious sense
Done with this Coccinelle semantic patch

    @@
    expression FMT, E, S;
    expression list ARGS;
    @@
    -    error_report(FMT, ARGS, error_get_pretty(E));
    +    error_reportf_err(E, FMT/*@@@*/, ARGS);
    (
    -    error_free(E);
    |
	 exit(S);
    |
	 abort();
    )

followed by a replace of '%s"/*@@@*/' by '"' and some line rewrapping,
because I can't figure out how to make Coccinelle transform strings.

We now use the error whole instead of just its message obtained with
error_get_pretty().  This avoids suppressing its hint (see commit
50b7b00), but I can't see how the errors touched in this commit could
come with hints.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1450452927-8346-12-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2016-01-13 15:16:17 +01:00
Markus Armbruster 8aa802a6b7 error: Don't decorate original error message when adding to it
Prepend the additional information, colon, space to the original
message without enclosing it in parenthesis or quotes, like we do
elsewhere.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-11-git-send-email-armbru@redhat.com>
2016-01-13 15:16:17 +01:00
Markus Armbruster 8277d2aa58 error: New error_prepend(), error_reportf_err()
Instead of simply propagating an error verbatim, we sometimes want to
add to its message, like this:

    frobnicate(arg, &err);
    error_setg(errp, "Can't frobnicate %s: %s",
                     arg, error_get_pretty(err));
    error_free(err);

This is suboptimal, because it loses err's hint (if any).  Moreover,
when errp is &error_abort or is subsequently propagated to
&error_abort, the abort message points to the place where we last
added to the error, not to the place where it originated.

To avoid these issues, provide means to add to an error's message in
place:

    frobnicate(arg, errp);
    error_prepend(errp, "Can't frobnicate %s: ", arg);

Likewise, reporting an error like

    frobnicate(arg, &err);
    error_report("Can't frobnicate %s: %s", arg, error_get_pretty(err));

can lose err's hint.  To avoid:

    error_reportf_err(err, "Can't frobnicate %s: ", arg);

The next commits will put these functions to use.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-10-git-send-email-armbru@redhat.com>
2016-01-13 15:16:17 +01:00
Markus Armbruster 73eaa04777 test-throttle: Simplify qemu_init_main_loop() error handling
The code looks like it tries to check for both qemu_init_main_loop()
and qemu_get_aio_context() failure in one conditional.  In fact,
qemu_get_aio_context() can fail only after qemu_init_main_loop()
failed.

Simplify accordingly: check for qemu_init_main_loop() error directly,
without bothering to improve its error message.  Call
qemu_get_aio_context() only when qemu_get_aio_context() succeeded.  It
can't fail then, so no need to check.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-9-git-send-email-armbru@redhat.com>
2016-01-13 15:16:17 +01:00
Markus Armbruster a4699e55f5 qemu-nbd: Clean up "Failed to load snapshot" error message
bdrv_snapshot_load_tmp() sets an error and returns -errno on failure.
We report both even though the error message is self-contained.  Drop
the redundant strerror().

While there: setting errno right before exit() is pointless, so drop
that, too.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-8-git-send-email-armbru@redhat.com>
2016-01-13 15:16:17 +01:00
Markus Armbruster cd5c2dac2e block: Clean up "Could not create temporary overlay" error message
bdrv_create() sets an error and returns -errno on failure.  When the
latter is interesting, the error is created with error_setg_errno().

bdrv_append_temp_snapshot() uses the error's message to create a new
one with error_setg_errno().  This adds a strerror() that is either
uninteresting or duplicate.  Use error_setg() instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-7-git-send-email-armbru@redhat.com>
2016-01-13 15:16:16 +01:00
Markus Armbruster f4d0064afc error: Improve documentation
While there, tighten error_append_hint()'s assertion.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1450452927-8346-6-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2016-01-13 15:16:16 +01:00
Markus Armbruster 7828867198 error: Use error_report_err() instead of ad hoc prints
Unlike ad hoc prints, error_report_err() uses the error whole instead
of just its message obtained with error_get_pretty().  This avoids
suppressing its hint (see commit 50b7b00).  Example:

    $ bld/ivshmem-server -l 42@
    Parameter 'shm_size' expects a size
    You may use k, M, G or T suffixes for kilobytes, megabytes, gigabytes and terabytes.

The last line is new with this patch.

While there, drop a "cannot parse shm size: " message prefix; it's
redundant, because the error message proper is always of the form
"Parameter 'shm_size' expects ...".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-5-git-send-email-armbru@redhat.com>
2016-01-13 15:16:16 +01:00
Markus Armbruster 193227f9e5 error: Use error_report_err() instead of monitor_printf()
Both error_report_err() and monitor_printf() print to the same
destination when monitor_printf() is used correctly, i.e. within an
HMP monitor.  Elsewhere, monitor_printf() does nothing, while
error_report_err() reports to stderr.

Most changed functions are HMP command handlers.  These should only
run within an HMP monitor.  The one exception is bdrv_password_cb(),
which should also only run within an HMP monitor.

Four command handlers prefix the error message with the command name:
balloon, migrate_set_capability, migrate_set_parameter, migrate.
Pointless, drop.

Unlike monitor_printf(), error_report_err() uses the error whole
instead of just its message obtained with error_get_pretty().  This
avoids suppressing its hint (see commit 50b7b00).  Example:

    (qemu) device_add ivshmem,id=666
    Parameter 'id' expects an identifier
    Identifiers consist of letters, digits, '-', '.', '_', starting with a letter.
    Try "help device_add" for more information

The "Identifiers consist of..." line is new with this patch.

Coccinelle semantic patch:

    @@
    expression M, E;
    @@
    -    monitor_printf(M, "%s\n", error_get_pretty(E));
    -    error_free(E);
    +    error_report_err(E);
    @r1@
    expression M, E;
    format F;
    position p;
    @@
    -    monitor_printf(M, "...%@F@\n", error_get_pretty(E));@p
    -    error_free(E);
    +    error_report_err(E);
    @script:python@
	p << r1.p;
    @@
    print "%s:%s:%s: prefix dropped" % (p[0].file, p[0].line, p[0].column)

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-4-git-send-email-armbru@redhat.com>
2016-01-13 15:16:16 +01:00
Markus Armbruster 4fffeb5e19 error: Use error_report_err() where appropriate (again)
Same Coccinelle semantic patch as in commit 565f65d.

We now use the original error whole instead of just its message
obtained with error_get_pretty().  This avoids suppressing its hint
(see commit 50b7b00), but I don't think the errors touched in this
commit can come with hints.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-3-git-send-email-armbru@redhat.com>
2016-01-13 15:16:16 +01:00
Markus Armbruster 85b01e0960 qemu-nbd: Replace BSDism <err.h> by error_report()
Coccinelle semantic patch

    @@
    expression E;
    expression list ARGS;
    @@
    -       errx(E, ARGS);
    +       error_report(ARGS);
    +       exit(E);
    @@
    expression E, FMT;
    expression list ARGS;
    @@
    -       err(E, FMT, ARGS);
    +       error_report(FMT /*": %s"*/, ARGS, strerror(errno));
    +       exit(E);

followed by a replace of '"/*": %s"*/' by ' : %s"', because I can't
figure out how to make Coccinelle transform strings.

A few of the error messages touched have trailing newlines.  They'll
be stripped later in this series.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-2-git-send-email-armbru@redhat.com>
2016-01-13 15:16:16 +01:00
Markus Armbruster acef5c02e5 xen-hvm: Mark inappropriate error handling FIXME
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: xen-devel@lists.xensource.com
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1450370121-5768-14-git-send-email-armbru@redhat.com>
2016-01-13 15:16:16 +01:00
Markus Armbruster 7e274652e4 audio: Clean up inappropriate and unreachable use of hw_error()
audio_init() should not use hw_error(), because dumping CPU registers
is unhelpful there, and aborting is wrong, because it can be called
called from an audio device's realize() method.

The two uses of hw_error() come from commit 0d9acba:

* When qemu_new_timer() fails.  It couldn't fail back then, and it
  can't fail now.  Drop the unreachable error handling.

* When no_audio_driver can't be initialized.  It couldn't fail back
  then, and it can't fail now.  Replace the error handling by an
  assertion.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
2016-01-13 15:16:16 +01:00
Markus Armbruster 675463d9b6 isa: Clean up inappropriate hw_error()
isa_bus_irqs(), isa_create() and isa_try_create() call hw_error() when
passed a null bus.  Use of hw_error() has always been questionable,
because these are used only during machine initialization, and
printing CPU registers isn't useful there.

Since the previous commit, passing a null bus is a programming error.
Drop the hw_error() and simply let it crash.

Cc: Richard Henderson <rth@twiddle.net>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: "Hervé Poussineau" <hpoussin@reactos.org>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Reviewed-by: Hervé Poussineau <hpoussin@reactos.org>
Message-Id: <1450354795-31608-12-git-send-email-armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
2016-01-13 15:15:57 +01:00
Markus Armbruster d10e54329b isa: Clean up error handling around isa_bus_new()
We can have at most one ISA bus.  If you try to create another one,
isa_bus_new() complains to stderr and returns null.

isa_bus_new() is called in two contexts, machine's init() and device's
realize() methods.  Since complaining to stderr is not proper in the
latter context, convert isa_bus_new() to Error.

Machine's init():

* mips_jazz_init(), called from the init() methods of machines
  "magnum" and "pica"

* mips_r4k_init(), the init() method of machine "mips"

* pc_init1() called from the init() methods of non-q35 PC machines

* typhoon_init(), called from clipper_init(), the init() method of
  machine "clipper"

These callers always create the first ISA bus, hence isa_bus_new()
can't fail.  Simply pass &error_abort.

Device's realize():

* i82378_realize(), of PCI device "i82378"

* ich9_lpc_realize(), of PCI device "ICH9-LPC"

* pci_ebus_realize(), of PCI device "ebus"

* piix3_realize(), of PCI device "pci-piix3", abstract parent of
  "PIIX3" and "PIIX3-xen"

* piix4_realize(), of PCI device "PIIX4"

* vt82c686b_realize(), of PCI device "VT82C686B"

Propagate the error.  Note that these devices are typically created
only by machine init() methods with qdev_init_nofail() or similar.  If
we screwed up and created an ISA bus before that call, we now give up
right away.  Before, we'd hobble on, and typically die in
isa_bus_irqs().  Similar if someone finds a way to hot-plug one of
these critters.

Cc: Richard Henderson <rth@twiddle.net>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: "Hervé Poussineau" <hpoussin@reactos.org>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Hervé Poussineau <hpoussin@reactos.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <1450370121-5768-11-git-send-email-armbru@redhat.com>
2016-01-13 11:58:59 +01:00
Markus Armbruster 3a80ceadcb isa: Trivially convert remaining PCI-ISA bridges to realize()
These are "ICH9-LPC" and "ebus".

Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <1450370121-5768-10-git-send-email-armbru@redhat.com>
2016-01-13 11:58:58 +01:00
Markus Armbruster c72fbf98cb sysbus: Don't use hw_error() in machine_init_done_notifiers
platform_bus_map_irq() and platform_bus_map_mmio() use hw_error() to
fail.  They run in machine_init_done_notifiers, via
platform_bus_init_notify() and link_sysbus_device().  Printing CPU
registers is not helpful there.

Replace hw_error() by error_report(); exit(1).  If these are
programming errors, it should be replaced by an assertion instead.

While there, observe that both functions always return 0, and
link_sysbus_device() ignores the return value.  Change them to void.

Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1450370121-5768-9-git-send-email-armbru@redhat.com>
2016-01-13 11:58:58 +01:00
Markus Armbruster 7b55044f9d hw/arm/virt: Fix property "gic-version" error handling
virt_set_gic_version() calls exit(1) when passed an invalid property
value.  Property setters are not supposed to do that.  Screwed up in
commit b92ad39.  Harmless, because the property belongs to a machine.
Set an error object instead.

Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
2016-01-13 11:58:58 +01:00
Markus Armbruster 543202c0dd error: Don't append a newline when printing the error hint
Since commit 50b7b00, we have error_append_hint() to conveniently
accumulate Error member @hint.  error_report_err() prints it with a
newline appended.  Consequently, users of error_append_hint() need to
know whether theirs is the final line of the hint to decide whether it
needs a newline.  Not a nice interface.

Change error_report_err() to print just the hint, and the (still few)
users of error_append_hint() to add the required newline.

Cc: Eric Blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450370121-5768-7-git-send-email-armbru@redhat.com>
2016-01-13 11:58:58 +01:00
Markus Armbruster 9280eb34de raven: Mark use of hw_error() in realize() FIXME
Device realize() methods aren't supposed to call hw_error(), they
should set an error and fail cleanly.  Blindly doing that would be
easy enough, but then realize() would fail without undoing its side
effects.  Just mark it FIXME for now.

Cc: "Andreas Färber" <andreas.faerber@web.de>
Cc: qemu-ppc@nongnu.org
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1450370121-5768-6-git-send-email-armbru@redhat.com>
2016-01-13 11:58:58 +01:00
Markus Armbruster 5a8de107e3 etraxfs_eth: Don't use hw_error() in init() method
Device init() methods aren't supposed to call hw_error(), they should
report the error and fail cleanly.  Do that.

Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Message-Id: <1450370121-5768-5-git-send-email-armbru@redhat.com>
2016-01-13 11:58:58 +01:00
Markus Armbruster b097e48121 arm_mptimer: Don't use hw_error() in realize() method
Device realize() methods aren't supposed to call hw_error(), they
should set an error and fail cleanly.  Do that.

Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <1450370121-5768-4-git-send-email-armbru@redhat.com>
2016-01-13 11:58:58 +01:00
Markus Armbruster 84a3a53cf6 omap: Don't use hw_error() in device init() methods
Device init() methods aren't supposed to call hw_error(), they should
report the error and fail cleanly.  Do that.

The errors are all device misconfiguration.  All callers use
qdev_init_nofail(), so this patch merely converts hw_error() crashes
into &error_abort crashes.  Improvement, because now it crashes closer
to where the misconfiguration bug would be, and a few more bad
examples of hw_error() use are gone.

Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <1450370121-5768-3-git-send-email-armbru@redhat.com>
2016-01-13 11:58:58 +01:00
Markus Armbruster c525436e69 hw: Don't use hw_error() for machine initialization errors
Printing CPU registers is not helpful during machine initialization.
Moreover, these are straightforward configuration or "can get
resources" errors, so dumping core isn't appropriate either.  Replace
hw_error() by error_report(); exit(1).  Matches how we report these
errors in other machine initializations.

Cc: Richard Henderson <rth@twiddle.net>
Cc: qemu-arm@nongnu.org
Cc: qemu-ppc@nongnu.org
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1450370121-5768-2-git-send-email-armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
2016-01-13 11:58:58 +01:00
Markus Armbruster 6231a6da9f hw: Inline the qdev_prop_set_drive_nofail() wrapper
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1449764955-10741-3-git-send-email-armbru@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
2016-01-13 11:58:58 +01:00
Markus Armbruster 007b06578a Use error_fatal to simplify obvious fatal errors
Done with this Coccinelle semantic patch:

    @@
    type T;
    identifier FUN, RET;
    expression list ARGS;
    expression ERR, EC;
    @@
    (
    -    T RET = FUN(ARGS, &ERR);
    +    T RET = FUN(ARGS, &error_fatal);
    |
    -    RET = FUN(ARGS, &ERR);
    +    RET = FUN(ARGS, &error_fatal);
    |
    -    FUN(ARGS, &ERR);
    +    FUN(ARGS, &error_fatal);
    )
    -    if (ERR != NULL) {
    -        error_report_err(ERR);
    -        exit(EC);
    -    }

This is actually a more elegant version of my initial semantic patch
by courtesy of Eduardo.

It leaves dead Error * variables behind, cleaned up manually.

Cc: qemu-arm@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
2016-01-13 11:58:58 +01:00
Markus Armbruster 8d780f4392 error: Document how to accumulate multiple errors
Suggested-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1447776349-2344-1-git-send-email-armbru@redhat.com>
2016-01-13 11:58:57 +01:00
Peter Maydell 649a1bbaf9 VirtFS update:
Cleanups mostly isolating virtio related details into separate files. This
 is done to enable easy addition of Xen transport for VirtFS.
 
 The changes include:
 
 1. Rename a bunch of files and functions to make clear they are generic.
 2. disentangle virtio transport code and generic 9pfs code.
 3. Some function name clean-up.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJWlJdzAAoJEN5BpP4ExOI689QP/i4nPm/TFRlScnyXX6METu/E
 vDJv+9lWlJJ57len4MKDmGZYG+AbFzAY8BWtK4Ssr33aj/8GeNSq8u3rBJoE7SdJ
 BKQXAdP7mJRJOPh0WfCbeGaGa95hPzyOfZZs+IHXhulNFagraMrfWcNNdyNXsaw1
 uhKZbB4QmM29vyj0Mp7/ynMP2WJbS2sxkoJDhOjelGxS0E2JdSE7UO0h6l2WUk5B
 OK7YdsaO8tge8/45ECD/veIwOex55OeKHbZyQjgx0MK7QLhowEGNyY2r7wpjJB8Z
 xicGpY9/iY/YHqJhtKTa8vrs3tUlPl669u3QqNpXDGpwYMkNwfvyljx2tr3t1Nn5
 KSxfkYzOsf9TUnf+maMlFVJkMMQWshxR7zfr26+Fo/O+PJKsoF6Jdr63V/p3yNH8
 G8QoLhWv1sQfV15sFGUSjbTeIfhOAXPE+tYnAg3tn+PEFMoROUAxvDDMFYQzuVtZ
 IfzdhgFTQUVNzWxsa20pVSJ36+z+3TFzdEnTyRKixreZSkrvDJ62RfPgjtfbZkf+
 Of+TUvDmHiUcIexBZJeQhu/VcsLwuEAxOtomfsOxfrYVTmFWAoAmFzFn5Q6dr9Sd
 XV7/L0ApTnkFlQ9d2NgNkIKeMyL2BXQbAYSRs3bCIcvoSWctRa/Zx/L+BTp+iGwy
 3FrR2/jpdXKPeFmz+iZ7
 =ZBhb
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kvaneesh/tags/for-upstream-signed' into staging

VirtFS update:

Cleanups mostly isolating virtio related details into separate files. This
is done to enable easy addition of Xen transport for VirtFS.

The changes include:

1. Rename a bunch of files and functions to make clear they are generic.
2. disentangle virtio transport code and generic 9pfs code.
3. Some function name clean-up.

# gpg: Signature made Tue 12 Jan 2016 06:04:35 GMT using RSA key ID 04C4E23A
# gpg: Good signature from "Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 4846 9DE7 1860 360F A6E9  968C DE41 A4FE 04C4 E23A

* remotes/kvaneesh/tags/for-upstream-signed: (25 commits)
  9pfs: introduce V9fsVirtioState
  9pfs: factor out v9fs_device_{,un}realize_common
  9pfs: rename virtio-9p.c to 9p.c
  9pfs: rename virtio_9p_set_fd_limit to use v9fs_ prefix
  9pfs: move handle_9p_output and make it static function
  9pfs: export pdu_{submit,alloc,free}
  9pfs: factor out virtio_9p_push_and_notify
  9pfs: break out 9p.h from virtio-9p.h
  9pfs: break out virtio_init_iov_from_pdu
  9pfs: factor out pdu_push_and_notify
  9pfs: factor out virtio_pdu_{,un}marshal
  9pfs: make pdu_{,un}marshal proper functions
  9pfs: PDU processing functions should start pdu_ prefix
  9pfs: PDU processing functions don't need to take V9fsState as argument
  fsdev: rename virtio-9p-marshal.{c,h} to 9p-iov-marshal.{c,h}
  fsdev: break out 9p-marshal.{c,h} from virtio-9p-marshal.{c,h}
  9pfs: remove dead code
  9pfs: merge hw/virtio/virtio-9p.h into hw/9pfs/virtio-9p.h
  9pfs: rename virtio-9p-xattr{,-user}.{c,h} to 9p-xattr{,-user}.{c,h}
  9pfs: rename virtio-9p-synth.{c,h} to 9p-synth.{c,h}
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-01-12 17:37:22 +00:00
Peter Maydell 8acc216b95 disas/libvixl: Suppress gcc 4.6.3 sign-compare warnings
The VIXL code includes some equality comparisons between signed
and unsigned types. Modern gcc and clang do not complain about
these, but older versions of gcc such as gcc 4.6.3 do. Since
libvixl is an upstream library, the simplest approach is to
suppress the warnings by applying -Wno-sign-compare to the
relevant files.

(GCC 4.6 is not quite yet irrelevant for us; it is the gcc
shipped with Ubuntu Precise, for example, which is an LTS
release not yet out of its support period.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1452604204-27202-1-git-send-email-peter.maydell@linaro.org
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
2016-01-12 16:45:45 +00:00
Peter Maydell cf57c2f18b -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
 
 iQIcBAABAgAGBQJWk/+LAAoJEH3vgQaq/DkOkxwP/ivsjXs69noYV+xpAiah5OwR
 MrfudT/4xFg2cSAbFDvAXbkk+6ibcxpd46zYX6X3aS56469vU0kOh5xueQtZeMOl
 0XTZNN2LifbD+aa7DcnmHPqppe1cF0wJCzhZzc0cSv+LxASqyi9iQKt2ewscXdXO
 fkOoJxLA6620jYRrMet7linKWxAoM/Gp0gz0/jspOluzNrW1XbE2lrf8JPkUsKQB
 8rgEJ9dUtye7duW790twGPTql/vrmRu/ZtVLjVvjwyhqPrIQnE+QhQ9qCQg9QBiW
 wNctK27X9Hck4XEH90TS5/M6van8h+OT9ouG2BAr7Uo8iacoSHmxV2w/IT+BglXL
 0XFbAp377hEUKe3DzneKB7aLMOmPGnyKlr4/ZWJeYGyyaBadafsDvn0ALHM6ymUe
 qRtDhcQ7rjzkFU/AcNhdpT4wIO9hhUXSrZqb6KNYvipdtk1ul6RSOoiMS7Vz5nMI
 Kjeg7rbHBzKHmf1/rQGfT7YlMgQSo4kzSII6NDc6/HsrAYx4Zm7AL35nJN0LcC9h
 l11LEtyEp80X1hI9h25OHch50CfojWXNE29Rq9EuG7poa4mTGQDAIhmGiF5EZLF8
 wkI0euoL0UwaAWbgNhaEECjMq6FSkH9I3xHmf2QuYaaa7oxnAYCcc0bh/eJQ7ARf
 hpkGcjG7/l1uT1MZ8dZb
 =5saf
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging

# gpg: Signature made Mon 11 Jan 2016 19:16:27 GMT using RSA key ID AAFC390E
# gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>"

* remotes/jnsnow/tags/ide-pull-request:
  libqos/ahci: organize header
  qtest/ahci: ATAPI data tests
  libqos/ahci: add ahci_exec
  libqos/ahci: allow nondata commands for ahci_io variants
  libqos: allow zero-size allocations
  libqos/ahci: Switch to mutable properties
  libqos/ahci: ATAPI identify
  libqos/ahci: ATAPI support
  ahci-test: fix memory leak
  ide: ahci: reset ncq object to unused on error
  macio: fix overflow in lba to offset conversion for ATAPI devices

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-01-12 10:38:08 +00:00
Wei Liu 00588a0aa2 9pfs: introduce V9fsVirtioState
V9fsState now only contains generic fields. Introduce V9fsVirtioState
for virtio transport.  Change virtio-pci and virtio-ccw to use
V9fsVirtioState.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2016-01-12 11:04:14 +05:30
John Snow c5620e658e libqos/ahci: organize header
Organize the prototypes into nice little sections.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1452282920-21550-10-git-send-email-jsnow@redhat.com
2016-01-11 14:10:44 -05:00
John Snow e8109694c7 qtest/ahci: ATAPI data tests
Simple I/O tests for DMA and PIO pathways in the AHCI HBA.

I believe at this point in time all of the common, major IO pathways
in BMDMA and AHCI are covered by qtests now.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1452282920-21550-9-git-send-email-jsnow@redhat.com
2016-01-11 14:10:43 -05:00
John Snow 9350df7cea libqos/ahci: add ahci_exec
add ahci_exec, which is a standard purpose flexible command dispatcher
and tester for the AHCI device. The intent is to eventually cut down on
the absurd amount of boilerplate inside of the AHCI qtest.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1452282920-21550-8-git-send-email-jsnow@redhat.com
2016-01-11 14:10:43 -05:00
John Snow b682d3a7cf libqos/ahci: allow nondata commands for ahci_io variants
These variants try to set a data offset, even if you don't specify one.
In the cases where the offset is zero and it's a nondata command, just
ignore the instruction.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1452282920-21550-7-git-send-email-jsnow@redhat.com
2016-01-11 14:10:43 -05:00
John Snow b1b66c3b5e libqos: allow zero-size allocations
As part of streamlining the AHCI tests interface, it'd be nice
if specying a size of zero could be handled without special branches
and the allocator could handle this special case gracefully.

This lets me use the "ahci_io" macros for non-data commands, too,
which moves me forward towards shepherding all AHCI qtests into
a common set of commands in a unified pipeline.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1452282920-21550-6-git-send-email-jsnow@redhat.com
2016-01-11 14:10:43 -05:00
John Snow b88641e236 libqos/ahci: Switch to mutable properties
ATAPI commands are, unfortunately, weird in that they can
be either DMA or PIO depending on a header bit. In order to
accommodate them, I'll need to make AHCI command properties
mutable so we can toggle between which "flavor" of ATAPI command
we want to test.

The default ATAPI transfer mechanism is PIO and the default
properties are adjusted accordingly.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1452282920-21550-5-git-send-email-jsnow@redhat.com
2016-01-11 14:10:43 -05:00
John Snow d0b282a58c libqos/ahci: ATAPI identify
We need to say "hello!" to our ATAPI friends
in a slightly different manner.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1452282920-21550-4-git-send-email-jsnow@redhat.com
2016-01-11 14:10:42 -05:00
John Snow 54d268b26a libqos/ahci: ATAPI support
Add pathways to tolerate ATAPI commands.

Notably, unlike ATA, each SCSI command's layout is a little different,
so support will have to be patched in for each command as we want to
test them in e.g. ahci_command_set_sizes and ahci_command_set_offset.

For now, I'm adding support for 0x28, READ (10).

[Maintainer edit: replaced type-punning with stl_be_p(). --js]

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1452282920-21550-3-git-send-email-jsnow@redhat.com
2016-01-11 14:10:42 -05:00
John Snow 248de4a899 ahci-test: fix memory leak
Use the proper free command to detroy an AHCICommand.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1452282920-21550-2-git-send-email-jsnow@redhat.com
2016-01-11 14:10:42 -05:00