[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC 06/15] memory-device: Move memory_device_check_addable() dire
From: |
David Hildenbrand |
Subject: |
[PATCH RFC 06/15] memory-device: Move memory_device_check_addable() directly into memory_device_pre_plug() |
Date: |
Wed, 13 Oct 2021 12:33:21 +0200 |
Move it out of memory_device_get_free_addr(), which is cleaner and
prepares for future changes.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
hw/mem/memory-device.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
index 7f76a09e57..68a2c3dbcc 100644
--- a/hw/mem/memory-device.c
+++ b/hw/mem/memory-device.c
@@ -67,9 +67,10 @@ static int memory_device_used_region_size(Object *obj, void
*opaque)
return 0;
}
-static void memory_device_check_addable(MachineState *ms, uint64_t size,
+static void memory_device_check_addable(MachineState *ms, MemoryRegion *mr,
Error **errp)
{
+ const uint64_t size = memory_region_size(mr);
uint64_t used_region_size = 0;
/* we will need a new memory slot for kvm and vhost */
@@ -99,7 +100,6 @@ static uint64_t memory_device_get_free_addr(MachineState *ms,
uint64_t align, uint64_t size,
Error **errp)
{
- Error *err = NULL;
GSList *list = NULL, *item;
Range as, new = range_empty;
@@ -125,12 +125,6 @@ static uint64_t memory_device_get_free_addr(MachineState
*ms,
align);
}
- memory_device_check_addable(ms, size, &err);
- if (err) {
- error_propagate(errp, err);
- return 0;
- }
-
if (hint && !QEMU_IS_ALIGNED(*hint, align)) {
error_setg(errp, "address must be aligned to 0x%" PRIx64 " bytes",
align);
@@ -259,6 +253,11 @@ void memory_device_pre_plug(MemoryDeviceState *md,
MachineState *ms,
goto out;
}
+ memory_device_check_addable(ms, mr, &local_err);
+ if (local_err) {
+ goto out;
+ }
+
if (legacy_align) {
align = *legacy_align;
} else {
--
2.31.1
- [PATCH RFC 00/15] virtio-mem: Expose device memory via separate memslots, David Hildenbrand, 2021/10/13
- [PATCH RFC 01/15] memory: Drop mapping check from memory_region_get_ram_discard_manager(), David Hildenbrand, 2021/10/13
- [PATCH RFC 02/15] kvm: Return number of free memslots, David Hildenbrand, 2021/10/13
- [PATCH RFC 03/15] vhost: Return number of free memslots, David Hildenbrand, 2021/10/13
- [PATCH RFC 04/15] memory: Allow for marking memory region aliases unmergeable, David Hildenbrand, 2021/10/13
- [PATCH RFC 05/15] vhost: Don't merge unmergeable memory sections, David Hildenbrand, 2021/10/13
- [PATCH RFC 06/15] memory-device: Move memory_device_check_addable() directly into memory_device_pre_plug(),
David Hildenbrand <=
- [PATCH RFC 07/15] memory-device: Generalize memory_device_used_region_size(), David Hildenbrand, 2021/10/13
- [PATCH RFC 08/15] memory-device: Support memory devices that consume a variable number of memslots, David Hildenbrand, 2021/10/13
- [PATCH RFC 09/15] vhost: Respect reserved memslots for memory devices when realizing a vhost device, David Hildenbrand, 2021/10/13
- [PATCH RFC 10/15] virtio-mem: Set the RamDiscardManager for the RAM memory region earlier, David Hildenbrand, 2021/10/13
- [PATCH RFC 11/15] virtio-mem: Fix typo in virito_mem_intersect_memory_section() function name, David Hildenbrand, 2021/10/13
- [PATCH RFC 12/15] virtio-mem: Expose device memory via separate memslots, David Hildenbrand, 2021/10/13
- [PATCH RFC 13/15] vhost-user: Increase VHOST_USER_MAX_RAM_SLOTS to 496 with CONFIG_VIRTIO_MEM, David Hildenbrand, 2021/10/13