Merge tag 'pull-loongarch-20241016' of https://gitlab.com/gaosong/qemu into staging
[qemu/armbru.git] / hw / block / virtio-blk-common.c
blobe2f8e2f6da80190719422b9fcfba56da307bba31
1 /*
2 * Virtio Block Device common helpers
4 * Copyright IBM, Corp. 2007
6 * Authors:
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, \
21 max_discard_sectors)
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)},
32 {.flags = 1ULL << VIRTIO_BLK_F_ZONED,
33 .end = endof(struct virtio_blk_config, zoned)},
37 const VirtIOConfigSizeParams virtio_blk_cfg_size_params = {
38 .min_size = VIRTIO_BLK_CFG_SIZE,
39 .max_size = sizeof(struct virtio_blk_config),
40 .feature_sizes = feature_sizes