qcow2: Write full header on image creation
When creating a qcow2 image, we didn't necessarily call qcow2_update_header(), but could end up with the basic header that qcow2_create2() created manually. One thing that this basic header lacks is the feature table. Let's make sure that it's always present. This requires a few updates to test cases as well. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
1a4828c793
commit
b527c9b392
|
@ -2239,6 +2239,13 @@ static int qcow2_create2(const char *filename, int64_t total_size,
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Create a full header (including things like feature table) */
|
||||||
|
ret = qcow2_update_header(bs);
|
||||||
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret, "Could not update qcow2 header");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
/* Okay, now that we have a valid image, let's give it the right size */
|
/* Okay, now that we have a valid image, let's give it the right size */
|
||||||
ret = bdrv_truncate(bs, total_size);
|
ret = bdrv_truncate(bs, total_size);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
|
|
@ -115,6 +115,11 @@ autoclear_features 0x0
|
||||||
refcount_order 4
|
refcount_order 4
|
||||||
header_length 104
|
header_length 104
|
||||||
|
|
||||||
|
Header extension:
|
||||||
|
magic 0x6803f857
|
||||||
|
length 144
|
||||||
|
data <binary>
|
||||||
|
|
||||||
Header extension:
|
Header extension:
|
||||||
magic 0x12345678
|
magic 0x12345678
|
||||||
length 31
|
length 31
|
||||||
|
|
|
@ -57,6 +57,7 @@ _make_test_img 64M
|
||||||
$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63
|
$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63
|
||||||
|
|
||||||
# Without feature table
|
# Without feature table
|
||||||
|
$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857
|
||||||
$PYTHON qcow2.py "$TEST_IMG" dump-header
|
$PYTHON qcow2.py "$TEST_IMG" dump-header
|
||||||
_img_info
|
_img_info
|
||||||
|
|
||||||
|
@ -73,6 +74,7 @@ $PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 62
|
||||||
$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63
|
$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63
|
||||||
|
|
||||||
# Without feature table
|
# Without feature table
|
||||||
|
$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857
|
||||||
_img_info
|
_img_info
|
||||||
|
|
||||||
# With feature table containing bit 63
|
# With feature table containing bit 63
|
||||||
|
|
|
@ -56,6 +56,11 @@ autoclear_features 0x8000000000000000
|
||||||
refcount_order 4
|
refcount_order 4
|
||||||
header_length 104
|
header_length 104
|
||||||
|
|
||||||
|
Header extension:
|
||||||
|
magic 0x6803f857
|
||||||
|
length 144
|
||||||
|
data <binary>
|
||||||
|
|
||||||
|
|
||||||
=== Repair image ===
|
=== Repair image ===
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,11 @@ autoclear_features 0x0
|
||||||
refcount_order 4
|
refcount_order 4
|
||||||
header_length 104
|
header_length 104
|
||||||
|
|
||||||
|
Header extension:
|
||||||
|
magic 0x6803f857
|
||||||
|
length 144
|
||||||
|
data <binary>
|
||||||
|
|
||||||
magic 0x514649fb
|
magic 0x514649fb
|
||||||
version 2
|
version 2
|
||||||
backing_file_offset 0x0
|
backing_file_offset 0x0
|
||||||
|
@ -76,6 +81,11 @@ autoclear_features 0x0
|
||||||
refcount_order 4
|
refcount_order 4
|
||||||
header_length 104
|
header_length 104
|
||||||
|
|
||||||
|
Header extension:
|
||||||
|
magic 0x6803f857
|
||||||
|
length 144
|
||||||
|
data <binary>
|
||||||
|
|
||||||
ERROR cluster 5 refcount=0 reference=1
|
ERROR cluster 5 refcount=0 reference=1
|
||||||
ERROR cluster 6 refcount=0 reference=1
|
ERROR cluster 6 refcount=0 reference=1
|
||||||
Rebuilding refcount structure
|
Rebuilding refcount structure
|
||||||
|
@ -126,6 +136,11 @@ autoclear_features 0x40000000000
|
||||||
refcount_order 4
|
refcount_order 4
|
||||||
header_length 104
|
header_length 104
|
||||||
|
|
||||||
|
Header extension:
|
||||||
|
magic 0x6803f857
|
||||||
|
length 144
|
||||||
|
data <binary>
|
||||||
|
|
||||||
magic 0x514649fb
|
magic 0x514649fb
|
||||||
version 2
|
version 2
|
||||||
backing_file_offset 0x0
|
backing_file_offset 0x0
|
||||||
|
@ -228,6 +243,11 @@ autoclear_features 0x0
|
||||||
refcount_order 4
|
refcount_order 4
|
||||||
header_length 104
|
header_length 104
|
||||||
|
|
||||||
|
Header extension:
|
||||||
|
magic 0x6803f857
|
||||||
|
length 144
|
||||||
|
data <binary>
|
||||||
|
|
||||||
ERROR cluster 5 refcount=0 reference=1
|
ERROR cluster 5 refcount=0 reference=1
|
||||||
ERROR cluster 6 refcount=0 reference=1
|
ERROR cluster 6 refcount=0 reference=1
|
||||||
Rebuilding refcount structure
|
Rebuilding refcount structure
|
||||||
|
|
Loading…
Reference in New Issue