diff --git a/dump.c b/dump.c index ce646bcc51..71d3e946e6 100644 --- a/dump.c +++ b/dump.c @@ -71,18 +71,14 @@ uint64_t cpu_to_dump64(DumpState *s, uint64_t val) static int dump_cleanup(DumpState *s) { - int ret = 0; - guest_phys_blocks_free(&s->guest_phys_blocks); memory_mapping_list_free(&s->list); - if (s->fd != -1) { - close(s->fd); - } + close(s->fd); if (s->resume) { vm_start(); } - return ret; + return 0; } static void dump_error(DumpState *s, const char *reason) @@ -1499,6 +1495,8 @@ static int dump_init(DumpState *s, int fd, bool has_format, s->begin = begin; s->length = length; + memory_mapping_list_init(&s->list); + guest_phys_blocks_init(&s->guest_phys_blocks); guest_phys_blocks_append(&s->guest_phys_blocks); @@ -1526,7 +1524,6 @@ static int dump_init(DumpState *s, int fd, bool has_format, } /* get memory mapping */ - memory_mapping_list_init(&s->list); if (paging) { qemu_get_guest_memory_mapping(&s->list, &s->guest_phys_blocks, &err); if (err != NULL) { @@ -1622,12 +1619,7 @@ static int dump_init(DumpState *s, int fd, bool has_format, return 0; cleanup: - guest_phys_blocks_free(&s->guest_phys_blocks); - - if (s->resume) { - vm_start(); - } - + dump_cleanup(s); return -1; } diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 3d6929d6cd..78a5fc8197 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -64,7 +64,7 @@ AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id, Error **errp); int monitor_fdset_get_fd(int64_t fdset_id, int flags); int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd); -int monitor_fdset_dup_fd_remove(int dup_fd); +void monitor_fdset_dup_fd_remove(int dup_fd); int monitor_fdset_dup_fd_find(int dup_fd); #endif /* !MONITOR_H */ diff --git a/monitor.c b/monitor.c index cdbaa60f98..34cee74eb3 100644 --- a/monitor.c +++ b/monitor.c @@ -2542,8 +2542,10 @@ static int monitor_fdset_dup_fd_find_remove(int dup_fd, bool remove) if (QLIST_EMPTY(&mon_fdset->dup_fds)) { monitor_fdset_cleanup(mon_fdset); } + return -1; + } else { + return mon_fdset->id; } - return mon_fdset->id; } } } @@ -2555,9 +2557,9 @@ int monitor_fdset_dup_fd_find(int dup_fd) return monitor_fdset_dup_fd_find_remove(dup_fd, false); } -int monitor_fdset_dup_fd_remove(int dup_fd) +void monitor_fdset_dup_fd_remove(int dup_fd) { - return monitor_fdset_dup_fd_find_remove(dup_fd, true); + monitor_fdset_dup_fd_find_remove(dup_fd, true); } int monitor_handle_fd_param(Monitor *mon, const char *fdname) @@ -4521,16 +4523,15 @@ void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str) void watchdog_action_completion(ReadLineState *rs, int nb_args, const char *str) { + int i; + if (nb_args != 2) { return; } readline_set_completion_index(rs, strlen(str)); - add_completion_option(rs, str, "reset"); - add_completion_option(rs, str, "shutdown"); - add_completion_option(rs, str, "poweroff"); - add_completion_option(rs, str, "pause"); - add_completion_option(rs, str, "debug"); - add_completion_option(rs, str, "none"); + for (i = 0; WatchdogExpirationAction_lookup[i]; i++) { + add_completion_option(rs, str, WatchdogExpirationAction_lookup[i]); + } } void migrate_set_capability_completion(ReadLineState *rs, int nb_args, diff --git a/stubs/fdset-remove-fd.c b/stubs/fdset-remove-fd.c index b3886d9f45..7f6d61e619 100644 --- a/stubs/fdset-remove-fd.c +++ b/stubs/fdset-remove-fd.c @@ -1,7 +1,6 @@ #include "qemu-common.h" #include "monitor/monitor.h" -int monitor_fdset_dup_fd_remove(int dupfd) +void monitor_fdset_dup_fd_remove(int dupfd) { - return -1; }