Let's reuse qemu_get_guest_simple_memory_mapping(), which does exactly
what we want.
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Claudio Fontana <cfontana@suse.de>
Cc: Thomas Huth <thuth@redhat.com>
Cc: "Alex Bennée" <alex.bennee@linaro.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>
Cc: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
softmmu/memory_mapping.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/softmmu/memory_mapping.c b/softmmu/memory_mapping.c
index e7af276546..d63f896b30 100644
--- a/softmmu/memory_mapping.c
+++ b/softmmu/memory_mapping.c
@@ -288,8 +288,6 @@ void qemu_get_guest_memory_mapping(MemoryMappingList *list,
Error **errp)
{
CPUState *cpu, *first_paging_enabled_cpu;
- GuestPhysBlock *block;
- ram_addr_t offset, length;
first_paging_enabled_cpu = find_paging_enabled_cpu(first_cpu);
if (first_paging_enabled_cpu) {
@@ -309,11 +307,7 @@ void qemu_get_guest_memory_mapping(MemoryMappingList *list,
* If the guest doesn't use paging, the virtual address is equal to physical
* address.
*/
- QTAILQ_FOREACH(block, &guest_phys_blocks->head, next) {
- offset = block->target_start;
- length = block->target_end - block->target_start;
- create_new_memory_mapping(list, offset, offset, length);
- }
+ qemu_get_guest_simple_memory_mapping(list, guest_phys_blocks);
}
void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list,
--
2.31.1
On 7/20/21 9:03 AM, David Hildenbrand wrote:
> Let's reuse qemu_get_guest_simple_memory_mapping(), which does exactly
> what we want.
>
> Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Cc: Igor Mammedov <imammedo@redhat.com>
> Cc: Claudio Fontana <cfontana@suse.de>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: "Alex Bennée" <alex.bennee@linaro.org>
> Cc: Peter Xu <peterx@redhat.com>
> Cc: Laurent Vivier <lvivier@redhat.com>
> Cc: Stefan Berger <stefanb@linux.ibm.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> softmmu/memory_mapping.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/softmmu/memory_mapping.c b/softmmu/memory_mapping.c
> index e7af276546..d63f896b30 100644
> --- a/softmmu/memory_mapping.c
> +++ b/softmmu/memory_mapping.c
> @@ -288,8 +288,6 @@ void qemu_get_guest_memory_mapping(MemoryMappingList *list,
> Error **errp)
> {
> CPUState *cpu, *first_paging_enabled_cpu;
> - GuestPhysBlock *block;
> - ram_addr_t offset, length;
>
> first_paging_enabled_cpu = find_paging_enabled_cpu(first_cpu);
> if (first_paging_enabled_cpu) {
> @@ -309,11 +307,7 @@ void qemu_get_guest_memory_mapping(MemoryMappingList *list,
> * If the guest doesn't use paging, the virtual address is equal to physical
> * address.
> */
> - QTAILQ_FOREACH(block, &guest_phys_blocks->head, next) {
> - offset = block->target_start;
> - length = block->target_end - block->target_start;
> - create_new_memory_mapping(list, offset, offset, length);
> - }
> + qemu_get_guest_simple_memory_mapping(list, guest_phys_blocks);
> }
I thought I'd find a 1:1 replacement for the above here:
void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list,
const GuestPhysBlockList
*guest_phys_blocks)
{
GuestPhysBlock *block;
QTAILQ_FOREACH(block, &guest_phys_blocks->head, next) {
create_new_memory_mapping(list, block->target_start, 0,
block->target_end - block->target_start);
}
}
But this is calling create_new_memory_mapping() with a different 3rd
parameter: 0 vs. offset.
>
> void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list,
On 20.07.21 15:37, Stefan Berger wrote:
>
> On 7/20/21 9:03 AM, David Hildenbrand wrote:
>> Let's reuse qemu_get_guest_simple_memory_mapping(), which does exactly
>> what we want.
>>
>> Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Cc: "Michael S. Tsirkin" <mst@redhat.com>
>> Cc: Eduardo Habkost <ehabkost@redhat.com>
>> Cc: Alex Williamson <alex.williamson@redhat.com>
>> Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
>> Cc: Igor Mammedov <imammedo@redhat.com>
>> Cc: Claudio Fontana <cfontana@suse.de>
>> Cc: Thomas Huth <thuth@redhat.com>
>> Cc: "Alex Bennée" <alex.bennee@linaro.org>
>> Cc: Peter Xu <peterx@redhat.com>
>> Cc: Laurent Vivier <lvivier@redhat.com>
>> Cc: Stefan Berger <stefanb@linux.ibm.com>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
>> softmmu/memory_mapping.c | 8 +-------
>> 1 file changed, 1 insertion(+), 7 deletions(-)
>>
>> diff --git a/softmmu/memory_mapping.c b/softmmu/memory_mapping.c
>> index e7af276546..d63f896b30 100644
>> --- a/softmmu/memory_mapping.c
>> +++ b/softmmu/memory_mapping.c
>> @@ -288,8 +288,6 @@ void qemu_get_guest_memory_mapping(MemoryMappingList *list,
>> Error **errp)
>> {
>> CPUState *cpu, *first_paging_enabled_cpu;
>> - GuestPhysBlock *block;
>> - ram_addr_t offset, length;
>>
>> first_paging_enabled_cpu = find_paging_enabled_cpu(first_cpu);
>> if (first_paging_enabled_cpu) {
>> @@ -309,11 +307,7 @@ void qemu_get_guest_memory_mapping(MemoryMappingList *list,
>> * If the guest doesn't use paging, the virtual address is equal to physical
>> * address.
>> */
>> - QTAILQ_FOREACH(block, &guest_phys_blocks->head, next) {
>> - offset = block->target_start;
>> - length = block->target_end - block->target_start;
>> - create_new_memory_mapping(list, offset, offset, length);
>> - }
>> + qemu_get_guest_simple_memory_mapping(list, guest_phys_blocks);
>> }
>
> I thought I'd find a 1:1 replacement for the above here:
>
> void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list,
> const GuestPhysBlockList
> *guest_phys_blocks)
> {
> GuestPhysBlock *block;
>
> QTAILQ_FOREACH(block, &guest_phys_blocks->head, next) {
> create_new_memory_mapping(list, block->target_start, 0,
> block->target_end - block->target_start);
> }
> }
>
> But this is calling create_new_memory_mapping() with a different 3rd
> parameter: 0 vs. offset.
Oh, thanks for noticing! Will drop this patch then -- thanks!
--
Thanks,
David / dhildenb
© 2016 - 2026 Red Hat, Inc.