Skip to contentSkip to conversation

qcow2: set bdi->is_dirty

PATCH Applied Vladimir Sementsov-Ogievskiy 4 participants 4 messages May 4, 2021 – May 5, 2021 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qcow2: set bdi->is_dirty

Set bdi->is_dirty, so that qemu-img info could show dirty flag.

After this commit the following check will show '"dirty-flag": true':

./build/qemu-img create -f qcow2 -o lazy_refcounts=on x 1M ./build/qemu-io x
qemu-io> write 0 1M

After "write" command success, kill the qemu-io process:

kill -9 <qemu-io pid>

./build/qemu-img info --output=json x

This will show '"dirty-flag": true' among other things. (before this commit it shows '"dirty-flag": false')

Note, that qcow2's dirty-bit is not a "dirty bit for the image". It only protects qcow2 lazy refcounts feature. So, there are a lot of conditions when qcow2 session may be not closed correctly, but bit is
0. Still, when bit is set, the last session is definitely not finished correctly and it's better to report it.

---
 block/qcow2.c | 1 +
 1 file changed, 1 insertion(+)
block/qcow2.c +1 -0
index 9727ae8fe3..39b91ef940 100644
@@ -5089,6 +5089,7 @@ static int qcow2_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
     BDRVQcow2State *s = bs->opaque;
     bdi->cluster_size = s->cluster_size;
     bdi->vm_state_offset = qcow2_vm_state_offset(s);
+    bdi->is_dirty = s->incompatible_features & QCOW2_INCOMPAT_DIRTY;
     return 0;
 }
 
Signature · 1 line
2.29.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Vladimir Sementsov-Ogievskiy

Set bdi->is_dirty, so that qemu-img info could show dirty flag.

After this commit the following check will show '"dirty-flag": true':

./build/qemu-img create -f qcow2 -o lazy_refcounts=on x 1M ./build/qemu-io x
qemu-io> write 0 1M

After "write" command success, kill the qemu-io process:

kill -9 <qemu-io pid>

./build/qemu-img info --output=json x

This will show '"dirty-flag": true' among other things. (before this commit it shows '"dirty-flag": false')

Note, that qcow2's dirty-bit is not a "dirty bit for the image". It only protects qcow2 lazy refcounts feature. So, there are a lot of conditions when qcow2 session may be not closed correctly, but bit is
0. Still, when bit is set, the last session is definitely not finished correctly and it's better to report it.

Quoted 4 lines
---
 block/qcow2.c | 1 +
 1 file changed, 1 insertion(+)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
Tested-by on v1 1/1
#2 lore raw
In reply to Vladimir Sementsov-Ogievskiy
Quoted 17 lines · Vladimir Sementsov-Ogievskiy

Set bdi->is_dirty, so that qemu-img info could show dirty flag.

After this commit the following check will show '"dirty-flag": true':

./build/qemu-img create -f qcow2 -o lazy_refcounts=on x 1M ./build/qemu-io x
qemu-io> write 0 1M

After "write" command success, kill the qemu-io process:

kill -9 <qemu-io pid>

./build/qemu-img info --output=json x

This will show '"dirty-flag": true' among other things. (before this commit it shows '"dirty-flag": false')

Quoted 7 lines

Note, that qcow2's dirty-bit is not a "dirty bit for the image". It only protects qcow2 lazy refcounts feature. So, there are a lot of conditions when qcow2 session may be not closed correctly, but bit is
0. Still, when bit is set, the last session is definitely not finished correctly and it's better to report it.

Works for me. Thanks,

Quoted 17 lines
---
 block/qcow2.c | 1 +
 1 file changed, 1 insertion(+)
block/qcow2.c +1 -0
index 9727ae8fe3..39b91ef940 100644
@@ -5089,6 +5089,7 @@ static int qcow2_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
     BDRVQcow2State *s = bs->opaque;
     bdi->cluster_size = s->cluster_size;
     bdi->vm_state_offset = qcow2_vm_state_offset(s);
+    bdi->is_dirty = s->incompatible_features & QCOW2_INCOMPAT_DIRTY;
     return 0;
 }
 
Applied
#3 lore raw
In reply to Vladimir Sementsov-Ogievskiy

Am 04.05.2021 um 18:06 hat Vladimir Sementsov-Ogievskiy geschrieben:

Quoted 17 lines

Set bdi->is_dirty, so that qemu-img info could show dirty flag.

After this commit the following check will show '"dirty-flag": true':

./build/qemu-img create -f qcow2 -o lazy_refcounts=on x 1M ./build/qemu-io x
qemu-io> write 0 1M

After "write" command success, kill the qemu-io process:

kill -9 <qemu-io pid>

./build/qemu-img info --output=json x

This will show '"dirty-flag": true' among other things. (before this commit it shows '"dirty-flag": false')

Quoted 7 lines

Note, that qcow2's dirty-bit is not a "dirty bit for the image". It only protects qcow2 lazy refcounts feature. So, there are a lot of conditions when qcow2 session may be not closed correctly, but bit is
0. Still, when bit is set, the last session is definitely not finished correctly and it's better to report it.

Thanks, applied to the block branch.

Kevin