mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
dataplane: replace internal thread with IOThread
Today virtio-blk dataplane uses a 1:1 device-per-thread model. Now that IOThreads have been introduced we can generalize this to N:M devices per threads. This patch drops thread code from dataplane in favor of running inside an IOThread AioContext. As a bonus we solve the case where a guest keeps submitting I/O requests while dataplane is trying to stop. Previously the dataplane thread would continue to process requests until the request gave it a break. Now we can shut down in bounded time thanks to aio_context_acquire/release. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
6e4a876b43
commit
48ff269272
2 changed files with 60 additions and 44 deletions
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "hw/virtio/virtio.h"
|
||||
#include "hw/block/block.h"
|
||||
#include "sysemu/iothread.h"
|
||||
|
||||
#define TYPE_VIRTIO_BLK "virtio-blk-device"
|
||||
#define VIRTIO_BLK(obj) \
|
||||
|
@ -106,6 +107,7 @@ struct virtio_scsi_inhdr
|
|||
struct VirtIOBlkConf
|
||||
{
|
||||
BlockConf conf;
|
||||
IOThread *iothread;
|
||||
char *serial;
|
||||
uint32_t scsi;
|
||||
uint32_t config_wce;
|
||||
|
@ -140,13 +142,15 @@ typedef struct VirtIOBlock {
|
|||
DEFINE_BLOCK_CHS_PROPERTIES(_state, _field.conf), \
|
||||
DEFINE_PROP_STRING("serial", _state, _field.serial), \
|
||||
DEFINE_PROP_BIT("config-wce", _state, _field.config_wce, 0, true), \
|
||||
DEFINE_PROP_BIT("scsi", _state, _field.scsi, 0, true)
|
||||
DEFINE_PROP_BIT("scsi", _state, _field.scsi, 0, true), \
|
||||
DEFINE_PROP_IOTHREAD("x-iothread", _state, _field.iothread)
|
||||
#else
|
||||
#define DEFINE_VIRTIO_BLK_PROPERTIES(_state, _field) \
|
||||
DEFINE_BLOCK_PROPERTIES(_state, _field.conf), \
|
||||
DEFINE_BLOCK_CHS_PROPERTIES(_state, _field.conf), \
|
||||
DEFINE_PROP_STRING("serial", _state, _field.serial), \
|
||||
DEFINE_PROP_BIT("config-wce", _state, _field.config_wce, 0, true)
|
||||
DEFINE_PROP_BIT("config-wce", _state, _field.config_wce, 0, true), \
|
||||
DEFINE_PROP_IOTHREAD("x-iothread", _state, _field.iothread)
|
||||
#endif /* __linux__ */
|
||||
|
||||
void virtio_blk_set_conf(DeviceState *dev, VirtIOBlkConf *blk);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue