[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC 3/4] exec: don't exit unconditionally if failed
From: |
Hu Tao |
Subject: |
[Qemu-devel] [PATCH RFC 3/4] exec: don't exit unconditionally if failed to allocate memory |
Date: |
Sat, 14 Jun 2014 12:48:58 +0800 |
return -1 instead.
Now user can add objects memory-backend-ram on-the-fly, fail it if
cannot allocate memory rather than quit qemu.
Signed-off-by: Hu Tao <address@hidden>
---
backends/hostmem-ram.c | 3 +++
exec.c | 6 +++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c
index d9a8290..afb305d 100644
--- a/backends/hostmem-ram.c
+++ b/backends/hostmem-ram.c
@@ -28,6 +28,9 @@ ram_backend_memory_alloc(HostMemoryBackend *backend, Error
**errp)
path = object_get_canonical_path_component(OBJECT(backend));
memory_region_init_ram(&backend->mr, OBJECT(backend), path,
backend->size);
+ if (backend->mr.ram_addr == -1) {
+ error_setg(errp, "can't allocate memory");
+ }
g_free(path);
}
diff --git a/exec.c b/exec.c
index 8705cc5..74560e5 100644
--- a/exec.c
+++ b/exec.c
@@ -1228,7 +1228,7 @@ static ram_addr_t ram_block_add(RAMBlock *new_block)
if (!new_block->host) {
fprintf(stderr, "Cannot set up guest memory '%s': %s\n",
new_block->mr->name, strerror(errno));
- exit(1);
+ return -1;
}
memory_try_enable_merging(new_block->host, new_block->length);
}
@@ -1356,6 +1356,10 @@ void qemu_ram_free(ram_addr_t addr)
{
RAMBlock *block;
+ if (addr == -1) {
+ return;
+ }
+
/* This assumes the iothread lock is taken here too. */
qemu_mutex_lock_ramlist();
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
--
1.9.3
- Re: [Qemu-devel] [PATCH v5 00/16] NUMA series v5, (continued)
- Re: [Qemu-devel] [PATCH v5 00/16] NUMA series v5, Michael S. Tsirkin, 2014/06/13
- Re: [Qemu-devel] [PATCH v5 00/16] NUMA series v5, Paolo Bonzini, 2014/06/13
- Re: [Qemu-devel] [PATCH v5 00/16] NUMA series v5, Michael S. Tsirkin, 2014/06/13
- Re: [Qemu-devel] [PATCH v5 00/16] NUMA series v5, Hu Tao, 2014/06/13
- Re: [Qemu-devel] [PATCH v5 00/16] NUMA series v5, Michael S. Tsirkin, 2014/06/13
- [Qemu-devel] [PATCH RFC 0/4] fixes for pci tree, Hu Tao, 2014/06/14
- [Qemu-devel] [PATCH RFC 1/4] get rid of signed range, Hu Tao, 2014/06/14
- Re: [Qemu-devel] [PATCH RFC 1/4] get rid of signed range, Michael S. Tsirkin, 2014/06/15
- Re: [Qemu-devel] [PATCH RFC 1/4] get rid of signed range, Hu Tao, 2014/06/16
- Re: [Qemu-devel] [PATCH RFC 1/4] get rid of signed range, Michael S. Tsirkin, 2014/06/16
- [Qemu-devel] [PATCH RFC 3/4] exec: don't exit unconditionally if failed to allocate memory,
Hu Tao <=
- Re: [Qemu-devel] [PATCH RFC 3/4] exec: don't exit unconditionally if failed to allocate memory, Paolo Bonzini, 2014/06/14
- Re: [Qemu-devel] [PATCH RFC 3/4] exec: don't exit unconditionally if failed to allocate memory, Michael S. Tsirkin, 2014/06/15
- Re: [Qemu-devel] [PATCH RFC 3/4] exec: don't exit unconditionally if failed to allocate memory, Hu Tao, 2014/06/16
- Re: [Qemu-devel] [PATCH RFC 3/4] exec: don't exit unconditionally if failed to allocate memory, Paolo Bonzini, 2014/06/16
- [Qemu-devel] [PATCH RFC 2/4] check if we have space left for hotplugged memory, Hu Tao, 2014/06/14
- Re: [Qemu-devel] [PATCH RFC 2/4] check if we have space left for hotplugged memory, Michael S. Tsirkin, 2014/06/15
- Re: [Qemu-devel] [PATCH RFC 2/4] check if we have space left for hotplugged memory, Hu Tao, 2014/06/16
- [Qemu-devel] [PATCH RFC 4/4] memory-backend-file: error out if failed to allocate memory, Hu Tao, 2014/06/14
- Re: [Qemu-devel] [PATCH RFC 4/4] memory-backend-file: error out if failed to allocate memory, Paolo Bonzini, 2014/06/14
- Re: [Qemu-devel] [PATCH RFC 4/4] memory-backend-file: error out if failed to allocate memory, Hu Tao, 2014/06/16