kvm: API to obtain max supported mem slots

Introduce kvm_get_max_memslots() API that can be used to obtain the
maximum number of memslots supported by KVM.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Bharata B Rao 2016-06-01 15:21:24 +05:30 committed by David Gibson
parent a575d9ab2e
commit 44f2e6c10e
2 changed files with 8 additions and 0 deletions

View File

@ -527,4 +527,5 @@ int kvm_set_one_reg(CPUState *cs, uint64_t id, void *source);
* Returns: 0 on success, or a negative errno on failure. * Returns: 0 on success, or a negative errno on failure.
*/ */
int kvm_get_one_reg(CPUState *cs, uint64_t id, void *target); int kvm_get_one_reg(CPUState *cs, uint64_t id, void *target);
int kvm_get_max_memslots(void);
#endif #endif

View File

@ -126,6 +126,13 @@ static const KVMCapabilityInfo kvm_required_capabilites[] = {
KVM_CAP_LAST_INFO KVM_CAP_LAST_INFO
}; };
int kvm_get_max_memslots(void)
{
KVMState *s = KVM_STATE(current_machine->accelerator);
return s->nr_slots;
}
static KVMSlot *kvm_get_free_slot(KVMMemoryListener *kml) static KVMSlot *kvm_get_free_slot(KVMMemoryListener *kml)
{ {
KVMState *s = kvm_state; KVMState *s = kvm_state;