mirror of https://github.com/xqemu/xqemu.git
block migration: Avoid large stack buffer
Move a potentially large buffer from stack to heap. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
c6d2283068
commit
575a58d763
|
@ -321,10 +321,12 @@ static int blk_mig_save_bulked_block(QEMUFile *f, int is_async)
|
||||||
static void blk_mig_save_dirty_blocks(QEMUFile *f)
|
static void blk_mig_save_dirty_blocks(QEMUFile *f)
|
||||||
{
|
{
|
||||||
BlkMigDevState *bmds;
|
BlkMigDevState *bmds;
|
||||||
uint8_t buf[BLOCK_SIZE];
|
uint8_t *buf;
|
||||||
int64_t sector;
|
int64_t sector;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
buf = qemu_malloc(BLOCK_SIZE);
|
||||||
|
|
||||||
for (bmds = block_mig_state->bmds_first; bmds != NULL; bmds = bmds->next) {
|
for (bmds = block_mig_state->bmds_first; bmds != NULL; bmds = bmds->next) {
|
||||||
for (sector = 0; sector < bmds->cur_sector;) {
|
for (sector = 0; sector < bmds->cur_sector;) {
|
||||||
if (bdrv_get_dirty(bmds->bs, sector)) {
|
if (bdrv_get_dirty(bmds->bs, sector)) {
|
||||||
|
@ -350,6 +352,8 @@ static void blk_mig_save_dirty_blocks(QEMUFile *f)
|
||||||
sector += BDRV_SECTORS_PER_DIRTY_CHUNK;
|
sector += BDRV_SECTORS_PER_DIRTY_CHUNK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qemu_free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flush_blks(QEMUFile* f)
|
static void flush_blks(QEMUFile* f)
|
||||||
|
@ -458,8 +462,6 @@ static int block_load(QEMUFile *f, void *opaque, int version_id)
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
|
||||||
buf = qemu_malloc(BLOCK_SIZE);
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
addr = qemu_get_be64(f);
|
addr = qemu_get_be64(f);
|
||||||
|
|
||||||
|
@ -475,6 +477,8 @@ static int block_load(QEMUFile *f, void *opaque, int version_id)
|
||||||
|
|
||||||
bs = bdrv_find(device_name);
|
bs = bdrv_find(device_name);
|
||||||
|
|
||||||
|
buf = qemu_malloc(BLOCK_SIZE);
|
||||||
|
|
||||||
qemu_get_buffer(f, buf, BLOCK_SIZE);
|
qemu_get_buffer(f, buf, BLOCK_SIZE);
|
||||||
if (bs != NULL) {
|
if (bs != NULL) {
|
||||||
bdrv_write(bs, addr, buf, BDRV_SECTORS_PER_DIRTY_CHUNK);
|
bdrv_write(bs, addr, buf, BDRV_SECTORS_PER_DIRTY_CHUNK);
|
||||||
|
@ -482,14 +486,14 @@ static int block_load(QEMUFile *f, void *opaque, int version_id)
|
||||||
printf("Error unknown block device %s\n", device_name);
|
printf("Error unknown block device %s\n", device_name);
|
||||||
/* FIXME: add error handling */
|
/* FIXME: add error handling */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qemu_free(buf);
|
||||||
} else if (!(flags & BLK_MIG_FLAG_EOS)) {
|
} else if (!(flags & BLK_MIG_FLAG_EOS)) {
|
||||||
printf("Unknown flags\n");
|
printf("Unknown flags\n");
|
||||||
/* FIXME: add error handling */
|
/* FIXME: add error handling */
|
||||||
}
|
}
|
||||||
} while (!(flags & BLK_MIG_FLAG_EOS));
|
} while (!(flags & BLK_MIG_FLAG_EOS));
|
||||||
|
|
||||||
qemu_free(buf);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue