From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkFE5-0006Qy-83 for qemu-devel@nongnu.org; Fri, 31 Oct 2014 12:39:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XkFDz-0002fR-3U for qemu-devel@nongnu.org; Fri, 31 Oct 2014 12:39:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36396) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkFDy-0002fN-SM for qemu-devel@nongnu.org; Fri, 31 Oct 2014 12:38:55 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9VGcsP8016245 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 31 Oct 2014 12:38:54 -0400 From: Igor Mammedov Date: Fri, 31 Oct 2014 16:38:33 +0000 Message-Id: <1414773522-7756-3-git-send-email-imammedo@redhat.com> In-Reply-To: <1414773522-7756-1-git-send-email-imammedo@redhat.com> References: <1414773522-7756-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH 02/11] kvm: provide API to query amount of memory slots supported by KVM List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, mst@redhat.com Signed-off-by: Igor Mammedov --- include/sysemu/kvm.h | 1 + kvm-all.c | 14 ++++++++++++++ kvm-stub.c | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 22e42ef..a49c1cd 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -163,6 +163,7 @@ extern KVMState *kvm_state; /* external API */ +int kvm_free_slot_count(MachineState *ms); bool kvm_has_free_slot(MachineState *ms); int kvm_has_sync_mmu(void); int kvm_has_vcpu_events(void); diff --git a/kvm-all.c b/kvm-all.c index c24e74b..bb61f0d 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -132,6 +132,20 @@ static const KVMCapabilityInfo kvm_required_capabilites[] = { KVM_CAP_LAST_INFO }; +int kvm_free_slot_count(MachineState *ms) +{ + int i, count; + KVMState *s = KVM_STATE(ms->accelerator); + + for (i = 0, count = 0; i < s->nr_slots; i++) { + if (s->slots[i].memory_size == 0) { + ++count; + } + } + + return count; +} + static KVMSlot *kvm_get_free_slot(KVMState *s) { int i; diff --git a/kvm-stub.c b/kvm-stub.c index 7ba90c5..e49d732 100644 --- a/kvm-stub.c +++ b/kvm-stub.c @@ -152,4 +152,9 @@ bool kvm_has_free_slot(MachineState *ms) { return false; } + +int kvm_free_slot_count(MachineState *ms) +{ + return INT_MAX; +} #endif -- 1.8.3.1