Skip to content

Commit

Permalink
qcow2: Write feature table only for v3 images
Browse files Browse the repository at this point in the history
Version 2 images don't have feature bits, so writing a feature table to
those images is kind of pointless.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
  • Loading branch information
kevmw committed Jan 20, 2016
1 parent 80c71a2 commit 1a4828c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 49 deletions.
48 changes: 25 additions & 23 deletions block/qcow2.c
Expand Up @@ -1895,31 +1895,33 @@ int qcow2_update_header(BlockDriverState *bs)
}

/* Feature table */
Qcow2Feature features[] = {
{
.type = QCOW2_FEAT_TYPE_INCOMPATIBLE,
.bit = QCOW2_INCOMPAT_DIRTY_BITNR,
.name = "dirty bit",
},
{
.type = QCOW2_FEAT_TYPE_INCOMPATIBLE,
.bit = QCOW2_INCOMPAT_CORRUPT_BITNR,
.name = "corrupt bit",
},
{
.type = QCOW2_FEAT_TYPE_COMPATIBLE,
.bit = QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR,
.name = "lazy refcounts",
},
};
if (s->qcow_version >= 3) {
Qcow2Feature features[] = {
{
.type = QCOW2_FEAT_TYPE_INCOMPATIBLE,
.bit = QCOW2_INCOMPAT_DIRTY_BITNR,
.name = "dirty bit",
},
{
.type = QCOW2_FEAT_TYPE_INCOMPATIBLE,
.bit = QCOW2_INCOMPAT_CORRUPT_BITNR,
.name = "corrupt bit",
},
{
.type = QCOW2_FEAT_TYPE_COMPATIBLE,
.bit = QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR,
.name = "lazy refcounts",
},
};

ret = header_ext_add(buf, QCOW2_EXT_MAGIC_FEATURE_TABLE,
features, sizeof(features), buflen);
if (ret < 0) {
goto fail;
ret = header_ext_add(buf, QCOW2_EXT_MAGIC_FEATURE_TABLE,
features, sizeof(features), buflen);
if (ret < 0) {
goto fail;
}
buf += ret;
buflen -= ret;
}
buf += ret;
buflen -= ret;

/* Keep unknown header extensions */
QLIST_FOREACH(uext, &s->unknown_header_ext, next) {
Expand Down
12 changes: 1 addition & 11 deletions tests/qemu-iotests/031.out
Expand Up @@ -52,11 +52,6 @@ autoclear_features 0x0
refcount_order 4
header_length 72

Header extension:
magic 0x6803f857
length 144
data <binary>

Header extension:
magic 0x12345678
length 31
Expand All @@ -68,7 +63,7 @@ No errors were found on the image.

magic 0x514649fb
version 2
backing_file_offset 0x128
backing_file_offset 0x90
backing_file_size 0x17
cluster_bits 16
size 67108864
Expand All @@ -90,11 +85,6 @@ magic 0xe2792aca
length 11
data 'host_device'

Header extension:
magic 0x6803f857
length 144
data <binary>

Header extension:
magic 0x12345678
length 31
Expand Down
15 changes: 0 additions & 15 deletions tests/qemu-iotests/061.out
Expand Up @@ -43,11 +43,6 @@ autoclear_features 0x0
refcount_order 4
header_length 72

Header extension:
magic 0x6803f857
length 144
data <binary>

read 131072/131072 bytes at offset 0
128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
No errors were found on the image.
Expand Down Expand Up @@ -105,11 +100,6 @@ autoclear_features 0x0
refcount_order 4
header_length 72

Header extension:
magic 0x6803f857
length 144
data <binary>

read 131072/131072 bytes at offset 0
128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
No errors were found on the image.
Expand Down Expand Up @@ -155,11 +145,6 @@ autoclear_features 0x0
refcount_order 4
header_length 72

Header extension:
magic 0x6803f857
length 144
data <binary>

No errors were found on the image.

=== Testing version upgrade and resize ===
Expand Down

0 comments on commit 1a4828c

Please sign in to comment.