* [Qemu-devel] [PULL 27/28] replay: vmstate for replay module
2016-09-26 13:40 [Qemu-devel] [PULL " Paolo Bonzini
@ 2016-09-26 13:40 ` Paolo Bonzini
0 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2016-09-26 13:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Pavel Dovgalyuk
From: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
This patch introduces vmstate for replay data structures.
It allows saving and loading vmstate while replaying.
Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
Message-Id: <20160926080810.6992.68420.stgit@PASHA-ISP>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
replay/Makefile.objs | 1 +
replay/replay-internal.h | 9 ++++++++
replay/replay-snapshot.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
replay/replay.c | 1 +
4 files changed, 71 insertions(+)
create mode 100644 replay/replay-snapshot.c
diff --git a/replay/Makefile.objs b/replay/Makefile.objs
index fcb3f74..c8ad3eb 100644
--- a/replay/Makefile.objs
+++ b/replay/Makefile.objs
@@ -4,3 +4,4 @@ common-obj-y += replay-events.o
common-obj-y += replay-time.o
common-obj-y += replay-input.o
common-obj-y += replay-char.o
+common-obj-y += replay-snapshot.o
diff --git a/replay/replay-internal.h b/replay/replay-internal.h
index 9b02d7d..e07eb7d 100644
--- a/replay/replay-internal.h
+++ b/replay/replay-internal.h
@@ -66,6 +66,8 @@ typedef struct ReplayState {
unsigned int data_kind;
/*! Flag which indicates that event is not processed yet. */
unsigned int has_unread_data;
+ /*! Temporary variable for saving current log offset. */
+ uint64_t file_offset;
} ReplayState;
extern ReplayState replay_state;
@@ -157,4 +159,11 @@ void replay_event_char_read_save(void *opaque);
/*! Reads char event read from the file. */
void *replay_event_char_read_load(void);
+/* VMState-related functions */
+
+/* Registers replay VMState.
+ Should be called before virtual devices initialization
+ to make cached timers available for post_load functions. */
+void replay_vmstate_register(void);
+
#endif
diff --git a/replay/replay-snapshot.c b/replay/replay-snapshot.c
new file mode 100644
index 0000000..bd95dcd
--- /dev/null
+++ b/replay/replay-snapshot.c
@@ -0,0 +1,60 @@
+/*
+ * replay-snapshot.c
+ *
+ * Copyright (c) 2010-2016 Institute for System Programming
+ * of the Russian Academy of Sciences.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "qemu-common.h"
+#include "sysemu/replay.h"
+#include "replay-internal.h"
+#include "sysemu/sysemu.h"
+#include "monitor/monitor.h"
+#include "qapi/qmp/qstring.h"
+#include "qemu/error-report.h"
+#include "migration/vmstate.h"
+
+static void replay_pre_save(void *opaque)
+{
+ ReplayState *state = opaque;
+ state->file_offset = ftello64(replay_file);
+}
+
+static int replay_post_load(void *opaque, int version_id)
+{
+ ReplayState *state = opaque;
+ fseeko64(replay_file, state->file_offset, SEEK_SET);
+ /* If this was a vmstate, saved in recording mode,
+ we need to initialize replay data fields. */
+ replay_fetch_data_kind();
+
+ return 0;
+}
+
+static const VMStateDescription vmstate_replay = {
+ .name = "replay",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .pre_save = replay_pre_save,
+ .post_load = replay_post_load,
+ .fields = (VMStateField[]) {
+ VMSTATE_INT64_ARRAY(cached_clock, ReplayState, REPLAY_CLOCK_COUNT),
+ VMSTATE_UINT64(current_step, ReplayState),
+ VMSTATE_INT32(instructions_count, ReplayState),
+ VMSTATE_UINT32(data_kind, ReplayState),
+ VMSTATE_UINT32(has_unread_data, ReplayState),
+ VMSTATE_UINT64(file_offset, ReplayState),
+ VMSTATE_END_OF_LIST()
+ },
+};
+
+void replay_vmstate_register(void)
+{
+ vmstate_register(NULL, 0, &vmstate_replay, &replay_state);
+}
diff --git a/replay/replay.c b/replay/replay.c
index cc2238d..c797aea 100644
--- a/replay/replay.c
+++ b/replay/replay.c
@@ -292,6 +292,7 @@ void replay_configure(QemuOpts *opts)
exit(1);
}
+ replay_vmstate_register();
replay_enable(fname, mode);
out:
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PULL v2 00/28] Misc patches for 2016-09-26
@ 2016-09-28 19:43 Paolo Bonzini
2016-09-28 19:43 ` [Qemu-devel] [PULL 02/28] memory: introduce IOMMUOps.notify_flag_changed Paolo Bonzini
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Paolo Bonzini @ 2016-09-28 19:43 UTC (permalink / raw)
To: qemu-devel
The following changes since commit 7cfdc02dae0d2ff58c897496cfdbbafc0eda0f3f:
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2016-09-26 19:47:00 +0100)
are available in the git repository at:
git://github.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to 6d0ceb80ffe18ad4b28aab7356f440636c0be7be:
replay: allow replay stopping and restarting (2016-09-27 11:57:30 +0200)
----------------------------------------------------------------
* thread-safe tb_flush (Fred, Alex, Sergey, me, Richard, Emilio,... :-)
* license clarification for compiler.h (Felipe)
* glib cflags improvement (Marc-André)
* checkpatch silencing (Paolo)
* SMRAM migration fix (Paolo)
* Replay improvements (Pavel)
* IOMMU notifier improvements (Peter)
* IOAPIC now defaults to version 0x20 (Peter)
----------------------------------------------------------------
Alex Bennée (1):
cpus: pass CPUState to run_on_cpu helpers
Felipe Franciosi (1):
compiler: Swap 'public domain' header for license
Marc-André Lureau (2):
build-sys: remove unused GLIB_CFLAGS
build-sys: put glib_cflags in QEMU_CFLAGS
Paolo Bonzini (11):
checkpatch: downgrade "architecture specific defines should be avoided"
migration: sync all address spaces
cpus-common: move CPU list management to common code
cpus-common: fix uninitialized variable use in run_on_cpu
cpus-common: move exclusive work infrastructure from linux-user
docs: include formal model for TCG exclusive sections
cpus-common: always defer async_run_on_cpu work items
cpus-common: remove redundant call to exclusive_idle()
cpus-common: simplify locking for start_exclusive/end_exclusive
cpus-common: Introduce async_safe_run_on_cpu()
cpus-common: lock-free fast path for cpu_exec_start/end
Pavel Dovgalyuk (3):
replay: move internal data to the structure
replay: vmstate for replay module
replay: allow replay stopping and restarting
Peter Xu (4):
memory: introduce IOMMUNotifier and its caps
memory: introduce IOMMUOps.notify_flag_changed
intel_iommu, amd_iommu: allow UNMAP notifiers
x86: ioapic: boost default version to 0x20
Sergey Fedorov (6):
cpus: Move common code out of {async_, }run_on_cpu()
cpus: Rename flush_queued_work()
linux-user: Use QemuMutex and QemuCond
linux-user: Add qemu_cpu_is_self() and qemu_cpu_kick()
cpus-common: move CPU work item management to common code
tcg: Make tb_flush() thread safe
Makefile.objs | 2 +-
block/blkreplay.c | 15 +-
bsd-user/main.c | 33 +---
configure | 3 +-
cpu-exec.c | 12 +-
cpus-common.c | 352 ++++++++++++++++++++++++++++++++++++++++++
cpus.c | 100 +-----------
docs/tcg-exclusive.promela | 225 +++++++++++++++++++++++++++
exec.c | 37 +----
hw/i386/amd_iommu.c | 16 +-
hw/i386/intel_iommu.c | 18 ++-
hw/i386/kvm/apic.c | 5 +-
hw/i386/kvmvapic.c | 6 +-
hw/intc/ioapic.c | 2 +-
hw/ppc/ppce500_spin.c | 31 ++--
hw/ppc/spapr.c | 6 +-
hw/ppc/spapr_hcall.c | 17 +-
hw/ppc/spapr_iommu.c | 18 ++-
hw/vfio/common.c | 4 +-
include/exec/cpu-common.h | 5 +
include/exec/exec-all.h | 11 --
include/exec/memory.h | 63 ++++++--
include/exec/tb-context.h | 2 +-
include/hw/compat.h | 4 +
include/hw/vfio/vfio-common.h | 2 +-
include/qemu/compiler.h | 6 +-
include/qom/cpu.h | 102 ++++++++++--
include/sysemu/replay.h | 4 +
kvm-all.c | 21 +--
linux-user/main.c | 130 +++++-----------
memory.c | 106 +++++++++----
migration/ram.c | 2 +-
replay/Makefile.objs | 1 +
replay/replay-events.c | 10 +-
replay/replay-internal.c | 20 ++-
replay/replay-internal.h | 23 ++-
replay/replay-snapshot.c | 61 ++++++++
replay/replay-time.c | 2 +-
replay/replay.c | 16 +-
scripts/checkpatch.pl | 2 +-
stubs/replay.c | 5 +
target-i386/helper.c | 19 +--
target-i386/kvm.c | 6 +-
target-s390x/cpu.c | 4 +-
target-s390x/cpu.h | 7 +-
target-s390x/kvm.c | 98 ++++++------
target-s390x/misc_helper.c | 4 +-
translate-all.c | 38 +++--
vl.c | 2 +
49 files changed, 1157 insertions(+), 521 deletions(-)
create mode 100644 cpus-common.c
create mode 100644 docs/tcg-exclusive.promela
create mode 100644 replay/replay-snapshot.c
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PULL 02/28] memory: introduce IOMMUOps.notify_flag_changed
2016-09-28 19:43 [Qemu-devel] [PULL v2 00/28] Misc patches for 2016-09-26 Paolo Bonzini
@ 2016-09-28 19:43 ` Paolo Bonzini
2016-09-28 19:43 ` [Qemu-devel] [PULL 03/28] intel_iommu, amd_iommu: allow UNMAP notifiers Paolo Bonzini
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2016-09-28 19:43 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Xu
From: Peter Xu <peterx@redhat.com>
The new interface can be used to replace the old notify_started() and
notify_stopped(). Meanwhile it provides explicit flags so that IOMMUs
can know what kind of notifications it is requested for.
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <1474606948-14391-3-git-send-email-peterx@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/i386/amd_iommu.c | 6 ++++--
hw/i386/intel_iommu.c | 6 ++++--
hw/ppc/spapr_iommu.c | 18 ++++++++++--------
include/exec/memory.h | 9 +++++----
memory.c | 29 +++++++++++++++++++++--------
5 files changed, 44 insertions(+), 24 deletions(-)
diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index a91a179..a868539 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -1066,7 +1066,9 @@ static const MemoryRegionOps mmio_mem_ops = {
}
};
-static void amdvi_iommu_notify_started(MemoryRegion *iommu)
+static void amdvi_iommu_notify_flag_changed(MemoryRegion *iommu,
+ IOMMUNotifierFlag old,
+ IOMMUNotifierFlag new)
{
AMDVIAddressSpace *as = container_of(iommu, AMDVIAddressSpace, iommu);
@@ -1080,7 +1082,7 @@ static void amdvi_init(AMDVIState *s)
amdvi_iotlb_reset(s);
s->iommu_ops.translate = amdvi_translate;
- s->iommu_ops.notify_started = amdvi_iommu_notify_started;
+ s->iommu_ops.notify_flag_changed = amdvi_iommu_notify_flag_changed;
s->devtab_len = 0;
s->cmdbuf_len = 0;
s->cmdbuf_head = 0;
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index d6e02c8..b6cc38c 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -1974,7 +1974,9 @@ static IOMMUTLBEntry vtd_iommu_translate(MemoryRegion *iommu, hwaddr addr,
return ret;
}
-static void vtd_iommu_notify_started(MemoryRegion *iommu)
+static void vtd_iommu_notify_flag_changed(MemoryRegion *iommu,
+ IOMMUNotifierFlag old,
+ IOMMUNotifierFlag new)
{
VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
@@ -2348,7 +2350,7 @@ static void vtd_init(IntelIOMMUState *s)
memset(s->womask, 0, DMAR_REG_SIZE);
s->iommu_ops.translate = vtd_iommu_translate;
- s->iommu_ops.notify_started = vtd_iommu_notify_started;
+ s->iommu_ops.notify_flag_changed = vtd_iommu_notify_flag_changed;
s->root = 0;
s->root_extended = false;
s->dmar_enabled = false;
diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c
index f20b0b8..ae30bbe 100644
--- a/hw/ppc/spapr_iommu.c
+++ b/hw/ppc/spapr_iommu.c
@@ -156,14 +156,17 @@ static uint64_t spapr_tce_get_min_page_size(MemoryRegion *iommu)
return 1ULL << tcet->page_shift;
}
-static void spapr_tce_notify_started(MemoryRegion *iommu)
+static void spapr_tce_notify_flag_changed(MemoryRegion *iommu,
+ IOMMUNotifierFlag old,
+ IOMMUNotifierFlag new)
{
- spapr_tce_set_need_vfio(container_of(iommu, sPAPRTCETable, iommu), true);
-}
+ struct sPAPRTCETable *tbl = container_of(iommu, sPAPRTCETable, iommu);
-static void spapr_tce_notify_stopped(MemoryRegion *iommu)
-{
- spapr_tce_set_need_vfio(container_of(iommu, sPAPRTCETable, iommu), false);
+ if (old == IOMMU_NOTIFIER_NONE && new != IOMMU_NOTIFIER_NONE) {
+ spapr_tce_set_need_vfio(tbl, true);
+ } else if (old != IOMMU_NOTIFIER_NONE && new == IOMMU_NOTIFIER_NONE) {
+ spapr_tce_set_need_vfio(tbl, false);
+ }
}
static int spapr_tce_table_post_load(void *opaque, int version_id)
@@ -246,8 +249,7 @@ static const VMStateDescription vmstate_spapr_tce_table = {
static MemoryRegionIOMMUOps spapr_iommu_ops = {
.translate = spapr_tce_translate_iommu,
.get_min_page_size = spapr_tce_get_min_page_size,
- .notify_started = spapr_tce_notify_started,
- .notify_stopped = spapr_tce_notify_stopped,
+ .notify_flag_changed = spapr_tce_notify_flag_changed,
};
static int spapr_tce_table_realize(DeviceState *dev)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 14cda67..a3f988b 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -174,10 +174,10 @@ struct MemoryRegionIOMMUOps {
IOMMUTLBEntry (*translate)(MemoryRegion *iommu, hwaddr addr, bool is_write);
/* Returns minimum supported page size */
uint64_t (*get_min_page_size)(MemoryRegion *iommu);
- /* Called when the first notifier is set */
- void (*notify_started)(MemoryRegion *iommu);
- /* Called when the last notifier is removed */
- void (*notify_stopped)(MemoryRegion *iommu);
+ /* Called when IOMMU Notifier flag changed */
+ void (*notify_flag_changed)(MemoryRegion *iommu,
+ IOMMUNotifierFlag old_flags,
+ IOMMUNotifierFlag new_flags);
};
typedef struct CoalescedMemoryRange CoalescedMemoryRange;
@@ -223,6 +223,7 @@ struct MemoryRegion {
unsigned ioeventfd_nb;
MemoryRegionIoeventfd *ioeventfds;
QLIST_HEAD(, IOMMUNotifier) iommu_notify;
+ IOMMUNotifierFlag iommu_notify_flags;
};
/**
diff --git a/memory.c b/memory.c
index 69d9d9a..27a3f2f 100644
--- a/memory.c
+++ b/memory.c
@@ -1414,6 +1414,7 @@ void memory_region_init_iommu(MemoryRegion *mr,
mr->iommu_ops = ops,
mr->terminates = true; /* then re-forwards */
QLIST_INIT(&mr->iommu_notify);
+ mr->iommu_notify_flags = IOMMU_NOTIFIER_NONE;
}
static void memory_region_finalize(Object *obj)
@@ -1508,16 +1509,31 @@ bool memory_region_is_logging(MemoryRegion *mr, uint8_t client)
return memory_region_get_dirty_log_mask(mr) & (1 << client);
}
+static void memory_region_update_iommu_notify_flags(MemoryRegion *mr)
+{
+ IOMMUNotifierFlag flags = IOMMU_NOTIFIER_NONE;
+ IOMMUNotifier *iommu_notifier;
+
+ QLIST_FOREACH(iommu_notifier, &mr->iommu_notify, node) {
+ flags |= iommu_notifier->notifier_flags;
+ }
+
+ if (flags != mr->iommu_notify_flags &&
+ mr->iommu_ops->notify_flag_changed) {
+ mr->iommu_ops->notify_flag_changed(mr, mr->iommu_notify_flags,
+ flags);
+ }
+
+ mr->iommu_notify_flags = flags;
+}
+
void memory_region_register_iommu_notifier(MemoryRegion *mr,
IOMMUNotifier *n)
{
/* We need to register for at least one bitfield */
assert(n->notifier_flags != IOMMU_NOTIFIER_NONE);
- if (mr->iommu_ops->notify_started &&
- QLIST_EMPTY(&mr->iommu_notify)) {
- mr->iommu_ops->notify_started(mr);
- }
QLIST_INSERT_HEAD(&mr->iommu_notify, n, node);
+ memory_region_update_iommu_notify_flags(mr);
}
uint64_t memory_region_iommu_get_min_page_size(MemoryRegion *mr)
@@ -1555,10 +1571,7 @@ void memory_region_unregister_iommu_notifier(MemoryRegion *mr,
IOMMUNotifier *n)
{
QLIST_REMOVE(n, node);
- if (mr->iommu_ops->notify_stopped &&
- QLIST_EMPTY(&mr->iommu_notify)) {
- mr->iommu_ops->notify_stopped(mr);
- }
+ memory_region_update_iommu_notify_flags(mr);
}
void memory_region_notify_iommu(MemoryRegion *mr,
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PULL 03/28] intel_iommu, amd_iommu: allow UNMAP notifiers
2016-09-28 19:43 [Qemu-devel] [PULL v2 00/28] Misc patches for 2016-09-26 Paolo Bonzini
2016-09-28 19:43 ` [Qemu-devel] [PULL 02/28] memory: introduce IOMMUOps.notify_flag_changed Paolo Bonzini
@ 2016-09-28 19:43 ` Paolo Bonzini
2016-09-28 19:43 ` [Qemu-devel] [PULL 27/28] replay: vmstate for replay module Paolo Bonzini
2016-09-28 23:33 ` [Qemu-devel] [PULL v2 00/28] Misc patches for 2016-09-26 Peter Maydell
3 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2016-09-28 19:43 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Xu
From: Peter Xu <peterx@redhat.com>
x86 vIOMMUs still lack of a complete IOMMU notifier mechanism.
Before that is achieved, let's open a door for vhost DMAR support,
which only requires cache invalidations (UNMAP operations).
Meanwhile, convert hw_error() to error_report() and exit(1), to make
the error messages cleaner and obvious (no CPU registers will be dumped).
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <1474606948-14391-4-git-send-email-peterx@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/i386/amd_iommu.c | 10 +++++++---
hw/i386/intel_iommu.c | 12 ++++++++----
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index a868539..023de52 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -21,6 +21,7 @@
*/
#include "qemu/osdep.h"
#include "hw/i386/amd_iommu.h"
+#include "qemu/error-report.h"
#include "trace.h"
/* used AMD-Vi MMIO registers */
@@ -1072,9 +1073,12 @@ static void amdvi_iommu_notify_flag_changed(MemoryRegion *iommu,
{
AMDVIAddressSpace *as = container_of(iommu, AMDVIAddressSpace, iommu);
- hw_error("device %02x.%02x.%x requires iommu notifier which is not "
- "currently supported", as->bus_num, PCI_SLOT(as->devfn),
- PCI_FUNC(as->devfn));
+ if (new & IOMMU_NOTIFIER_MAP) {
+ error_report("device %02x.%02x.%x requires iommu notifier which is not "
+ "currently supported", as->bus_num, PCI_SLOT(as->devfn),
+ PCI_FUNC(as->devfn));
+ exit(1);
+ }
}
static void amdvi_init(AMDVIState *s)
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index b6cc38c..9f4e64a 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -1980,10 +1980,14 @@ static void vtd_iommu_notify_flag_changed(MemoryRegion *iommu,
{
VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
- hw_error("Device at bus %s addr %02x.%d requires iommu notifier which "
- "is currently not supported by intel-iommu emulation",
- vtd_as->bus->qbus.name, PCI_SLOT(vtd_as->devfn),
- PCI_FUNC(vtd_as->devfn));
+ if (new & IOMMU_NOTIFIER_MAP) {
+ error_report("Device at bus %s addr %02x.%d requires iommu "
+ "notifier which is currently not supported by "
+ "intel-iommu emulation",
+ vtd_as->bus->qbus.name, PCI_SLOT(vtd_as->devfn),
+ PCI_FUNC(vtd_as->devfn));
+ exit(1);
+ }
}
static const VMStateDescription vtd_vmstate = {
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PULL 27/28] replay: vmstate for replay module
2016-09-28 19:43 [Qemu-devel] [PULL v2 00/28] Misc patches for 2016-09-26 Paolo Bonzini
2016-09-28 19:43 ` [Qemu-devel] [PULL 02/28] memory: introduce IOMMUOps.notify_flag_changed Paolo Bonzini
2016-09-28 19:43 ` [Qemu-devel] [PULL 03/28] intel_iommu, amd_iommu: allow UNMAP notifiers Paolo Bonzini
@ 2016-09-28 19:43 ` Paolo Bonzini
2016-09-28 23:33 ` [Qemu-devel] [PULL v2 00/28] Misc patches for 2016-09-26 Peter Maydell
3 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2016-09-28 19:43 UTC (permalink / raw)
To: qemu-devel; +Cc: Pavel Dovgalyuk
From: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
This patch introduces vmstate for replay data structures.
It allows saving and loading vmstate while replaying.
Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
Message-Id: <20160926080810.6992.68420.stgit@PASHA-ISP>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
replay/Makefile.objs | 1 +
replay/replay-internal.h | 9 ++++++++
replay/replay-snapshot.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
replay/replay.c | 1 +
4 files changed, 71 insertions(+)
create mode 100644 replay/replay-snapshot.c
diff --git a/replay/Makefile.objs b/replay/Makefile.objs
index fcb3f74..c8ad3eb 100644
--- a/replay/Makefile.objs
+++ b/replay/Makefile.objs
@@ -4,3 +4,4 @@ common-obj-y += replay-events.o
common-obj-y += replay-time.o
common-obj-y += replay-input.o
common-obj-y += replay-char.o
+common-obj-y += replay-snapshot.o
diff --git a/replay/replay-internal.h b/replay/replay-internal.h
index 9b02d7d..e07eb7d 100644
--- a/replay/replay-internal.h
+++ b/replay/replay-internal.h
@@ -66,6 +66,8 @@ typedef struct ReplayState {
unsigned int data_kind;
/*! Flag which indicates that event is not processed yet. */
unsigned int has_unread_data;
+ /*! Temporary variable for saving current log offset. */
+ uint64_t file_offset;
} ReplayState;
extern ReplayState replay_state;
@@ -157,4 +159,11 @@ void replay_event_char_read_save(void *opaque);
/*! Reads char event read from the file. */
void *replay_event_char_read_load(void);
+/* VMState-related functions */
+
+/* Registers replay VMState.
+ Should be called before virtual devices initialization
+ to make cached timers available for post_load functions. */
+void replay_vmstate_register(void);
+
#endif
diff --git a/replay/replay-snapshot.c b/replay/replay-snapshot.c
new file mode 100644
index 0000000..a17e80e
--- /dev/null
+++ b/replay/replay-snapshot.c
@@ -0,0 +1,60 @@
+/*
+ * replay-snapshot.c
+ *
+ * Copyright (c) 2010-2016 Institute for System Programming
+ * of the Russian Academy of Sciences.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "qemu-common.h"
+#include "sysemu/replay.h"
+#include "replay-internal.h"
+#include "sysemu/sysemu.h"
+#include "monitor/monitor.h"
+#include "qapi/qmp/qstring.h"
+#include "qemu/error-report.h"
+#include "migration/vmstate.h"
+
+static void replay_pre_save(void *opaque)
+{
+ ReplayState *state = opaque;
+ state->file_offset = ftell(replay_file);
+}
+
+static int replay_post_load(void *opaque, int version_id)
+{
+ ReplayState *state = opaque;
+ fseek(replay_file, state->file_offset, SEEK_SET);
+ /* If this was a vmstate, saved in recording mode,
+ we need to initialize replay data fields. */
+ replay_fetch_data_kind();
+
+ return 0;
+}
+
+static const VMStateDescription vmstate_replay = {
+ .name = "replay",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .pre_save = replay_pre_save,
+ .post_load = replay_post_load,
+ .fields = (VMStateField[]) {
+ VMSTATE_INT64_ARRAY(cached_clock, ReplayState, REPLAY_CLOCK_COUNT),
+ VMSTATE_UINT64(current_step, ReplayState),
+ VMSTATE_INT32(instructions_count, ReplayState),
+ VMSTATE_UINT32(data_kind, ReplayState),
+ VMSTATE_UINT32(has_unread_data, ReplayState),
+ VMSTATE_UINT64(file_offset, ReplayState),
+ VMSTATE_END_OF_LIST()
+ },
+};
+
+void replay_vmstate_register(void)
+{
+ vmstate_register(NULL, 0, &vmstate_replay, &replay_state);
+}
diff --git a/replay/replay.c b/replay/replay.c
index cc2238d..c797aea 100644
--- a/replay/replay.c
+++ b/replay/replay.c
@@ -292,6 +292,7 @@ void replay_configure(QemuOpts *opts)
exit(1);
}
+ replay_vmstate_register();
replay_enable(fname, mode);
out:
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PULL v2 00/28] Misc patches for 2016-09-26
2016-09-28 19:43 [Qemu-devel] [PULL v2 00/28] Misc patches for 2016-09-26 Paolo Bonzini
` (2 preceding siblings ...)
2016-09-28 19:43 ` [Qemu-devel] [PULL 27/28] replay: vmstate for replay module Paolo Bonzini
@ 2016-09-28 23:33 ` Peter Maydell
3 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2016-09-28 23:33 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: QEMU Developers
On 28 September 2016 at 12:43, Paolo Bonzini <pbonzini@redhat.com> wrote:
> The following changes since commit 7cfdc02dae0d2ff58c897496cfdbbafc0eda0f3f:
>
> Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2016-09-26 19:47:00 +0100)
>
> are available in the git repository at:
>
> git://github.com/bonzini/qemu.git tags/for-upstream
>
> for you to fetch changes up to 6d0ceb80ffe18ad4b28aab7356f440636c0be7be:
>
> replay: allow replay stopping and restarting (2016-09-27 11:57:30 +0200)
>
> ----------------------------------------------------------------
> * thread-safe tb_flush (Fred, Alex, Sergey, me, Richard, Emilio,... :-)
> * license clarification for compiler.h (Felipe)
> * glib cflags improvement (Marc-André)
> * checkpatch silencing (Paolo)
> * SMRAM migration fix (Paolo)
> * Replay improvements (Pavel)
> * IOMMU notifier improvements (Peter)
> * IOAPIC now defaults to version 0x20 (Peter)
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-09-28 23:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-28 19:43 [Qemu-devel] [PULL v2 00/28] Misc patches for 2016-09-26 Paolo Bonzini
2016-09-28 19:43 ` [Qemu-devel] [PULL 02/28] memory: introduce IOMMUOps.notify_flag_changed Paolo Bonzini
2016-09-28 19:43 ` [Qemu-devel] [PULL 03/28] intel_iommu, amd_iommu: allow UNMAP notifiers Paolo Bonzini
2016-09-28 19:43 ` [Qemu-devel] [PULL 27/28] replay: vmstate for replay module Paolo Bonzini
2016-09-28 23:33 ` [Qemu-devel] [PULL v2 00/28] Misc patches for 2016-09-26 Peter Maydell
-- strict thread matches above, loose matches on Subject: below --
2016-09-26 13:40 [Qemu-devel] [PULL " Paolo Bonzini
2016-09-26 13:40 ` [Qemu-devel] [PULL 27/28] replay: vmstate for replay module Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).