[PATCH v4 07/31] s390: Fix error_append_hint/error_prepend usage

Vladimir Sementsov-Ogievskiy posted 31 patches 6 years, 4 months ago
Maintainers: Max Reitz <mreitz@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Juan Quintela <quintela@redhat.com>, Fam Zheng <fam@euphon.net>, "Michael S. Tsirkin" <mst@redhat.com>, Yuval Shaia <yuval.shaia@oracle.com>, Stefan Hajnoczi <stefanha@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Jason Wang <jasowang@redhat.com>, Paul Burton <pburton@wavecomp.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Eric Farman <farman@linux.ibm.com>, Paolo Bonzini <pbonzini@redhat.com>, Markus Armbruster <armbru@redhat.com>, Eric Blake <eblake@redhat.com>, Aleksandar Rikalo <arikalo@wavecomp.com>, Joel Stanley <joel@jms.id.au>, Subbaraya Sundeep <sundeep.lkml@gmail.com>, David Gibson <david@gibson.dropbear.id.au>, Halil Pasic <pasic@linux.ibm.com>, Gerd Hoffmann <kraxel@redhat.com>, Stefan Weil <sw@weilnetz.de>, John Snow <jsnow@redhat.com>, "Cédric Le Goater" <clg@kaod.org>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Alex Williamson <alex.williamson@redhat.com>, Richard Henderson <rth@twiddle.net>, "Daniel P. Berrangé" <berrange@redhat.com>, Cornelia Huck <cohuck@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Andrew Jeffery <andrew@aj.id.au>, Greg Kurz <groug@kaod.org>, Christian Borntraeger <borntraeger@de.ibm.com>, Eduardo Habkost <ehabkost@redhat.com>, David Hildenbrand <david@redhat.com>, Michael Roth <mdroth@linux.vnet.ibm.com>, Jeff Cody <codyprime@gmail.com>
There is a newer version of this series
[PATCH v4 07/31] s390: Fix error_append_hint/error_prepend usage
Posted by Vladimir Sementsov-Ogievskiy 6 years, 4 months ago
If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call).  Fix such cases.

This commit (together with its neighbors) was generated by

git grep -l 'error_\(append_hint\|prepend\)(errp' | while read f; do \
spatch --sp-file scripts/coccinelle/fix-error-add-info.cocci \
--in-place $f; done

and then

./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"

(auto-msg was a file with this commit message)

and then by hand, for not maintained changed files:

git commit -m "<SUB-SYSTEM>: $(< auto-msg)" <FILES>

Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.

Reported-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 hw/s390x/s390-ccw.c       | 1 +
 target/s390x/cpu_models.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/hw/s390x/s390-ccw.c b/hw/s390x/s390-ccw.c
index 0c5a5b60bd..c0a648a7e0 100644
--- a/hw/s390x/s390-ccw.c
+++ b/hw/s390x/s390-ccw.c
@@ -55,6 +55,7 @@ static void s390_ccw_get_dev_info(S390CCWDevice *cdev,
                                   char *sysfsdev,
                                   Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     unsigned int cssid, ssid, devid;
     char dev_path[PATH_MAX] = {0}, *tmp;
 
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
index 009afc38b9..32f2e5e822 100644
--- a/target/s390x/cpu_models.c
+++ b/target/s390x/cpu_models.c
@@ -840,6 +840,7 @@ static void error_prepend_missing_feat(const char *name, void *opaque)
 static void check_compatibility(const S390CPUModel *max_model,
                                 const S390CPUModel *model, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     S390FeatBitmap missing;
 
     if (model->def->gen > max_model->def->gen) {
@@ -922,6 +923,7 @@ static inline void apply_cpu_model(const S390CPUModel *model, Error **errp)
 
 void s390_realize_cpu_model(CPUState *cs, Error **errp)
 {
+    ERRP_AUTO_PROPAGATE();
     S390CPUClass *xcc = S390_CPU_GET_CLASS(cs);
     S390CPU *cpu = S390_CPU(cs);
     const S390CPUModel *max_model;
-- 
2.21.0


Re: [PATCH v4 07/31] s390: Fix error_append_hint/error_prepend usage
Posted by Markus Armbruster 6 years, 4 months ago
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:

> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
>
> This commit (together with its neighbors) was generated by
>
> git grep -l 'error_\(append_hint\|prepend\)(errp' | while read f; do \
> spatch --sp-file scripts/coccinelle/fix-error-add-info.cocci \
> --in-place $f; done

Make that:

    $ spatch --sp-file scripts/coccinelle/fix-error-add-info.cocci --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff `git grep -l 'error_\(append_hint\|prepend\)(errp' \*.[ch]`

Adding --macro-file is essential, as Eric noted.  Without it, we miss
qcow2_store_persistent_dirty_bitmaps() in PATCH 23 and
nbd_negotiate_send_rep_verr() in PATCH 29.  There should be a way to
make spatch warn when it gives up parsing, but I can't find it right
now.

Avoiding the loop is just for speed and simplicity.

--no-show-diff goes well with --in-place.

The even simpler

    $ spatch --sp-file scripts/coccinelle/fix-error-add-info.cocci --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff --use-gitgrep

misses include/block/nbd.h's nbd_read() in PATCH 23 somehow.

I recommend to add the spatch invocation to the coccinelle script's
commit message, too [PATCH 05].

[...]

Re: [PATCH v4 07/31] s390: Fix error_append_hint/error_prepend usage
Posted by Vladimir Sementsov-Ogievskiy 6 years, 4 months ago
09.10.2019 10:42, Markus Armbruster wrote:
> Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:
> 
>> If we want to add some info to errp (by error_prepend() or
>> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
>> Otherwise, this info will not be added when errp == &fatal_err
>> (the program will exit prior to the error_append_hint() or
>> error_prepend() call).  Fix such cases.
>>
>> This commit (together with its neighbors) was generated by
>>
>> git grep -l 'error_\(append_hint\|prepend\)(errp' | while read f; do \
>> spatch --sp-file scripts/coccinelle/fix-error-add-info.cocci \
>> --in-place $f; done
> 
> Make that:
> 
>      $ spatch --sp-file scripts/coccinelle/fix-error-add-info.cocci --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff `git grep -l 'error_\(append_hint\|prepend\)(errp' \*.[ch]`
> 
> Adding --macro-file is essential, as Eric noted.  Without it, we miss
> qcow2_store_persistent_dirty_bitmaps() in PATCH 23 and
> nbd_negotiate_send_rep_verr() in PATCH 29.  There should be a way to
> make spatch warn when it gives up parsing, but I can't find it right
> now.
> 
> Avoiding the loop is just for speed and simplicity.

Seems without loop it hangs or at least works slower. And loop provides a kind of progress, so I'll keep the loop.

> 
> --no-show-diff goes well with --in-place.
> 
> The even simpler
> 
>      $ spatch --sp-file scripts/coccinelle/fix-error-add-info.cocci --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff --use-gitgrep
> 
> misses include/block/nbd.h's nbd_read() in PATCH 23 somehow.
> 
> I recommend to add the spatch invocation to the coccinelle script's
> commit message, too [PATCH 05].
> 
> [...]
> 


-- 
Best regards,
Vladimir
Re: [PATCH v4 07/31] s390: Fix error_append_hint/error_prepend usage
Posted by Cornelia Huck 6 years, 4 months ago
On Tue,  1 Oct 2019 18:52:55 +0300
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:

> If we want to add some info to errp (by error_prepend() or
> error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
> Otherwise, this info will not be added when errp == &fatal_err
> (the program will exit prior to the error_append_hint() or
> error_prepend() call).  Fix such cases.
> 
> This commit (together with its neighbors) was generated by
> 
> git grep -l 'error_\(append_hint\|prepend\)(errp' | while read f; do \
> spatch --sp-file scripts/coccinelle/fix-error-add-info.cocci \
> --in-place $f; done
> 
> and then
> 
> ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
> 
> (auto-msg was a file with this commit message)
> 
> and then by hand, for not maintained changed files:
> 
> git commit -m "<SUB-SYSTEM>: $(< auto-msg)" <FILES>
> 
> Still, for backporting it may be more comfortable to use only the first
> command and then do one huge commit.
> 
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  hw/s390x/s390-ccw.c       | 1 +
>  target/s390x/cpu_models.c | 2 ++
>  2 files changed, 3 insertions(+)

Acked-by: Cornelia Huck <cohuck@redhat.com>