Skip to contentSkip to conversation

spec/qcow2: bitmaps: zero bitmap table offset

PATCH NAK Vladimir Sementsov-Ogievskiy 4 participants 6 messages Jun 30, 2016 – Jul 1, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 spec/qcow2: bitmaps: zero bitmap table offset

After loading bitmap from image and setting IN_USE flag in it's header, corresponding data (bitmap table and data clusters) becomes inconsistent and is no longer needed. It is better to free bitmap table and corresponding clusters from the image immediately after loading the bitmap than free them when the bitmap is saved, or deleted or set non-persistent.

For now it is impossible to store only bitmap header without bitmap table, as specification requires it. Storing zeroed bitmap table (one or more clusters) is the only option to implement the behaviour similar to specified above.

The same problem is for just storing empty bitmaps.

This patch allows storing only bitmap header for empty bitmaps.

---

Additional note. Should we also allow here bitmap_table_offset = 1, like in bitmap table, for the bitmap with all bits set? I am not sure that it is needed at all, but just to keep the company..

 docs/specs/qcow2.txt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
docs/specs/qcow2.txt +4 -1
index 80cdfd0..9826222 100644
@@ -435,9 +435,12 @@ Structure of a bitmap directory entry:
                     Offset into the image file at which the bitmap table
                     (described below) for the bitmap starts. Must be aligned to
                     a cluster boundary.
+                    Zero value means that bitmap table is not allocated and the
+                    bitmap should be considered as empty (all bits are zero).
 
          8 - 11:    bitmap_table_size
-                    Number of entries in the bitmap table of the bitmap.
+                    Number of entries in the bitmap table of the bitmap. It
+                    must be zero if bitmap_table_offset is zero.
 
         12 - 15:    flags
                     Bit
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 34 lines · Vladimir Sementsov-Ogievskiy

After loading bitmap from image and setting IN_USE flag in it's header, corresponding data (bitmap table and data clusters) becomes inconsistent and is no longer needed. It is better to free bitmap table and corresponding clusters from the image immediately after loading the bitmap than free them when the bitmap is saved, or deleted or set non-persistent.

For now it is impossible to store only bitmap header without bitmap table, as specification requires it. Storing zeroed bitmap table (one or more clusters) is the only option to implement the behaviour similar to specified above.

The same problem is for just storing empty bitmaps.

This patch allows storing only bitmap header for empty bitmaps.

---

Additional note. Should we also allow here bitmap_table_offset = 1, like in bitmap table, for the bitmap with all bits set? I am not sure that it is needed at all, but just to keep the company..

  docs/specs/qcow2.txt | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
docs/specs/qcow2.txt +0 -0
index 80cdfd0..9826222 100644
@@ -435,9 +435,12 @@ Structure of a bitmap directory entry:
                      Offset into the image file at which the bitmap table
                      (described below) for the bitmap starts. Must be aligned to
                      a cluster boundary.

docs/specs/qcow2.txt Structure of a bitmap directory entry: · line 446

Quoted 10 lines
docs/specs/qcow2.txt +4 -1
+                    Zero value means that bitmap table is not allocated and the
+                    bitmap should be considered as empty (all bits are zero).
 
           8 - 11:    bitmap_table_size
-                    Number of entries in the bitmap table of the bitmap.
+                    Number of entries in the bitmap table of the bitmap. It
+                    must be zero if bitmap_table_offset is zero.
 
          12 - 15:    flags
                      Bit

NACK

no guys, we can not make this change at the moment. We do have QEMU available in the field which is working with the currently specified format.

Den

#2 lore raw
Quoted 50 lines · Denis V. Lunev
Quoted 45 lines · Vladimir Sementsov-Ogievskiy

After loading bitmap from image and setting IN_USE flag in it's header, corresponding data (bitmap table and data clusters) becomes inconsistent and is no longer needed. It is better to free bitmap table and corresponding clusters from the image immediately after loading the bitmap than free them when the bitmap is saved, or deleted or set non-persistent.

For now it is impossible to store only bitmap header without bitmap table, as specification requires it. Storing zeroed bitmap table (one or more clusters) is the only option to implement the behaviour similar to specified above.

The same problem is for just storing empty bitmaps.

This patch allows storing only bitmap header for empty bitmaps.

---

Additional note. Should we also allow here bitmap_table_offset = 1, like in bitmap table, for the bitmap with all bits set? I am not sure that it is needed at all, but just to keep the company..

  docs/specs/qcow2.txt | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
docs/specs/qcow2.txt +0 -0
index 80cdfd0..9826222 100644
@@ -435,9 +435,12 @@ Structure of a bitmap directory entry:
                      Offset into the image file at which the bitmap

table
(described below) for the bitmap starts. Must be
aligned to
a cluster boundary.
+ Zero value means that bitmap table is not
allocated and the
+ bitmap should be considered as empty (all bits
are zero).
8 - 11: bitmap_table_size

docs/specs/qcow2.txt +1 -1
-                    Number of entries in the bitmap table of the bitmap.
+                    Number of entries in the bitmap table of the

bitmap. It
+ must be zero if bitmap_table_offset is zero.

Quoted 2 lines
            12 - 15:    flags
                      Bit

NACK

Quoted 6 lines

no guys, we can not make this change at the moment. We do have QEMU available in the field which is working with the currently specified format.

Den

But I think the new format is a /compatible/ change. Under the old spec, I think this field is *NEVER* zero.

Am I wrong?

#3 lore raw
Quoted 56 lines · John Snow
Quoted 54 lines · Denis V. Lunev
Quoted 45 lines · Vladimir Sementsov-Ogievskiy

After loading bitmap from image and setting IN_USE flag in it's header, corresponding data (bitmap table and data clusters) becomes inconsistent and is no longer needed. It is better to free bitmap table and corresponding clusters from the image immediately after loading the bitmap than free them when the bitmap is saved, or deleted or set non-persistent.

For now it is impossible to store only bitmap header without bitmap table, as specification requires it. Storing zeroed bitmap table (one or more clusters) is the only option to implement the behaviour similar to specified above.

The same problem is for just storing empty bitmaps.

This patch allows storing only bitmap header for empty bitmaps.

---

Additional note. Should we also allow here bitmap_table_offset = 1, like in bitmap table, for the bitmap with all bits set? I am not sure that it is needed at all, but just to keep the company..

   docs/specs/qcow2.txt | 5 ++++-
   1 file changed, 4 insertions(+), 1 deletion(-)
docs/specs/qcow2.txt +0 -0
index 80cdfd0..9826222 100644
@@ -435,9 +435,12 @@ Structure of a bitmap directory entry:
                       Offset into the image file at which the bitmap

table
(described below) for the bitmap starts. Must be
aligned to
a cluster boundary.
+ Zero value means that bitmap table is not
allocated and the
+ bitmap should be considered as empty (all bits
are zero).
8 - 11: bitmap_table_size

docs/specs/qcow2.txt +1 -1
-                    Number of entries in the bitmap table of the bitmap.
+                    Number of entries in the bitmap table of the

bitmap. It
+ must be zero if bitmap_table_offset is zero.

Quoted 2 lines
             12 - 15:    flags
                       Bit

NACK

no guys, we can not make this change at the moment. We do have QEMU available in the field which is working with the currently specified format.

Quoted 6 lines
Quoted 2 lines

Den

But I think the new format is a /compatible/ change. Under the old spec, I think this field is *NEVER* zero.

Am I wrong?

yes

but as far as I can understand this breaks backward compatibility, i.e. software working with the current revision of the specification will not be able to load new images.

#4 lore raw

Am 30.06.2016 um 19:23 hat Denis V. Lunev geschrieben:

Quoted 62 lines · John Snow
Quoted 61 lines · Denis V. Lunev
Quoted 50 lines · Vladimir Sementsov-Ogievskiy
Quoted 45 lines

After loading bitmap from image and setting IN_USE flag in it's header, corresponding data (bitmap table and data clusters) becomes inconsistent and is no longer needed. It is better to free bitmap table and corresponding clusters from the image immediately after loading the bitmap than free them when the bitmap is saved, or deleted or set non-persistent.

For now it is impossible to store only bitmap header without bitmap table, as specification requires it. Storing zeroed bitmap table (one or more clusters) is the only option to implement the behaviour similar to specified above.

The same problem is for just storing empty bitmaps.

This patch allows storing only bitmap header for empty bitmaps.

---

Additional note. Should we also allow here bitmap_table_offset = 1, like in bitmap table, for the bitmap with all bits set? I am not sure that it is needed at all, but just to keep the company..

  docs/specs/qcow2.txt | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
docs/specs/qcow2.txt +0 -0
index 80cdfd0..9826222 100644
@@ -435,9 +435,12 @@ Structure of a bitmap directory entry:
                      Offset into the image file at which the bitmap

table
(described below) for the bitmap starts. Must be
aligned to
a cluster boundary.
+ Zero value means that bitmap table is not
allocated and the
+ bitmap should be considered as empty (all bits
are zero).
8 - 11: bitmap_table_size

docs/specs/qcow2.txt +1 -1
-                    Number of entries in the bitmap table of the bitmap.
+                    Number of entries in the bitmap table of the

bitmap. It
+ must be zero if bitmap_table_offset is zero.

Quoted 2 lines
            12 - 15:    flags
                      Bit

NACK

Quoted 6 lines

no guys, we can not make this change at the moment. We do have QEMU available in the field which is working with the currently specified format.

Den

But I think the new format is a /compatible/ change. Under the old spec, I think this field is *NEVER* zero.

Quoted 6 lines
Quoted 1 line

Am I wrong?

yes

but as far as I can understand this breaks backward compatibility, i.e. software working with the current revision of the specification will not be able to load new images.

This is okay if it means that it cleanly errors out. I'm a bit worried that it might take the 0 literally, though, and use the image header as the bitmap table. Can you check that, Den?

If that's the case, we can make the change only with an incompatible feature bit, and that's probably not worth it.

Kevin

#5 lore raw
Quoted 68 lines · Kevin Wolf

Am 30.06.2016 um 19:23 hat Denis V. Lunev geschrieben:

Quoted 61 lines · John Snow
Quoted 60 lines · Denis V. Lunev
Quoted 50 lines · Vladimir Sementsov-Ogievskiy
Quoted 45 lines

After loading bitmap from image and setting IN_USE flag in it's header, corresponding data (bitmap table and data clusters) becomes inconsistent and is no longer needed. It is better to free bitmap table and corresponding clusters from the image immediately after loading the bitmap than free them when the bitmap is saved, or deleted or set non-persistent.

For now it is impossible to store only bitmap header without bitmap table, as specification requires it. Storing zeroed bitmap table (one or more clusters) is the only option to implement the behaviour similar to specified above.

The same problem is for just storing empty bitmaps.

This patch allows storing only bitmap header for empty bitmaps.

---

Additional note. Should we also allow here bitmap_table_offset = 1, like in bitmap table, for the bitmap with all bits set? I am not sure that it is needed at all, but just to keep the company..

   docs/specs/qcow2.txt | 5 ++++-
   1 file changed, 4 insertions(+), 1 deletion(-)
docs/specs/qcow2.txt +0 -0
index 80cdfd0..9826222 100644
@@ -435,9 +435,12 @@ Structure of a bitmap directory entry:
                       Offset into the image file at which the bitmap

table
(described below) for the bitmap starts. Must be
aligned to
a cluster boundary.
+ Zero value means that bitmap table is not
allocated and the
+ bitmap should be considered as empty (all bits
are zero).
8 - 11: bitmap_table_size

docs/specs/qcow2.txt +1 -1
-                    Number of entries in the bitmap table of the bitmap.
+                    Number of entries in the bitmap table of the

bitmap. It
+ must be zero if bitmap_table_offset is zero.

Quoted 2 lines
             12 - 15:    flags
                       Bit

NACK

Quoted 6 lines

no guys, we can not make this change at the moment. We do have QEMU available in the field which is working with the currently specified format.

Den

But I think the new format is a /compatible/ change. Under the old spec, I think this field is *NEVER* zero.

Quoted 6 lines
Quoted 1 line

Am I wrong?

yes

but as far as I can understand this breaks backward compatibility, i.e. software working with the current revision of the specification will not be able to load new images.

Quoted 8 lines

This is okay if it means that it cleanly errors out. I'm a bit worried that it might take the 0 literally, though, and use the image header as the bitmap table. Can you check that, Den?

If that's the case, we can make the change only with an incompatible feature bit, and that's probably not worth it.

Kevin

Current version will error out with "Bitmap doesn't satisfy the constraints.", because I check that

int check_constraints(...)
uint64_t phys_bitmap_bytes =

        (uint64_t)h->bitmap_table_size * cluster_size;
  uint64_t max_virtual_bits = (phys_bitmap_bytes * 8) << 
h->granularity_bits;
   int fail =
       .... ||
       (disk_size > max_virtual_bits) ||
        ...

    return fail ? -EINVAL : 0;
}

(max_virtual_bits will be zero if bitmap_table_size is zero)

Signature · 2 lines
Best regards,
Vladimir