From: Juan Quintela <quint...@trasno.org> Once there, print all sections that take more than 100ms to migrate. buffered file runs a timer at that 100ms interval.
Signed-off-by: Juan Quintela <quint...@trasno.org> Signed-off-by: Juan Quintela <quint...@redhat.com> --- savevm.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 46 insertions(+), 2 deletions(-) diff --git a/savevm.c b/savevm.c index 4e49765..ceed6de 100644 --- a/savevm.c +++ b/savevm.c @@ -83,6 +83,24 @@ #include "migration.h" #include "qemu_socket.h" #include "qemu-queue.h" +#include "buffered_file.h" + +//#define DEBUG_SAVEVM + +#ifdef DEBUG_SAVEVM +#define DPRINTF(fmt, ...) \ + do { printf("savevm: " fmt, ## __VA_ARGS__); } while (0) +static int64_t start, stop; +#define START_SAVEVM_CLOCK() do { start = qemu_get_clock(rt_clock); } while (0) +#define STOP_SAVEVM_CLOCK() \ + do { stop = qemu_get_clock(rt_clock) - start; \ + } while (0) +#else +#define DPRINTF(fmt, ...) \ + do { } while (0) +#define START_SAVEVM_CLOCK() do { } while (0) +#define STOP_SAVEVM_CLOCK() do { } while (0) +#endif #define SELF_ANNOUNCE_ROUNDS 5 @@ -1480,11 +1498,23 @@ int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f) if (se->save_live_state == NULL) continue; + START_SAVEVM_CLOCK(); + /* Section type */ qemu_put_byte(f, QEMU_VM_SECTION_PART); qemu_put_be32(f, se->section_id); ret = se->save_live_state(mon, f, QEMU_VM_SECTION_PART, se->opaque); + STOP_SAVEVM_CLOCK(); +#ifdef DEBUG_SAVEVM + if (stop > buffered_file_interval) { + /* buffered_file run a timer at 100ms */ + static int times_missing = 1; + DPRINTF("save live iterate section id %u name %s took %ld milliseconds %u times\n", + se->section_id, se->idstr, stop, times_missing++); + } +#endif + if (!ret) { /* Do not proceed to the next vmstate before this one reported completion of the current stage. This serializes the migration @@ -1516,13 +1546,18 @@ int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f) if (se->save_live_state == NULL) continue; + START_SAVEVM_CLOCK(); /* Section type */ qemu_put_byte(f, QEMU_VM_SECTION_END); qemu_put_be32(f, se->section_id); se->save_live_state(mon, f, QEMU_VM_SECTION_END, se->opaque); + STOP_SAVEVM_CLOCK(); + DPRINTF("save live end section id %u name %s took %ld milliseconds\n", + se->section_id, se->idstr, stop); } + START_SAVEVM_CLOCK(); QTAILQ_FOREACH(se, &savevm_handlers, entry) { int len; @@ -1542,12 +1577,14 @@ int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f) qemu_put_be32(f, se->version_id); r = vmstate_save(f, se); + DPRINTF("save section id %u name %s\n", se->section_id, se->idstr); if (r < 0) { monitor_printf(mon, "cannot migrate with device '%s'\n", se->idstr); return r; } } - + STOP_SAVEVM_CLOCK(); + DPRINTF("save devices took %ld milliseconds\n", stop); qemu_put_byte(f, QEMU_VM_EOF); if (qemu_file_has_error(f)) @@ -1746,8 +1783,11 @@ int qemu_loadvm_state(QEMUFile *f) le->section_id = section_id; le->version_id = version_id; QLIST_INSERT_HEAD(&loadvm_handlers, le, entry); - + START_SAVEVM_CLOCK(); ret = vmstate_load(f, le->se, le->version_id); + STOP_SAVEVM_CLOCK(); + DPRINTF("load section id %u name %s took %ld milliseconds\n", le->section_id, + le->se->idstr, stop); if (ret < 0) { fprintf(stderr, "qemu: warning: error while loading state for instance 0x%x of device '%s'\n", instance_id, idstr); @@ -1769,7 +1809,11 @@ int qemu_loadvm_state(QEMUFile *f) goto out; } + START_SAVEVM_CLOCK(); ret = vmstate_load(f, le->se, le->version_id); + STOP_SAVEVM_CLOCK(); + DPRINTF("load section id %u name %s took %ld milliseconds\n", le->section_id, + le->se->idstr, stop); if (ret < 0) { fprintf(stderr, "qemu: warning: error while loading state section id %d\n", section_id); -- 1.7.3.2