From patchwork Mon Mar 18 03:18:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mrhines@linux.vnet.ibm.com X-Patchwork-Id: 228357 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 13FBF2C0079 for ; Mon, 18 Mar 2013 14:24:13 +1100 (EST) Received: from localhost ([::1]:48119 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHQgF-0004ys-8E for incoming@patchwork.ozlabs.org; Sun, 17 Mar 2013 23:24:11 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHQbo-0005yv-0T for qemu-devel@nongnu.org; Sun, 17 Mar 2013 23:19:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UHQbf-0004WG-SJ for qemu-devel@nongnu.org; Sun, 17 Mar 2013 23:19:35 -0400 Received: from e8.ny.us.ibm.com ([32.97.182.138]:48055) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHQbf-0004Vo-O0 for qemu-devel@nongnu.org; Sun, 17 Mar 2013 23:19:27 -0400 Received: from /spool/local by e8.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 17 Mar 2013 23:19:27 -0400 Received: from d01dlp03.pok.ibm.com (9.56.250.168) by e8.ny.us.ibm.com (192.168.1.108) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 17 Mar 2013 23:19:25 -0400 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 1C8E1C9001E for ; Sun, 17 Mar 2013 23:19:25 -0400 (EDT) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2I3JOHr61407338 for ; Sun, 17 Mar 2013 23:19:24 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2I3JOdA009264 for ; Sun, 17 Mar 2013 23:19:24 -0400 Received: from mrhinesdev.klabtestbed.com (klinux.watson.ibm.com [9.2.208.21]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r2I3JMH2009195; Sun, 17 Mar 2013 23:19:24 -0400 From: mrhines@linux.vnet.ibm.com To: qemu-devel@nongnu.org Date: Sun, 17 Mar 2013 23:18:57 -0400 Message-Id: <1363576743-6146-5-git-send-email-mrhines@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1363576743-6146-1-git-send-email-mrhines@linux.vnet.ibm.com> References: <1363576743-6146-1-git-send-email-mrhines@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13031803-9360-0000-0000-0000115CF408 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 32.97.182.138 Cc: aliguori@us.ibm.com, mst@redhat.com, owasserm@redhat.com, abali@us.ibm.com, mrhines@us.ibm.com, gokul@us.ibm.com, pbonzini@redhat.com Subject: [Qemu-devel] [RFC PATCH RDMA support v4: 04/10] iterators for getting the RAMBlocks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Michael R. Hines" This introduces: 1. qemu_ram_foreach_block 2. qemu_ram_count_blocks Both used in communicating the RAMBlocks to each side for later memory registration. Signed-off-by: Michael R. Hines --- exec.c | 21 +++++++++++++++++++++ include/exec/cpu-common.h | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/exec.c b/exec.c index 8a6aac3..a985da8 100644 --- a/exec.c +++ b/exec.c @@ -2629,3 +2629,24 @@ bool cpu_physical_memory_is_io(hwaddr phys_addr) memory_region_is_romd(section->mr)); } #endif + +void qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque) +{ + RAMBlock *block; + + QTAILQ_FOREACH(block, &ram_list.blocks, next) { + func(block->host, block->offset, block->length, opaque); + } +} + +int qemu_ram_count_blocks(void) +{ + RAMBlock *block; + int total = 0; + + QTAILQ_FOREACH(block, &ram_list.blocks, next) { + total++; + } + + return total; +} diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 2e5f11f..aea3fe0 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -119,6 +119,12 @@ extern struct MemoryRegion io_mem_rom; extern struct MemoryRegion io_mem_unassigned; extern struct MemoryRegion io_mem_notdirty; +typedef void (RAMBlockIterFunc)(void *host_addr, + ram_addr_t offset, ram_addr_t length, void *opaque); + +void qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque); +int qemu_ram_count_blocks(void); + #endif #endif /* !CPU_COMMON_H */