From 5b23186a954a88ecabb2696cd846e0e67a9e349c Mon Sep 17 00:00:00 2001 From: David Hildenbrand Date: Tue, 26 Sep 2023 20:57:24 +0200 Subject: kvm: Return number of free memslots MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let's return the number of free slots instead of only checking if there is a free slot. While at it, check all address spaces, which will also consider SMM under x86 correctly. This is a preparation for memory devices that consume multiple memslots. Message-ID: <20230926185738.277351-5-david@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Maciej S. Szmigiero Reviewed-by: Michael S. Tsirkin Signed-off-by: David Hildenbrand --- hw/mem/memory-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw/mem/memory-device.c') diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c index 667d56bd29..98e355c960 100644 --- a/hw/mem/memory-device.c +++ b/hw/mem/memory-device.c @@ -59,7 +59,7 @@ static void memory_device_check_addable(MachineState *ms, MemoryRegion *mr, const uint64_t size = memory_region_size(mr); /* we will need a new memory slot for kvm and vhost */ - if (kvm_enabled() && !kvm_has_free_slot(ms)) { + if (kvm_enabled() && !kvm_get_free_memslots()) { error_setg(errp, "hypervisor has no free memory slots left"); return; } -- cgit 1.4.1