]> git.proxmox.com Git - qemu.git/commitdiff
memory_mapping: Improve qemu_get_guest_memory_mapping() error reporting
authorAndreas Färber <afaerber@suse.de>
Wed, 29 May 2013 19:54:03 +0000 (21:54 +0200)
committerAndreas Färber <afaerber@suse.de>
Tue, 11 Jun 2013 17:38:13 +0000 (19:38 +0200)
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>
dump.c
include/sysemu/memory_mapping.h
memory_mapping.c

diff --git a/dump.c b/dump.c
index 87ca12cee0379b417571308113f1541fff8e8842..44a1339c8a6fdb9ade12a6e7b7df70b497d53bf5 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -707,6 +707,7 @@ static int dump_init(DumpState *s, int fd, bool paging, bool has_filter,
 {
     CPUArchState *env;
     int nr_cpus;
+    Error *err = NULL;
     int ret;
 
     if (runstate_is_running()) {
@@ -757,7 +758,11 @@ static int dump_init(DumpState *s, int fd, bool paging, bool has_filter,
     /* get memory mapping */
     memory_mapping_list_init(&s->list);
     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 {
         qemu_get_guest_simple_memory_mapping(&s->list);
     }
index c47e6ee1fd1dd1baaf9cd72c1aa9b6ef91d8f882..6dfb68ddcdba13912f5fb5e34400a9051dd67545 100644 (file)
@@ -45,13 +45,7 @@ void memory_mapping_list_free(MemoryMappingList *list);
 
 void memory_mapping_list_init(MemoryMappingList *list);
 
-/*
- * Return value:
- *    0: success
- *   -1: failed
- *   -2: unsupported
- */
-int qemu_get_guest_memory_mapping(MemoryMappingList *list);
+void qemu_get_guest_memory_mapping(MemoryMappingList *list, Error **errp);
 
 /* get guest's memory mapping without do paging(virtual address is 0). */
 void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list);
index 9bd24cecd259dfc79e4187aad665342abc722001..5634f813cd8442b9f788f87b215c8aed251d74eb 100644 (file)
@@ -178,7 +178,7 @@ static CPUArchState *find_paging_enabled_cpu(CPUArchState *start_cpu)
     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;
     RAMBlock *block;
@@ -190,11 +190,11 @@ int qemu_get_guest_memory_mapping(MemoryMappingList *list)
             Error *err = NULL;
             cpu_get_memory_mapping(ENV_GET_CPU(env), list, &err);
             if (err) {
-                error_free(err);
-                return -1;
+                error_propagate(errp, err);
+                return;
             }
         }
-        return 0;
+        return;
     }
 
     /*
@@ -206,8 +206,6 @@ int qemu_get_guest_memory_mapping(MemoryMappingList *list)
         length = block->length;
         create_new_memory_mapping(list, offset, offset, length);
     }
-
-    return 0;
 }
 
 void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list)