Let QAPI maintain the Qcow2DiscardType enum values. Mechanical renaming to Qcow2DiscardType doing:
$ sed -i -e 's/enum qcow2_discard_type/Qcow2DiscardType/g' \ $(git grep -l qcow2_discard_type) Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org> --- block/qcow2-cluster.c | 4 ++-- block/qcow2-refcount.c | 10 +++++----- block/qcow2.h | 17 ++++------------- qapi/block-core.json | 10 ++++++++++ 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index a525afc7c3..8e25eec98a 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1898,7 +1898,7 @@ again: */ static int discard_in_l2_slice(BlockDriverState *bs, uint64_t offset, uint64_t nb_clusters, - enum qcow2_discard_type type, bool full_discard) + Qcow2DiscardType type, bool full_discard) { BDRVQcow2State *s = bs->opaque; uint64_t *l2_slice; @@ -1967,7 +1967,7 @@ static int discard_in_l2_slice(BlockDriverState *bs, uint64_t offset, } int qcow2_cluster_discard(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, enum qcow2_discard_type type, + uint64_t bytes, Qcow2DiscardType type, bool full_discard) { BDRVQcow2State *s = bs->opaque; diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 94f7bf9a57..cb72c7e213 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -38,7 +38,7 @@ static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t size, G_GNUC_WARN_UNUSED_RESULT static int update_refcount(BlockDriverState *bs, int64_t offset, int64_t length, uint64_t addend, - bool decrease, enum qcow2_discard_type type); + bool decrease, Qcow2DiscardType type); static uint64_t get_refcount_ro0(const void *refcount_array, uint64_t index); static uint64_t get_refcount_ro1(const void *refcount_array, uint64_t index); @@ -811,7 +811,7 @@ static int update_refcount(BlockDriverState *bs, int64_t length, uint64_t addend, bool decrease, - enum qcow2_discard_type type) + Qcow2DiscardType type) { BDRVQcow2State *s = bs->opaque; int64_t start, last, cluster_offset; @@ -945,7 +945,7 @@ fail: int qcow2_update_cluster_refcount(BlockDriverState *bs, int64_t cluster_index, uint64_t addend, bool decrease, - enum qcow2_discard_type type) + Qcow2DiscardType type) { BDRVQcow2State *s = bs->opaque; int ret; @@ -1145,7 +1145,7 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size) void qcow2_free_clusters(BlockDriverState *bs, int64_t offset, int64_t size, - enum qcow2_discard_type type) + Qcow2DiscardType type) { int ret; @@ -1162,7 +1162,7 @@ void qcow2_free_clusters(BlockDriverState *bs, * normal cluster, compressed cluster, etc.) */ void qcow2_free_any_cluster(BlockDriverState *bs, uint64_t l2_entry, - enum qcow2_discard_type type) + Qcow2DiscardType type) { BDRVQcow2State *s = bs->opaque; QCow2ClusterType ctype = qcow2_get_cluster_type(bs, l2_entry); diff --git a/block/qcow2.h b/block/qcow2.h index d6ce7fce32..280485ed12 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -287,15 +287,6 @@ enum { | QCOW2_AUTOCLEAR_DATA_FILE_RAW, }; -enum qcow2_discard_type { - QCOW2_DISCARD_TYPE_NEVER = 0, - QCOW2_DISCARD_TYPE_ALWAYS, - QCOW2_DISCARD_TYPE_REQUEST, - QCOW2_DISCARD_TYPE_SNAPSHOT, - QCOW2_DISCARD_TYPE_OTHER, - QCOW2_DISCARD_TYPE__MAX -}; - typedef struct Qcow2Feature { uint8_t type; uint8_t bit; @@ -854,7 +845,7 @@ int qcow2_get_refcount(BlockDriverState *bs, int64_t cluster_index, int qcow2_update_cluster_refcount(BlockDriverState *bs, int64_t cluster_index, uint64_t addend, bool decrease, - enum qcow2_discard_type type); + Qcow2DiscardType type); int64_t qcow2_refcount_area(BlockDriverState *bs, uint64_t offset, uint64_t additional_clusters, bool exact_size, @@ -867,9 +858,9 @@ int64_t qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size); void qcow2_free_clusters(BlockDriverState *bs, int64_t offset, int64_t size, - enum qcow2_discard_type type); + Qcow2DiscardType type); void qcow2_free_any_cluster(BlockDriverState *bs, uint64_t l2_entry, - enum qcow2_discard_type type); + Qcow2DiscardType type); int qcow2_update_snapshot_refcount(BlockDriverState *bs, int64_t l1_table_offset, int l1_size, int addend); @@ -922,7 +913,7 @@ int coroutine_fn qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m); void qcow2_alloc_cluster_abort(BlockDriverState *bs, QCowL2Meta *m); int qcow2_cluster_discard(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, enum qcow2_discard_type type, + uint64_t bytes, Qcow2DiscardType type, bool full_discard); int coroutine_fn qcow2_subcluster_zeroize(BlockDriverState *bs, uint64_t offset, uint64_t bytes, int flags); diff --git a/qapi/block-core.json b/qapi/block-core.json index 7f331eb8ea..8d80e989b5 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4811,6 +4811,16 @@ { 'enum': 'Qcow2CompressionType', 'data': [ 'zlib', { 'name': 'zstd', 'if': 'CONFIG_ZSTD' } ] } +## +# @Qcow2DiscardType: +# +# Determines type of discard request +# +# Since: 8.0 +## +{ 'enum': 'Qcow2DiscardType', + 'data': [ 'never', 'always', 'request', 'snapshot', 'other' ] } + ## # @BlockdevCreateOptionsQcow2: # -- 2.38.1