qemu-img: Cannot create fixed vhdx image
cover qemu-img: Cannot create fixed vhdx image
*** BLURB HERE ***
Adelina Tuvenie (1):
qemu-img: Cannot create fixed vhdx image
block/vhdx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
1.9.1
PATCH 1/1 qemu-img: Cannot create fixed vhdx image
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.
--- block/vhdx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/vhdx.c +1 -1
@@ -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; }
Quoted 4 lines · Adelina Tuvenie
When trying to create a fixed vhd image qemu-img will return the following error:
Quoted 8 lines
qemu-img: test.vhdx: Could not create image: Cannot allocate memory
This happens because of a incorrect check in
vhdx.c. Specifficaly, invhdx_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 ifs->batisn't NULL, which is true in case of succsessful allocation, and exits with error ENOMEM.
Applying to -trivial, as it is an obvious trivial one-liner, hopefully it's okay for kwolf@ and stefanha@. But please,
- Cc qemu-devel and the subsystem maintainers (Cc'ed)
- do not send an "intro" email for single patches
- do not attach the patch, place it inline if possible
(Since the original patch was in an attachment, I copy it here for completness:
block/vhdx.c +1 -1
@@ -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; }
)
I also modified the subject line, to read:
block: allow creation of fixed vhdx images
Thanks,
/mjt
Kevin Wolf
Acked-byAm 20.09.2014 um 15:53 hat Michael Tokarev geschrieben:
Quoted 37 lines
Quoted 4 lines · Adelina Tuvenie
When trying to create a fixed vhd image qemu-img will return the following error:
Quoted 8 lines
qemu-img: test.vhdx: Could not create image: Cannot allocate memory
This happens because of a incorrect check in
vhdx.c. Specifficaly, invhdx_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 ifs->batisn't NULL, which is true in case of succsessful allocation, and exits with error ENOMEM.Applying to -trivial, as it is an obvious trivial one-liner, hopefully it's okay for kwolf@ and stefanha@. But please,
- Cc qemu-devel and the subsystem maintainers (Cc'ed)
- do not send an "intro" email for single patches
- do not attach the patch, place it inline if possible(Since the original patch was in an attachment, I copy it here for completness:
block/vhdx.c +1
-1@@ -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; }
Quoted 1 line
)
Whoops, this is what happens when you make mechanical changes manually. And I fooled two reviewers with this code. :-)