c9ac1458 | 07-Oct-2020 |
Kevin Wolf <kwolf@redhat.com> |
qom: Add user_creatable_print_help_from_qdict()
This adds a function that, given a QDict of non-help options, prints help for user creatable objects.
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Re
qom: Add user_creatable_print_help_from_qdict()
This adds a function that, given a QDict of non-help options, prints help for user creatable objects.
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20201007164903.282198-4-kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
show more ...
|
4c880f36 | 15-Sep-2020 |
Richard Henderson <richard.henderson@linaro.org> |
qom: Allow objects to be allocated with increased alignment
It turns out that some hosts have a default malloc alignment less than that required for vectors.
We assume that, with compiler annotatio
qom: Allow objects to be allocated with increased alignment
It turns out that some hosts have a default malloc alignment less than that required for vectors.
We assume that, with compiler annotation on CPUArchState, that we can properly align the vector portion of the guest state. Fix the alignment of the allocation by using qemu_memalloc when required.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20200916004638.2444147-3-richard.henderson@linaro.org> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
show more ...
|
0dde9fd1 | 14-Jul-2020 |
Markus Armbruster <armbru@redhat.com> |
qom: Make info qom-tree sort children more efficiently
Commit e8c9e65816 "qom: Make "info qom-tree" show children sorted" sorts children the simple, stupid, quadratic way. I thought the number of c
qom: Make info qom-tree sort children more efficiently
Commit e8c9e65816 "qom: Make "info qom-tree" show children sorted" sorts children the simple, stupid, quadratic way. I thought the number of children would be small enough for this not to matter. I was wrong: there are outliers with several hundred children, e.g ARM machines nuri and smdkc210 each have a node with 513 children.
While n^2 sorting isn't noticeable in normal, human usage even for n=513, it can be quite noticeable in certain automated tests. In particular, the sort made device-introspect-test even slower. Commit 3e7b80f84d "tests: improve performance of device-introspect-test" just fixed that by cutting back its excessive use of "info qom-tree". Sorting more efficiently makes sense regardless, so do it.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20200714160202.3121879-6-armbru@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
show more ...
|
af175e85 | 07-Jul-2020 |
Markus Armbruster <armbru@redhat.com> |
error: Eliminate error_propagate() with Coccinelle, part 2
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
error: Eliminate error_propagate() with Coccinelle, part 2
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 with a Coccinelle script I consider fairly trustworthy. This commit uses the same script with the matching of return taken out, i.e. we convert
if (!foo(..., &err)) { ... error_propagate(errp, err); ... }
to
if (!foo(..., errp)) { ... ... }
This is unsound: @err could still be read between afterwards. I don't know how to express "no read of @err without an intervening write" in Coccinelle. Instead, I manually double-checked for uses of @err.
Suboptimal line breaks tweaked manually. qdev_realize() simplified further to placate scripts/checkpatch.pl.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20200707160613.848843-36-armbru@redhat.com>
show more ...
|
668f62ec | 07-Jul-2020 |
Markus Armbruster <armbru@redhat.com> |
error: Eliminate error_propagate() with Coccinelle, part 1
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
error: Eliminate error_propagate() with Coccinelle, part 1
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. Convert
if (!foo(..., &err)) { ... error_propagate(errp, err); ... return ... }
to
if (!foo(..., errp)) { ... ... return ... }
where nothing else needs @err. Coccinelle script:
@rule1 forall@ identifier fun, err, errp, lbl; expression list args, args2; binary operator op; constant c1, c2; symbol false; @@ if ( ( - fun(args, &err, args2) + fun(args, errp, args2) | - !fun(args, &err, args2) + !fun(args, errp, args2) | - fun(args, &err, args2) op c1 + fun(args, errp, args2) op c1 ) ) { ... when != err when != lbl: when strict - error_propagate(errp, err); ... when != err ( return; | return c2; | return false; ) }
@rule2 forall@ identifier fun, err, errp, lbl; expression list args, args2; expression var; binary operator op; constant c1, c2; symbol false; @@ - var = fun(args, &err, args2); + var = fun(args, errp, args2); ... when != err if ( ( var | !var | var op c1 ) ) { ... when != err when != lbl: when strict - error_propagate(errp, err); ... when != err ( return; | return c2; | return false; | return var; ) }
@depends on rule1 || rule2@ identifier err; @@ - Error *err = NULL; ... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) { goto out } ... out: error_propagate(errp, err);
even though other paths to label out still need the error_propagate(). For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(), incorrectly. I don't know what exactly "when strict" does, only that it helps here.
The match of return is narrower than what I want, but I can't figure out how to express "return where the operand doesn't use @err". For an example where it's too narrow, see vfio_intx_enable().
Silently fails to convert hw/arm/armsse.c, because Coccinelle gets confused by ARMSSE being used both as typedef and function-like macro there. Converted manually.
Line breaks tidied up manually. One nested declaration of @local_err deleted manually. Preexisting unwanted blank line dropped in hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20200707160613.848843-35-armbru@redhat.com>
show more ...
|
b783f54d | 07-Jul-2020 |
Markus Armbruster <armbru@redhat.com> |
qom: Make functions taking Error ** return bool, not 0/-1
Just for consistency. Also fix the example in object_set_props()'s documentation.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Rev
qom: Make functions taking Error ** return bool, not 0/-1
Just for consistency. Also fix the example in object_set_props()'s documentation.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20200707160613.848843-31-armbru@redhat.com>
show more ...
|
778a2dc5 | 07-Jul-2020 |
Markus Armbruster <armbru@redhat.com> |
qom: Use returned bool to check for failure, Coccinelle part
The previous commit enables conversion of
foo(..., &err); if (err) { ... }
to
if (!foo(..., errp)) { .
qom: Use returned bool to check for failure, Coccinelle part
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_initialize_child_with_props, object_initialize_child_with_propsv, object_property_get, object_property_get_bool, object_property_parse, object_property_set, object_property_set_bool, object_property_set_int, object_property_set_link, object_property_set_qobject, object_property_set_str, object_property_set_uint, object_set_props, object_set_propv, user_creatable_add_dict, user_creatable_complete, user_creatable_del }; expression list args, args2; typedef Error; Error *err; @@ - fun(args, &err, args2); - if (err) + if (!fun(args, &err, args2)) { ... }
Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by ARMSSE being used both as typedef and function-like macro there. Convert manually.
Line breaks tidied up manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20200707160613.848843-29-armbru@redhat.com>
show more ...
|
6fd5bef1 | 07-Jul-2020 |
Markus Armbruster <armbru@redhat.com> |
qom: Make functions taking Error ** return bool, not void
See recent commit "error: Document Error API usage rules" for rationale.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by:
qom: Make functions taking Error ** return bool, not void
See recent commit "error: Document Error API usage rules" for rationale.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20200707160613.848843-28-armbru@redhat.com>
show more ...
|