[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/11] pc: check if KVM has enough memory slots for
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH 03/11] pc: check if KVM has enough memory slots for DIMM devices |
Date: |
Fri, 31 Oct 2014 16:38:34 +0000 |
check amount of available KVM memory slots after all
devices were initialized and exit with error if
there isn't enough free memory slots for DIMMs.
Signed-off-by: Igor Mammedov <address@hidden>
---
hw/i386/pc.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index f6dfd9b..41d91fb 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1125,6 +1125,36 @@ PcGuestInfo *pc_guest_info_init(ram_addr_t
below_4g_mem_size,
return guest_info;
}
+static int pc_dimm_count(Object *obj, void *opaque)
+{
+ int *count = opaque;
+
+ if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
+ (*count)++;
+ }
+
+ object_child_foreach(obj, pc_dimm_count, opaque);
+ return 0;
+}
+
+static void pc_kvm_slot_check(Notifier *notifier, void *data)
+{
+ MachineState *ms = MACHINE(qdev_get_machine());
+ int free_slots = kvm_free_slot_count(ms);
+ int used_ram_slots = 0;
+
+ pc_dimm_count(OBJECT(ms), &used_ram_slots);
+ if ((ms->ram_slots - used_ram_slots) > free_slots) {
+ error_report("KVM doesn't support more than %d memory slots",
+ kvm_free_slot_count(ms));
+ exit(EXIT_FAILURE);
+ }
+}
+
+static Notifier kvm_slot_check_on_machine_done = {
+ .notify = pc_kvm_slot_check
+ };
+
/* setup pci memory address space mapping into system address space */
void pc_pci_as_mapping_init(Object *owner, MemoryRegion *system_memory,
MemoryRegion *pci_address_space)
@@ -1269,6 +1299,8 @@ FWCfgState *pc_memory_init(MachineState *machine,
"hotplug-memory", hotplug_mem_size);
memory_region_add_subregion(system_memory, pcms->hotplug_memory_base,
&pcms->hotplug_memory);
+
+ qemu_add_machine_init_done_notifier(&kvm_slot_check_on_machine_done);
}
/* Initialize PC system firmware */
--
1.8.3.1
- [Qemu-devel] [PATCH 00/11] pc: kvm: memory hotplug fixes, Igor Mammedov, 2014/10/31
- [Qemu-devel] [PATCH 01/11] pc: kvm: check if KVM has free memory slots to avoid abort(), Igor Mammedov, 2014/10/31
- [Qemu-devel] [PATCH 02/11] kvm: provide API to query amount of memory slots supported by KVM, Igor Mammedov, 2014/10/31
- [Qemu-devel] [PATCH 03/11] pc: check if KVM has enough memory slots for DIMM devices,
Igor Mammedov <=
- [Qemu-devel] [PATCH 04/11] pc: make pc_dimm_plug() more readble, Igor Mammedov, 2014/10/31
- [Qemu-devel] [PATCH 05/11] pc: limit DIMM address and size to page aligned values, Igor Mammedov, 2014/10/31
- [Qemu-devel] [PATCH 06/11] memory: expose alignment used for allocating RAM as MemoryRegion API, Igor Mammedov, 2014/10/31
- [Qemu-devel] [PATCH 08/11] pc: align DIMM's address/size by backend's alignment value, Igor Mammedov, 2014/10/31
- [Qemu-devel] [PATCH 07/11] pc: add pc_init_pci_2_1() and pc_compat_2_1(), Igor Mammedov, 2014/10/31
- [Qemu-devel] [PATCH 09/11] pc: pc-dimm: use backend alignment during address auto allocation, Igor Mammedov, 2014/10/31
- [Qemu-devel] [PATCH 10/11] pc: explicitly check maxmem limit when adding DIMM, Igor Mammedov, 2014/10/31
- [Qemu-devel] [PATCH 11/11] pc: count in 1Gb hugepage alignment when sizing hotplug-memory container, Igor Mammedov, 2014/10/31