summaryrefslogtreecommitdiff
path: root/savevm.c
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-04-05 19:10:55 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-04-05 19:10:55 +0000
commit178e08a58f40dd5aef2ce774fe0850f5d0e56918 (patch)
tree4884054a59eaaad4b5df2f47403cee9a81e8e2db /savevm.c
parent8185d2c9a20975114ebb59b0f46b615cbb83c730 (diff)
downloadqemu-178e08a58f40dd5aef2ce774fe0850f5d0e56918.tar.gz
Fix savevm after BDRV_FILE size enforcement
We now enforce that you cannot write beyond the end of a non-growable file. qcow2 files are not growable but we rely on them being growable to do savevm/loadvm. Temporarily allow them to be growable by introducing a new API specifically for savevm read/write operations. Reported-by: malc Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6994 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'savevm.c')
-rw-r--r--savevm.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/savevm.c b/savevm.c
index ce12628084..793ea70695 100644
--- a/savevm.c
+++ b/savevm.c
@@ -310,18 +310,18 @@ typedef struct QEMUFileBdrv
int64_t base_offset;
} QEMUFileBdrv;
-static int bdrv_put_buffer(void *opaque, const uint8_t *buf,
+static int block_put_buffer(void *opaque, const uint8_t *buf,
int64_t pos, int size)
{
QEMUFileBdrv *s = opaque;
- bdrv_pwrite(s->bs, s->base_offset + pos, buf, size);
+ bdrv_put_buffer(s->bs, buf, s->base_offset + pos, size);
return size;
}
-static int bdrv_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
+static int block_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
{
QEMUFileBdrv *s = opaque;
- return bdrv_pread(s->bs, s->base_offset + pos, buf, size);
+ return bdrv_get_buffer(s->bs, buf, s->base_offset + pos, size);
}
static int bdrv_fclose(void *opaque)
@@ -341,9 +341,9 @@ static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int64_t offset, int is_wr
s->base_offset = offset;
if (is_writable)
- return qemu_fopen_ops(s, bdrv_put_buffer, NULL, bdrv_fclose, NULL);
+ return qemu_fopen_ops(s, block_put_buffer, NULL, bdrv_fclose, NULL);
- return qemu_fopen_ops(s, NULL, bdrv_get_buffer, bdrv_fclose, NULL);
+ return qemu_fopen_ops(s, NULL, block_get_buffer, bdrv_fclose, NULL);
}
QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer,