summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeLeMan <geleman@gmail.com>2010-02-08 16:20:00 +0800
committerAurelien Jarno <aurelien@aurel32.net>2010-05-07 09:07:42 +0200
commit8cef921d18025b4ce4e749eed391308033fee232 (patch)
treeb0cdf43b52aef52f42eeabe9a00b4c4d9a15296e
parentb04c3db504f35b57a2ce519313f3d49fcecf6cb3 (diff)
downloadqemu-8cef921d18025b4ce4e749eed391308033fee232.tar.gz
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: TeLeMan <geleman@gmail.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> (cherry picked from commit 72ff25e4e98d6dba9286d032b9ff5432553bbad5)
-rw-r--r--qemu-img.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/qemu-img.c b/qemu-img.c
index 1d97f2ebfb..2824178ae7 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -537,7 +537,7 @@ static int img_convert(int argc, char **argv)
BlockDriverState **bs, *out_bs;
int64_t total_sectors, nb_sectors, sector_num, bs_offset;
uint64_t bs_sectors;
- uint8_t buf[IO_BUF_SIZE];
+ uint8_t * buf;
const uint8_t *buf1;
BlockDriverInfo bdi;
QEMUOptionParameter *param = NULL;
@@ -656,6 +656,7 @@ static int img_convert(int argc, char **argv)
bs_i = 0;
bs_offset = 0;
bdrv_get_geometry(bs[0], &bs_sectors);
+ buf = qemu_malloc(IO_BUF_SIZE);
if (flags & BLOCK_FLAG_COMPRESS) {
if (bdrv_get_info(out_bs, &bdi) < 0)
@@ -788,6 +789,7 @@ static int img_convert(int argc, char **argv)
}
}
}
+ qemu_free(buf);
bdrv_delete(out_bs);
for (bs_i = 0; bs_i < bs_n; bs_i++)
bdrv_delete(bs[bs_i]);