[PATCH 02/46] error: Document Error API usage rules

2020-06-24 Thread Markus Armbruster
This merely codifies existing practice, with one exception: the rule advising against returning void, where existing practice is mixed. When the Error API was created, we adopted the (unwritten) rule to return void when the function returns no useful value on success, unlike GError, which recommen

[PATCH 14/46] qemu-option: Factor out helper opt_create()

2020-06-24 Thread Markus Armbruster
There is just one use so far. The next commit will add more. Signed-off-by: Markus Armbruster --- util/qemu-option.c | 27 ++- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index d9293814b4..3cdf0c0800 100644 --- a

[PATCH 10/46] qemu-option: Check return value instead of @err where convenient

2020-06-24 Thread Markus Armbruster
Convert uses like opts = qemu_opts_create(..., &err); if (err) { ... } to opts = qemu_opts_create(..., &err); if (!opts) { ... } Eliminate error_propagate() that are now unnecessary. Delete @err that are now unused. Signed-off-by: Markus Armbruster ---

[PATCH 04/46] macio: Tidy up error handling in macio_newworld_realize()

2020-06-24 Thread Markus Armbruster
macio_newworld_realize() effectively ignores ns->gpio realization errors, leaking the Error object. Fortunately, macio_gpio_realize() can't actually fail. Tidy up. Cc: Mark Cave-Ayland Cc: David Gibson Signed-off-by: Markus Armbruster --- hw/misc/macio/macio.c | 4 +++- 1 file changed, 3 ins

[PATCH 08/46] error: Avoid unnecessary error_propagate() after error_setg()

2020-06-24 Thread Markus Armbruster
Replace error_setg(&err, ...); error_propagate(errp, err); by error_setg(errp, ...); Related pattern: if (...) { error_setg(&err, ...); goto out; } ... out: error_propagate(errp, err); return; When all paths to label out are that way, replace b

[PATCH 06/46] error: Avoid error_propagate() when error is not used here

2020-06-24 Thread Markus Armbruster
When all we do with an Error we receive into a local variable is propagating to somewhere else, we can just as well receive it there right away. Coccinelle script: @@ identifier fun, err, errp; expression list args; @@ -fun(args, &err); +fun(args, errp); .

[PATCH 12/46] qemu-option: Factor out helper find_default_by_name()

2020-06-24 Thread Markus Armbruster
Signed-off-by: Markus Armbruster --- util/qemu-option.c | 47 ++ 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index 9941005c91..ddcf3072c5 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.

[PATCH 31/46] qom: Use error_reportf_err() instead of g_printerr() in examples

2020-06-24 Thread Markus Armbruster
Signed-off-by: Markus Armbruster --- include/qom/object.h | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 94a61ccc3f..b70edd8cd9 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -671,8 +671,7 @@ Object *obj

[PATCH 13/46] qemu-option: Simplify around find_default_by_name()

2020-06-24 Thread Markus Armbruster
Signed-off-by: Markus Armbruster --- util/qemu-option.c | 13 - 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index ddcf3072c5..d9293814b4 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -286,11 +286,9 @@ const char *

[PATCH 03/46] qdev: Smooth error checking of qdev_realize() & friends

2020-06-24 Thread Markus Armbruster
Convert foo(..., &err); if (err) { ... } to if (!foo(..., &err)) { ... } for qdev_realize(), qdev_realize_and_unref(), qbus_realize() and their wrappers isa_realize_and_unref(), pci_realize_and_unref(), sysbus_realize(), sysbus_realize_and_unref(), usb_realiz

[PATCH 18/46] qemu-option: Smooth error checking manually

2020-06-24 Thread Markus Armbruster
When foo(..., &err) is followed by error_propagate(errp, err), we can often just as well do foo(..., errp). The previous commit did that for simple cases with Coccinelle. Do it for a few more manually. Signed-off-by: Markus Armbruster --- block.c | 2 +- block/gluster.c | 8 +++

[PATCH 09/46] error: Avoid error_propagate() after migrate_add_blocker()

2020-06-24 Thread Markus Armbruster
When migrate_add_blocker(blocker, &errp) is followed by error_propagate(errp, err), we can often just as well do migrate_add_blocker(..., errp). Do that with this Coccinelle script: @@ expression blocker, err, errp; expression ret; @@ -ret = migrate_add_blocker(blocker, &e

[PATCH 27/46] qapi: Purge error_propagate() from QAPI core

2020-06-24 Thread Markus Armbruster
Signed-off-by: Markus Armbruster --- qapi/qapi-visit-core.c | 40 +++- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index 5a9c47aabf..7e5f40e7f0 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qa

[PATCH 24/46] qapi: Smooth error checking manually

2020-06-24 Thread Markus Armbruster
When foo(..., &err) is followed by error_propagate(errp, err), we can often just as well do foo(..., errp). The previous commit did that for simple cases with Coccinelle. Do it for a few more manually. Signed-off-by: Markus Armbruster --- accel/kvm/kvm-all.c | 50 ++--

[PATCH 25/46] qapi: Smooth visitor error checking in generated code

2020-06-24 Thread Markus Armbruster
Use visitor functions' return values to check for failure. Eliminate error_propagate() that are now unnecessary. Delete @err that are now unused. Signed-off-by: Markus Armbruster --- docs/devel/qapi-code-gen.txt | 60 ++-- scripts/qapi/commands.py | 22 +

[PATCH 33/46] qom: Crash more nicely on object_property_get_link() failure

2020-06-24 Thread Markus Armbruster
Pass &error_abort instead of NULL where the returned value is dereferenced or asserted to be non-null. Signed-off-by: Markus Armbruster --- hw/core/platform-bus.c | 5 +++-- hw/ppc/spapr_drc.c | 3 ++- hw/ppc/spapr_hcall.c | 3 ++- hw/ppc/spapr_pci_nvlink2.c | 8 +--- ui/vn

[PATCH 35/46] qom: Use return values to check for error where that's simpler

2020-06-24 Thread Markus Armbruster
When using the Error object to check for error, we need to receive it into a local variable, then propagate() it to @errp. Using the return value permits allows receiving it straight to @errp. Signed-off-by: Markus Armbruster --- qom/object.c | 10 -- 1 file changed, 4 insertions(+), 6

[PATCH 30/46] s390x/pci: Fix harmless mistake in zpci's property fid's setter

2020-06-24 Thread Markus Armbruster
s390_pci_set_fid() sets zpci->fid_defined to true even when visit_type_uint32() failed. Reproducer: "-device zpci,fid=junk". Harmless in practice, because qdev_device_add() then fails, throwing away @zpci. Fix it anyway. Cc: Matthew Rosato Cc: Cornelia Huck Signed-off-by: Markus Armbruster --

[PATCH 17/46] qemu-option: Smooth error checking with Coccinelle

2020-06-24 Thread Markus Armbruster
The previous commit enables conversion of foo(..., &err); if (err) { ... } to if (!foo(..., &err)) { ... } for QemuOpts functions that now return true / false on success / error. Coccinelle script: @@ identifier fun = {opts_do_parse, parse_option_bo

[PATCH 23/46] qapi: Smooth error checking with Coccinelle

2020-06-24 Thread Markus Armbruster
The previous commit enables conversion of visit_foo(..., &err); if (err) { ... } to if (!visit_foo(..., errp)) { ... } for visitor functions that now return true / false on success / error. Coccinelle script: @@ identifier fun =~ "check_list|input_t

[PATCH 20/46] block: Avoid error accumulation in bdrv_img_create()

2020-06-24 Thread Markus Armbruster
When creating an image fails because the format doesn't support option "backing_file" or "backing_fmt", bdrv_img_create() first has qemu_opt_set() put a generic error into @local_err, then puts the real error into @errp with error_setg(), and then propagates the former to the latter, which throws a

[PATCH 26/46] qapi: Smooth another visitor error checking pattern

2020-06-24 Thread Markus Armbruster
Convert visit_type_FOO(v, ..., &ptr, &err); ... if (err) { ... } to visit_type_FOO(v, ..., &ptr, errp); ... if (!ptr) { ... } for functions that set @ptr to non-null / null on success / error. Eliminate error_propagate() that are now unnecessary.

[PATCH 37/46] qom: Make functions taking Error ** return bool, not void

2020-06-24 Thread Markus Armbruster
See recent commit "error: Document Error API usage rules" for rationale. Signed-off-by: Markus Armbruster --- include/qom/object.h| 42 - include/qom/object_interfaces.h | 12 +++-- include/qom/qom-qobject.h | 4 +- qom/object.c| 84

[PATCH 07/46] error: Avoid more error_propagate() when error is not used here

2020-06-24 Thread Markus Armbruster
When all we do with an Error we receive into a local variable is propagating to somewhere else, we can just as well receive it there right away. The previous commit did that for simple cases with Coccinelle. Do it for a few more manually. Signed-off-by: Markus Armbruster --- blockdev.c |

[PATCH 34/46] qom: Don't handle impossible object_property_get_link() failure

2020-06-24 Thread Markus Armbruster
Don't handle object_property_get_link() failure that can't happen unless the programmer screwed up, pass &error_abort. Signed-off-by: Markus Armbruster --- hw/arm/bcm2835_peripherals.c | 7 +-- hw/arm/bcm2836.c | 7 +-- hw/display/bcm2835_fb.c | 8 +--- hw/dma/bcm

[PATCH 05/46] virtio-crypto-pci: Tidy up virtio_crypto_pci_realize()

2020-06-24 Thread Markus Armbruster
virtio_crypto_pci_realize() continues after realization of its "virtio-crypto-device" fails. Only an object_property_set_link() follows; looks harmless to me. Tidy up anyway: return after failure, just like virtio_rng_pci_realize() does. Cc: "Gonglei (Arei)" Cc: Michael S. Tsirkin Signed-off-b

[PATCH 39/46] qom: Smooth error checking manually

2020-06-24 Thread Markus Armbruster
When foo(..., &err) is followed by error_propagate(errp, err), we can often just as well do foo(..., errp). The previous commit did that for simple cases with Coccinelle. Do it for a few more manually. Signed-off-by: Markus Armbruster --- hw/core/bus.c | 6 +- hw/s390x/s390-v

[PATCH 38/46] qom: Smooth error checking with Coccinelle

2020-06-24 Thread Markus Armbruster
The previous commit enables conversion of foo(..., &err); if (err) { ... } to if (!foo(..., errp)) { ... } for QOM functions that now return true / false on success / error. Coccinelle script: @@ identifier fun = {object_apply_global_props, object_i

[PATCH 44/46] qemu-img: Ignore Error objects where the return value suffices

2020-06-24 Thread Markus Armbruster
Signed-off-by: Markus Armbruster --- qemu-img.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 27bf94e7ae..c11bfe0268 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -464,22 +464,18 @@ static int add_old_style_options(const char *fmt, QemuOp

[PATCH 21/46] hmp: Eliminate a variable in hmp_migrate_set_parameter()

2020-06-24 Thread Markus Armbruster
Signed-off-by: Markus Armbruster --- monitor/hmp-cmds.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 2b0b58a336..d7810cb564 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1247,7 +1247,6 @@ void hmp_migrate_

[PATCH 29/46] acpi: Avoid unnecessary error_propagate() after error_setg()

2020-06-24 Thread Markus Armbruster
The commit before previous enables another round of the transformation from recent commit "error: Avoid unnecessary error_propagate() after error_setg()". Signed-off-by: Markus Armbruster --- hw/acpi/core.c | 15 ++- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/hw/ac

[PATCH 16/46] qemu-option: Make functions taking Error ** return bool, not void

2020-06-24 Thread Markus Armbruster
See recent commit "error: Document Error API usage rules" for rationale. Signed-off-by: Markus Armbruster --- include/qemu/option.h | 16 blockdev.c| 5 ++- util/qemu-option.c| 92 +-- 3 files changed, 64 insertions(+), 49 deletio

[PATCH 15/46] qemu-option: Tidy up opt_set() not to free arguments on failure

2020-06-24 Thread Markus Armbruster
opt_set() frees its argument @value on failure. Slightly unclean; functions ideally do nothing on failure. To tidy this up, move opt_create() from opt_set() into its callers, along with the cleanup. Signed-off-by: Markus Armbruster --- util/qemu-option.c | 33 ++---

[PATCH 00/46] Less clumsy error checking

2020-06-24 Thread Markus Armbruster
When the Error API was created, we adopted the (unwritten) rule to return void when the function returns no useful value on success, unlike GError, which recommends to return true on success and false on error then. When a function returns a distinct error value, say false, a checked call that pas

[PATCH 28/46] block/parallels: Simplify parallels_open() after previous commit

2020-06-24 Thread Markus Armbruster
Signed-off-by: Markus Armbruster --- block/parallels.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 9e85ab995e..3c22dfdc9d 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -839,6 +839,7 @@ static int parallels_open

[PATCH 43/46] qdev: Smooth error checking manually

2020-06-24 Thread Markus Armbruster
When foo(..., &err) is followed by error_propagate(errp, err), we can often just as well do foo(..., errp). The previous commit did that for simple cases with Coccinelle. Do it for one more manually. Signed-off-by: Markus Armbruster --- hw/block/fdc.c | 8 +++- 1 file changed, 3 insertions

Re: [PATCH v4 6/8] hw/arm/aspeed: Describe each PCA9552 device

2020-06-24 Thread Philippe Mathieu-Daudé
Hi Cédric, On Mon, Jun 22, 2020 at 10:35 AM Philippe Mathieu-Daudé wrote: > On 6/22/20 8:49 AM, Cédric Le Goater wrote: > > On 6/21/20 12:58 AM, Philippe Mathieu-Daudé wrote: > >> We have 2 distinct PCA9552 devices. Set their description > >> to distinguish them when looking at the trace events.

[PATCH 22/46] qapi: Make visitor functions taking Error ** return bool, not void

2020-06-24 Thread Markus Armbruster
See recent commit "error: Document Error API usage rules" for rationale. Signed-off-by: Markus Armbruster --- docs/devel/qapi-code-gen.txt | 51 +-- include/qapi/clone-visitor.h | 8 +- include/qapi/visitor-impl.h | 26 +++--- include/qapi/visitor.h| 102 -

[PATCH 40/46] qom: Make functions taking Error ** return bool, not 0/-1

2020-06-24 Thread Markus Armbruster
Just for consistency. Also fix the example in object_set_props()'s documentation. Signed-off-by: Markus Armbruster --- include/qom/object.h | 28 +++- qom/object.c | 14 +++--- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/include/qom/o

Re: [PATCH 00/46] Less clumsy error checking

2020-06-24 Thread Paolo Bonzini
On 24/06/20 18:42, Markus Armbruster wrote: > When the Error API was created, we adopted the (unwritten) rule to > return void when the function returns no useful value on success, > unlike GError, which recommends to return true on success and false on > error then. I was actually never aware of

[PATCH 32/46] qom: Rename qdev_get_type() to object_get_type()

2020-06-24 Thread Markus Armbruster
Commit 2f262e06f0 lifted qdev_get_type() from qdev to object without renaming it accordingly. Do that now. Signed-off-by: Markus Armbruster --- qom/object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qom/object.c b/qom/object.c index b8aac074c2..f6e9f0e413 100644 --

[PATCH v4] sm501: Fix and optimize overlap check

2020-06-24 Thread BALATON Zoltan
When doing reverse blit we need to check if source and dest overlap but it is not trivial due to possible different base and pitch of source and dest. Do rectangle overlap if base and pitch match, otherwise just check if memory area containing the rects overlaps so rects could possibly overlap. Si

[PATCH 11/46] qemu-option: Make uses of find_desc_by_name() more similar

2020-06-24 Thread Markus Armbruster
This is to make the next commit easier to review. Signed-off-by: Markus Armbruster --- util/qemu-option.c | 32 ++-- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index 6119f971a4..9941005c91 100644 --- a/util/

[PATCH 45/46] qdev: Ignore Error objects where the return value suffices

2020-06-24 Thread Markus Armbruster
Signed-off-by: Markus Armbruster --- hw/core/qdev-properties.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index e1ad147339..8eb4283a56 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -653,

[PATCH 46/46] hmp: Ignore Error objects where the return value suffices

2020-06-24 Thread Markus Armbruster
qdev_print_props() receives and throws away Error objects just to check for object_property_get_str() and object_property_print() failure. Unnecessary, both return suitable values, so use those instead. Signed-off-by: Markus Armbruster --- qdev-monitor.c | 12 ++-- 1 file changed, 6 ins

[PATCH 41/46] qdev: Make functions taking Error ** return bool, not void

2020-06-24 Thread Markus Armbruster
See recent commit "error: Document Error API usage rules" for rationale. Signed-off-by: Markus Armbruster --- include/hw/qdev-properties.h | 4 ++-- hw/core/qdev-properties-system.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/hw/qdev-properties.h b/includ

[PATCH 42/46] qdev: Smooth error checking with Coccinelle

2020-06-24 Thread Markus Armbruster
The previous commit enables conversion of qdev_prop_set_drive_err(..., &err); if (err) { ... } to if (!qdev_prop_set_drive_err(..., errp)) { ... } Coccinelle script: @@ identifier fun = qdev_prop_set_drive_err; expression list args, args2; typedef Er

[PATCH 19/46] block: Avoid unnecessary error_propagate() after error_setg()

2020-06-24 Thread Markus Armbruster
The previous commit enables another round of the transformation from recent commit "error: Avoid unnecessary error_propagate() after error_setg()". Signed-off-by: Markus Armbruster --- block/quorum.c | 16 +++- block/replication.c | 12 +--- block/vxhs.c| 10

RE: [PATCH v4] arm/virt: Add memory hot remove support

2020-06-24 Thread Shameerali Kolothum Thodi
> -Original Message- > From: Igor Mammedov [mailto:imamm...@redhat.com] > Sent: 24 June 2020 15:09 > To: Shameerali Kolothum Thodi > Cc: qemu-devel@nongnu.org; qemu-...@nongnu.org; > peter.mayd...@linaro.org; m...@redhat.com; Linuxarm > ; xuwei (O) ; > eric.au...@redhat.com; Zengtao (B)

Re: [PATCH v10 1/9] error: auto propagated local_err

2020-06-24 Thread Markus Armbruster
Greg Kurz writes: > On Mon, 15 Jun 2020 07:21:03 +0200 > Markus Armbruster wrote: > >> Greg Kurz writes: >> >> > On Tue, 17 Mar 2020 18:16:17 +0300 >> > Vladimir Sementsov-Ogievskiy wrote: >> > >> >> Introduce a new ERRP_AUTO_PROPAGATE macro, to be used at start of >> >> functions with an err

Re: [PATCH 01/46] error: Improve examples in error.h's big comment

2020-06-24 Thread Eric Blake
On 6/24/20 11:42 AM, Markus Armbruster wrote: Show errp instead of &err where &err is actually unusual. Add a missing declaration. Add a second error pileup example. Signed-off-by: Markus Armbruster --- include/qapi/error.h | 19 +++ 1 file changed, 15 insertions(+), 4 dele

Re: [PATCH v4 6/8] hw/arm/aspeed: Describe each PCA9552 device

2020-06-24 Thread Cédric Le Goater
On 6/24/20 6:54 PM, Philippe Mathieu-Daudé wrote: > Hi Cédric, > > On Mon, Jun 22, 2020 at 10:35 AM Philippe Mathieu-Daudé > wrote: >> On 6/22/20 8:49 AM, Cédric Le Goater wrote: >>> On 6/21/20 12:58 AM, Philippe Mathieu-Daudé wrote: We have 2 distinct PCA9552 devices. Set their description

Re: [PATCH v2 1/2] qom: Introduce object_property_try_add_child()

2020-06-24 Thread Auger Eric
Hi Paolo, On 6/24/20 6:16 PM, Paolo Bonzini wrote: > On 24/06/20 18:02, Auger Eric wrote: >> Hi Paolo, >> >> On 6/24/20 4:17 PM, Auger Eric wrote: >>> Hi Paolo, >>> >>> On 6/24/20 4:12 PM, Paolo Bonzini wrote: On 24/06/20 14:43, Eric Auger wrote: > +op = object_property_try_add(obj, n

RE: [PATCH 1/2] hw/386: Fix uninitialized memory with -device and CPU hotplug

2020-06-24 Thread Babu Moger
> -Original Message- > From: Igor Mammedov > Sent: Wednesday, June 24, 2020 8:48 AM > To: Moger, Babu > Cc: ehabk...@redhat.com; m...@redhat.com; qemu-devel@nongnu.org; > pbonz...@redhat.com; r...@twiddle.net > Subject: Re: [PATCH 1/2] hw/386: Fix uninitialized memory with -device and

Re: [PATCH 02/46] error: Document Error API usage rules

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: This merely codifies existing practice, with one exception: the rule advising against returning void, where existing practice is mixed. When the Error API was created, we adopted the (unwritten) rule to return void when the function returns no useful

Re: Migration vmdesc and xen-save-devices-state

2020-06-24 Thread Dr. David Alan Gilbert
* Jason Andryuk (jandr...@gmail.com) wrote: > Hi, > > At some point, QEMU changed to add a json VM description (vmdesc) > after the migration data. The vmdesc is not needed to restore the > migration data, but qemu_loadvm_state() will read and discard the > vmdesc to clear the stream when should_

Re: [PATCH 03/46] qdev: Smooth error checking of qdev_realize() & friends

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: Convert foo(..., &err); if (err) { ... } to if (!foo(..., &err)) { ... } for qdev_realize(), qdev_realize_and_unref(), qbus_realize() and their wrappers isa_realize_and_unref(), pci_realize_and_unref(), s

Re: [PATCH 06/46] error: Avoid error_propagate() when error is not used here

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: When all we do with an Error we receive into a local variable is propagating to somewhere else, we can just as well receive it there right away. Coccinelle script: This seems to be a recurring cleanup (witness commit 06592d7e, c0e90679, 6b62d961).

Re: [PATCH 07/46] error: Avoid more error_propagate() when error is not used here

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: When all we do with an Error we receive into a local variable is propagating to somewhere else, we can just as well receive it there right away. The previous commit did that for simple cases with Coccinelle. Do it for a few more manually. Signed-of

Re: [PATCH 08/46] error: Avoid unnecessary error_propagate() after error_setg()

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: Replace error_setg(&err, ...); error_propagate(errp, err); by error_setg(errp, ...); Related pattern: Nice explanation. Bonus: the elimination of gotos will make later patches in this series easier to review. Candidates for con

[PATCH v2 1/9] hw/pci-host: add pci-intack write method

2020-06-24 Thread P J P
From: Prasad J Pandit Add pci-intack mmio write method to avoid NULL pointer dereference issue. Reported-by: Lei Sun Signed-off-by: Prasad J Pandit --- hw/pci-host/prep.c | 8 1 file changed, 8 insertions(+) diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c index 367e408b91..3c8f

Re: [PATCH QEMU v25 13/17] vfio: create mapped iova list when vIOMMU is enabled

2020-06-24 Thread Alex Williamson
On Sun, 21 Jun 2020 01:51:22 +0530 Kirti Wankhede wrote: > Create mapped iova list when vIOMMU is enabled. For each mapped iova > save translated address. Add node to list on MAP and remove node from > list on UNMAP. > This list is used to track dirty pages during migration. This seems like a lo

Re: [PATCH QEMU v25 11/17] vfio: Get migration capability flags for container

2020-06-24 Thread Alex Williamson
On Sun, 21 Jun 2020 01:51:20 +0530 Kirti Wankhede wrote: > Added helper functions to get IOMMU info capability chain. > Added function to get migration capability information from that > capability chain for IOMMU container. > > Similar change was proposed earlier: > https://lists.gnu.org/archiv

Re: [PATCH QEMU v25 14/17] vfio: Add vfio_listener_log_sync to mark dirty pages

2020-06-24 Thread Alex Williamson
On Sun, 21 Jun 2020 01:51:23 +0530 Kirti Wankhede wrote: > vfio_listener_log_sync gets list of dirty pages from container using > VFIO_IOMMU_GET_DIRTY_BITMAP ioctl and mark those pages dirty when all > devices are stopped and saving state. > Return early for the RAM block section of mapped MMIO r

[PATCH v2 7/9] tz-ppc: add dummy read/write methods

2020-06-24 Thread P J P
From: Prasad J Pandit Add tz-ppc-dummy mmio read/write methods to avoid assert failure during initialisation. Signed-off-by: Prasad J Pandit --- hw/misc/tz-ppc.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/hw/misc/tz-ppc.c b/hw/misc/tz-ppc.c index 6431257b52..dc8892f61

Re: [PATCH QEMU v25 15/17] vfio: Add ioctl to get dirty pages bitmap during dma unmap.

2020-06-24 Thread Alex Williamson
On Sun, 21 Jun 2020 01:51:24 +0530 Kirti Wankhede wrote: > With vIOMMU, IO virtual address range can get unmapped while in pre-copy > phase of migration. In that case, unmap ioctl should return pages pinned > in that range and QEMU should find its correcponding guest physical > addresses and repo

[PATCH v2 3/9] vfio: add quirk device write method

2020-06-24 Thread P J P
From: Prasad J Pandit Add vfio quirk device mmio write method to avoid NULL pointer dereference issue. Reported-by: Lei Sun Signed-off-by: Prasad J Pandit --- hw/vfio/pci-quirks.c | 8 1 file changed, 8 insertions(+) Update v2: use LOG_GUEST_ERROR -> https://lists.gnu.org/archive/

Re: [PATCH QEMU v25 09/17] vfio: Add load state functions to SaveVMHandlers

2020-06-24 Thread Alex Williamson
On Sun, 21 Jun 2020 01:51:18 +0530 Kirti Wankhede wrote: > Sequence during _RESUMING device state: > While data for this device is available, repeat below steps: > a. read data_offset from where user application should write data. > b. write data of data_size to migration region from data_offset

[PATCH] net: tap: check if the file descriptor is valid before using it

2020-06-24 Thread Laurent Vivier
qemu_set_nonblock() checks that the file descriptor can be used and, if not, crashes QEMU. An assert() is used for that. The use of assert() is used to detect programming error and the coredump will allow to debug the problem. But in the case of the tap device, this assert() can be triggered by a

Re: [PATCH QEMU v25 12/17] vfio: Add function to start and stop dirty pages tracking

2020-06-24 Thread Alex Williamson
On Sun, 21 Jun 2020 01:51:21 +0530 Kirti Wankhede wrote: > Call VFIO_IOMMU_DIRTY_PAGES ioctl to start and stop dirty pages tracking > for VFIO devices. > > Signed-off-by: Kirti Wankhede > Reviewed-by: Dr. David Alan Gilbert > --- > hw/vfio/migration.c | 36

[PATCH v2 0/9] memory: assert and define MemoryRegionOps callbacks

2020-06-24 Thread P J P
From: Prasad J Pandit Hello, * This series asserts that MemoryRegionOps objects define read/write callback methods. Thus avoids potential NULL pointer dereference. ex. -> https://git.qemu.org/?p=qemu.git;a=commit;h=bb15013ef34617eb1344f5276292cadd326c21b2 * Also adds various undefined Memo

[PATCH v2 9/9] memory: assert MemoryRegionOps callbacks are defined

2020-06-24 Thread P J P
From: Prasad J Pandit When registering a MemoryRegionOps object, assert that its read/write callback methods are defined. This avoids potential guest crash via a NULL pointer dereference. Suggested-by: Peter Maydell Signed-off-by: Prasad J Pandit --- memory.c | 10 +- 1 file changed,

[PATCH v2 2/9] pci-host: add pcie-msi read method

2020-06-24 Thread P J P
From: Prasad J Pandit Add pcie-msi mmio read method to avoid NULL pointer dereference issue. Reported-by: Lei Sun Signed-off-by: Prasad J Pandit --- hw/pci-host/designware.c | 9 + 1 file changed, 9 insertions(+) diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c index

[PATCH v2 4/9] prep: add ppc-parity write method

2020-06-24 Thread P J P
From: Prasad J Pandit Add ppc-parity mmio write method to avoid NULL pointer dereference issue. Reported-by: Lei Sun Signed-off-by: Prasad J Pandit --- hw/ppc/prep_systemio.c | 8 1 file changed, 8 insertions(+) Update v2: use LOG_GUEST_ERROR -> https://lists.gnu.org/archive/html/

[PATCH v2 5/9] nvram: add nrf51_soc flash read method

2020-06-24 Thread P J P
From: Prasad J Pandit Add nrf51_soc mmio read method to avoid NULL pointer dereference issue. Reported-by: Lei Sun Signed-off-by: Prasad J Pandit --- hw/nvram/nrf51_nvm.c | 8 1 file changed, 8 insertions(+) Update v2: return ldl_le_p() -> https://lists.gnu.org/archive/html/qemu-d

[PATCH v2 8/9] imx7-ccm: add digprog mmio write method

2020-06-24 Thread P J P
From: Prasad J Pandit Add digprog mmio write method to avoid assert failure during initialisation. Signed-off-by: Prasad J Pandit --- hw/misc/imx7_ccm.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/hw/misc/imx7_ccm.c b/hw/misc/imx7_ccm.c index 02fc1ae8d0..5ac5ecf74c 100644 --- a/

[PATCH v2 6/9] spapr_pci: add spapr msi read method

2020-06-24 Thread P J P
From: Prasad J Pandit Add spapr msi mmio read method to avoid NULL pointer dereference issue. Reported-by: Lei Sun Signed-off-by: Prasad J Pandit --- hw/ppc/spapr_pci.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c i

Re: [PATCH v2 22/25] arm/stm32f205 arm/stm32f405: Fix realize error API violation

2020-06-24 Thread Alistair Francis
On Wed, Jun 24, 2020 at 1:44 AM Markus Armbruster wrote: > > The Error ** argument must be NULL, &error_abort, &error_fatal, or a > pointer to a variable containing NULL. Passing an argument of the > latter kind twice without clearing it in between is wrong: if the > first call sets an error, it

Re: [PATCH v2 1/7] configure: Create symbolic links for pc-bios/*.elf files

2020-06-24 Thread Alistair Francis
On Sun, Jun 21, 2020 at 11:34 PM Bin Meng wrote: > > From: Bin Meng > > Now we need to ship the OpenSBI fw_jump.elf image for the > RISC-V Spike machine, it requires us to create symbolic > links for pc-bios/*.elf files. > > Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Alistair > >

Re: [PATCH 30/46] s390x/pci: Fix harmless mistake in zpci's property fid's setter

2020-06-24 Thread Matthew Rosato
On 6/24/20 12:43 PM, Markus Armbruster wrote: s390_pci_set_fid() sets zpci->fid_defined to true even when visit_type_uint32() failed. Reproducer: "-device zpci,fid=junk". Harmless in practice, because qdev_device_add() then fails, throwing away @zpci. Fix it anyway. Cc: Matthew Rosato Cc: Cor

Re: [PATCH 09/46] error: Avoid error_propagate() after migrate_add_blocker()

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: When migrate_add_blocker(blocker, &errp) is followed by error_propagate(errp, err), we can often just as well do migrate_add_blocker(..., errp). Do that with this Coccinelle script: Double-check @err is not used afterwards. Dereferencing it woul

Re: [PATCH 10/46] qemu-option: Check return value instead of @err where convenient

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: Convert uses like opts = qemu_opts_create(..., &err); if (err) { ... } to opts = qemu_opts_create(..., &err); if (!opts) { ... } Eliminate error_propagate() that are now unnecessary. Delete @err tha

Re: [PATCH 11/46] qemu-option: Make uses of find_desc_by_name() more similar

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: This is to make the next commit easier to review. Signed-off-by: Markus Armbruster --- util/qemu-option.c | 32 ++-- 1 file changed, 18 insertions(+), 14 deletions(-) Reviewed-by: Eric Blake -- Eric Blake, Princip

Re: [PATCH 12/46] qemu-option: Factor out helper find_default_by_name()

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: Signed-off-by: Markus Armbruster --- util/qemu-option.c | 47 ++ 1 file changed, 27 insertions(+), 20 deletions(-) Reviewed-by: Eric Blake -- Eric Blake, Principal Software Engineer Red Hat, Inc.

Re: [PATCH 13/46] qemu-option: Simplify around find_default_by_name()

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: Signed-off-by: Markus Armbruster --- util/qemu-option.c | 13 - 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index ddcf3072c5..d9293814b4 100644 --- a/util/qemu-option.c +++ b/ut

Re: [PATCH 14/46] qemu-option: Factor out helper opt_create()

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: There is just one use so far. The next commit will add more. Signed-off-by: Markus Armbruster --- util/qemu-option.c | 27 ++- 1 file changed, 18 insertions(+), 9 deletions(-) Reviewed-by: Eric Blake -- Eric Blake, P

[PATCH v3 1/2] qom: Introduce object_property_try_add_child()

2020-06-24 Thread Eric Auger
object_property_add() does not allow object_property_try_add() to gracefully fail as &error_abort is passed as an error handle. However such failure can easily be triggered from the QMP shell when, for instance, one attempts to create an object with an id that already exists. This is achived from

[PATCH v3 2/2] tests/qmp-cmd-test: Add qmp/object-add-duplicate-id

2020-06-24 Thread Eric Auger
This new test checks that attempting to create an object with an existing ID gracefully fails. Signed-off-by: Eric Auger Acked-by: Thomas Huth --- tests/qtest/qmp-cmd-test.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd

Re: [PATCH v10 1/9] error: auto propagated local_err

2020-06-24 Thread Greg Kurz
On Wed, 24 Jun 2020 18:53:05 +0200 Markus Armbruster wrote: > Greg Kurz writes: > > > On Mon, 15 Jun 2020 07:21:03 +0200 > > Markus Armbruster wrote: > > > >> Greg Kurz writes: > >> > >> > On Tue, 17 Mar 2020 18:16:17 +0300 > >> > Vladimir Sementsov-Ogievskiy wrote: > >> > > >> >> Introduce

Re: [PATCH v5 0/7] Introduce 'yank' oob qmp command to recover from hanging qemu

2020-06-24 Thread Lukas Straub
On Tue, 23 Jun 2020 16:42:30 +0200 Lukas Straub wrote: > Hello Everyone, > In many cases, if qemu has a network connection (qmp, migration, chardev, > etc.) > to some other server and that server dies or hangs, qemu hangs too. > These patches introduce the new 'yank' out-of-band qmp command to r

[PATCH v3 0/2] Avoid abort on QMP attempt to add an object with duplicate id

2020-06-24 Thread Eric Auger
Attempting to add an object through QMP with an id that is already used leads to a qemu abort. This is a regression since d2623129a7de ("qom: Drop parameter @errp of object_property_add() & friends"). The first patch fixes the issue and the second patch adds a test to check the error is gracefully

Re: [PATCH QEMU v25 03/17] vfio: Add save and load functions for VFIO PCI devices

2020-06-24 Thread Alex Williamson
On Wed, 24 Jun 2020 19:59:39 +0530 Kirti Wankhede wrote: > On 6/23/2020 1:58 AM, Alex Williamson wrote: > > On Sun, 21 Jun 2020 01:51:12 +0530 > > Kirti Wankhede wrote: > > > >> These functions save and restore PCI device specific data - config > >> space of PCI device. > >> Tested save and r

Re: [PATCH 15/46] qemu-option: Tidy up opt_set() not to free arguments on failure

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: opt_set() frees its argument @value on failure. Slightly unclean; functions ideally do nothing on failure. To tidy this up, move opt_create() from opt_set() into its callers, along with the cleanup. Signed-off-by: Markus Armbruster --- util/qemu

Re: [PATCH 16/46] qemu-option: Make functions taking Error ** return bool, not void

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: See recent commit "error: Document Error API usage rules" for rationale. Signed-off-by: Markus Armbruster --- include/qemu/option.h | 16 blockdev.c| 5 ++- util/qemu-option.c| 92 +--

Re: [PATCH v4] arm/virt: Add memory hot remove support

2020-06-24 Thread Peter Maydell
On Wed, 24 Jun 2020 at 17:50, Shameerali Kolothum Thodi wrote: > > > > > -Original Message- > > From: Igor Mammedov [mailto:imamm...@redhat.com] > > doesn't pc_dimm_unplug() do unrealize already? > > (/me wonders why it doesn't explode here, > > are we leaking a refference somewhere so dim

Re: [PATCH 17/46] qemu-option: Smooth error checking with Coccinelle

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: The previous commit enables conversion of foo(..., &err); if (err) { ... } to if (!foo(..., &err)) { ... } for QemuOpts functions that now return true / false on success / error. Coccinelle script:

Re: [PATCH 18/46] qemu-option: Smooth error checking manually

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: When foo(..., &err) is followed by error_propagate(errp, err), we can often just as well do foo(..., errp). The previous commit did that for simple cases with Coccinelle. Do it for a few more manually. Signed-off-by: Markus Armbruster --- block.

Re: [PATCH 19/46] block: Avoid unnecessary error_propagate() after error_setg()

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: The previous commit enables another round of the transformation from recent commit "error: Avoid unnecessary error_propagate() after error_setg()". Signed-off-by: Markus Armbruster --- block/quorum.c | 16 +++- block/replication.

Re: [PATCH 20/46] block: Avoid error accumulation in bdrv_img_create()

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: When creating an image fails because the format doesn't support option "backing_file" or "backing_fmt", bdrv_img_create() first has qemu_opt_set() put a generic error into @local_err, then puts the real error into @errp with error_setg(), and then pro

Re: [PATCH 21/46] hmp: Eliminate a variable in hmp_migrate_set_parameter()

2020-06-24 Thread Eric Blake
On 6/24/20 11:43 AM, Markus Armbruster wrote: Signed-off-by: Markus Armbruster --- monitor/hmp-cmds.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) Reviewed-by: Eric Blake -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization:

<    1   2   3   4   5   6   >