memory_mapping: Improve qemu_get_guest_memory_mapping() error reporting

Pass any Error out into dump_init() and have it actually stop on errors.
Whether it is unsupported on a certain CPU can be checked by looking for
a NULL CPUClass::get_memory_mapping field.

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
[AF: Reverted changes to CPU loops]
Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
Andreas Färber 2013-05-29 21:54:03 +02:00
parent 1b3509ca5b
commit 11ed09cf07
3 changed files with 11 additions and 14 deletions

7
dump.c
View File

@ -707,6 +707,7 @@ static int dump_init(DumpState *s, int fd, bool paging, bool has_filter,
{ {
CPUArchState *env; CPUArchState *env;
int nr_cpus; int nr_cpus;
Error *err = NULL;
int ret; int ret;
if (runstate_is_running()) { if (runstate_is_running()) {
@ -757,7 +758,11 @@ static int dump_init(DumpState *s, int fd, bool paging, bool has_filter,
/* get memory mapping */ /* get memory mapping */
memory_mapping_list_init(&s->list); memory_mapping_list_init(&s->list);
if (paging) { if (paging) {
qemu_get_guest_memory_mapping(&s->list); qemu_get_guest_memory_mapping(&s->list, &err);
if (err != NULL) {
error_propagate(errp, err);
goto cleanup;
}
} else { } else {
qemu_get_guest_simple_memory_mapping(&s->list); qemu_get_guest_simple_memory_mapping(&s->list);
} }

View File

@ -45,13 +45,7 @@ void memory_mapping_list_free(MemoryMappingList *list);
void memory_mapping_list_init(MemoryMappingList *list); void memory_mapping_list_init(MemoryMappingList *list);
/* void qemu_get_guest_memory_mapping(MemoryMappingList *list, Error **errp);
* Return value:
* 0: success
* -1: failed
* -2: unsupported
*/
int qemu_get_guest_memory_mapping(MemoryMappingList *list);
/* get guest's memory mapping without do paging(virtual address is 0). */ /* get guest's memory mapping without do paging(virtual address is 0). */
void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list); void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list);

View File

@ -178,7 +178,7 @@ static CPUArchState *find_paging_enabled_cpu(CPUArchState *start_cpu)
return NULL; return NULL;
} }
int qemu_get_guest_memory_mapping(MemoryMappingList *list) void qemu_get_guest_memory_mapping(MemoryMappingList *list, Error **errp)
{ {
CPUArchState *env, *first_paging_enabled_cpu; CPUArchState *env, *first_paging_enabled_cpu;
RAMBlock *block; RAMBlock *block;
@ -190,11 +190,11 @@ int qemu_get_guest_memory_mapping(MemoryMappingList *list)
Error *err = NULL; Error *err = NULL;
cpu_get_memory_mapping(ENV_GET_CPU(env), list, &err); cpu_get_memory_mapping(ENV_GET_CPU(env), list, &err);
if (err) { if (err) {
error_free(err); error_propagate(errp, err);
return -1; return;
} }
} }
return 0; return;
} }
/* /*
@ -206,8 +206,6 @@ int qemu_get_guest_memory_mapping(MemoryMappingList *list)
length = block->length; length = block->length;
create_new_memory_mapping(list, offset, offset, length); create_new_memory_mapping(list, offset, offset, length);
} }
return 0;
} }
void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list) void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list)