All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 06/17] qcow2: Write feature table only for v3 images
Date: Wed, 20 Jan 2016 17:24:55 +0100	[thread overview]
Message-ID: <1453307106-28330-7-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1453307106-28330-1-git-send-email-kwolf@redhat.com>

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>
---
 block/qcow2.c              | 48 ++++++++++++++++++++++++----------------------
 tests/qemu-iotests/031.out | 12 +-----------
 tests/qemu-iotests/061.out | 15 ---------------
 3 files changed, 26 insertions(+), 49 deletions(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index e4e2754..20e4057 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 fce3ce0..f065404 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 57aae28..d604682 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 ===
-- 
1.8.3.1

  parent reply	other threads:[~2016-01-20 16:25 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-20 16:24 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
2016-01-20 16:24 ` [Qemu-devel] [PULL 01/17] block: Fix .bdrv_open flags Kevin Wolf
2016-01-20 16:24 ` [Qemu-devel] [PULL 02/17] block/raw-posix: avoid bogus fixup for cylinders on DASD disks Kevin Wolf
2016-01-20 16:24 ` [Qemu-devel] [PULL 03/17] qemu-img: Speed up comparing empty/zero images Kevin Wolf
2016-01-20 16:24 ` [Qemu-devel] [PULL 04/17] qemu-iotests: Reduce racy output in 028 Kevin Wolf
2016-01-20 16:24 ` [Qemu-devel] [PULL 05/17] block: Clean up includes Kevin Wolf
2016-01-20 16:24 ` Kevin Wolf [this message]
2016-01-20 16:24 ` [Qemu-devel] [PULL 07/17] qcow2: Write full header on image creation Kevin Wolf
2016-01-20 16:24 ` [Qemu-devel] [PULL 08/17] block: Assert no write requests under BDRV_O_INCOMING Kevin Wolf
2016-02-18 16:03   ` Laurent Vivier
2016-02-19  9:17     ` Kevin Wolf
2016-02-19 10:37       ` Laurent Vivier
2016-02-19 13:47         ` Kevin Wolf
2016-02-19 14:11           ` Paolo Bonzini
2016-02-19 14:17             ` Kevin Wolf
2016-01-20 16:24 ` [Qemu-devel] [PULL 09/17] block: Fix error path in bdrv_invalidate_cache() Kevin Wolf
2016-01-20 16:24 ` [Qemu-devel] [PULL 10/17] block: Rename BDRV_O_INCOMING to BDRV_O_INACTIVE Kevin Wolf
2016-01-20 16:25 ` [Qemu-devel] [PULL 11/17] block: Inactivate BDS when migration completes Kevin Wolf
2016-01-20 16:25 ` [Qemu-devel] [PULL 12/17] qcow2: Implement .bdrv_inactivate Kevin Wolf
2016-01-22 11:24   ` Paolo Bonzini
2016-01-20 16:25 ` [Qemu-devel] [PULL 13/17] qcow2: Fix BDRV_O_INACTIVE handling in qcow2_invalidate_cache() Kevin Wolf
2016-01-20 16:25 ` [Qemu-devel] [PULL 14/17] qcow2: Make image inaccessible after failed qcow2_invalidate_cache() Kevin Wolf
2016-01-20 16:25 ` [Qemu-devel] [PULL 15/17] vmdk: Create streamOptimized as version 3 Kevin Wolf
2016-01-20 16:25 ` [Qemu-devel] [PULL 16/17] blockdev: Error out on negative throttling option values Kevin Wolf
2016-01-20 16:25 ` [Qemu-devel] [PULL 17/17] iotests: Test that throttle values ranges Kevin Wolf
2016-01-21 13:42 ` [Qemu-devel] [PULL 00/17] Block patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453307106-28330-7-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.