[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 08/16] memory: Disallow resizing to 0
From: |
David Hildenbrand |
Subject: |
[PATCH v2 08/16] memory: Disallow resizing to 0 |
Date: |
Wed, 12 Feb 2020 14:35:53 +0100 |
Memory regions / qemu ramblocks always have to have a size > 0.
Especially, otherwise, ramblock_ptr() will bail out with an assert.
Enforce this.
Signed-off-by: David Hildenbrand <address@hidden>
---
exec.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/exec.c b/exec.c
index 5bc9b231c4..161e40e16e 100644
--- a/exec.c
+++ b/exec.c
@@ -2160,6 +2160,11 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize,
Error **errp)
return 0;
}
+ if (!newsize) {
+ error_setg_errno(errp, EINVAL, "Length cannot be 0: %s", block->idstr);
+ return -EINVAL;
+ }
+
if (!qemu_ram_is_resizable(block)) {
error_setg_errno(errp, EINVAL,
"Length mismatch: %s: 0x" RAM_ADDR_FMT
--
2.24.1
- [PATCH v2 00/16] Ram blocks with resizable anonymous allocations under POSIX, David Hildenbrand, 2020/02/12
- [PATCH v2 02/16] virtio-pci: Proxy for virtio-mem, David Hildenbrand, 2020/02/12
- [PATCH v2 01/16] virtio-mem: Prototype, David Hildenbrand, 2020/02/12
- [PATCH v2 03/16] hmp: Handle virtio-mem when printing memory device infos, David Hildenbrand, 2020/02/12
- [PATCH v2 04/16] numa: Handle virtio-mem in NUMA stats, David Hildenbrand, 2020/02/12
- [PATCH v2 05/16] pc: Support for virtio-mem-pci, David Hildenbrand, 2020/02/12
- [PATCH v2 06/16] exec: Provide owner when resizing memory region, David Hildenbrand, 2020/02/12
- [PATCH v2 07/16] memory: Add memory_region_max_size() and memory_region_is_resizable(), David Hildenbrand, 2020/02/12
- [PATCH v2 08/16] memory: Disallow resizing to 0,
David Hildenbrand <=
- [PATCH v2 09/16] memory-device: properly deal with resizable memory regions, David Hildenbrand, 2020/02/12
- [PATCH v2 10/16] hostmem: Factor out applying settings, David Hildenbrand, 2020/02/12
- [PATCH v2 11/16] hostmem: Factor out common checks into host_memory_backend_validate(), David Hildenbrand, 2020/02/12
- [PATCH v2 12/16] hostmem: Introduce "managed-size" for memory-backend-ram, David Hildenbrand, 2020/02/12
- [PATCH v2 13/16] qmp/hmp: Expose "managed-size" for memory backends, David Hildenbrand, 2020/02/12
- [PATCH v2 14/16] virtio-mem: Support for resizable memory regions, David Hildenbrand, 2020/02/12
- [PATCH v2 15/16] memory: Add region_resize() callback to memory notifier, David Hildenbrand, 2020/02/12
- [PATCH v2 16/16] kvm: Implement region_resize() for atomic memory section resizes, David Hildenbrand, 2020/02/12
- Re: [PATCH v2 00/16] Ram blocks with resizable anonymous allocations under POSIX, David Hildenbrand, 2020/02/12