From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, "Hanna Reitz" <hreitz@redhat.com>,
"Vladimir Sementsov-Ogievskiy" <vsementsov@yandex-team.ru>,
"Kevin Wolf" <kwolf@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Eric Blake" <eblake@redhat.com>, "John Snow" <jsnow@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH 2/2] block/qcow2: QAPI'fy Qcow2DiscardType
Date: Fri, 24 Feb 2023 16:20:19 +0100 [thread overview]
Message-ID: <20230224152019.19278-3-philmd@linaro.org> (raw)
In-Reply-To: <20230224152019.19278-1-philmd@linaro.org>
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é <philmd@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
next prev parent reply other threads:[~2023-02-24 15:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-24 15:20 [PATCH 0/2] block/qcow2: QAPI'fy Qcow2DiscardType Philippe Mathieu-Daudé
2023-02-24 15:20 ` [PATCH 1/2] block/qcow2: Rename QCOW2_DISCARD_TYPE enum definitions Philippe Mathieu-Daudé
2023-02-24 15:20 ` Philippe Mathieu-Daudé [this message]
2023-02-24 21:26 ` [PATCH 0/2] block/qcow2: QAPI'fy Qcow2DiscardType Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230224152019.19278-3-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@yandex-team.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).