*/
#include "qemu/osdep.h"
-#include <glib.h>
+#include "qapi/error.h"
-#include "qemu-common.h"
#include "cpu.h"
#include "sysemu/memory_mapping.h"
#include "exec/memory.h"
QTAILQ_FOREACH_SAFE(p, &list->head, next, q) {
QTAILQ_REMOVE(&list->head, p, next);
+ memory_region_unref(p->mr);
g_free(p);
}
list->num = 0;
/* we only care about RAM */
if (!memory_region_is_ram(section->mr) ||
- memory_region_is_skip_dump(section->mr)) {
+ memory_region_is_ram_device(section->mr) ||
+ memory_region_is_nonvolatile(section->mr)) {
return;
}
if (!QTAILQ_EMPTY(&g->list->head)) {
hwaddr predecessor_size;
- predecessor = QTAILQ_LAST(&g->list->head, GuestPhysBlockHead);
+ predecessor = QTAILQ_LAST(&g->list->head);
predecessor_size = predecessor->target_end - predecessor->target_start;
/* the memory API guarantees monotonically increasing traversal */
block->target_start = target_start;
block->target_end = target_end;
block->host_addr = host_addr;
+ block->mr = section->mr;
+ memory_region_ref(section->mr);
QTAILQ_INSERT_TAIL(&g->list->head, block, next);
++g->list->num;
#ifdef DEBUG_GUEST_PHYS_REGION_ADD
fprintf(stderr, "%s: target_start=" TARGET_FMT_plx " target_end="
- TARGET_FMT_plx ": %s (count: %u)\n", __FUNCTION__, target_start,
+ TARGET_FMT_plx ": %s (count: %u)\n", __func__, target_start,
target_end, predecessor ? "joined" : "added", g->list->num);
#endif
}
if (cur->phys_addr >= begin + length ||
cur->phys_addr + cur->length <= begin) {
QTAILQ_REMOVE(&list->head, cur, next);
+ g_free(cur);
list->num--;
continue;
}