From: Adelina Tuvenie Date: Thu, 18 Sep 2014 15:17:44 +0000 (+0300) Subject: block: allow creation of fixed vhdx images X-Git-Tag: TizenStudio_2.0_p2.3.2~208^2~582^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a011898d25b8a26a311d56dfe37e8d3a4374ec65;p=sdk%2Femulator%2Fqemu.git block: allow creation of fixed vhdx images 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 Acked-by: Kevin Wolf Signed-off-by: Michael Tokarev --- diff --git a/block/vhdx.c b/block/vhdx.c index 796b7bd..5bf292e 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -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; }