aboutsummaryrefslogtreecommitdiff
path: root/block/vpc.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2014-05-21 18:08:38 +0200
committerKevin Wolf <kwolf@redhat.com>2014-08-15 15:07:16 +0200
commit5fb09cd5867aabf26d5b85b0913dccd496b71421 (patch)
tree3ca9d2389f1f24135a643f4fa9c01532cc67b9c3 /block/vpc.c
parentd6e5993197990ff55c660714526681fa7028299e (diff)
downloadqemu-5fb09cd5867aabf26d5b85b0913dccd496b71421.zip
qemu-5fb09cd5867aabf26d5b85b0913dccd496b71421.tar.gz
qemu-5fb09cd5867aabf26d5b85b0913dccd496b71421.tar.bz2
vpc: Handle failure for potentially large allocations
Some code in the block layer makes potentially huge allocations. Failure is not completely unexpected there, so avoid aborting qemu and handle out-of-memory situations gracefully. This patch addresses the allocations in the vpc block driver. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Benoit Canet <benoit@irqsave.net>
Diffstat (limited to 'block/vpc.c')
-rw-r--r--block/vpc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/block/vpc.c b/block/vpc.c
index 9690344..055efc4 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -269,7 +269,11 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
goto fail;
}
- s->pagetable = qemu_blockalign(bs, s->max_table_entries * 4);
+ s->pagetable = qemu_try_blockalign(bs->file, s->max_table_entries * 4);
+ if (s->pagetable == NULL) {
+ ret = -ENOMEM;
+ goto fail;
+ }
s->bat_offset = be64_to_cpu(dyndisk_header->table_offset);