]> Git Repo - qemu.git/commitdiff
block: allow creation of fixed vhdx images
authorAdelina Tuvenie <[email protected]>
Thu, 18 Sep 2014 15:17:44 +0000 (18:17 +0300)
committerMichael Tokarev <[email protected]>
Mon, 22 Sep 2014 08:09:31 +0000 (12:09 +0400)
When trying to create a fixed vhd image qemu-img will return the
following error:

 qemu-img: test.vhdx: Could not create image: Cannot allocate memory

This happens because of a incorrect check in vhdx.c. Specifficaly,
in vhdx_create_bat(), after allocating memory for the BAT entry,
there is a check to determine if the allocation was unsuccsessful.
The error comes from the fact that it checks if s->bat isn't NULL,
which is true in case of succsessful allocation,  and exits with
error ENOMEM.

Signed-off-by: Adelina Tuvenie <[email protected]>
Acked-by: Kevin Wolf <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
block/vhdx.c

index 796b7bd88450b38c0a0903edfd629d8c4710542c..5bf292e33d5cd187421364158f610c50858facdf 100644 (file)
@@ -1593,7 +1593,7 @@ static int vhdx_create_bat(BlockDriverState *bs, BDRVVHDXState *s,
                 bdrv_has_zero_init(bs) == 0) {
         /* for a fixed file, the default BAT entry is not zero */
         s->bat = g_try_malloc0(length);
-        if (length && s->bat != NULL) {
+        if (length && s->bat == NULL) {
             ret = -ENOMEM;
             goto exit;
         }
This page took 0.032534 seconds and 4 git commands to generate.