提交 8cef921d 编写于 作者: T TeLeMan 提交者: Aurelien Jarno

qemu-img: use the heap instead of the huge stack array for win32

The default stack size of PE is 1MB on win32 and IO_BUF_SIZE in
img_convert() & img_rebase() is 2MB, so qemu-img will crash when doing
"convert" & "rebase" on win32.
Although we can improve the stack size of PE to resolve it, I think we
should avoid using the huge stack variables.
Signed-off-by: NTeLeMan <geleman@gmail.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 72ff25e4)
上级 b04c3db5
...@@ -537,7 +537,7 @@ static int img_convert(int argc, char **argv) ...@@ -537,7 +537,7 @@ static int img_convert(int argc, char **argv)
BlockDriverState **bs, *out_bs; BlockDriverState **bs, *out_bs;
int64_t total_sectors, nb_sectors, sector_num, bs_offset; int64_t total_sectors, nb_sectors, sector_num, bs_offset;
uint64_t bs_sectors; uint64_t bs_sectors;
uint8_t buf[IO_BUF_SIZE]; uint8_t * buf;
const uint8_t *buf1; const uint8_t *buf1;
BlockDriverInfo bdi; BlockDriverInfo bdi;
QEMUOptionParameter *param = NULL; QEMUOptionParameter *param = NULL;
...@@ -656,6 +656,7 @@ static int img_convert(int argc, char **argv) ...@@ -656,6 +656,7 @@ static int img_convert(int argc, char **argv)
bs_i = 0; bs_i = 0;
bs_offset = 0; bs_offset = 0;
bdrv_get_geometry(bs[0], &bs_sectors); bdrv_get_geometry(bs[0], &bs_sectors);
buf = qemu_malloc(IO_BUF_SIZE);
if (flags & BLOCK_FLAG_COMPRESS) { if (flags & BLOCK_FLAG_COMPRESS) {
if (bdrv_get_info(out_bs, &bdi) < 0) if (bdrv_get_info(out_bs, &bdi) < 0)
...@@ -788,6 +789,7 @@ static int img_convert(int argc, char **argv) ...@@ -788,6 +789,7 @@ static int img_convert(int argc, char **argv)
} }
} }
} }
qemu_free(buf);
bdrv_delete(out_bs); bdrv_delete(out_bs);
for (bs_i = 0; bs_i < bs_n; bs_i++) for (bs_i = 0; bs_i < bs_n; bs_i++)
bdrv_delete(bs[bs_i]); bdrv_delete(bs[bs_i]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册