Re: [RFC PATCH 0/9] hw/sd: Allow card size not power of 2 again

2021-06-25 Thread Alexander Bulekov
On 210624 1012, Philippe Mathieu-Daudé wrote: > On 6/24/21 4:50 AM, Alexander Bulekov wrote: > > On 210623 2000, Philippe Mathieu-Daudé wrote: > >> Hi Ubi-Wan Kenubi and Tom, > >> > >> In commit a9bcedd (SD card size has to be power of 2) we decided > >> to restrict SD card size to avoid security

Re: [RFC PATCH 06/10] hw/sd: Add sd_cmd_unimplemented() handler

2021-06-25 Thread Bin Meng
On Sat, Jun 26, 2021 at 1:17 AM Philippe Mathieu-Daudé wrote: > > On 6/25/21 3:49 PM, Bin Meng wrote: > > On Thu, Jun 24, 2021 at 10:28 PM Philippe Mathieu-Daudé > > wrote: > >> > >> Signed-off-by: Philippe Mathieu-Daudé > >> --- > >> hw/sd/sd.c | 21 - > >> 1 file

Re: [PATCH v2 00/11] hw/nvme: reimplement all multi-aio commands with custom aiocbs

2021-06-25 Thread Keith Busch
On Thu, Jun 17, 2021 at 09:06:46PM +0200, Klaus Jensen wrote: > From: Klaus Jensen > > This series reimplements flush, dsm, copy, zone reset and format nvm to > allow cancellation. I posted an RFC back in March ("hw/block/nvme: > convert ad-hoc aio tracking to aiocb") and I've applied some

[PATCH 10/10] python: Add iotest linters to test suite

2021-06-25 Thread John Snow
As a convenience, since iotests is an extremely prominent user of the qemu.qmp and qemu.machine packages and already implements a linting regime, run those tests as well so that it's very hard to miss regressions caused by changes to the python library. Signed-off-by: John Snow ---

[PATCH 09/10] iotests/linters: Add entry point for Python CI linters

2021-06-25 Thread John Snow
Add a main() function to linters.py so that the Python CI infrastructure has something it can run. Now, linters.py represents an invocation of the linting scripts that more resembles a "normal" execution of pylint/mypy, like you'd expect to use if 'qemu' was a bona-fide package you obtained from

[PATCH 08/10] iotests/297: split linters.py off from 297

2021-06-25 Thread John Snow
Split the linter execution itself out from 297, leaving just environment setup in 297. This is done so that non-iotest code can invoke the linters without needing to worry about imports of unpackaged iotest code. Eventually, it should be possible to replace linters.py with mypy.ini and pylintrc

[PATCH 06/10] iotests/297: Add 'directory' argument to run_linters

2021-06-25 Thread John Snow
Allow run_linters to work well if it's executed from a different directory. Signed-off-by: John Snow --- tests/qemu-iotests/297 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297 index c7428af901..1e8334d1d4 100755 --- a/tests/qemu-iotests/297

[PATCH 04/10] iotests/297: Create main() function

2021-06-25 Thread John Snow
Instead of running "run_linters" directly, create a main() function that will be responsible for environment setup, leaving run_linters() responsible only for execution of the linters. (That environment setup will be moved over in forthcoming commits.) Signed-off-by: John Snow ---

[PATCH 07/10] iotests/297: return error code from run_linters()

2021-06-25 Thread John Snow
This turns run_linters() into a bit of a hybrid test; returning non-zero on failed execution while also printing diffable information. This is done for the benefit of the avocado simple test runner, which will soon be attempting to execute this test from a different environment. (Note:

[PATCH 03/10] iotests/297: Don't rely on distro-specific linter binaries

2021-06-25 Thread John Snow
'pylint-3' is another Fedora-ism. Use "python3 -m pylint" or "python3 -m mypy" to access these scripts instead. This style of invocation will prefer the "correct" tool when run in a virtual environment. Note that we still check for "pylint-3" before the test begins -- this check is now "overly

[PATCH 02/10] iotests/297: Add get_files() function

2021-06-25 Thread John Snow
Split out file discovery into its own method to begin separating out the "environment setup" and "test execution" phases. Signed-off-by: John Snow --- tests/qemu-iotests/297 | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/297

[PATCH 05/10] iotests/297: Separate environment setup from test execution

2021-06-25 Thread John Snow
Move environment setup into main(), leaving pure test execution behind in run_linters(). Signed-off-by: John Snow --- tests/qemu-iotests/297 | 36 +--- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297

[PATCH 01/10] iotests/297: modify is_python_file to work from any CWD

2021-06-25 Thread John Snow
Add a directory argument to is_python_file to allow it to work correctly no matter what CWD we happen to run it from. This is done in anticipation of running the iotests from another directory (./python/). Signed-off-by: John Snow --- tests/qemu-iotests/297 | 8 +--- 1 file changed, 5

[PATCH 00/10] python/iotests: Run iotest linters during Python CI

2021-06-25 Thread John Snow
Based-on: <20210625154540.783306-1-js...@redhat.com> GitLab: https://gitlab.com/jsnow/qemu/-/commits/python-package-iotest CI: https://gitlab.com/jsnow/qemu/-/pipelines/327413868 Since iotests are such a heavy and prominent user of the Python qemu.qmp and qemu.machine packages, it would be

Re: [RFC PATCH 06/10] hw/sd: Add sd_cmd_unimplemented() handler

2021-06-25 Thread Philippe Mathieu-Daudé
On 6/25/21 3:49 PM, Bin Meng wrote: > On Thu, Jun 24, 2021 at 10:28 PM Philippe Mathieu-Daudé > wrote: >> >> Signed-off-by: Philippe Mathieu-Daudé >> --- >> hw/sd/sd.c | 21 - >> 1 file changed, 12 insertions(+), 9 deletions(-) >> qemu_log_mask(LOG_GUEST_ERROR, "SD:

Re: [PULL 0/1] Block patch

2021-06-25 Thread Peter Maydell
On Thu, 24 Jun 2021 at 12:43, Max Reitz wrote: > > The following changes since commit b22726abdfa54592d6ad88f65b0297c0e8b363e2: > > Merge remote-tracking branch > 'remotes/vivier2/tags/linux-user-for-6.1-pull-request' into staging > (2021-06-22 16:07:53 +0100) > > are available in the Git

[PATCH v2 6/6] iotests/fuse-allow-other: Test allow-other

2021-06-25 Thread Max Reitz
Signed-off-by: Max Reitz --- tests/qemu-iotests/tests/fuse-allow-other | 175 ++ tests/qemu-iotests/tests/fuse-allow-other.out | 88 + 2 files changed, 263 insertions(+) create mode 100755 tests/qemu-iotests/tests/fuse-allow-other create mode 100644

[PATCH v2 5/6] iotests/308: Test +w on read-only FUSE exports

2021-06-25 Thread Max Reitz
Test that +w on read-only FUSE exports returns an EROFS error. u+x on the other hand should work. (There is no special reason to choose u+x here, it simply is like +w another flag that is not set by default.) Signed-off-by: Max Reitz --- tests/qemu-iotests/308 | 11 +++

[PATCH v2 1/6] export/fuse: Pass default_permissions for mount

2021-06-25 Thread Max Reitz
We do not do any permission checks in fuse_open(), so let the kernel do them. We already let fuse_getattr() report the proper UNIX permissions, so this should work the way we want. This causes a change in 308's reference output, because now opening a non-writable export with O_RDWR fails

[PATCH v2 3/6] export/fuse: Give SET_ATTR_SIZE its own branch

2021-06-25 Thread Max Reitz
In order to support changing other attributes than the file size in fuse_setattr(), we have to give each its own independent branch. This also applies to the only attribute we do support right now. Signed-off-by: Max Reitz Reviewed-by: Kevin Wolf --- block/export/fuse.c | 20

[PATCH v2 2/6] export/fuse: Add allow-other option

2021-06-25 Thread Max Reitz
Without the allow_other mount option, no user (not even root) but the one who started qemu/the storage daemon can access the export. Allow users to configure the export such that such accesses are possible. While allow_other is probably what users want, we cannot make it an unconditional

[PATCH v2 0/6] export/fuse: Allow other users access to the export

2021-06-25 Thread Max Reitz
Hi, The v1 cover letter is here: https://lists.nongnu.org/archive/html/qemu-block/2021-06/msg00730.html In v2, I changed the following: - default_permissions is now passed always. This is the right thing to do regardless of whether allow_other is active or not. - allow_other is no longer a

[PATCH v2 4/6] export/fuse: Let permissions be adjustable

2021-06-25 Thread Max Reitz
Allow changing the file mode, UID, and GID through SETATTR. Without allow_other, UID and GID are not allowed to be changed, because it would not make sense. Also, changing group or others' permissions is not allowed either. For read-only exports, +w cannot be set. Signed-off-by: Max Reitz ---

Re: [RFC PATCH 10/10] hw/sd: Add sd_cmd_SEND_RELATIVE_ADDR() handler

2021-06-25 Thread Bin Meng
On Thu, Jun 24, 2021 at 10:28 PM Philippe Mathieu-Daudé wrote: > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/sd/sd.c | 28 +++- > 1 file changed, 15 insertions(+), 13 deletions(-) > Reviewed-by: Bin Meng

Re: [RFC PATCH 07/10] hw/sd: Add sd_cmd_GO_IDLE_STATE() handler

2021-06-25 Thread Bin Meng
On Thu, Jun 24, 2021 at 10:29 PM Philippe Mathieu-Daudé wrote: > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/sd/sd.c | 24 > 1 file changed, 12 insertions(+), 12 deletions(-) > Reviewed-by: Bin Meng

Re: [RFC PATCH 09/10] hw/sd: Add sd_cmd_ALL_SEND_CID() handler

2021-06-25 Thread Bin Meng
On Thu, Jun 24, 2021 at 10:23 PM Philippe Mathieu-Daudé wrote: > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/sd/sd.c | 23 --- > 1 file changed, 12 insertions(+), 11 deletions(-) > Reviewed-by: Bin Meng

Re: [RFC PATCH 06/10] hw/sd: Add sd_cmd_unimplemented() handler

2021-06-25 Thread Bin Meng
On Thu, Jun 24, 2021 at 10:28 PM Philippe Mathieu-Daudé wrote: > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/sd/sd.c | 21 - > 1 file changed, 12 insertions(+), 9 deletions(-) > > diff --git a/hw/sd/sd.c b/hw/sd/sd.c > index 0215bdb3689..2647fd26566 100644 > ---

Re: [RFC PATCH 05/10] hw/sd: Add sd_cmd_illegal() handler

2021-06-25 Thread Bin Meng
On Thu, Jun 24, 2021 at 10:23 PM Philippe Mathieu-Daudé wrote: > > Log illegal commands as GUEST_ERROR. > > Note: we are logging back the SDIO commands (CMD5, CMD52-54). > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/sd/sd.c | 57 ++ > 1

Re: [RFC PATCH 04/10] hw/sd: Introduce sd_cmd_handler type

2021-06-25 Thread Bin Meng
On Thu, Jun 24, 2021 at 10:27 PM Philippe Mathieu-Daudé wrote: > > Add 2 command handler arrays in SDProto, for CMD and ACMD. > Have sd_normal_command() / sd_app_command() use these arrays: > if an command handler is registered, call it, otherwise fall a command > back to current code base. > >

[PULL 02/10] block-copy: let ratelimit handle a speed of 0

2021-06-25 Thread Vladimir Sementsov-Ogievskiy
From: Paolo Bonzini Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Paolo Bonzini Signed-off-by: Emanuele Giuseppe Esposito Message-Id: <20210614081130.22134-3-eespo...@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/block-copy.c | 28 +++-

[PULL 10/10] block-copy: atomic .cancelled and .finished fields in BlockCopyCallState

2021-06-25 Thread Vladimir Sementsov-Ogievskiy
From: Emanuele Giuseppe Esposito By adding acquire/release pairs, we ensure that .ret and .error_is_read fields are written by block_copy_dirty_clusters before .finished is true, and that they are read by API user after .finished is true. The atomic here are necessary because the fields are

[PULL 08/10] block-copy: move progress_set_remaining in block_copy_task_end

2021-06-25 Thread Vladimir Sementsov-Ogievskiy
From: Emanuele Giuseppe Esposito Moving this function in task_end ensures to update the progress anyways, even if there is an error. It also helps in next patch, allowing task_end to have only one critical section. Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Emanuele Giuseppe

[PULL 05/10] co-shared-resource: protect with a mutex

2021-06-25 Thread Vladimir Sementsov-Ogievskiy
From: Emanuele Giuseppe Esposito co-shared-resource is currently not thread-safe, as also reported in co-shared-resource.h. Add a QemuMutex because co_try_get_from_shres can also be invoked from non-coroutine context. Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Emanuele Giuseppe

[PULL 06/10] block-copy: small refactor in block_copy_task_entry and block_copy_common

2021-06-25 Thread Vladimir Sementsov-Ogievskiy
From: Emanuele Giuseppe Esposito Use a local variable instead of referencing BlockCopyState through a BlockCopyCallState or BlockCopyTask every time. This is in preparation for next patches. No functional change intended. Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Emanuele

[PULL 09/10] block-copy: add CoMutex lock

2021-06-25 Thread Vladimir Sementsov-Ogievskiy
From: Emanuele Giuseppe Esposito Group various structures fields, to better understand what we need to protect with a lock and what doesn't need it. Then, add a CoMutex to protect concurrent access of block-copy data structures. This mutex also protects .copy_bitmap, because its thread-safe API

[PULL 07/10] block-copy: streamline choice of copy_range vs. read/write

2021-06-25 Thread Vladimir Sementsov-Ogievskiy
From: Paolo Bonzini Put the logic to determine the copy size in a separate function, so that there is a simple state machine for the possible methods of copying data from one BlockDriverState to the other. Use .method instead of .copy_range as in-out argument, and include also .zeroes as an

[PULL 03/10] blockjob: let ratelimit handle a speed of 0

2021-06-25 Thread Vladimir Sementsov-Ogievskiy
From: Paolo Bonzini Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Paolo Bonzini Signed-off-by: Emanuele Giuseppe Esposito Message-Id: <20210614081130.22134-4-eespo...@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy --- blockjob.c | 13 +++-- 1 file changed, 3

[PULL 04/10] progressmeter: protect with a mutex

2021-06-25 Thread Vladimir Sementsov-Ogievskiy
From: Emanuele Giuseppe Esposito Progressmeter is protected by the AioContext mutex, which is taken by the block jobs and their caller (like blockdev). We would like to remove the dependency of block layer code on the AioContext mutex, since most drivers and the core I/O code are already not

[PULL 00/10] Block Jobs patches

2021-06-25 Thread Vladimir Sementsov-Ogievskiy
The following changes since commit e0da9171e02f4534124b9a9e0782b38376c6: Merge remote-tracking branch 'remotes/kraxel/tags/ui-20210624-pull-request' into staging (2021-06-25 09:10:37 +0100) are available in the Git repository at: ssh://g...@src.openvz.org/~vsementsov/qemu.git

[PULL 01/10] ratelimit: treat zero speed as unlimited

2021-06-25 Thread Vladimir Sementsov-Ogievskiy
From: Paolo Bonzini Both users of RateLimit, block-copy.c and blockjob.c, treat a speed of zero as unlimited, while RateLimit treats it as "as slow as possible". The latter is nicer from the code point of view but pretty useless, so disable rate limiting if a speed of zero is provided.

[PULL 5/6] hw/block/fdc: Extract SysBus floppy controllers to fdc-sysbus.c

2021-06-25 Thread John Snow
From: Philippe Mathieu-Daudé Some machines use floppy controllers via the SysBus interface, and don't need to pull in all the SysBus code. Extract the SysBus specific code to a new unit: fdc-sysbus.c, and add a new Kconfig symbol: "FDC_SYSBUS". Reviewed-by: John Snow Acked-by: Mark Cave-Ayland

[PULL 2/6] hw/block/fdc: Replace disabled fprintf() by trace event

2021-06-25 Thread John Snow
From: Philippe Mathieu-Daudé Reviewed-by: John Snow Acked-by: Mark Cave-Ayland Reviewed-by: Mark Cave-Ayland Acked-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daudé Message-id: 20210614193220.2007159-3-phi...@redhat.com Signed-off-by: John Snow --- hw/block/fdc.c| 7 +--

[PULL 1/6] hw/isa/Kconfig: Fix missing dependency ISA_SUPERIO -> FDC

2021-06-25 Thread John Snow
From: Philippe Mathieu-Daudé isa_superio_realize() calls isa_fdc_init_drives(), which is defined in hw/block/fdc.c, so ISA_SUPERIO needs to select the FDC symbol. Reported-by: John Snow Reviewed-by: Thomas Huth Acked-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daudé Message-id:

[PULL 6/6] hw/block/fdc: Add description to floppy controllers

2021-06-25 Thread John Snow
From: Philippe Mathieu-Daudé Change the '-device help' output from: Storage devices: name "floppy", bus floppy-bus, desc "virtual floppy drive" name "isa-fdc", bus ISA to: Storage devices: name "floppy", bus floppy-bus, desc "virtual floppy drive" name "isa-fdc", bus ISA, desc

[PULL 4/6] hw/block/fdc: Extract ISA floppy controllers to fdc-isa.c

2021-06-25 Thread John Snow
From: Philippe Mathieu-Daudé Some machines use floppy controllers via the SysBus interface, and don't need to pull in all the ISA code. Extract the ISA specific code to a new unit: fdc-isa.c, and add a new Kconfig symbol: "FDC_ISA". This allows us to remove the FIXME from commit dd0ff8191ab

[PULL 3/6] hw/block/fdc: Declare shared prototypes in fdc-internal.h

2021-06-25 Thread John Snow
From: Philippe Mathieu-Daudé We want to extract ISA/SysBus code from the generic fdc.c file. First, declare the prototypes we will access from the new units into a new local header: "fdc-internal.h". Acked-by: Mark Cave-Ayland Reviewed-by: Mark Cave-Ayland Acked-by: Paolo Bonzini

[PULL 0/6] Floppy patches

2021-06-25 Thread John Snow
The following changes since commit e0da9171e02f4534124b9a9e0782b38376c6: Merge remote-tracking branch 'remotes/kraxel/tags/ui-20210624-pull-request' into staging (2021-06-25 09:10:37 +0100) are available in the Git repository at: https://gitlab.com/jsnow/qemu.git

Re: [PATCH v5 0/5] block-copy: protect block-copy internal structures

2021-06-25 Thread Vladimir Sementsov-Ogievskiy
24.06.2021 10:20, Emanuele Giuseppe Esposito wrote: This serie of patches aims to reduce the usage of the AioContexlock in block-copy, by introducing smaller granularity locks thus on making the block layer thread safe. This serie depends on my previous serie that brings thread safety to the

Re: [PATCH v3 0/5] block-copy: make helper APIs thread safe

2021-06-25 Thread Vladimir Sementsov-Ogievskiy
14.06.2021 11:11, Emanuele Giuseppe Esposito wrote: This serie of patches bring thread safety to the smaller APIs used by block-copy, namely ratelimit, progressmeter, co-shared-resource and aiotask. The end goal is to reduce the usage of AioContexlock in block-copy, by introducing smaller

Re: [PATCH v5 0/5] block-copy: protect block-copy internal structures

2021-06-25 Thread Vladimir Sementsov-Ogievskiy
24.06.2021 10:20, Emanuele Giuseppe Esposito wrote: This serie of patches aims to reduce the usage of the AioContexlock in block-copy, by introducing smaller granularity locks thus on making the block layer thread safe. This serie depends on my previous serie that brings thread safety to the

Re: [PATCH v5 00/11] block: file-posix queue

2021-06-25 Thread Max Reitz
On 25.06.21 10:52, Paolo Bonzini wrote: On 25/06/21 10:37, Max Reitz wrote: Thanks, looks good to me, though I’m afraid I’ll be on PTO the next two weeks so I can’t take this series through my tree... (I don’t really want to send a pull request today when I probably wouldn’t be able to deal

Re: [PATCH v5 00/11] block: file-posix queue

2021-06-25 Thread Paolo Bonzini
On 25/06/21 10:37, Max Reitz wrote: Thanks, looks good to me, though I’m afraid I’ll be on PTO the next two weeks so I can’t take this series through my tree... (I don’t really want to send a pull request today when I probably wouldn’t be able to deal with potential problems) I can take it

Re: [PATCH v5 00/11] block: file-posix queue

2021-06-25 Thread Max Reitz
On 24.06.21 20:04, Paolo Bonzini wrote: New patches: - 3/4 (for review comments), - 9 (split for ease of review), - 11 (new bugfix) v1->v2: add missing patch v2->v3: add max_hw_transfer to BlockLimits v3->v4: fix compilation after patch 1, tweak commit messages according to

Re: [PATCH 11/11] file-posix: handle EINTR during ioctl

2021-06-25 Thread Max Reitz
On 24.06.21 20:04, Paolo Bonzini wrote: Similar to other handle_aiocb_* functions, handle_aiocb_ioctl needs to cater for the possibility that ioctl is interrupted by a signal. Otherwise, the I/O is incorrectly reported as a failure to the guest. Reported-by: Gordon Watson Signed-off-by: Paolo

Re: [PATCH 11/11] file-posix: handle EINTR during ioctl

2021-06-25 Thread Philippe Mathieu-Daudé
On 6/24/21 8:04 PM, Paolo Bonzini wrote: > Similar to other handle_aiocb_* functions, handle_aiocb_ioctl needs to cater > for the possibility that ioctl is interrupted by a signal. Otherwise, the > I/O is incorrectly reported as a failure to the guest. > > Reported-by: Gordon Watson >

Re: [PATCH 10/11] block: detect DKIOCGETBLOCKCOUNT/SIZE before use

2021-06-25 Thread Max Reitz
On 24.06.21 20:04, Paolo Bonzini wrote: From: Joelle van Dyne iOS hosts do not have these defined so we fallback to the default behaviour. Co-authored-by: Warner Losh Signed-off-by: Joelle van Dyne Signed-off-by: Paolo Bonzini --- block/file-posix.c | 2 +- 1 file changed, 1

Re: [PATCH 09/11] block: try BSD disk size ioctls one after another

2021-06-25 Thread Max Reitz
On 24.06.21 20:04, Paolo Bonzini wrote: Try all the possible ioctls for disk size as long as they are supported, to keep the #if ladder simple. Extracted and cleaned up from a patch by Joelle van Dyne and Warner Losh. Signed-off-by: Paolo Bonzini --- block/file-posix.c | 34

Re: [PATCH 03/11] osdep: provide ROUND_DOWN macro

2021-06-25 Thread Philippe Mathieu-Daudé
On 6/24/21 8:04 PM, Paolo Bonzini wrote: > osdep.h provides a ROUND_UP macro to hide bitwise operations for the > purpose of rounding a number up to a power of two; add a ROUND_DOWN > macro that does the same with truncation towards zero. > > While at it, change the formatting of some comments. >

Re: [PATCH 07/11] block: feature detection for host block support

2021-06-25 Thread Max Reitz
On 24.06.21 20:04, Paolo Bonzini wrote: From: Joelle van Dyne On Darwin (iOS), there are no system level APIs for directly accessing host block devices. We detect this at configure time. Signed-off-by: Joelle van Dyne Message-Id: <20210315180341.31638-...@getutm.app> Signed-off-by: Paolo

Re: [PATCH 06/11] file-posix: try BLKSECTGET on block devices too, do not round to power of 2

2021-06-25 Thread Max Reitz
On 24.06.21 20:04, Paolo Bonzini wrote: bs->sg is only true for character devices, but block devices can also be used with scsi-block and scsi-generic. Unfortunately BLKSECTGET returns bytes in an int for /dev/sgN devices, and sectors in a short for block devices, so account for that in the

Re: [PATCH 05/11] block: add max_hw_transfer to BlockLimits

2021-06-25 Thread Max Reitz
On 24.06.21 20:04, Paolo Bonzini wrote: For block host devices, I/O can happen through either the kernel file descriptor I/O system calls (preadv/pwritev, io_submit, io_uring) or the SCSI passthrough ioctl SG_IO. In the latter case, the size of each transfer can be limited by the HBA, while for

Re: [PATCH 04/11] block-backend: align max_transfer to request alignment

2021-06-25 Thread Max Reitz
On 24.06.21 20:04, Paolo Bonzini wrote: Block device requests must be aligned to bs->bl.request_alignment. It makes sense for drivers to align bs->bl.max_transfer the same way; however when there is no specified limit, blk_get_max_transfer just returns INT_MAX. Since the contract of the

Re: [PATCH 03/11] osdep: provide ROUND_DOWN macro

2021-06-25 Thread Max Reitz
On 24.06.21 20:04, Paolo Bonzini wrote: osdep.h provides a ROUND_UP macro to hide bitwise operations for the purpose of rounding a number up to a power of two; add a ROUND_DOWN macro that does the same with truncation towards zero. While at it, change the formatting of some comments.

Re: [RFC PATCH 03/10] hw/sd: Move proto_name to SDProto structure

2021-06-25 Thread Bin Meng
On Thu, Jun 24, 2021 at 10:24 PM Philippe Mathieu-Daudé wrote: > > Introduce a new structure to hold the bus protocol specific > fields: SDProto. The first field is the protocol name. > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/sd/sd.c | 28 > 1 file

Re: [RFC PATCH 02/10] hw/sd: Extract address_in_range() helper, log invalid accesses

2021-06-25 Thread Bin Meng
On Thu, Jun 24, 2021 at 10:24 PM Philippe Mathieu-Daudé wrote: > > Multiple commands have to check the address requested is valid. > Extract this code pattern as a new address_in_range() helper, and > log invalid accesses as guest errors. > > Signed-off-by: Philippe Mathieu-Daudé > --- >

Re: [RFC PATCH 01/10] hw/sd: When card is in wrong state, log which state it is

2021-06-25 Thread Bin Meng
On Thu, Jun 24, 2021 at 10:22 PM Philippe Mathieu-Daudé wrote: > > We report the card is in an inconsistent state, but don't precise %s/don't/is not > in which state it is. Add this information, as it is useful when > debugging problems. > > Since we will reuse this code, extract as