From: Markus Armbruster <armbru@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: How can I find problematic uses of error_report() with vrc?
Date: Mon, 08 May 2023 10:32:40 +0200 [thread overview]
Message-ID: <87v8h3mdef.fsf@pond.sub.org> (raw)
Calling error_report() from within a function using Error to return
error information is almost always wrong. Example:
QMP command qmp_migrate()
calls rdma_start_outgoing_migration()
calls qemu_rdma_source_init()
calls qemu_rdma_reg_control()
The first four have an Error **errp parameter, and use it to return
error information. Good.
The last one does not. Instead, qemu_rdma_reg_control() calls
error_report() on failure:
error_report("qemu_rdma_reg_control failed");
return -1;
Its caller qemu_rdma_source_init() detects the failure and sets an
error:
ret = qemu_rdma_reg_control(rdma, idx);
if (ret) {
error_setg(temp, "RDMA ERROR: rdma migration: error registering %d control!",
idx);
goto err_rdma_source_init;
}
Because of this, QMP command migrate spams stderr on this particular
failure. Inappropriate.
Easy enough to fix, but I'm after the error pattern, not a single
instance that happened to catch my eye.
Problem: find call chains from functions using Error to error_report().
Two sub-problems:
1. Find functions using Error
Doesn't have to be perfect. I have a simple Coccinelle script
(appended) that spits out some 4400 functions. I run it like
$ spatch --sp-file find-error-fns.cocci --macro-file scripts/cocci-macro-file.h `git-grep -Fl 'Error **' \*.[ch]`
2. Find call chains from these functions to error_report()
I'm hoping vrc can do that for me. How?
Here's my find-error-fns.cocci:
@r@
identifier fn, errp;
position p;
@@
fn@p(..., Error **errp, ...)
{
...
}
@script:python@
fn << r.fn;
p << r.p;
@@
print(f'{p[0].file}:{p[0].line}:{p[0].column}:{fn}')
next reply other threads:[~2023-05-08 8:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-08 8:32 Markus Armbruster [this message]
2023-05-08 10:41 ` How can I find problematic uses of error_report() with vrc? Paolo Bonzini
2023-05-08 15:11 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87v8h3mdef.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).