[PATCH 2/2] util/async: print leaked BH name when AioContext finalizes

2021-04-14 Thread Stefan Hajnoczi
BHs must be deleted before the AioContext is finalized. If not, it's a bug and probably indicates that some part of the program still expects the BH to run in the future. That can lead to memory leaks, inconsistent state, or just hangs. Unfortunately the assert(flags & BH_DELETED) call in

[PATCH 0/2] util/async: print leaked BH name when AioContext finalizes

2021-04-14 Thread Stefan Hajnoczi
Eric Ernst and I debugged a BH leak and it was more involved than it should be. The problem is that BHs don't have a human-readable identifier, so low-level debugging techniques and inferences about the code are required to figure out which BH was leaked in production environments without easy

[PATCH 1/2] util/async: add a human-readable name to BHs for debugging

2021-04-14 Thread Stefan Hajnoczi
It can be difficult to debug issues with BHs in production environments. Although BHs can usually be identified by looking up their ->cb() function pointer, this requires debug information for the program. It is also not possible to print human-readable diagnostics about BHs because they have no

[PATCH v3 13/15] docs/devel/testing: add -valgrind option to the debug section of QEMU iotests

2021-04-14 Thread Emanuele Giuseppe Esposito
Signed-off-by: Emanuele Giuseppe Esposito --- docs/devel/testing.rst | 7 +++ 1 file changed, 7 insertions(+) diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst index 2ee77a057b..62902cfd2d 100644 --- a/docs/devel/testing.rst +++ b/docs/devel/testing.rst @@ -236,6 +236,13 @@ given

[PATCH v3 10/15] qemu_iotests: extent QMP socket timeout when using valgrind

2021-04-14 Thread Emanuele Giuseppe Esposito
As with gdbserver, valgrind delays the test execution, so the default QMP socket timeout timeout too soon. Signed-off-by: Emanuele Giuseppe Esposito --- python/qemu/machine.py| 2 +- tests/qemu-iotests/iotests.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git

[PATCH v3 14/15] qemu_iotests: add option to show qemu binary logs on stdout

2021-04-14 Thread Emanuele Giuseppe Esposito
Using the flag -p, allow the qemu binary to print to stdout. This helps especially when doing print-debugging. Signed-off-by: Emanuele Giuseppe Esposito --- tests/qemu-iotests/check | 3 ++- tests/qemu-iotests/iotests.py | 9 + tests/qemu-iotests/testenv.py | 9 +++-- 3 files

[PATCH v3 15/15] docs/devel/testing: add -p option to the debug section of QEMU iotests

2021-04-14 Thread Emanuele Giuseppe Esposito
Signed-off-by: Emanuele Giuseppe Esposito --- docs/devel/testing.rst | 4 1 file changed, 4 insertions(+) diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst index 62902cfd2d..0c18fc4571 100644 --- a/docs/devel/testing.rst +++ b/docs/devel/testing.rst @@ -246,6 +246,10 @@ given as

[PATCH v3 05/15] qemu-iotests: delay QMP socket timers

2021-04-14 Thread Emanuele Giuseppe Esposito
Attaching a gdbserver implies that the qmp socket should wait indefinitely for an answer from QEMU. Signed-off-by: Emanuele Giuseppe Esposito --- python/qemu/machine.py| 3 +++ tests/qemu-iotests/iotests.py | 10 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git

[PATCH v3 11/15] qemu_iotests: allow valgrind to read/delete the generated log file

2021-04-14 Thread Emanuele Giuseppe Esposito
When using -valgrind on the script tests, it generates a log file in $TEST_DIR that is either read (if valgrind finds problems) or otherwise deleted. Provide the same exact behavior when using -valgrind on the python tests. Signed-off-by: Emanuele Giuseppe Esposito ---

[PATCH v3 09/15] qemu_iotests: extend the check script to support valgrind for python tests

2021-04-14 Thread Emanuele Giuseppe Esposito
Currently, the check script only parses the option and sets the VALGRIND_QEMU environmental variable to "y". Add another local python variable that prepares the command line, identical to the one provided in the test scripts. Because the python script does not know in advance the valgring PID to

[PATCH v3 08/15] docs/devel/testing: add -gdb option to the debugging section of QEMU iotests

2021-04-14 Thread Emanuele Giuseppe Esposito
Signed-off-by: Emanuele Giuseppe Esposito --- docs/devel/testing.rst | 7 +++ 1 file changed, 7 insertions(+) diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst index b7e2370e7e..2ee77a057b 100644 --- a/docs/devel/testing.rst +++ b/docs/devel/testing.rst @@ -229,6 +229,13 @@

[PATCH v3 12/15] qemu_iotests: insert valgrind command line as wrapper for qemu binary

2021-04-14 Thread Emanuele Giuseppe Esposito
The priority will be given to gdb command line, meaning if the -gdb parameter and -valgrind are given, gdb will be wrapped around the qemu binary. Signed-off-by: Emanuele Giuseppe Esposito --- tests/qemu-iotests/iotests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git

[PATCH v3 07/15] qemu-iotests: add gdbserver option to script tests too

2021-04-14 Thread Emanuele Giuseppe Esposito
The only limitation here is that running a script with gdbserver will make the test output mismatch with the expected results, making the test fail. Signed-off-by: Emanuele Giuseppe Esposito --- tests/qemu-iotests/common.rc | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff

[PATCH v3 03/15] docs/devel/testing: add debug section to the QEMU iotests chapter

2021-04-14 Thread Emanuele Giuseppe Esposito
Introduce the "Debugging a test case" section, in preparation to the additional flags that will be added in the next patches. Signed-off-by: Emanuele Giuseppe Esposito --- docs/devel/testing.rst | 8 1 file changed, 8 insertions(+) diff --git a/docs/devel/testing.rst

[PATCH v3 06/15] qemu_iotests: insert gdbserver command line as wrapper for qemu binary

2021-04-14 Thread Emanuele Giuseppe Esposito
Signed-off-by: Emanuele Giuseppe Esposito --- tests/qemu-iotests/iotests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 380527245e..4f3fb13915 100644 --- a/tests/qemu-iotests/iotests.py +++

[PATCH v3 02/15] python: qemu: pass the wrapper field from QEMUQtestmachine to QEMUMachine

2021-04-14 Thread Emanuele Giuseppe Esposito
Signed-off-by: Emanuele Giuseppe Esposito --- python/qemu/qtest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/qemu/qtest.py b/python/qemu/qtest.py index 39a0cf62fe..c18eae96c6 100644 --- a/python/qemu/qtest.py +++ b/python/qemu/qtest.py @@ -111,6 +111,7 @@

[PATCH v3 04/15] qemu-iotests: add option to attach gdbserver

2021-04-14 Thread Emanuele Giuseppe Esposito
Add -gdb flag and GDB_QEMU environmental variable to python tests to attach a gdbserver to each qemu instance. if -gdb is not provided but $GDB_QEMU is set, ignore the environmental variable. Signed-off-by: Emanuele Giuseppe Esposito --- tests/qemu-iotests/check | 6 +-

[PATCH v3 01/15] python: qemu: add timer parameter for qmp.accept socket

2021-04-14 Thread Emanuele Giuseppe Esposito
Add a new _qmp_timer field to the QEMUMachine class. The default timer is 15 sec, as per the default in the qmp accept() function. Signed-off-by: Emanuele Giuseppe Esposito --- python/qemu/machine.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/qemu/machine.py

[PATCH v3 00/15] qemu_iotests: improve debugging options

2021-04-14 Thread Emanuele Giuseppe Esposito
This series adds the option to attach gdbserver and valgrind to the QEMU binary running in qemu_iotests. It also allows to redirect QEMU binaries output of the python tests to the stdout, instead of a log file. Patches 1-6 introduce the -gdb option to both python and bash tests, 7-10 extend the

Re: [PATCH] hw/block/nvme: remove redundant invalid_lba_range trace

2021-04-14 Thread Philippe Mathieu-Daudé
On 4/14/21 9:04 AM, Gollu Appalanaidu wrote: > Currently pci_nvme_err_invalid_lba_range tace being called indvidually Typos "trace", "individually". > at each function, add this in nvme_check_bounds and remove redundant > usage of it. > > Signed-off-by: Gollu Appalanaidu > --- >

Re: [PATCH] ratelimit: protect with a mutex

2021-04-14 Thread Emanuele Giuseppe Esposito
On 13/04/2021 14:55, Paolo Bonzini wrote: Right now, rate limiting is protected by the AioContext mutex, which is taken for example both by the block jobs and by qmp_block_job_set_speed (via find_block_job). We would like to remove the dependency of block layer code on the AioContext mutex,

Re: [PATCH] ratelimit: protect with a mutex

2021-04-14 Thread Stefan Hajnoczi
On Tue, Apr 13, 2021 at 02:55:33PM +0200, Paolo Bonzini wrote: > Right now, rate limiting is protected by the AioContext mutex, which is > taken for example both by the block jobs and by qmp_block_job_set_speed > (via find_block_job). > > We would like to remove the dependency of block layer code

Re: [PATCH v2] vhost-user-blk: Fail gracefully on too large queue size

2021-04-14 Thread Stefan Hajnoczi
On Tue, Apr 13, 2021 at 06:56:54PM +0200, Kevin Wolf wrote: > virtio_add_queue() aborts when queue_size > VIRTQUEUE_MAX_SIZE, so > vhost_user_blk_device_realize() should check this before calling it. > > Simple reproducer: > > qemu-system-x86_64 \ > -chardev null,id=foo \ > -device

[PATCH] hw/block/nvme: remove redundant invalid_lba_range trace

2021-04-14 Thread Gollu Appalanaidu
Currently pci_nvme_err_invalid_lba_range tace being called indvidually at each function, add this in nvme_check_bounds and remove redundant usage of it. Signed-off-by: Gollu Appalanaidu --- hw/block/nvme.c | 9 + 1 file changed, 1 insertion(+), 8 deletions(-) diff --git