diff mbox

[RFC,RDMA,support,v4:,04/10] iterators for getting the RAMBlocks

Message ID 1363576743-6146-5-git-send-email-mrhines@linux.vnet.ibm.com
State New
Headers show

Commit Message

mrhines@linux.vnet.ibm.com March 18, 2013, 3:18 a.m. UTC
From: "Michael R. Hines" <mrhines@us.ibm.com>

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 <mrhines@us.ibm.com>
---
 exec.c                    |   21 +++++++++++++++++++++
 include/exec/cpu-common.h |    6 ++++++
 2 files changed, 27 insertions(+)

Comments

Paolo Bonzini March 18, 2013, 8:48 a.m. UTC | #1
Il 18/03/2013 04:18, mrhines@linux.vnet.ibm.com ha scritto:
> From: "Michael R. Hines" <mrhines@us.ibm.com>
> 
> 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 <mrhines@us.ibm.com>
> ---
>  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++;
> +    }

Please move this to rdma.c, and implement it using qemu_ram_foreach_block.

Otherwise looks good.

Paolo

> +    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 */
>
mrhines@linux.vnet.ibm.com March 18, 2013, 8:25 p.m. UTC | #2
Acnkowledged.

On 03/18/2013 04:48 AM, Paolo Bonzini wrote:
> Il 18/03/2013 04:18, mrhines@linux.vnet.ibm.com ha scritto:
>> From: "Michael R. Hines" <mrhines@us.ibm.com>
>>
>> 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 <mrhines@us.ibm.com>
>> ---
>>   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++;
>> +    }
> Please move this to rdma.c, and implement it using qemu_ram_foreach_block.
>
> Otherwise looks good.
>
> Paolo
>
>> +    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 */
>>
>
diff mbox

Patch

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 */