diff options
Diffstat (limited to 'softmmu')
-rw-r--r-- | softmmu/memory.c | 61 | ||||
-rw-r--r-- | softmmu/meson.build | 5 | ||||
-rw-r--r-- | softmmu/physmem.c | 1 | ||||
-rw-r--r-- | softmmu/qtest.c | 1 | ||||
-rw-r--r-- | softmmu/runstate.c | 3 | ||||
-rw-r--r-- | softmmu/vl.c | 1 |
6 files changed, 54 insertions, 18 deletions
diff --git a/softmmu/memory.c b/softmmu/memory.c index 678dc62..8060c6d 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -2790,19 +2790,32 @@ void memory_global_after_dirty_log_sync(void) MEMORY_LISTENER_CALL_GLOBAL(log_global_after_sync, Forward); } +/* + * Dirty track stop flags that are postponed due to VM being stopped. Should + * only be used within vmstate_change hook. + */ +static unsigned int postponed_stop_flags; static VMChangeStateEntry *vmstate_change; +static void memory_global_dirty_log_stop_postponed_run(void); void memory_global_dirty_log_start(unsigned int flags) { - unsigned int old_flags = global_dirty_tracking; + unsigned int old_flags; + + assert(flags && !(flags & (~GLOBAL_DIRTY_MASK))); if (vmstate_change) { - qemu_del_vm_change_state_handler(vmstate_change); - vmstate_change = NULL; + /* If there is postponed stop(), operate on it first */ + postponed_stop_flags &= ~flags; + memory_global_dirty_log_stop_postponed_run(); } - assert(flags && !(flags & (~GLOBAL_DIRTY_MASK))); - assert(!(global_dirty_tracking & flags)); + flags &= ~global_dirty_tracking; + if (!flags) { + return; + } + + old_flags = global_dirty_tracking; global_dirty_tracking |= flags; trace_global_dirty_changed(global_dirty_tracking); @@ -2830,29 +2843,45 @@ static void memory_global_dirty_log_do_stop(unsigned int flags) } } +/* + * Execute the postponed dirty log stop operations if there is, then reset + * everything (including the flags and the vmstate change hook). + */ +static void memory_global_dirty_log_stop_postponed_run(void) +{ + /* This must be called with the vmstate handler registered */ + assert(vmstate_change); + + /* Note: postponed_stop_flags can be cleared in log start routine */ + if (postponed_stop_flags) { + memory_global_dirty_log_do_stop(postponed_stop_flags); + postponed_stop_flags = 0; + } + + qemu_del_vm_change_state_handler(vmstate_change); + vmstate_change = NULL; +} + static void memory_vm_change_state_handler(void *opaque, bool running, RunState state) { - unsigned int flags = (unsigned int)(uintptr_t)opaque; if (running) { - memory_global_dirty_log_do_stop(flags); - - if (vmstate_change) { - qemu_del_vm_change_state_handler(vmstate_change); - vmstate_change = NULL; - } + memory_global_dirty_log_stop_postponed_run(); } } void memory_global_dirty_log_stop(unsigned int flags) { if (!runstate_is_running()) { + /* Postpone the dirty log stop, e.g., to when VM starts again */ if (vmstate_change) { - return; + /* Batch with previous postponed flags */ + postponed_stop_flags |= flags; + } else { + postponed_stop_flags = flags; + vmstate_change = qemu_add_vm_change_state_handler( + memory_vm_change_state_handler, NULL); } - vmstate_change = qemu_add_vm_change_state_handler( - memory_vm_change_state_handler, - (void *)(uintptr_t)flags); return; } diff --git a/softmmu/meson.build b/softmmu/meson.build index d8e0301..39f766c 100644 --- a/softmmu/meson.build +++ b/softmmu/meson.build @@ -27,6 +27,9 @@ softmmu_ss.add(files( 'qdev-monitor.c', ), sdl, libpmem, libdaxctl) -softmmu_ss.add(when: 'CONFIG_TPM', if_true: files('tpm.c')) +if have_tpm + softmmu_ss.add(files('tpm.c')) +endif + softmmu_ss.add(when: seccomp, if_true: files('qemu-seccomp.c')) softmmu_ss.add(when: fdt, if_true: files('device_tree.c')) diff --git a/softmmu/physmem.c b/softmmu/physmem.c index dddf70e..a13289a 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -23,6 +23,7 @@ #include "qemu/cutils.h" #include "qemu/cacheflush.h" +#include "qemu/madvise.h" #ifdef CONFIG_TCG #include "hw/core/tcg-cpu-ops.h" diff --git a/softmmu/qtest.c b/softmmu/qtest.c index 72751e1..8b7cb6a 100644 --- a/softmmu/qtest.c +++ b/softmmu/qtest.c @@ -19,6 +19,7 @@ #include "chardev/char-fe.h" #include "exec/ioport.h" #include "exec/memory.h" +#include "hw/qdev-core.h" #include "hw/irq.h" #include "qemu/accel.h" #include "sysemu/cpu-timers.h" diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 10d9b73..e0d869b 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -30,7 +30,6 @@ #include "crypto/cipher.h" #include "crypto/init.h" #include "exec/cpu-common.h" -#include "exec/exec-all.h" #include "exec/gdbstub.h" #include "hw/boards.h" #include "migration/misc.h" @@ -43,7 +42,9 @@ #include "qapi/qapi-events-run-state.h" #include "qemu-common.h" #include "qemu/error-report.h" +#include "qemu/log.h" #include "qemu/job.h" +#include "qemu/log.h" #include "qemu/module.h" #include "qemu/plugin.h" #include "qemu/sockets.h" diff --git a/softmmu/vl.c b/softmmu/vl.c index 5e1b35b..1fe0288 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -36,6 +36,7 @@ #include "qemu-version.h" #include "qemu/cutils.h" #include "qemu/help_option.h" +#include "qemu/hw-version.h" #include "qemu/uuid.h" #include "sysemu/reset.h" #include "sysemu/runstate.h" |