diff options
author | Kevin Wolf <kwolf@redhat.com> | 2015-12-02 19:11:04 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2016-01-20 13:36:23 +0100 |
commit | 1a4828c7934f592c146bc3dc979e78df430545cf (patch) | |
tree | a644fd6e2cc3341cfa06a02e610c9235d1045fcc | |
parent | 80c71a241ae3cd3b89527865ba730b2fa1f9e46f (diff) |
qcow2: Write feature table only for v3 images
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>
-rw-r--r-- | block/qcow2.c | 48 | ||||
-rw-r--r-- | tests/qemu-iotests/031.out | 12 | ||||
-rw-r--r-- | tests/qemu-iotests/061.out | 15 |
3 files changed, 26 insertions, 49 deletions
diff --git a/block/qcow2.c b/block/qcow2.c index e4e2754ca2..20e4057ca2 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -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) { diff --git a/tests/qemu-iotests/031.out b/tests/qemu-iotests/031.out index fce3ce0984..f065404561 100644 --- a/tests/qemu-iotests/031.out +++ b/tests/qemu-iotests/031.out @@ -53,11 +53,6 @@ refcount_order 4 header_length 72 Header extension: -magic 0x6803f857 -length 144 -data <binary> - -Header extension: magic 0x12345678 length 31 data 'This is a test header extension' @@ -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 @@ -91,11 +86,6 @@ length 11 data 'host_device' Header extension: -magic 0x6803f857 -length 144 -data <binary> - -Header extension: magic 0x12345678 length 31 data 'This is a test header extension' diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out index 57aae28e53..d604682da9 100644 --- a/tests/qemu-iotests/061.out +++ b/tests/qemu-iotests/061.out @@ -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. @@ -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. @@ -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 === |