mirror of
https://github.com/qemu/qemu.git
synced 2024-12-16 16:53:28 +08:00
4f7366506a
This patch extends virtio-blk emulation to handle zoned device commands by calling the new block layer APIs to perform zoned device I/O on behalf of the guest. It supports Report Zone, four zone oparations (open, close, finish, reset), and Append Zone. The VIRTIO_BLK_F_ZONED feature bit will only be set if the host does support zoned block devices. Regular block devices(conventional zones) will not be set. The guest os can use blktests, fio to test those commands on zoned devices. Furthermore, using zonefs to test zone append write is also supported. Signed-off-by: Sam Li <faithilikerun@gmail.com> Message-id: 20230508051916.178322-2-faithilikerun@gmail.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
42 lines
1.3 KiB
C
42 lines
1.3 KiB
C
/*
|
|
* Virtio Block Device common helpers
|
|
*
|
|
* Copyright IBM, Corp. 2007
|
|
*
|
|
* Authors:
|
|
* Anthony Liguori <aliguori@us.ibm.com>
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2. See
|
|
* the COPYING file in the top-level directory.
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
|
|
#include "standard-headers/linux/virtio_blk.h"
|
|
#include "hw/virtio/virtio.h"
|
|
#include "hw/virtio/virtio-blk-common.h"
|
|
|
|
/* Config size before the discard support (hide associated config fields) */
|
|
#define VIRTIO_BLK_CFG_SIZE offsetof(struct virtio_blk_config, \
|
|
max_discard_sectors)
|
|
|
|
/*
|
|
* Starting from the discard feature, we can use this array to properly
|
|
* set the config size depending on the features enabled.
|
|
*/
|
|
static const VirtIOFeature feature_sizes[] = {
|
|
{.flags = 1ULL << VIRTIO_BLK_F_DISCARD,
|
|
.end = endof(struct virtio_blk_config, discard_sector_alignment)},
|
|
{.flags = 1ULL << VIRTIO_BLK_F_WRITE_ZEROES,
|
|
.end = endof(struct virtio_blk_config, write_zeroes_may_unmap)},
|
|
{.flags = 1ULL << VIRTIO_BLK_F_ZONED,
|
|
.end = endof(struct virtio_blk_config, zoned)},
|
|
{}
|
|
};
|
|
|
|
const VirtIOConfigSizeParams virtio_blk_cfg_size_params = {
|
|
.min_size = VIRTIO_BLK_CFG_SIZE,
|
|
.max_size = sizeof(struct virtio_blk_config),
|
|
.feature_sizes = feature_sizes
|
|
};
|