2 * Virtio Block Device common helpers
4 * Copyright IBM, Corp. 2007
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
13 #include "qemu/osdep.h"
15 #include "standard-headers/linux/virtio_blk.h"
16 #include "hw/virtio/virtio.h"
17 #include "hw/virtio/virtio-blk-common.h"
19 /* Config size before the discard support (hide associated config fields) */
20 #define VIRTIO_BLK_CFG_SIZE offsetof(struct virtio_blk_config, \
24 * Starting from the discard feature, we can use this array to properly
25 * set the config size depending on the features enabled.
27 static const VirtIOFeature feature_sizes
[] = {
28 {.flags
= 1ULL << VIRTIO_BLK_F_DISCARD
,
29 .end
= endof(struct virtio_blk_config
, discard_sector_alignment
)},
30 {.flags
= 1ULL << VIRTIO_BLK_F_WRITE_ZEROES
,
31 .end
= endof(struct virtio_blk_config
, write_zeroes_may_unmap
)},
35 const VirtIOConfigSizeParams virtio_blk_cfg_size_params
= {
36 .min_size
= VIRTIO_BLK_CFG_SIZE
,
37 .max_size
= sizeof(struct virtio_blk_config
),
38 .feature_sizes
= feature_sizes