Re: [RFC PATCH v3] hw/nvme:Adding Support for namespace management

2021-11-23 Thread Lukasz Maniak
On Wed, Nov 10, 2021 at 04:56:29PM +0530, Naveen wrote: > From: Naveen Nagar > > This patch supports namespace management : create and delete operations > This patch has been tested with the following command and size of image > file for unallocated namespaces is taken as 0GB. ns_create will

Re: [PULL 0/7] Python patches

2021-11-23 Thread Richard Henderson
On 11/23/21 3:37 AM, John Snow wrote: The following changes since commit 89d2f9e4c63799f7f03e9180c63b7dc45fc2a04a: Merge tag 'pull-target-arm-20211122' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2021-11-22 16:35:54 +0100) are available in the Git repository at:

Re: [PATCH] block vvfat.c fix leak when failure occurs

2021-11-23 Thread Hanna Reitz
On 19.11.21 12:25, Daniella Lee wrote: Based on your suggestions. I made a new patch which contians: 1.format detection 2.replace calloc with g_malloc0 in enable_write_target function 3.use g_free without null pointer detection in vvfat_open function 4.delete line "ret = 0", use return ret

[PULL 0/3] Block patches

2021-11-23 Thread Hanna Reitz
The following changes since commit 73e0f70e097b7c92a5ce16ee35b53afe119b20d7: Merge tag 'pull-lu-20211123' of https://gitlab.com/rth7680/qemu into staging (2021-11-23 11:33:14 +0100) are available in the Git repository at: https://gitlab.com/hreitz/qemu.git tags/pull-block-2021-11-23

[PULL 1/3] block/vvfat.c fix leak when failure occurs

2021-11-23 Thread Hanna Reitz
From: Daniella Lee Function vvfat_open called function enable_write_target and init_directories, and these functions malloc new memory for BDRVVVFATState::qcow_filename, BDRVVVFATState::used_clusters, and BDRVVVFATState::cluster_buff. When the specified folder does not exist ,it may contains

[PULL 3/3] iotests/149: Skip on unsupported ciphers

2021-11-23 Thread Hanna Reitz
Whenever qemu-img or qemu-io report that some cipher is unsupported, skip the whole test, because that is probably because qemu has been configured with the gnutls crypto backend. We could taylor the algorithm list to what gnutls supports, but this is a test that is run rather rarely anyway

Re: [PATCH-for-6.2 v3 2/2] tests/qtest/fdc-test: Add a regression test for CVE-2021-20196

2021-11-23 Thread Alexander Bulekov
On 211123 1449, Philippe Mathieu-Daudé wrote: > On 11/23/21 14:42, Hanna Reitz wrote: > > On 18.11.21 13:06, Philippe Mathieu-Daudé wrote: > >> From: Alexander Bulekov > >> > >> Without the previous commit, when running 'make check-qtest-i386' > >> with QEMU configured with '--enable-sanitizers'

Re: [PATCH-for-6.2 v3 1/2] hw/block/fdc: Kludge missing floppy drive to fix CVE-2021-20196

2021-11-23 Thread Hanna Reitz
On 18.11.21 13:06, Philippe Mathieu-Daudé wrote: Guest might select another drive on the bus by setting the DRIVE_SEL bit of the DIGITAL OUTPUT REGISTER (DOR). The current controller model doesn't expect a BlockBackend to be NULL. A simple way to fix CVE-2021-20196 is to create an empty

Re: [PATCH-for-6.2 v3 2/2] tests/qtest/fdc-test: Add a regression test for CVE-2021-20196

2021-11-23 Thread Hanna Reitz
On 18.11.21 13:06, Philippe Mathieu-Daudé wrote: From: Alexander Bulekov Without the previous commit, when running 'make check-qtest-i386' with QEMU configured with '--enable-sanitizers' we get: AddressSanitizer:DEADLYSIGNAL

Re: [PATCH-for-6.2 v3 2/2] tests/qtest/fdc-test: Add a regression test for CVE-2021-20196

2021-11-23 Thread Hanna Reitz
On 23.11.21 14:49, Philippe Mathieu-Daudé wrote: On 11/23/21 14:42, Hanna Reitz wrote: On 18.11.21 13:06, Philippe Mathieu-Daudé wrote: From: Alexander Bulekov Without the previous commit, when running 'make check-qtest-i386' with QEMU configured with '--enable-sanitizers' we get:   

[PULL 2/3] iotests: Use aes-128-cbc

2021-11-23 Thread Hanna Reitz
Our gnutls crypto backend (which is the default as of 8bd0931f6) supports neither twofish-128 nor the CTR mode. CBC and aes-128 are supported by all of our backends (as far as I can tell), so use aes-128-cbc in our iotests. (We could also use e.g. aes-256-cbc, but the different key sizes would

Re: [PATCH-for-6.2 2/2] tests/qtest/fdc-test: Add a regression test for CVE-2021-3507

2021-11-23 Thread Hanna Reitz
On 18.11.21 12:57, Philippe Mathieu-Daudé wrote: Add the reproducer from https://gitlab.com/qemu-project/qemu/-/issues/339 Without the previous commit, when running 'make check-qtest-i386' with QEMU configured with '--enable-sanitizers' we get: ==4028352==ERROR: AddressSanitizer:

Re: [PATCH-for-6.2 v3 2/2] tests/qtest/fdc-test: Add a regression test for CVE-2021-20196

2021-11-23 Thread Philippe Mathieu-Daudé
On 11/23/21 14:42, Hanna Reitz wrote: > On 18.11.21 13:06, Philippe Mathieu-Daudé wrote: >> From: Alexander Bulekov >> >> Without the previous commit, when running 'make check-qtest-i386' >> with QEMU configured with '--enable-sanitizers' we get: >> >>    AddressSanitizer:DEADLYSIGNAL >>   

Re: [PATCH-for-6.2 v3 1/2] hw/block/fdc: Kludge missing floppy drive to fix CVE-2021-20196

2021-11-23 Thread Philippe Mathieu-Daudé
On 11/23/21 14:33, Hanna Reitz wrote: > On 18.11.21 13:06, Philippe Mathieu-Daudé wrote: >> Guest might select another drive on the bus by setting the >> DRIVE_SEL bit of the DIGITAL OUTPUT REGISTER (DOR). >> The current controller model doesn't expect a BlockBackend >> to be NULL. A simple way to

Re: [PATCH-for-6.2 1/2] hw/block/fdc: Prevent end-of-track overrun (CVE-2021-3507)

2021-11-23 Thread Hanna Reitz
On 18.11.21 12:57, Philippe Mathieu-Daudé wrote: Per the 82078 datasheet, if the end-of-track (EOT byte in the FIFO) is more than the number of sectors per side, the command is terminated unsuccessfully: Patch looks OK to me (can’t believe I’ve looked into the spec...), just one question

Re: [PATCH-for-6.2 2/2] tests/qtest/fdc-test: Add a regression test for CVE-2021-3507

2021-11-23 Thread Alexander Bulekov
On 28 1257, Philippe Mathieu-Daudé wrote: > Add the reproducer from https://gitlab.com/qemu-project/qemu/-/issues/339 > > Without the previous commit, when running 'make check-qtest-i386' > with QEMU configured with '--enable-sanitizers' we get: > > ==4028352==ERROR: AddressSanitizer:

Re: [PULL 0/3] Block patches

2021-11-23 Thread Richard Henderson
On 11/23/21 4:59 PM, Hanna Reitz wrote: The following changes since commit 73e0f70e097b7c92a5ce16ee35b53afe119b20d7: Merge tag 'pull-lu-20211123' of https://gitlab.com/rth7680/qemu into staging (2021-11-23 11:33:14 +0100) are available in the Git repository at: https://gitlab.com

[PATCH 1/4] block_int: make bdrv_backing_overridden static

2021-11-23 Thread Emanuele Giuseppe Esposito
bdrv_backing_overridden is only used in block.c, so there is no need to leave it in block_int.h Signed-off-by: Emanuele Giuseppe Esposito --- include/block/block_int.h | 3 --- block.c | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git

[PATCH 3/4] include/sysemu/blockdev.h: move drive_add and inline drive_def

2021-11-23 Thread Emanuele Giuseppe Esposito
drive_add is only used in softmmu/vl.c, so it can be a static function there, and drive_def is only a particular use case of qemu_opts_parse_noisily, so it can be inlined. Also remove drive_mark_claimed_by_board, as it is only defined but not implemented (nor used) anywhere. Signed-off-by:

[PATCH v5 01/31] main-loop.h: introduce qemu_in_main_thread()

2021-11-23 Thread Emanuele Giuseppe Esposito
When invoked from the main loop, this function is the same as qemu_mutex_iothread_locked, and returns true if the BQL is held. When invoked from iothreads or tests, it returns true only if the current AioContext is the Main Loop. This essentially just extends qemu_mutex_iothread_locked to work

[PATCH v5 02/31] include/block/block: split header into I/O and global state API

2021-11-23 Thread Emanuele Giuseppe Esposito
block.h currently contains a mix of functions: some of them run under the BQL and modify the block layer graph, others are instead thread-safe and perform I/O in iothreads. It is not easy to understand which function is part of which group (I/O vs GS), and this patch aims to clarify it. The "GS"

[PATCH v5 07/31] include/block/block_int: split header into I/O and global state API

2021-11-23 Thread Emanuele Giuseppe Esposito
Similarly to the previous patch, split block_int.h in block_int-io.h and block_int-global-state.h block_int-common.h contains the structures shared between the two headers, and the functions that can't be categorized as I/O or global state. Assertions are added in the next patch. Signed-off-by:

[PATCH v5 13/31] block.c: add assertions to static functions

2021-11-23 Thread Emanuele Giuseppe Esposito
Following the assertion derived from the API split, propagate the assertion also in the static functions. Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 45 - 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c

[PATCH v5 11/31] include/block/blockjob_int.h: split header into I/O and GS API

2021-11-23 Thread Emanuele Giuseppe Esposito
Since the I/O functions are not many, keep a single file. Also split the function pointers in BlockJobDriver. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Stefan Hajnoczi --- include/block/blockjob_int.h | 28 1 file changed, 28 insertions(+) diff --git

[PATCH v5 15/31] assertions for blockjob.h global state API

2021-11-23 Thread Emanuele Giuseppe Esposito
Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Stefan Hajnoczi --- blockjob.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/blockjob.c b/blockjob.c index 10c807413e..74476af473 100644 --- a/blockjob.c +++ b/blockjob.c @@ -62,6 +62,7 @@ static bool is_block_job(Job

[PATCH v5 24/31] block_int-common.h: assertions in the callers of BdrvChildClass function pointers

2021-11-23 Thread Emanuele Giuseppe Esposito
Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 9 + 1 file changed, 9 insertions(+) diff --git a/block.c b/block.c index 180884b8c0..a0309f827d 100644 --- a/block.c +++ b/block.c @@ -1491,6 +1491,7 @@ const BdrvChildClass child_of_bds = { AioContext

[PATCH v5 09/31] block: introduce assert_bdrv_graph_writable

2021-11-23 Thread Emanuele Giuseppe Esposito
We want to be sure that the functions that write the child and parent list of a bs are under BQL and drain. BQL prevents from concurrent writings from the GS API, while drains protect from I/O. TODO: drains are missing in some functions using this assert. Therefore a proper assertion will fail.

[PATCH v5 26/31] job.h: split function pointers in JobDriver

2021-11-23 Thread Emanuele Giuseppe Esposito
The job API will be handled separately in another serie. Signed-off-by: Emanuele Giuseppe Esposito --- include/qemu/job.h | 22 ++ 1 file changed, 22 insertions(+) diff --git a/include/qemu/job.h b/include/qemu/job.h index 6e67b6977f..4ea7a4a0cd 100644 ---

[PATCH v5 29/31] jobs: introduce pre_run function in JobDriver

2021-11-23 Thread Emanuele Giuseppe Esposito
.pre_run takes care of doing some initial job setup just before the job is run inside the coroutine. Doing so can be useful to invoke GS functions that require the BQL held. Signed-off-by: Emanuele Giuseppe Esposito --- include/qemu/job.h | 9 + job.c | 13 + 2

[PATCH v5 17/31] assertions for blockdev.h global state API

2021-11-23 Thread Emanuele Giuseppe Esposito
Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi --- block/block-backend.c | 3 +++ blockdev.c| 15 +++ 2 files changed, 18 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index

[PATCH v5 18/31] include/block/snapshot: global state API + assertions

2021-11-23 Thread Emanuele Giuseppe Esposito
Snapshots run also under the BQL lock, so they all are in the global state API. The aiocontext lock that they hold is currently an overkill and in future could be removed. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi ---

[PATCH v5 31/31] block.c: assertions to the block layer permissions API

2021-11-23 Thread Emanuele Giuseppe Esposito
Now that we "covered" the three main cases where the permission API was being used under BQL (fuse, amend and invalidate_cache), we can safely assert for the permission functions implemented in block.c Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 12 1 file changed, 12

[PATCH v5 27/31] job.h: assertions in the callers of JobDriver funcion pointers

2021-11-23 Thread Emanuele Giuseppe Esposito
Also assert that job->run() callback is called in the job aiocontext. Signed-off-by: Emanuele Giuseppe Esposito --- job.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/job.c b/job.c index dbfa67bb0a..bb57ec6887 100644 --- a/job.c +++ b/job.c @@ -380,6 +380,8 @@ void

Re: [PATCH 2/4] include/sysemu/blockdev.h: rename if_name in block_if_name

2021-11-23 Thread Philippe Mathieu-Daudé
On 11/24/21 07:36, Emanuele Giuseppe Esposito wrote: > In preparation to next patch, where we export it to be used > also in softmmu/vlc.c "vl.c"? :) > > Signed-off-by: Emanuele Giuseppe Esposito > --- > blockdev.c | 14 +++--- > 1 file changed, 7 insertions(+), 7 deletions(-)

[PATCH 0/4] block: minor refactoring in preparation to the block layer API split

2021-11-23 Thread Emanuele Giuseppe Esposito
These patches are taken from my old patches and feedback of my series "block layer: split block APIs in global state and I/O". The reason for a separate series is that the original one is already too long, and these patches are just refactoring the code, mainly deleting or moving functions in

[PATCH 4/4] include/sysemu/blockdev.h: remove drive_get_max_devs

2021-11-23 Thread Emanuele Giuseppe Esposito
Remove drive_get_max_devs, as it is not used by anyone. Signed-off-by: Emanuele Giuseppe Esposito --- include/sysemu/blockdev.h | 1 - blockdev.c| 17 - 2 files changed, 18 deletions(-) diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h index

[PATCH 2/4] include/sysemu/blockdev.h: rename if_name in block_if_name

2021-11-23 Thread Emanuele Giuseppe Esposito
In preparation to next patch, where we export it to be used also in softmmu/vlc.c Signed-off-by: Emanuele Giuseppe Esposito --- blockdev.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/blockdev.c b/blockdev.c index b35072644e..1b6ffbbc73 100644 ---

[PATCH v5 00/31] block layer: split block APIs in global state and I/O

2021-11-23 Thread Emanuele Giuseppe Esposito
Currently, block layer APIs like block.h contain a mix of functions that are either running in the main loop and under the BQL, or are thread-safe functions and run in iothreads performing I/O. The functions running under BQL also take care of modifying the block graph, by using drain and/or

[PATCH v5 03/31] assertions for block global state API

2021-11-23 Thread Emanuele Giuseppe Esposito
All the global state (GS) API functions will check that qemu_in_main_thread() returns true. If not, it means that the safety of BQL cannot be guaranteed, and they need to be moved to I/O. Signed-off-by: Emanuele Giuseppe Esposito --- block.c| 135

[PATCH v5 05/31] block-backend: special comments for blk_set/get_perm due to fuse

2021-11-23 Thread Emanuele Giuseppe Esposito
Fuse logic can be classified as I/O, so there is no BQL held during its execution. And yet, it uses blk_{get/set}_perm functions, that are classified as BQL and clearly require the BQL lock. Since there is no easy solution for this, add a couple of TODOs and FIXME in the relevant sections of the

[PATCH v5 04/31] include/sysemu/block-backend: split header into I/O and global state (GS) API

2021-11-23 Thread Emanuele Giuseppe Esposito
Similarly to the previous patches, split block-backend.h in block-backend-io.h and block-backend-global-state.h In addition, remove "block/block.h" include as it seems it is not necessary anymore, together with "qemu/iov.h" block-backend-common.h contains the structures shared between the two

[PATCH v5 08/31] assertions for block_int global state API

2021-11-23 Thread Emanuele Giuseppe Esposito
Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 15 +++ block/backup.c | 1 + block/block-backend.c | 3 +++ block/commit.c | 2 ++ block/dirty-bitmap.c| 1 + block/io.c |

[PATCH v5 10/31] block.c: modify .attach and .detach callbacks of child_of_bds

2021-11-23 Thread Emanuele Giuseppe Esposito
According to the assertions put in the previous patch, we should first drain and then modify the ->children list. In this way we prevent other iothreads to read the list while it is being updated. In this case, moving the drain won't cause any harm, because child is a parameter of the drain

[PATCH v5 06/31] block/block-backend.c: assertions for block-backend

2021-11-23 Thread Emanuele Giuseppe Esposito
All the global state (GS) API functions will check that qemu_in_main_thread() returns true. If not, it means that the safety of BQL cannot be guaranteed, and they need to be moved to I/O. Signed-off-by: Emanuele Giuseppe Esposito --- block/block-backend.c | 83

[PATCH v5 12/31] assertions for blockjob_int.h

2021-11-23 Thread Emanuele Giuseppe Esposito
Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Stefan Hajnoczi --- blockjob.c | 4 1 file changed, 4 insertions(+) diff --git a/blockjob.c b/blockjob.c index 4bad1408cb..10c807413e 100644 --- a/blockjob.c +++ b/blockjob.c @@ -84,6 +84,7 @@ BlockJob *block_job_get(const char *id)

[PATCH v5 14/31] include/block/blockjob.h: global state API

2021-11-23 Thread Emanuele Giuseppe Esposito
blockjob functions run always under the BQL lock. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Stefan Hajnoczi --- include/block/blockjob.h | 9 + 1 file changed, 9 insertions(+) diff --git a/include/block/blockjob.h b/include/block/blockjob.h index d200f33c10..fa0c3f7a47

[PATCH v5 16/31] include/sysemu/blockdev.h: global state API

2021-11-23 Thread Emanuele Giuseppe Esposito
blockdev functions run always under the BQL lock. Signed-off-by: Emanuele Giuseppe Esposito --- include/sysemu/blockdev.h | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h index c4b7b8b54e..e53eb91be6 100644

[PATCH v5 22/31] block_int-common.h: assertion in the callers of BlockDriver function pointers

2021-11-23 Thread Emanuele Giuseppe Esposito
Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Stefan Hajnoczi --- block.c| 18 ++ block/create.c | 10 ++ 2 files changed, 28 insertions(+) diff --git a/block.c b/block.c index b77ab0a104..180884b8c0 100644 --- a/block.c +++ b/block.c @@ -526,6 +526,7

[PATCH v5 19/31] block/copy-before-write.h: global state API + assertions

2021-11-23 Thread Emanuele Giuseppe Esposito
copy-before-write functions always run under BQL lock. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi --- block/copy-before-write.h | 7 +++ block/copy-before-write.c | 2 ++ 2 files changed, 9 insertions(+) diff --git

[PATCH v5 21/31] block_int-common.h: split function pointers in BlockDriver

2021-11-23 Thread Emanuele Giuseppe Esposito
Similar to the header split, also the function pointers in BlockDriver can be split in I/O and global state. Signed-off-by: Emanuele Giuseppe Esposito --- include/block/block_int-common.h | 440 +-- 1 file changed, 235 insertions(+), 205 deletions(-) diff --git

[PATCH v5 25/31] block-backend-common.h: split function pointers in BlockDevOps

2021-11-23 Thread Emanuele Giuseppe Esposito
Assertions in the callers of the function pointrs are already added by previous patches. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daudé --- include/sysemu/block-backend-common.h | 28 ++- 1 file changed, 23

[PATCH v5 20/31] block/coroutines: I/O API

2021-11-23 Thread Emanuele Giuseppe Esposito
block coroutines functions run in different aiocontext, and are not protected by the BQL. Therefore are I/O. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi --- block/coroutines.h | 6 ++ 1 file changed, 6 insertions(+) diff --git

[PATCH v5 23/31] block_int-common.h: split function pointers in BdrvChildClass

2021-11-23 Thread Emanuele Giuseppe Esposito
Signed-off-by: Emanuele Giuseppe Esposito --- include/block/block_int-common.h | 67 +++- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h index 0e63dc694f..3ceb2365a8 100644 ---

[PATCH v5 28/31] block.c: assert BQL lock held in bdrv_co_invalidate_cache

2021-11-23 Thread Emanuele Giuseppe Esposito
bdrv_co_invalidate_cache is special: it is an I/O function, but uses the block layer permission API, which is GS. Because of this, we can assert that either the function is being called with BQL held, and thus can use the permission API, or make sure that the permission API is not used, by

[PATCH v5 30/31] crypto: delegate permission functions to JobDriver .pre_run

2021-11-23 Thread Emanuele Giuseppe Esposito
block_crypto_amend_options_generic_luks uses the block layer permission API, therefore it should be called with the BQL held. However, the same function is being called ib two BlockDriver callbacks: bdrv_amend_options (under BQL) and bdrv_co_amend (I/O). The latter is I/O because it is invoked