提交 a011898d 编写于 作者: A Adelina Tuvenie 提交者: Michael Tokarev

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: NAdelina Tuvenie <atuvenie@cloudbasesolutions.com>
Acked-by: NKevin Wolf <kwolf@redhat.com>
Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
上级 4d63322c
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册