Skip to content

Commit

Permalink
block: allow creation of fixed vhdx images
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
adelina-t authored and Michael Tokarev committed Sep 22, 2014
1 parent 4d63322 commit a011898
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion block/vhdx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit a011898

Please sign in to comment.