Re: [RFC 0/8] Introduce an extensible static analyzer

2022-07-02 Thread Paolo Bonzini
On 7/2/22 13:33, Alberto Faria wrote: The current primary motivation for this work is enforcing rules around block layer coroutines, which is why most of the series focuses on that. However, the static analyzer is intended to be sufficiently generic to satisfy other present and future QEMU static

Re: [RFC 4/8] Fix some direct calls from non-coroutine_fn to coroutine_fn

2022-07-02 Thread Paolo Bonzini
On 7/2/22 13:33, Alberto Faria wrote: @@ -1537,8 +1537,9 @@ static void blk_aio_read_entry(void *opaque) QEMUIOVector *qiov = rwco->iobuf; assert(qiov->size == acb->bytes); -rwco->ret = blk_co_do_preadv(rwco->blk, rwco->offset, acb->bytes, - qio

Re: [PATCH 00/18] Make block-backend-io.h API more consistent

2022-07-02 Thread Paolo Bonzini
On 5/17/22 13:35, Alberto Faria wrote: Adjust existing pairs of non-coroutine and coroutine functions to share the same calling convention, and add non-coroutine/coroutine counterparts where they don't exist. Also make the non-coroutine versions generated_co_wrappers. This series sits on top of

Re: [PATCH v5 00/10] Implement bdrv_{pread, pwrite, pwrite_sync, pwrite_zeroes}() using generated_co_wrapper

2022-07-02 Thread Paolo Bonzini
On 6/23/22 22:20, Alberto Faria wrote: On Thu, Jun 9, 2022 at 4:27 PM Alberto Faria wrote: Start by making the interfaces of analogous non-coroutine and coroutine functions consistent with each other, then implement the non-coroutine ones using generated_co_wrapper. For the bdrv_pwrite_sync()

[RFC 7/8] block: Add no_coroutine_fn marker

2022-07-02 Thread Alberto Faria
When applied to a function, it advertises that it should not be called from coroutine_fn functions. Make generated_co_wrapper evaluate to no_coroutine_fn, as coroutine_fn functions should instead directly call the coroutine_fn that backs the generated_co_wrapper. Extend static-analyzer.py's "coro

[RFC 5/8] static-analyzer: Enforce coroutine_fn restrictions on function pointers

2022-07-02 Thread Alberto Faria
Extend static-analyzer.py to enforce coroutine_fn restrictions on function pointer operations. Invalid operations include assigning a coroutine_fn value to a non-coroutine_fn function pointer, and invoking a coroutine_fn function pointer from a non-coroutine_fn function. Signed-off-by: Alberto Fa

[RFC 6/8] Fix some coroutine_fn indirect calls and pointer assignments

2022-07-02 Thread Alberto Faria
These problems were found by static-analyzer.py. Only a few of the reported cases were fixed. Signed-off-by: Alberto Faria --- include/block/block_int-common.h | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/include/block/block_int-common.h b/include/block/block_

[RFC 8/8] Avoid calls from coroutine_fn to no_coroutine_fn

2022-07-02 Thread Alberto Faria
These calls were found by static-analyzer.py. Signed-off-by: Alberto Faria --- block/block-backend.c | 2 +- block/io.c | 10 +- block/parallels.c | 4 ++-- block/qcow2-refcount.c | 2 +- block/qed-table.c | 2 +- block/qed.c| 2 +- block/vmdk.c

[RFC 3/8] static-analyzer: Enforce coroutine_fn restrictions for direct calls

2022-07-02 Thread Alberto Faria
Add a static-analyzer.py check ensuring that non-coroutine_fn functions don't perform direct calls to coroutine_fn functions. For the few cases where this must happen, introduce an __allow_coroutine_fn_call() macro that wraps offending calls and overrides the static analyzer. Signed-off-by: Alber

[RFC 4/8] Fix some direct calls from non-coroutine_fn to coroutine_fn

2022-07-02 Thread Alberto Faria
These problems were found by static-analyzer.py. Only a few of the reported cases were fixed. Signed-off-by: Alberto Faria --- block/block-backend.c | 13 - block/copy-before-write.c | 3 ++- block/dirty-bitmap.c | 6 -- block/iscsi.c | 3 ++- block/qcow2.

[RFC 2/8] Drop some unused static function return values

2022-07-02 Thread Alberto Faria
Make some non-void static functions whose return values are ignored by all callers return void instead. These functions were found by the shiny new static-analyzer.py. Only a few of the reported cases were fixed. Signed-off-by: Alberto Faria --- block/file-posix.c | 6 +- block/io.c

[RFC 1/8] Add an extensible static analyzer

2022-07-02 Thread Alberto Faria
Add a static-analyzer.py script that uses libclang's Python bindings to provide a common framework on which arbitrary static analysis checks can be developed and run against QEMU's code base. As an example, a simple check is included that verifies that the return value of static, non-void function

[RFC 0/8] Introduce an extensible static analyzer

2022-07-02 Thread Alberto Faria
This series introduces a static analyzer for QEMU. It consists of a single static-analyzer.py script that relies on libclang's Python bindings, and provides a common framework on which arbitrary static analysis checks can be developed and run against QEMU's code base. Summary of the series: - P