Re: [RFC v4 11/11] virtio-blk: use BDRV_REQ_REGISTERED_BUF optimization hint

2022-08-25 Thread David Hildenbrand
On 23.08.22 21:22, Stefan Hajnoczi wrote: > On Tue, Aug 23, 2022 at 10:01:59AM +0200, David Hildenbrand wrote: >> On 23.08.22 00:24, Stefan Hajnoczi wrote: >>> Register guest RAM using BlockRAMRegistrar and set the >>> BDRV_REQ_REGISTERED_BUF flag so block drivers can optimize memory >>> accesses i

[PATCH v2 2/3] hw/nvme: use KVM irqfd when available

2022-08-25 Thread Jinhao Fan
Use KVM's irqfd to send interrupts when possible. This approach is thread safe. Moreover, it does not have the inter-thread communication overhead of plain event notifiers since handler callback are called in the same system call as irqfd write. Signed-off-by: Jinhao Fan --- hw/nvme/ctrl.c | 50

[PATCH v2 1/3] hw/nvme: support irq(de)assertion with eventfd

2022-08-25 Thread Jinhao Fan
When the new option 'irq-eventfd' is turned on, the IO emulation code signals an eventfd when it want to (de)assert an irq. The main loop eventfd handler does the actual irq (de)assertion. This paves the way for iothread support since QEMU's interrupt emulation is not thread safe. Asserting and d

[PATCH v2 3/3] hw/nvme: add MSI-x mask handlers for irqfd

2022-08-25 Thread Jinhao Fan
When irqfd is enabled, we bypass QEMU's irq emulation and let KVM to directly assert the irq. However, KVM is not aware of the device's MSI-x masking status. Add MSI-x mask bookkeeping in NVMe emulation and detach the corresponding irqfd when the certain vector is masked. Signed-off-by: Jinhao Fan

Re: [PATCH 07/51] tests: Avoid using hardcoded /tmp in test cases

2022-08-25 Thread Thomas Huth
On 24/08/2022 11.39, Bin Meng wrote: From: Bin Meng Use g_get_tmp_dir() to get the directory to use for temporary files. Signed-off-by: Bin Meng --- tests/qtest/fuzz/generic_fuzz_configs.h | 6 -- tests/qtest/ahci-test.c | 15 +++ tests/qtest/aspeed_smc-t

Re: [PATCH v2 1/3] hw/nvme: support irq(de)assertion with eventfd

2022-08-25 Thread Klaus Jensen
On Aug 25 15:47, Jinhao Fan wrote: > When the new option 'irq-eventfd' is turned on, the IO emulation code > signals an eventfd when it want to (de)assert an irq. The main loop > eventfd handler does the actual irq (de)assertion. This paves the way > for iothread support since QEMU's interrupt emu

Re: [PATCH v2 1/3] hw/nvme: support irq(de)assertion with eventfd

2022-08-25 Thread Jinhao Fan
On 8/25/2022 5:33 PM, Klaus Jensen wrote: I'm still a bit perplexed by this issue, so I just tried moving nvme_init_irq_notifier() to the end of nvme_init_cq() and removing this first_io_cqe thing. I did not observe any particular issues? What bad behavior did you encounter, it seems to work fin

Re: [PATCH v2 1/3] hw/nvme: support irq(de)assertion with eventfd

2022-08-25 Thread Klaus Jensen
On Aug 25 19:16, Jinhao Fan wrote: > On 8/25/2022 5:33 PM, Klaus Jensen wrote: > > I'm still a bit perplexed by this issue, so I just tried moving > > nvme_init_irq_notifier() to the end of nvme_init_cq() and removing this > > first_io_cqe thing. I did not observe any particular issues? > > > > Wh

Re: [PATCH 30/51] tests: Skip iotests and qtest when '--without-default-devices'

2022-08-25 Thread Thomas Huth
On 24/08/2022 11.40, Bin Meng wrote: From: Bin Meng When QEMU is configured with '--without-default-devices', we should not build and run iotests and qtest because devices used by these test cases are not built in. Signed-off-by: Bin Meng --- tests/qemu-iotests/meson.build | 5 + test

Re: [PATCH 32/51] tests/qtest: Fix ERROR_SHARING_VIOLATION for win32

2022-08-25 Thread Thomas Huth
On 24/08/2022 11.40, Bin Meng wrote: From: Bin Meng On Windows, the MinGW provided mkstemp() API opens the file with exclusive access, denying other processes to read/write the file. Such behavior prevents the QEMU executable from opening the file, (e.g.: CreateFile returns ERROR_SHARING_VIOLAT

Re: [PATCH 38/51] tests/qtest: {ahci,ide}-test: Open file in binary mode

2022-08-25 Thread Thomas Huth
On 24/08/2022 11.40, Bin Meng wrote: From: Xuzhou Cheng By default Windows opens file in text mode, while a POSIX compliant implementation treats text files and binary files the same. The fopen() 'mode' string can include the letter 'b' to indicate binary mode shall be used. POSIX spec says th

Re: [PATCH v2 1/3] hw/nvme: support irq(de)assertion with eventfd

2022-08-25 Thread Klaus Jensen
On Aug 25 13:56, Klaus Jensen wrote: > On Aug 25 19:16, Jinhao Fan wrote: > > On 8/25/2022 5:33 PM, Klaus Jensen wrote: > > > I'm still a bit perplexed by this issue, so I just tried moving > > > nvme_init_irq_notifier() to the end of nvme_init_cq() and removing this > > > first_io_cqe thing. I did

Re: [PATCH v2 1/3] hw/nvme: support irq(de)assertion with eventfd

2022-08-25 Thread Jinhao Fan
> 在 2022年8月25日,20:39,Klaus Jensen 写道: > > On Aug 25 13:56, Klaus Jensen wrote: >>> On Aug 25 19:16, Jinhao Fan wrote: >>> On 8/25/2022 5:33 PM, Klaus Jensen wrote: I'm still a bit perplexed by this issue, so I just tried moving nvme_init_irq_notifier() to the end of nvme_init_cq() a

Re: [PATCH v1 3/5] vhost-user-blk: make it possible to disable write-zeroes/discard

2022-08-25 Thread Stefan Hajnoczi
On Wed, Aug 24, 2022 at 11:24:55PM +0300, Daniil Tatianin wrote: > On 8/24/22 9:00 PM, Stefan Hajnoczi wrote: > > On Wed, Aug 24, 2022 at 12:18:35PM +0300, Daniil Tatianin wrote: > > > diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c > > > index 9117222456..e89164c358 100644 > > >

Re: [PATCH v1 2/5] virtio-blk: move config space sizing code to virtio-blk-common

2022-08-25 Thread Stefan Hajnoczi
On Thu, Aug 25, 2022 at 12:11:10AM +0300, Daniil Tatianin wrote: > > > On 8/24/22 9:13 PM, Stefan Hajnoczi wrote: > > On Wed, Aug 24, 2022 at 12:18:34PM +0300, Daniil Tatianin wrote: > > > +size_t virtio_blk_common_get_config_size(uint64_t host_features) > > > +{ > > > +size_t config_size = M

Re: [PATCH v2 1/3] hw/nvme: support irq(de)assertion with eventfd

2022-08-25 Thread Klaus Jensen
On Aug 25 21:09, Jinhao Fan wrote: > > > > > 在 2022年8月25日,20:39,Klaus Jensen 写道: > > > > On Aug 25 13:56, Klaus Jensen wrote: > >>> On Aug 25 19:16, Jinhao Fan wrote: > >>> On 8/25/2022 5:33 PM, Klaus Jensen wrote: > I'm still a bit perplexed by this issue, so I just tried moving >

Re: [PATCH v2 1/3] hw/nvme: support irq(de)assertion with eventfd

2022-08-25 Thread Jinhao Fan
On 8/25/2022 7:56 PM, Klaus Jensen wrote: On Aug 25 19:16, Jinhao Fan wrote: On 8/25/2022 5:33 PM, Klaus Jensen wrote: I'm still a bit perplexed by this issue, so I just tried moving nvme_init_irq_notifier() to the end of nvme_init_cq() and removing this first_io_cqe thing. I did not observe an

Re: [PATCH v2 1/3] hw/nvme: support irq(de)assertion with eventfd

2022-08-25 Thread Jinhao Fan
On 8/25/2022 9:59 PM, Klaus Jensen wrote: On Aug 25 21:09, Jinhao Fan wrote: 在 2022年8月25日,20:39,Klaus Jensen 写道: On Aug 25 13:56, Klaus Jensen wrote: On Aug 25 19:16, Jinhao Fan wrote: On 8/25/2022 5:33 PM, Klaus Jensen wrote: I'm still a bit perplexed by this issue, so I just tried mov

[PATCH v6 07/10] parallels: Move check of cluster outside image to a separate function

2022-08-25 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov --- block/parallels.c | 59 ++- 1 file changed, 43 insertions(+)

[PATCH v6 05/10] parallels: Use generic infrastructure for BAT writing in parallels_co_check()

2022-08-25 Thread Alexander Ivanov
BAT is written in the context of conventional operations over the image inside bdrv_co_flush() when it calls parallels_co_flush_to_os() callback. Thus we should not modify BAT array directly, but call parallels_set_bat_entry() helper and bdrv_co_flush() further on. After that there is no need to ma

[PATCH v6 03/10] parallels: Fix data_end after out-of-image check

2022-08-25 Thread Alexander Ivanov
Set data_end to the end of the last cluster inside the image. In such a way we can be shure that corrupted offsets in the BAT can't affect on the image size. Signed-off-by: Alexander Ivanov --- block/parallels.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/parallels.c b/block/para

[PATCH v6 04/10] parallels: create parallels_set_bat_entry_helper() to assign BAT value

2022-08-25 Thread Alexander Ivanov
This helper will be reused in next patches during parallels_co_check rework to simplify its code. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff

Re: EBUSY when using NVMe Block Driver with multiple devices in the same IOMMU group

2022-08-25 Thread Chaitanya Kulkarni
> First, multiple QEMU instances cannot access nvme:// devices sharing the > same IOMMU group. I don't think this will ever be possible because it > opens a backdoor around process memory isolation. > > However, a single QEMU (or qemu-storage-daemon) instance should be able > to access multiple n

[PATCH v6 00/10] parallels: Refactor the code of images checks and fix a bug

2022-08-25 Thread Alexander Ivanov
Fix image inflation when offset in BAT is out of image. Replace whole BAT syncing by flushing only dirty blocks. Move all the checks outside the main check function in separate functions Use WITH_QEMU_LOCK_GUARD for simplier code. v6: 1: Move the error check inside the loop. Move file size get

[PATCH v6 08/10] parallels: Move check of leaks to a separate function

2022-08-25 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov --- block/parallels.c | 84 +-- 1 file changed, 52 insertions(+)

[PATCH v6 06/10] parallels: Move check of unclean image to a separate function

2022-08-25 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 31 +

[PATCH v6 01/10] parallels: Out of image offset in BAT leads to image inflation

2022-08-25 Thread Alexander Ivanov
data_end field in BDRVParallelsState is set to the biggest offset present in BAT. If this offset is outside of the image, any further write will create the cluster at this offset and/or the image will be truncated to this offset on close. This is definitely not correct. Raise an error in parallels_

[PATCH v6 09/10] parallels: Move statistic collection to a separate function

2022-08-25 Thread Alexander Ivanov
We will add more and more checks so we need a better code structure in parallels_co_check. Let each check performs in a separate loop in a separate helper. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 53 +

[PATCH v6 02/10] parallels: Fix high_off calculation in parallels_co_check()

2022-08-25 Thread Alexander Ivanov
Don't let high_off be more than the file size even if we don't fix the image. Signed-off-by: Alexander Ivanov --- block/parallels.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 93bc2750ef..7e8cdbbc3a 100644 --- a/block/parall

[PATCH v6 10/10] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD

2022-08-25 Thread Alexander Ivanov
Replace the way we use mutex in parallels_co_check() for simplier and less error prone code. Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev --- block/parallels.c | 33 ++--- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/block/parallels.

[PATCH v3 0/2] hw/nvme: add irqfd support

2022-08-25 Thread Klaus Jensen
From: Klaus Jensen This is a re-spin of Jinhao's irqfd support series that fixes msix vector masking/unmasking to work correctly. I kept being bugged out about that msi route not getting updated, so I hit the code into submission with a hammer. I finally noticed the core issue: 1. The vector

[PATCH v3 2/2] hw/nvme: use KVM irqfd when available

2022-08-25 Thread Klaus Jensen
From: Jinhao Fan Use KVM's irqfd to send interrupts when possible. This approach is thread safe. Moreover, it does not have the inter-thread communication overhead of plain event notifiers since handler callback are called in the same system call as irqfd write. Signed-off-by: Jinhao Fan Signed

[PATCH v3 1/2] hw/nvme: support irq(de)assertion with eventfd

2022-08-25 Thread Klaus Jensen
From: Jinhao Fan When the new option 'irq-eventfd' is turned on, the IO emulation code signals an eventfd when it want to (de)assert an irq. The main loop eventfd handler does the actual irq (de)assertion. This paves the way for iothread support since QEMU's interrupt emulation is not thread saf

Re: [PATCH v3 0/2] hw/nvme: add irqfd support

2022-08-25 Thread Jinhao Fan
at 4:14 AM, Klaus Jensen wrote: > From: Klaus Jensen > > This is a re-spin of Jinhao's irqfd support series that fixes msix > vector masking/unmasking to work correctly. > > I kept being bugged out about that msi route not getting updated, so I > hit the code into submission with a hammer. >

Re: [PATCH v3 0/2] hw/nvme: add irqfd support

2022-08-25 Thread Klaus Jensen
On Aug 26 10:03, Jinhao Fan wrote: > at 4:14 AM, Klaus Jensen wrote: > > > From: Klaus Jensen > > > > This is a re-spin of Jinhao's irqfd support series that fixes msix > > vector masking/unmasking to work correctly. > > > > I kept being bugged out about that msi route not getting updated, so