Re: Open qcow2 on multiple hosts simultaneously.

2023-11-20 Thread Alberto Faria
rites to it, accesses by the other nodes would lead to undefined behavior. It should be fine for live migration, although I wonder how it would behave in the case of migration failure? Alberto > > Best Regards, > Andrei Kvapil > > > On Wed, Aug 16, 2023 at 11:31 AM Alberto Faria wro

Announcing Subprovisioner, a qsd-powered k8s storage provider

2023-08-30 Thread Alberto Faria
use case for qsd. Thanks, Alberto Faria [1] https://gitlab.com/subprovisioner/subprovisioner

Re: Open qcow2 on multiple hosts simultaneously.

2023-08-16 Thread Alberto Faria
On Mon, Jun 19, 2023 at 6:29 PM kvaps wrote: > Hi Kevin and the community, > > I am designing a CSI driver for Kubernetes that allows efficient > utilization of SAN (Storage Area Network) and supports thin > provisioning, snapshots, and ReadWriteMany mode for block devices. > > To implement this,

Re: [PATCH v2 2/9] block-copy: add missing coroutine_fn annotations

2022-11-09 Thread Alberto Faria
On Wed, Nov 9, 2022 at 12:24 PM Emanuele Giuseppe Esposito wrote: > CCing also Alberto and Paolo > > So basically I think what we need is something that scans the whole > block layer code and puts the right coroutine_fn annotations (or > assertions, if you want) in the right places. > > The rule

[PATCH for-7.2] block/blkio: Set BlockDriver::has_variable_length to false

2022-11-08 Thread Alberto Faria
Kevin Wolf Signed-off-by: Alberto Faria --- block/blkio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/block/blkio.c b/block/blkio.c index 620fab28a7..5eae3adfaf 100644 --- a/block/blkio.c +++ b/block/blkio.c @@ -993,7 +993,6 @@ static void blkio_refresh_limits(BlockDriverState *bs, Er

[PATCH] qapi/block-core: Fix BlockdevOptionsNvmeIoUring @path description

2022-11-08 Thread Alberto Faria
The nvme-io_uring BlockDriver's path option must point at the character device of an NVMe namespace, not at an image file. Fixes: fd66dbd424f5 ("blkio: add libblkio block driver") Suggested-by: Stefano Garzarella Signed-off-by: Alberto Faria --- qapi/block-core.json | 2 +- 1 file

[PATCH] block/blkio: Tolerate device size changes

2022-10-29 Thread Alberto Faria
no preallocation is needed and the device already has a size compatible with what was requested. Signed-off-by: Alberto Faria --- This is based on Stefan's block tree: https://gitlab.com/stefanha/qemu/-/commits/block block/blkio.c | 27 +++ 1 file changed, 27 insertions

Re: [PATCH] block/blkio: Add virtio-blk-vfio-pci BlockDriver

2022-10-29 Thread Alberto Faria
On Fri, Oct 28, 2022 at 2:17 PM Alberto Faria wrote: > libblkio 1.1.0 [1] introduces a virtio-blk-vfio-pci driver, which > accesses a virtio-blk PCI device using VFIO. Add a corresponding > BlockDriver. > > [1] https://gitlab.com/libblkio/libblkio/-/tree/v1.1.0 > > Signed-

Re: [PATCH] block/blkio: Make driver nvme-io_uring take a "path" instead of a "filename"

2022-10-29 Thread Alberto Faria
On Sat, Oct 29, 2022 at 7:05 AM Markus Armbruster wrote: > Alberto Faria writes: > > > The nvme-io_uring driver expects a character special file such as > > /dev/ng0n1. Follow the convention of having a "filename" option when a > > regular file is expected, an

[PATCH] block/blkio: Make driver nvme-io_uring take a "path" instead of a "filename"

2022-10-28 Thread Alberto Faria
ption, as it accepts a regular file (even though it can also take a block special file). Signed-off-by: Alberto Faria --- block/blkio.c| 12 qapi/block-core.json | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/block/blkio.c b/block/blkio.c index

[PATCH] block/blkio: Add virtio-blk-vfio-pci BlockDriver

2022-10-28 Thread Alberto Faria
libblkio 1.1.0 [1] introduces a virtio-blk-vfio-pci driver, which accesses a virtio-blk PCI device using VFIO. Add a corresponding BlockDriver. [1] https://gitlab.com/libblkio/libblkio/-/tree/v1.1.0 Signed-off-by: Alberto Faria --- This is dependent on a pending libblkio fix [2], so we may

Re: [PATCH v6 12/13] blkio: implement BDRV_REQ_REGISTERED_BUF optimization

2022-10-10 Thread Alberto Faria
On Thu, Oct 6, 2022 at 10:35 PM Stefan Hajnoczi wrote: > Avoid bounce buffers when QEMUIOVector elements are within previously > registered bdrv_register_buf() buffers. > > The idea is that emulated storage controllers will register guest RAM > using bdrv_register_buf() and set the

Re: [PATCH v6 00/13] blkio: add libblkio BlockDriver

2022-10-10 Thread Alberto Faria
On Thu, Oct 6, 2022 at 10:35 PM Stefan Hajnoczi wrote: > v6: > - Add untested nvme-io_uring driver. Please test in your nested NVMe > environment, Alberto. [Alberto] I did some I/O verification using fio [1] and it seems to be working fine. Alberto [1]

Re: [PATCH v5 11/12] blkio: implement BDRV_REQ_REGISTERED_BUF optimization

2022-10-06 Thread Alberto Faria
On Thu, Oct 6, 2022 at 7:46 PM Stefan Hajnoczi wrote: > > Regardless, I'd say we want to map memory regions even if we don't > > strictly need to (in cases where we can do so at no additional cost), > > since that may improve performance for some drivers. > > The downside is that when

Re: [PATCH v5 11/12] blkio: implement BDRV_REQ_REGISTERED_BUF optimization

2022-10-06 Thread Alberto Faria
On Thu, Oct 6, 2022 at 7:00 PM Stefan Hajnoczi wrote: > s->needs_mem_regions determines if we'll use libblkio memory regions at > all. When it's false we skip blkio_map_mem_region() and therefore it's > safe to set s->mem_regions_pinned to false. blkio_register_buf() calls

Re: [PATCH v5 02/12] blkio: add libblkio block driver

2022-10-06 Thread Alberto Faria
On Tue, Sep 27, 2022 at 8:34 PM Stefan Hajnoczi wrote: > +static int blkio_virtio_blk_vhost_user_open(BlockDriverState *bs, > +QDict *options, int flags, Error **errp) > +{ > +const char *path = qdict_get_try_str(options, "path"); > +BDRVBlkioState *s = bs->opaque; > +int ret;

Re: [RFC v2 02/10] Drop unused static function return values

2022-08-12 Thread Alberto Faria
On Wed, Aug 3, 2022 at 12:15 PM Richard W.M. Jones wrote: > If it helps to think about this, Coverity checks for consistency. > Across the whole code base, is the return value of a function used or > ignored consistently. You will see Coverity errors like: > > Error: CHECKED_RETURN

Re: [RFC v2 02/10] Drop unused static function return values

2022-08-12 Thread Alberto Faria
On Wed, Aug 3, 2022 at 1:30 PM Peter Maydell wrote: > The problem with a patch like this is that it rolls up into a > single patch changes to the API of many functions in multiple > subsystems across the whole codebase. Some of those changes > might be right; some might be wrong. No single person

Re: [RFC v2 00/10] Introduce an extensible static analyzer

2022-08-12 Thread Alberto Faria
On Thu, Aug 4, 2022 at 12:44 PM Marc-André Lureau wrote: > Hi > > Great work so far! This seems easier to hack than my attempt to use > clang-tidy to write some qemu checks > (https://github.com/elmarco/clang-tools-extra) > > The code seems quite generic, I wonder if such a tool in python wasn't

Re: [RFC v2 02/10] Drop unused static function return values

2022-08-03 Thread Alberto Faria
On Wed, Aug 3, 2022 at 11:46 AM Dr. David Alan Gilbert wrote: > > * Alberto Faria (afa...@redhat.com) wrote: > > Make non-void static functions whose return values are ignored by > > all callers return void instead. > > > > These functions were found by stati

[RFC v2 08/10] Fix some bad coroutine_fn indirect calls and pointer assignments

2022-07-29 Thread Alberto Faria
These problems were found by static-analyzer.py. Not all occurrences of these problems were fixed. Signed-off-by: Alberto Faria --- block/backup.c | 2 +- include/block/block_int-common.h | 12 +--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/block

[RFC v2 10/10] Fix some calls from coroutine_fn to no_coroutine_fn

2022-07-29 Thread Alberto Faria
These calls were found by static-analyzer.py. Not all occurrences of this problem were fixed. Signed-off-by: Alberto Faria --- block/commit.c | 2 +- block/io.c | 4 ++-- block/mirror.c | 4 ++-- block/parallels.c | 28 ++-- block

[RFC v2 07/10] static-analyzer: Enforce coroutine_fn restrictions on function pointers

2022-07-29 Thread Alberto Faria
n function. Signed-off-by: Alberto Faria --- static_analyzer/__init__.py | 27 static_analyzer/coroutine_fn.py | 115 ++-- 2 files changed, 138 insertions(+), 4 deletions(-) diff --git a/static_analyzer/__init__.py b/static_analyzer/__init__.py index

[RFC v2 06/10] Fix some direct calls from non-coroutine_fn to coroutine_fn

2022-07-29 Thread Alberto Faria
. These problems were found by static-analyzer.py. Not all occurrences of these problems were fixed. Signed-off-by: Alberto Faria --- block.c| 2 +- block/dirty-bitmap.c | 6 -- block/io.c | 18 +++--- block/monitor/block-hmp-cmds.c

[RFC v2 04/10] static-analyzer: Avoid reanalyzing unmodified translation units

2022-07-29 Thread Alberto Faria
For each translation unit, run each check only if any of the translation unit's files has been modified since the last time the check ran and passed without reporting problems. Signed-off-by: Alberto Faria --- static-analyzer.py | 240 - 1 file

[RFC v2 05/10] static-analyzer: Enforce coroutine_fn restrictions for direct calls

2022-07-29 Thread Alberto Faria
c analyzer. Signed-off-by: Alberto Faria --- include/qemu/coroutine.h| 13 +++ static_analyzer/__init__.py | 46 - static_analyzer/coroutine_fn.py | 173 3 files changed, 231 insertions(+), 1 deletion(-) create mode 100644 stati

[RFC v2 09/10] block: Add no_coroutine_fn marker

2022-07-29 Thread Alberto Faria
uot; check to static-analyzer.py that enforces no_coroutine_fn rules. Signed-off-by: Alberto Faria --- include/block/block-common.h | 2 +- include/qemu/coroutine.h | 12 static_analyzer/no_coroutine_fn.py | 111 + 3 files changed, 124 insert

[RFC v2 03/10] static-analyzer: Support adding tests to checks

2022-07-29 Thread Alberto Faria
Introduce an add_check_tests() method to add output-comparison tests to checks, and add some tests to the "return-value-never-used" check. Signed-off-by: Alberto Faria --- static-analyzer.py | 133 - static_analyzer/__init__.py

[RFC v2 02/10] Drop unused static function return values

2022-07-29 Thread Alberto Faria
Make non-void static functions whose return values are ignored by all callers return void instead. These functions were found by static-analyzer.py. Not all occurrences of this problem were fixed. Signed-off-by: Alberto Faria --- accel/kvm/kvm-all.c | 12 ++--- accel/tcg

[RFC v2 01/10] Add an extensible static analyzer

2022-07-29 Thread Alberto Faria
turn value of static, non-void functions is used by at least one caller. Signed-off-by: Alberto Faria --- static-analyzer.py | 486 + static_analyzer/__init__.py| 242 ++ static_analyzer/return_value_never_used.py | 117

[RFC v2 00/10] Introduce an extensible static analyzer

2022-07-29 Thread Alberto Faria
hose checks. - Ignore translation units from git submodules. - And more. Alberto Faria (10): Add an extensible static analyzer Drop unused static function return values static-analyzer: Support adding tests to checks static-analyzer: Avoid reanalyzing unmodified translation units stat

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

2022-07-08 Thread Alberto Faria
On Wed, Jul 6, 2022 at 11:15 AM Daniel P. Berrangé wrote: > For clang-tidy, I've been trying it out integrated into emacs > via eglot and clangd. This means I get clang-tidy errors reported > interactively as I write code, so wouldn't need to run a full > tree analysis. Unfortunately, unless I'm

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

2022-07-06 Thread Alberto Faria
On Tue, Jul 5, 2022 at 5:13 PM Daniel P. Berrangé wrote: > FWIW, after applying this series 'make check' throws lots of failures > and hangs for me in the block I/O tests, so something appears not quite > correct here. I didn't bother to investigate/debug since you marked this > as just an RFC

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

2022-07-06 Thread Alberto Faria
On Tue, Jul 5, 2022 at 5:12 PM Daniel P. Berrangé wrote: > On Tue, Jul 05, 2022 at 12:28:55PM +0100, Alberto Faria wrote: > > On Tue, Jul 5, 2022 at 8:16 AM Daniel P. Berrangé > > wrote: > > > for i in `git ls-tree --name-only -r HEAD:` > > > do > &

[PATCH v2 18/18] block: Remove remaining unused symbols in coroutines.h

2022-07-05 Thread Alberto Faria
Some can be made static, others are unused generated_co_wrappers. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz --- block/block-backend.c | 6 +++--- block/coroutines.h| 19 --- 2 files changed, 3 insertions(+), 22 deletions(-) diff

[PATCH v2 16/18] block: Add blk_co_truncate()

2022-07-05 Thread Alberto Faria
Also convert blk_truncate() into a generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz --- block/block-backend.c | 7 --- include/sysemu/block-backend-io.h | 8 ++-- tests/unit/test-block-iothread.c | 14

[PATCH v2 13/18] block: Implement blk_pdiscard() using generated_co_wrapper

2022-07-05 Thread Alberto Faria
Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz --- block/block-backend.c | 12 block/coroutines.h| 3 --- include/sysemu/block-backend-io.h | 3 ++- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git

[PATCH v2 15/18] block: Add blk_co_ioctl()

2022-07-05 Thread Alberto Faria
Also convert blk_ioctl() into a generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz --- block/block-backend.c | 7 --- block/coroutines.h| 6 -- include/sysemu/block-backend-io.h | 5 - 3 files changed

[PATCH v2 17/18] block: Reorganize some declarations in block-backend-io.h

2022-07-05 Thread Alberto Faria
Keep generated_co_wrapper and coroutine_fn pairs together. This should make it clear that each I/O function has these two versions. Also move blk_co_{pread,pwrite}()'s implementations out of the header file for consistency. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini --- block

[PATCH v2 14/18] block: Implement blk_flush() using generated_co_wrapper

2022-07-05 Thread Alberto Faria
Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz --- block/block-backend.c | 11 --- block/coroutines.h| 2 -- include/sysemu/block-backend-io.h | 2 +- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/block

[PATCH v2 12/18] block: Implement blk_pwrite_zeroes() using generated_co_wrapper

2022-07-05 Thread Alberto Faria
Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz --- block/block-backend.c | 8 include/sysemu/block-backend-io.h | 5 +++-- tests/unit/test-block-iothread.c | 17 + 3 files changed, 20 insertions(+), 10 deletions(-) diff

[PATCH v2 08/18] block: Add blk_[co_]preadv_part()

2022-07-05 Thread Alberto Faria
Implement blk_preadv_part() using generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz --- block/block-backend.c | 30 +++--- block/coroutines.h| 5 - include/sysemu/block-backend-io.h

[PATCH v2 11/18] block: Add blk_co_pwrite_compressed()

2022-07-05 Thread Alberto Faria
Also convert blk_pwrite_compressed() into a generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz --- block/block-backend.c | 8 include/sysemu/block-backend-io.h | 7 +-- tests/unit/test-block-iothread.c | 18

[PATCH v2 10/18] block: Change blk_pwrite_compressed() param order

2022-07-05 Thread Alberto Faria
Swap 'buf' and 'bytes' around for consistency with other I/O functions. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz --- block/block-backend.c | 4 ++-- include/sysemu/block-backend-io.h | 4 ++-- qemu-img.c| 2 +- qemu

[PATCH v2 07/18] block: Add blk_{preadv,pwritev}()

2022-07-05 Thread Alberto Faria
Implement them using generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz --- include/sysemu/block-backend-io.h | 6 + tests/unit/test-block-iothread.c | 42 ++- 2 files changed, 47 insertions(+), 1 deletion

[PATCH v2 09/18] block: Export blk_pwritev_part() in block-backend-io.h

2022-07-05 Thread Alberto Faria
Also convert it into a generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz --- block/block-backend.c | 14 -- block/coroutines.h| 5 - include/sysemu/block-backend-io.h | 4 tests/unit/test

[PATCH v2 06/18] block: Implement blk_{pread, pwrite}() using generated_co_wrapper

2022-07-05 Thread Alberto Faria
We need to add include/sysemu/block-backend-io.h to the inputs of the block-gen.c target defined in block/meson.build. Signed-off-by: Alberto Faria Reviewed-by: Hanna Reitz --- block/block-backend.c | 23 --- block/coroutines.h| 4 block

[PATCH v2 05/18] block: Make blk_co_pwrite() take a const buffer

2022-07-05 Thread Alberto Faria
It does not mutate the buffer. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz --- include/sysemu/block-backend-io.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backend-io.h

[PATCH v2 04/18] block: Make 'bytes' param of blk_{pread, pwrite}() an int64_t

2022-07-05 Thread Alberto Faria
For consistency with other I/O functions, and in preparation to implement them using generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Hanna Reitz --- block/block-backend.c | 6 +++--- include/sysemu/block-backend-io.h | 6 +++--- 2 files

[PATCH v2 03/18] block: Change blk_{pread,pwrite}() param order

2022-07-05 Thread Alberto Faria
manually. Overly-long lines were then fixed by hand. Signed-off-by: Alberto Faria Reviewed-by: Eric Blake Reviewed-by: Hanna Reitz --- block.c | 2 +- block/block-backend.c | 4 +-- block/commit.c| 4 +-- block/crypto.c

[PATCH v2 02/18] block: Add a 'flags' param to blk_pread()

2022-07-05 Thread Alberto Faria
no effect on hw/block/nand.c, presumably due to the #if, so that file was updated manually. Overly-long lines were then fixed by hand. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Greg Kurz Reviewed-by: Hanna Reitz --- block.c | 2 +- block

[PATCH v2 01/18] block: Make blk_{pread, pwrite}() return 0 on success

2022-07-05 Thread Alberto Faria
They currently return the value of their 'bytes' parameter on success. Make them return 0 instead, for consistency with other I/O functions and in preparation to implement them using generated_co_wrapper. This also makes it clear that short reads/writes are not possible. Signed-off-by: Alberto

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

2022-07-05 Thread Alberto Faria
es from blk_{pread,pwrite}(), as they don't return a length anymore. - Drop variables in_ret and out_ret in qemu-img.c:img_dd(). - Initialize buf in test_sync_op_blk_pwritev_part(). - Keep blk_co_copy_range() in the "I/O API functions" section of include/sysemu/block-backen

Re: [PATCH 17/18] block: Reorganize some declarations in block-backend-io.h

2022-07-05 Thread Alberto Faria
On Tue, Jul 5, 2022 at 10:18 AM Hanna Reitz wrote: > This moves blk_co_copy_range() from the “I/O API functions” section of > this header into the “"I/O or GS" API functions” section. Is that intended? Oops, thanks, it wasn't intended. Will fix. Alberto

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

2022-07-05 Thread Alberto Faria
On Tue, Jul 5, 2022 at 8:16 AM Daniel P. Berrangé wrote: > for i in `git ls-tree --name-only -r HEAD:` > do > clang-tidy $i 1>/dev/null 2>&1 > done All of those invocations are probably failing quickly due to missing includes and other problems, since the location of the

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

2022-07-04 Thread Alberto Faria
On Mon, Jul 4, 2022 at 5:28 PM Daniel P. Berrangé wrote: > Have you done any measurement see how much of the overhead is from > the checks you implemented, vs how much is inherantly forced on us > by libclang ? ie what does it look like if you just load the libclang > framework and run it actross

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

2022-07-04 Thread Alberto Faria
On Mon, Jul 4, 2022 at 6:46 PM Víctor Colombo wrote: > Yes, this line is present at the beginning of the output > Is this caused by problems with the code being analyzed or is it because > libclang is getting confused with something that is outside of our > control? I think I found the problem:

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

2022-07-04 Thread Alberto Faria
Hi Víctor, On Mon, Jul 4, 2022 at 3:18 PM Víctor Colombo wrote: > And I receive an exception on the line above saying that node is of type > NoneType. Seems that `node = node.referenced` is setting `node` to None > in this case. > > I was unable to understand the root cause of it. Is this an

Re: [PATCH 01/18] block: Make blk_{pread, pwrite}() return 0 on success

2022-07-04 Thread Alberto Faria
On Mon, Jul 4, 2022 at 2:52 PM Hanna Reitz wrote: > There are a couple of places where you decided to replace “*len” > variables that used to store the return value by a plain “ret”. That > seems good to me, given how these functions no longer return length > values, but you haven’t done so

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

2022-07-03 Thread Alberto Faria
On Thu, Jun 23, 2022 at 10:47 PM Eric Blake wrote: > I did not get through all of the callers (you are right, there ARE a > lot), but the ones I checked, particularly in block/qcow2-*.c, appear > to handle -EIO just fine. > > I did notice, however, that qcow2-bitmap.c:free_bitmap_clusters() >

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

2022-07-03 Thread Alberto Faria
On Sat, Jul 2, 2022 at 3:12 PM Paolo Bonzini wrote: > Alberto, does this need a rebase? This applies cleanly on "[PATCH v5 00/10] Implement bdrv_{pread,pwrite,pwrite_sync,pwrite_zeroes}() using generated_co_wrapper" [1], which applies cleanly to master. Alberto [1]

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

2022-07-03 Thread Alberto Faria
On Sat, Jul 2, 2022 at 3:13 PM Paolo Bonzini wrote: > These functions should be coroutine_fn (all coroutine entry points > should be). Thanks, I see now that you fixed this in [1]. Alberto [1] https://patchew.org/QEMU/20220509103019.215041-1-pbonz...@redhat.com/

[RFC 7/8] block: Add no_coroutine_fn marker

2022-07-02 Thread Alberto Faria
"coroutine-annotation-validity" and "coroutine-calls" checks to enforce no_coroutine_fn rules. Signed-off-by: Alberto Faria --- include/block/block-common.h | 2 +- include/qemu/coroutine.h | 12 static-analyzer.py | 35

[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

[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

[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
-by: Alberto Faria --- include/qemu/coroutine.h | 13 +++ static-analyzer.py | 207 +++ 2 files changed, 220 insertions(+) diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h index 08c5bb3c76..40a4037525 100644 --- a/include/qemu/coroutine.h +++ b

[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
functions is used by at least one caller. Signed-off-by: Alberto Faria --- static-analyzer.py | 509 + 1 file changed, 509 insertions(+) create mode 100755 static-analyzer.py diff --git a/static-analyzer.py b/static-analyzer.py new file mode 100755 index

[RFC 0/8] Introduce an extensible static analyzer

2022-07-02 Thread Alberto Faria
suffice. Alberto Faria (8): Add an extensible static analyzer Drop some unused static function return values static-analyzer: Enforce coroutine_fn restrictions for direct calls Fix some direct calls from non-coroutine_fn to coroutine_fn static-analyzer: Enforce coroutine_fn restrictions

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

2022-06-23 Thread Alberto Faria
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() case, also

[PATCH v5 08/10] block: Add bdrv_co_pwrite_sync()

2022-06-09 Thread Alberto Faria
Also convert bdrv_pwrite_sync() to being implemented using generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- block/io.c | 9 + include/block/block-io.h | 8 ++-- 2 files changed, 11 insertions(+), 6 deletions

[PATCH v5 05/10] block: Make bdrv_co_pwrite() take a const buffer

2022-06-09 Thread Alberto Faria
It does not mutate the buffer. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi --- include/block/block_int-io.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h index bb454200e5

[PATCH v5 02/10] block: Change bdrv_{pread, pwrite, pwrite_sync}() param order

2022-06-09 Thread Alberto Faria
; @@ - bdrv_pwrite_sync(child, offset, buf, bytes, flags) + bdrv_pwrite_sync(child, offset, bytes, buf, flags) Resulting overly-long lines were then fixed by hand. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi Reviewed-by: Vladimir Sementsov-Ogievskiy --- block

[PATCH v5 09/10] block: Use bdrv_co_pwrite_sync() when caller is coroutine_fn

2022-06-09 Thread Alberto Faria
Convert uses of bdrv_pwrite_sync() into bdrv_co_pwrite_sync() when the callers are already coroutine_fn. Signed-off-by: Alberto Faria Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Stefan Hajnoczi --- block/parallels.c | 2 +- block/qcow2-snapshot.c | 6 +++--- block/qcow2.c

[PATCH v4 05/10] block: Make bdrv_co_pwrite() take a const buffer

2022-06-09 Thread Alberto Faria
It does not mutate the buffer. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini --- include/block/block_int-io.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h index bb454200e5..d4d3bed783 100644

[PATCH v4 04/10] crypto: Make block callbacks return 0 on success

2022-06-09 Thread Alberto Faria
They currently return the value of their headerlen/buflen parameter on success. Returning 0 instead makes it clear that short reads/writes are not possible. Signed-off-by: Alberto Faria Reviewed-by: Eric Blake --- block/crypto.c | 52 +- block

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

2022-06-09 Thread Alberto Faria
co_pwrite_sync() when the callers are already coroutine_fn. - Add patch making qcow2_mark_dirty() use bdrv_pwrite_sync() instead of calling bdrv_pwrite() and bdrv_flush() separately. Alberto Faria (10): block: Add a 'flags' param to bdrv_{pread,pwrite,pwrite_sync}() block: Change bdrv_{pread,pwrite

[PATCH v4 03/10] block: Make bdrv_{pread, pwrite}() return 0 on success

2022-06-09 Thread Alberto Faria
that rely on the previous behavior are adjusted accordingly by hand. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini --- block/cloop.c| 2 +- block/crypto.c | 4 ++-- block/dmg.c | 10 +- block/io.c | 10

[PATCH v5 10/10] block/qcow2: Use bdrv_pwrite_sync() in qcow2_mark_dirty()

2022-06-09 Thread Alberto Faria
Use bdrv_pwrite_sync() instead of calling bdrv_pwrite() and bdrv_flush() separately. Signed-off-by: Alberto Faria Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- block/qcow2.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c

[PATCH v5 07/10] block: Implement bdrv_{pread, pwrite, pwrite_zeroes}() using generated_co_wrapper

2022-06-09 Thread Alberto Faria
appropriate, which it didn't previously. Signed-off-by: Alberto Faria --- I audited all bdrv_{pread,pwrite}() callers to make sure that changing the -EINVAL return code to -EIO wont't break things. However, there are about 140 call sites, so the probability of me having missed something isn't negligible

[PATCH v5 04/10] crypto: Make block callbacks return 0 on success

2022-06-09 Thread Alberto Faria
They currently return the value of their headerlen/buflen parameter on success. Returning 0 instead makes it clear that short reads/writes are not possible. Signed-off-by: Alberto Faria Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- block/crypto.c | 52

[PATCH v4 06/10] block: Make 'bytes' param of bdrv_co_{pread, pwrite, preadv, pwritev}() an int64_t

2022-06-09 Thread Alberto Faria
or greater than BDRV_REQUEST_MAX_BYTES, which in turns never exceeds SIZE_MAX. Signed-off-by: Alberto Faria --- block/coroutines.h | 4 ++-- include/block/block_int-io.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/block/coroutines.h b/block/coroutines.h index

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

2022-06-09 Thread Alberto Faria
2_mark_dirty() use bdrv_pwrite_sync() instead of calling bdrv_pwrite() and bdrv_flush() separately. Alberto Faria (10): block: Add a 'flags' param to bdrv_{pread,pwrite,pwrite_sync}() block: Change bdrv_{pread,pwrite,pwrite_sync}() param order block: Make bdrv_{pread,pwrite}() return 0 on success

[PATCH v4 10/10] block/qcow2: Use bdrv_pwrite_sync() in qcow2_mark_dirty()

2022-06-09 Thread Alberto Faria
Use bdrv_pwrite_sync() instead of calling bdrv_pwrite() and bdrv_flush() separately. Signed-off-by: Alberto Faria Reviewed-by: Eric Blake --- block/qcow2.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index f2fb54c51f..90a2dd406b

[PATCH v4 09/10] block: Use bdrv_co_pwrite_sync() when caller is coroutine_fn

2022-06-09 Thread Alberto Faria
Convert uses of bdrv_pwrite_sync() into bdrv_co_pwrite_sync() when the callers are already coroutine_fn. Signed-off-by: Alberto Faria Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 2 +- block/qcow2-snapshot.c | 6 +++--- block/qcow2.c | 4 ++-- 3 files changed

[PATCH v4 07/10] block: Implement bdrv_{pread, pwrite, pwrite_zeroes}() using generated_co_wrapper

2022-06-09 Thread Alberto Faria
appropriate, which it didn't previously. Signed-off-by: Alberto Faria --- I audited all bdrv_{pread,pwrite}() callers to make sure that changing the -EINVAL return code to -EIO wont't break things. However, there are about 140 call sites, so the probability of me having missed something isn't negligible

[PATCH v4 02/10] block: Change bdrv_{pread, pwrite, pwrite_sync}() param order

2022-06-09 Thread Alberto Faria
; @@ - bdrv_pwrite_sync(child, offset, buf, bytes, flags) + bdrv_pwrite_sync(child, offset, bytes, buf, flags) Resulting overly-long lines were then fixed by hand. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini --- block/blklogwrites.c | 6 ++-- block/bochs.c| 10

[PATCH v5 06/10] block: Make 'bytes' param of bdrv_co_{pread, pwrite, preadv, pwritev}() an int64_t

2022-06-09 Thread Alberto Faria
or greater than BDRV_REQUEST_MAX_BYTES, which in turns never exceeds SIZE_MAX. Signed-off-by: Alberto Faria --- block/coroutines.h | 4 ++-- include/block/block_int-io.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/block/coroutines.h b/block/coroutines.h index

[PATCH v5 03/10] block: Make bdrv_{pread, pwrite}() return 0 on success

2022-06-09 Thread Alberto Faria
that rely on the previous behavior are adjusted accordingly by hand. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi --- block/cloop.c| 2 +- block/crypto.c | 4 ++-- block/dmg.c | 10 +- block

[PATCH v5 01/10] block: Add a 'flags' param to bdrv_{pread, pwrite, pwrite_sync}()

2022-06-09 Thread Alberto Faria
) Resulting overly-long lines were then fixed by hand. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/blklogwrites.c | 4 +-- block/bochs.c| 6 ++-- block/cloop.c

[PATCH v4 08/10] block: Add bdrv_co_pwrite_sync()

2022-06-09 Thread Alberto Faria
Also convert bdrv_pwrite_sync() to being implemented using generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Eric Blake --- block/io.c | 9 + include/block/block-io.h | 8 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/block/io.c b

[PATCH v4 01/10] block: Add a 'flags' param to bdrv_{pread, pwrite, pwrite_sync}()

2022-06-09 Thread Alberto Faria
) Resulting overly-long lines were then fixed by hand. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini --- block/blklogwrites.c | 4 +-- block/bochs.c| 6 ++-- block/cloop.c| 10 +++--- block/crypto.c | 4 +-- block/dmg.c

Re: [PATCH v3 07/10] block: Implement bdrv_{pread, pwrite, pwrite_zeroes}() using generated_co_wrapper

2022-06-09 Thread Alberto Faria
On Wed, Jun 8, 2022 at 1:50 PM Stefan Hajnoczi wrote: > Yes, that's fine. My main concern is that callers have been audited when > errnos are changed. If you switch bdrv_{pread,pwrite}() to -EIO and have > audited callers, then I'm happy. > > Consistent -EINVAL would be nice in the future, but I

Re: [PATCH v3 07/10] block: Implement bdrv_{pread, pwrite, pwrite_zeroes}() using generated_co_wrapper

2022-06-06 Thread Alberto Faria
Thanks for the feedback, and apologies for the delayed response. On Mon, May 30, 2022 at 1:49 PM Stefan Hajnoczi wrote: > If you find it's safe to change to -EINVAL then that's consistent with > how file I/O syscalls work and I think it would be nice. Switching to -EINVAL on negative bytes

Re: [PATCH v3 07/10] block: Implement bdrv_{pread, pwrite, pwrite_zeroes}() using generated_co_wrapper

2022-05-26 Thread Alberto Faria
On Thu, May 26, 2022 at 9:55 AM Stefan Hajnoczi wrote: > The bdrv_pread()/bdrv_pwrite() errno for negative bytes changes from > EINVAL to EIO. Did you audit the code to see if it matters? I don't believe I had, but I checked all calls now. There's ~140 of them, so the probability of me having

Re: [PATCH v3 06/10] block: Make 'bytes' param of bdrv_co_{pread, pwrite, preadv, pwritev}() an int64_t

2022-05-26 Thread Alberto Faria
On Thu, May 26, 2022 at 10:00 AM Stefan Hajnoczi wrote: > Maybe let the existing bdrv_check_request32() call in bdrv_co_preadv() > check this? It returns -EIO if bytes is too large. I'd be okay with that. Does this warrant changing blk_co_pread() and blk_co_pwrite() as well? Eric, what do you

Re: [PATCH] block: drop unused bdrv_co_drain() API

2022-05-23 Thread Alberto Faria
_begin()/bdrv_drained_end() instead. They are "mixed" > functions that can be called from coroutine context. Unlike > bdrv_co_drain(), these functions provide control of the length of the > drained section, which is usually the right thing. > > Signed-off-by: Stefan Hajnoczi Reviewed-by: Alberto Faria

Re: [PATCH] block: get rid of blk->guest_block_size

2022-05-19 Thread Alberto Faria
> > The last time the value of buffer_alignment/guest_block_size was > actually used was before commit 339064d50639 ("block: Don't use guest > sector size for qemu_blockalign()"). > > This value has not been used since 2013. Get rid of it. > > Cc: Xie Yongji > Signed-off-by: Stefan Hajnoczi Reviewed-by: Alberto Faria

  1   2   >