From patchwork Fri Jan 21 23:48:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 497061 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0LNmV7L003330 for ; Fri, 21 Jan 2011 23:48:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754710Ab1AUXs3 (ORCPT ); Fri, 21 Jan 2011 18:48:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:27059 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754462Ab1AUXs3 (ORCPT ); Fri, 21 Jan 2011 18:48:29 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0LNmQnS003897 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 21 Jan 2011 18:48:26 -0500 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0LNmPlC015429; Fri, 21 Jan 2011 18:48:25 -0500 From: Alex Williamson Subject: [RFC PATCH 1/2] kvm: Allow querying free slots To: kvm@vger.kernel.org Cc: alex.williamson@redhat.com, ddutile@redhat.com, mst@redhat.com, avi@redhat.com, chrisw@redhat.com, jan.kiszka@siemens.com Date: Fri, 21 Jan 2011 16:48:25 -0700 Message-ID: <20110121234809.22262.3194.stgit@s20.home> In-Reply-To: <20110121233040.22262.68117.stgit@s20.home> References: <20110121233040.22262.68117.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 21 Jan 2011 23:48:52 +0000 (UTC) diff --git a/kvm-all.c b/kvm-all.c index 2f203dd..4fe3631 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -96,6 +96,22 @@ static KVMSlot *kvm_alloc_slot(KVMState *s) abort(); } +int kvm_free_slots(void) +{ + KVMState *s = kvm_state; + int i, j; + + for (i = 0, j = 0; i < ARRAY_SIZE(s->slots); i++) { + /* KVM private memory slots and used slots */ + if ((i >= 8 && i < 12) || s->slots[i].memory_size) { + continue; + } + j++; + } + + return j; +} + static KVMSlot *kvm_lookup_matching_slot(KVMState *s, target_phys_addr_t start_addr, target_phys_addr_t end_addr) diff --git a/kvm.h b/kvm.h index 02280a6..93da155 100644 --- a/kvm.h +++ b/kvm.h @@ -221,4 +221,6 @@ int kvm_irqchip_in_kernel(void); int kvm_set_irq(int irq, int level, int *status); +int kvm_free_slots(void); + #endif