[Devel] [PATCH RH9] dm-qcow2: Extend status line

Kirill Tkhai ktkhai at virtuozzo.com
Mon Nov 15 12:09:32 MSK 2021


Add QCOW2 version and cluster size for top image.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-qcow2-target.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index c41f623fb7d7..b6915edd6a3c 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -837,16 +837,23 @@ static void qcow2_status(struct dm_target *ti, status_type_t type,
 			 unsigned int maxlen)
 {
 	struct qcow2_target *tgt = to_qcow2_target(ti);
+	struct QCowHeader *hdr;
 	unsigned int sz = 0;
+	struct qcow2 *qcow2;
+	u8 ref_index;
 
+	qcow2 = qcow2_ref_inc(tgt, &ref_index);
+	hdr = &qcow2->hdr;
 	switch (type) {
 	case STATUSTYPE_INFO:
 		result[0] = '\0';
 		break;
 	case STATUSTYPE_TABLE:
-		DMEMIT("%u", tgt->nr_images);
+		DMEMIT("%u v%u %llu", tgt->nr_images, hdr->version,
+				      to_sector(qcow2->clu_size));
 		break;
 	}
+	qcow2_ref_dec(tgt, ref_index);
 }
 
 static void qcow2_presuspend(struct dm_target *ti)




More information about the Devel mailing list