Re: [PATCH] qapi: merge common parts of NbdServerOptions and nbd-server-start data

2025-02-13 Thread Markus Armbruster
Eric Blake writes: > On Wed, Feb 12, 2025 at 05:33:51PM +0300, Vladimir Sementsov-Ogievskiy wrote: >> Instead of comment >> "Keep this type consistent with the nbd-server-start arguments", we >> can simply merge these things. >> >> Signed-off-by: Vladimir Sementsov-Ogievskiy >> --- >> >> No pr

Re: [PATCH] qapi: merge common parts of NbdServerOptions and nbd-server-start data

2025-02-13 Thread Vladimir Sementsov-Ogievskiy
On 13.02.25 11:26, Markus Armbruster wrote: Eric Blake writes: On Wed, Feb 12, 2025 at 05:33:51PM +0300, Vladimir Sementsov-Ogievskiy wrote: Instead of comment "Keep this type consistent with the nbd-server-start arguments", we can simply merge these things. Signed-off-by: Vladimir Sementsov

[PATCH 2/2] rust: add module to convert between -errno and io::Error

2025-02-13 Thread Paolo Bonzini
It is a common convention in QEMU to return a positive value in case of success, and a negated errno value in case of error. Unfortunately, using errno portably in Rust is a bit complicated; on Unix the errno values are supported natively by io::Error, but on Windows they are not; so, use the libc

[PATCH v2 0/2] rust: add module to convert between -errno and io::Error

2025-02-13 Thread Paolo Bonzini
Wrap access to errno, for use in the block layer and character device bindings. Supersedes: <20250212093958.3703269-1-pbonz...@redhat.com> v1->v2: - use the libc crate - provide separate From implementation for io::ErrorKind - hide GetErrno trait inside a submodule - add into_neg_errno() and corr

[PATCH 1/2] rust: subprojects: add libc crate

2025-02-13 Thread Paolo Bonzini
This allows access to errno values. Signed-off-by: Paolo Bonzini --- rust/Cargo.lock | 7 rust/qemu-api/Cargo.toml | 1 + scripts/archive-source.sh | 2 +- scripts/make-release | 2 +- subpro

Re: [PATCH 03/11] rust: Add some block layer bindings

2025-02-13 Thread Paolo Bonzini
On Wed, Feb 12, 2025 at 8:52 PM Kevin Wolf wrote: > I assume that sooner or later we'll have a reason to include it anyway, > so that might honestly be the best option. Sounds good. > Do you want to post it as a proper patch? It seems to depend on your > errno patch, but that shouldn't be a prob

[PATCH 05/12] virtio-scsi: introduce event and ctrl virtqueue locks

2025-02-13 Thread Stefan Hajnoczi
Virtqueues are not thread-safe. Until now this was not a major issue since all virtqueue processing happened in the same thread. The ctrl queue's Task Management Function (TMF) requests sometimes need the main loop, so a BH was used to schedule the virtqueue completion back in the thread that has v

[PATCH 12/12] virtio-scsi: handle ctrl virtqueue in main loop

2025-02-13 Thread Stefan Hajnoczi
Previously the ctrl virtqueue was handled in the AioContext where SCSI requests are processed. When IOThread Virtqueue Mapping was added things become more complicated because SCSI requests could run in other AioContexts. Simplify by handling the ctrl virtqueue in the main loop where reset operati

[PATCH 08/12] virtio-blk: extract cleanup_iothread_vq_mapping() function

2025-02-13 Thread Stefan Hajnoczi
This is the cleanup function that must be called after apply_iothread_vq_mapping() succeeds. virtio-scsi will need this function too, so extract it. Signed-off-by: Stefan Hajnoczi --- hw/block/virtio-blk.c | 27 +-- 1 file changed, 21 insertions(+), 6 deletions(-) diff -

[PATCH 02/12] dma: use current AioContext for dma_blk_io()

2025-02-13 Thread Stefan Hajnoczi
In the past a single AioContext was used for block I/O and it was fetched using blk_get_aio_context(). Nowadays the block layer supports running I/O from any AioContext and multiple AioContexts at the same time. Remove the dma_blk_io() AioContext argument and use the current AioContext instead. Th

[PATCH 10/12] virtio: extract iothread-vq-mapping.h API

2025-02-13 Thread Stefan Hajnoczi
The code that builds an array of AioContext pointers indexed by the virtqueue is not specific to virtio-blk. virtio-scsi will need to do the same thing, so extract the functions. Signed-off-by: Stefan Hajnoczi --- include/hw/virtio/iothread-vq-mapping.h | 45 hw/block/virtio-blk.c

[PATCH 07/12] virtio-scsi: perform TMFs in appropriate AioContexts

2025-02-13 Thread Stefan Hajnoczi
With IOThread Virtqueue Mapping there will be multiple AioContexts processing SCSI requests. scsi_req_cancel() and other SCSI request operations must be performed from the AioContext where the request is running. Introduce a virtio_scsi_defer_tmf_to_aio_context() function and the necessary VirtIOS

[PATCH 01/12] scsi-disk: drop unused SCSIDiskState->bh field

2025-02-13 Thread Stefan Hajnoczi
Commit 71544d30a6f8 ("scsi: push request restart to SCSIDevice") removed the only user of SCSIDiskState->bh. Signed-off-by: Stefan Hajnoczi --- hw/scsi/scsi-disk.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index e7f738b484..caf6c1437f 100644 ---

[PATCH 09/12] virtio-blk: tidy up iothread_vq_mapping functions

2025-02-13 Thread Stefan Hajnoczi
Use noun_verb() function naming instead of verb_noun() because the former is the most common naming style for APIs. The next commit will move these functions into a header file so that virtio-scsi can call them. Shorten iothread_vq_mapping_apply()'s iothread_vq_mapping_list argument to just "list"

[PATCH 11/12] virtio-scsi: add iothread-vq-mapping parameter

2025-02-13 Thread Stefan Hajnoczi
Allow virtio-scsi virtqueues to be assigned to different IOThreads. This makes it possible to take advantage of host multi-queue block layer scalability by assigning virtqueues that have affinity with vCPUs to different IOThreads that have affinity with host CPUs. The same feature was introduced fo

[PATCH 03/12] scsi: track per-SCSIRequest AioContext

2025-02-13 Thread Stefan Hajnoczi
Until now, a SCSIDevice's I/O requests have run in a single AioContext. In order to support multiple IOThreads it will be necessary to move to the concept of a per-SCSIRequest AioContext. Signed-off-by: Stefan Hajnoczi --- include/hw/scsi/scsi.h | 1 + hw/scsi/scsi-bus.c | 1 + hw/scsi/scs

[PATCH 00/12] virtio-scsi: add iothread-vq-mapping parameter

2025-02-13 Thread Stefan Hajnoczi
Implement --device virtio-scsi-pci,iothread-vq-mapping= support so that virtqueues can be assigned to different IOThreads. This improves SMP guest scalability where I/O-intensive applications can become bottlenecked on a single IOThread. The following benchmark results show the effect of iothread-

[PATCH 04/12] scsi: introduce requests_lock

2025-02-13 Thread Stefan Hajnoczi
SCSIDevice keeps track of in-flight requests for device reset and Task Management Functions (TMFs). The request list requires protection so that multi-threaded SCSI emulation can be implemented in commits that follow. Signed-off-by: Stefan Hajnoczi --- include/hw/scsi/scsi.h | 7 ++- hw/scsi/s

[PATCH 06/12] virtio-scsi: protect events_dropped field

2025-02-13 Thread Stefan Hajnoczi
The block layer can invoke the resize callback from any AioContext that is processing requests. The virtqueue is already protected but the events_dropped field also needs to be protected against races. Cover it using the event virtqueue lock because it is closely associated with accesses to the vir