summaryrefslogtreecommitdiffstats
path: root/block/qcow2.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2015-12-02 18:34:39 +0100
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 19:28:25 -0600
commit7dca9b8a9d54f8ea4e4a77e334656c7a5679df20 (patch)
tree76bfd36adc120142cdb8af6b0ade10046c83e8cf /block/qcow2.c
parent28e84914a01dc250470160327ed17f2a869ee864 (diff)
downloadhqemu-7dca9b8a9d54f8ea4e4a77e334656c7a5679df20.zip
hqemu-7dca9b8a9d54f8ea4e4a77e334656c7a5679df20.tar.gz
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>
Diffstat (limited to 'block/qcow2.c')
-rw-r--r--block/qcow2.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/block/qcow2.c b/block/qcow2.c
index 20e4057..037afbf 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2239,6 +2239,13 @@ static int qcow2_create2(const char *filename, int64_t total_size,
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 */
ret = bdrv_truncate(bs, total_size);
if (ret < 0) {
OpenPOWER on IntegriCloud