migration: add more traces
This replaces DPRINTF macro with tracepoints. This moves some messages from migration.c to savevm.c. This adds tracepoint to signal about fileds failed to migrate. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
This commit is contained in:
parent
4297c8ee6f
commit
9013dca553
30
migration.c
30
migration.c
@ -26,16 +26,6 @@
|
|||||||
#include "qmp-commands.h"
|
#include "qmp-commands.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
|
||||||
//#define DEBUG_MIGRATION
|
|
||||||
|
|
||||||
#ifdef DEBUG_MIGRATION
|
|
||||||
#define DPRINTF(fmt, ...) \
|
|
||||||
do { printf("migration: " fmt, ## __VA_ARGS__); } while (0)
|
|
||||||
#else
|
|
||||||
#define DPRINTF(fmt, ...) \
|
|
||||||
do { } while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MIG_STATE_ERROR = -1,
|
MIG_STATE_ERROR = -1,
|
||||||
MIG_STATE_NONE,
|
MIG_STATE_NONE,
|
||||||
@ -112,7 +102,6 @@ static void process_incoming_migration_co(void *opaque)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
qemu_announce_self();
|
qemu_announce_self();
|
||||||
DPRINTF("successfully loaded vm state\n");
|
|
||||||
|
|
||||||
bdrv_clear_incoming_migration_all();
|
bdrv_clear_incoming_migration_all();
|
||||||
/* Make sure all file formats flush their mutable metadata */
|
/* Make sure all file formats flush their mutable metadata */
|
||||||
@ -306,7 +295,7 @@ static void migrate_fd_cleanup(void *opaque)
|
|||||||
s->cleanup_bh = NULL;
|
s->cleanup_bh = NULL;
|
||||||
|
|
||||||
if (s->file) {
|
if (s->file) {
|
||||||
DPRINTF("closing file\n");
|
trace_migrate_fd_cleanup();
|
||||||
qemu_mutex_unlock_iothread();
|
qemu_mutex_unlock_iothread();
|
||||||
qemu_thread_join(&s->thread);
|
qemu_thread_join(&s->thread);
|
||||||
qemu_mutex_lock_iothread();
|
qemu_mutex_lock_iothread();
|
||||||
@ -329,7 +318,7 @@ static void migrate_fd_cleanup(void *opaque)
|
|||||||
|
|
||||||
void migrate_fd_error(MigrationState *s)
|
void migrate_fd_error(MigrationState *s)
|
||||||
{
|
{
|
||||||
DPRINTF("setting error state\n");
|
trace_migrate_fd_error();
|
||||||
assert(s->file == NULL);
|
assert(s->file == NULL);
|
||||||
s->state = MIG_STATE_ERROR;
|
s->state = MIG_STATE_ERROR;
|
||||||
trace_migrate_set_state(MIG_STATE_ERROR);
|
trace_migrate_set_state(MIG_STATE_ERROR);
|
||||||
@ -339,7 +328,7 @@ void migrate_fd_error(MigrationState *s)
|
|||||||
static void migrate_fd_cancel(MigrationState *s)
|
static void migrate_fd_cancel(MigrationState *s)
|
||||||
{
|
{
|
||||||
int old_state ;
|
int old_state ;
|
||||||
DPRINTF("cancelling migration\n");
|
trace_migrate_fd_cancel();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
old_state = s->state;
|
old_state = s->state;
|
||||||
@ -589,29 +578,23 @@ static void *migration_thread(void *opaque)
|
|||||||
int64_t start_time = initial_time;
|
int64_t start_time = initial_time;
|
||||||
bool old_vm_running = false;
|
bool old_vm_running = false;
|
||||||
|
|
||||||
DPRINTF("beginning savevm\n");
|
|
||||||
qemu_savevm_state_begin(s->file, &s->params);
|
qemu_savevm_state_begin(s->file, &s->params);
|
||||||
|
|
||||||
s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start;
|
s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start;
|
||||||
migrate_set_state(s, MIG_STATE_SETUP, MIG_STATE_ACTIVE);
|
migrate_set_state(s, MIG_STATE_SETUP, MIG_STATE_ACTIVE);
|
||||||
|
|
||||||
DPRINTF("setup complete\n");
|
|
||||||
|
|
||||||
while (s->state == MIG_STATE_ACTIVE) {
|
while (s->state == MIG_STATE_ACTIVE) {
|
||||||
int64_t current_time;
|
int64_t current_time;
|
||||||
uint64_t pending_size;
|
uint64_t pending_size;
|
||||||
|
|
||||||
if (!qemu_file_rate_limit(s->file)) {
|
if (!qemu_file_rate_limit(s->file)) {
|
||||||
DPRINTF("iterate\n");
|
|
||||||
pending_size = qemu_savevm_state_pending(s->file, max_size);
|
pending_size = qemu_savevm_state_pending(s->file, max_size);
|
||||||
DPRINTF("pending size %" PRIu64 " max %" PRIu64 "\n",
|
trace_migrate_pending(pending_size, max_size);
|
||||||
pending_size, max_size);
|
|
||||||
if (pending_size && pending_size >= max_size) {
|
if (pending_size && pending_size >= max_size) {
|
||||||
qemu_savevm_state_iterate(s->file);
|
qemu_savevm_state_iterate(s->file);
|
||||||
} else {
|
} else {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
DPRINTF("done iterating\n");
|
|
||||||
qemu_mutex_lock_iothread();
|
qemu_mutex_lock_iothread();
|
||||||
start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
|
start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
|
||||||
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
|
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
|
||||||
@ -650,9 +633,8 @@ static void *migration_thread(void *opaque)
|
|||||||
s->mbps = time_spent ? (((double) transferred_bytes * 8.0) /
|
s->mbps = time_spent ? (((double) transferred_bytes * 8.0) /
|
||||||
((double) time_spent / 1000.0)) / 1000.0 / 1000.0 : -1;
|
((double) time_spent / 1000.0)) / 1000.0 / 1000.0 : -1;
|
||||||
|
|
||||||
DPRINTF("transferred %" PRIu64 " time_spent %" PRIu64
|
trace_migrate_transferred(transferred_bytes, time_spent,
|
||||||
" bandwidth %g max_size %" PRId64 "\n",
|
bandwidth, max_size);
|
||||||
transferred_bytes, time_spent, bandwidth, max_size);
|
|
||||||
/* if we haven't sent anything, we don't want to recalculate
|
/* if we haven't sent anything, we don't want to recalculate
|
||||||
10000 is a small enough number for our purposes */
|
10000 is a small enough number for our purposes */
|
||||||
if (s->dirty_bytes_rate && transferred_bytes > 10000) {
|
if (s->dirty_bytes_rate && transferred_bytes > 10000) {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "block/coroutine.h"
|
#include "block/coroutine.h"
|
||||||
#include "migration/migration.h"
|
#include "migration/migration.h"
|
||||||
#include "migration/qemu-file.h"
|
#include "migration/qemu-file.h"
|
||||||
|
#include "trace.h"
|
||||||
|
|
||||||
#define IO_BUF_SIZE 32768
|
#define IO_BUF_SIZE 32768
|
||||||
#define MAX_IOV_SIZE MIN(IOV_MAX, 64)
|
#define MAX_IOV_SIZE MIN(IOV_MAX, 64)
|
||||||
@ -595,6 +596,7 @@ int qemu_fclose(QEMUFile *f)
|
|||||||
ret = f->last_error;
|
ret = f->last_error;
|
||||||
}
|
}
|
||||||
g_free(f);
|
g_free(f);
|
||||||
|
trace_qemu_file_fclose();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
savevm.c
8
savevm.c
@ -81,6 +81,7 @@ static void qemu_announce_self_iter(NICState *nic, void *opaque)
|
|||||||
uint8_t buf[60];
|
uint8_t buf[60];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
trace_qemu_announce_self_iter(qemu_ether_ntoa(&nic->conf->macaddr));
|
||||||
len = announce_self_create(buf, nic->conf->macaddr.a);
|
len = announce_self_create(buf, nic->conf->macaddr.a);
|
||||||
|
|
||||||
qemu_send_packet_raw(qemu_get_queue(nic), buf, len);
|
qemu_send_packet_raw(qemu_get_queue(nic), buf, len);
|
||||||
@ -429,6 +430,7 @@ void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
|
|||||||
|
|
||||||
static int vmstate_load(QEMUFile *f, SaveStateEntry *se, int version_id)
|
static int vmstate_load(QEMUFile *f, SaveStateEntry *se, int version_id)
|
||||||
{
|
{
|
||||||
|
trace_vmstate_load(se->idstr, se->vmsd ? se->vmsd->name : "(old)");
|
||||||
if (!se->vmsd) { /* Old style */
|
if (!se->vmsd) { /* Old style */
|
||||||
return se->ops->load_state(f, se->opaque, version_id);
|
return se->ops->load_state(f, se->opaque, version_id);
|
||||||
}
|
}
|
||||||
@ -437,6 +439,7 @@ static int vmstate_load(QEMUFile *f, SaveStateEntry *se, int version_id)
|
|||||||
|
|
||||||
static void vmstate_save(QEMUFile *f, SaveStateEntry *se)
|
static void vmstate_save(QEMUFile *f, SaveStateEntry *se)
|
||||||
{
|
{
|
||||||
|
trace_vmstate_save(se->idstr, se->vmsd ? se->vmsd->name : "(old)");
|
||||||
if (!se->vmsd) { /* Old style */
|
if (!se->vmsd) { /* Old style */
|
||||||
se->ops->save_state(f, se->opaque);
|
se->ops->save_state(f, se->opaque);
|
||||||
return;
|
return;
|
||||||
@ -463,6 +466,7 @@ void qemu_savevm_state_begin(QEMUFile *f,
|
|||||||
SaveStateEntry *se;
|
SaveStateEntry *se;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
trace_savevm_state_begin();
|
||||||
QTAILQ_FOREACH(se, &savevm_handlers, entry) {
|
QTAILQ_FOREACH(se, &savevm_handlers, entry) {
|
||||||
if (!se->ops || !se->ops->set_params) {
|
if (!se->ops || !se->ops->set_params) {
|
||||||
continue;
|
continue;
|
||||||
@ -515,6 +519,7 @@ int qemu_savevm_state_iterate(QEMUFile *f)
|
|||||||
SaveStateEntry *se;
|
SaveStateEntry *se;
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
|
|
||||||
|
trace_savevm_state_iterate();
|
||||||
QTAILQ_FOREACH(se, &savevm_handlers, entry) {
|
QTAILQ_FOREACH(se, &savevm_handlers, entry) {
|
||||||
if (!se->ops || !se->ops->save_live_iterate) {
|
if (!se->ops || !se->ops->save_live_iterate) {
|
||||||
continue;
|
continue;
|
||||||
@ -554,6 +559,8 @@ void qemu_savevm_state_complete(QEMUFile *f)
|
|||||||
SaveStateEntry *se;
|
SaveStateEntry *se;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
trace_savevm_state_complete();
|
||||||
|
|
||||||
cpu_synchronize_all_states();
|
cpu_synchronize_all_states();
|
||||||
|
|
||||||
QTAILQ_FOREACH(se, &savevm_handlers, entry) {
|
QTAILQ_FOREACH(se, &savevm_handlers, entry) {
|
||||||
@ -628,6 +635,7 @@ void qemu_savevm_state_cancel(void)
|
|||||||
{
|
{
|
||||||
SaveStateEntry *se;
|
SaveStateEntry *se;
|
||||||
|
|
||||||
|
trace_savevm_state_cancel();
|
||||||
QTAILQ_FOREACH(se, &savevm_handlers, entry) {
|
QTAILQ_FOREACH(se, &savevm_handlers, entry) {
|
||||||
if (se->ops && se->ops->cancel) {
|
if (se->ops && se->ops->cancel) {
|
||||||
se->ops->cancel(se->opaque);
|
se->ops->cancel(se->opaque);
|
||||||
|
16
trace-events
16
trace-events
@ -1042,6 +1042,17 @@ vmware_setmode(uint32_t w, uint32_t h, uint32_t bpp) "%dx%d @ %d bpp"
|
|||||||
# savevm.c
|
# savevm.c
|
||||||
savevm_section_start(const char *id, unsigned int section_id) "%s, section_id %u"
|
savevm_section_start(const char *id, unsigned int section_id) "%s, section_id %u"
|
||||||
savevm_section_end(const char *id, unsigned int section_id) "%s, section_id %u"
|
savevm_section_end(const char *id, unsigned int section_id) "%s, section_id %u"
|
||||||
|
savevm_state_begin(void) ""
|
||||||
|
savevm_state_iterate(void) ""
|
||||||
|
savevm_state_complete(void) ""
|
||||||
|
savevm_state_cancel(void) ""
|
||||||
|
vmstate_save(const char *idstr, const char *vmsd_name) "%s, %s"
|
||||||
|
vmstate_load(const char *idstr, const char *vmsd_name) "%s, %s"
|
||||||
|
vmstate_load_field_error(const char *field, int ret) "field \"%s\" load failed, ret = %d"
|
||||||
|
qemu_announce_self_iter(const char *mac) "%s"
|
||||||
|
|
||||||
|
# qemu-file.c
|
||||||
|
qemu_file_fclose(void) ""
|
||||||
|
|
||||||
# arch_init.c
|
# arch_init.c
|
||||||
migration_bitmap_sync_start(void) ""
|
migration_bitmap_sync_start(void) ""
|
||||||
@ -1181,6 +1192,11 @@ flic_reset_failed(int err) "flic: reset failed %d"
|
|||||||
|
|
||||||
# migration.c
|
# migration.c
|
||||||
migrate_set_state(int new_state) "new state %d"
|
migrate_set_state(int new_state) "new state %d"
|
||||||
|
migrate_fd_cleanup(void) ""
|
||||||
|
migrate_fd_error(void) ""
|
||||||
|
migrate_fd_cancel(void) ""
|
||||||
|
migrate_pending(uint64_t size, uint64_t max) "pending size %" PRIu64 " max %" PRIu64
|
||||||
|
migrate_transferred(uint64_t tranferred, uint64_t time_spent, double bandwidth, uint64_t size) "transferred %" PRIu64 " time_spent %" PRIu64 " bandwidth %g max_size %" PRId64
|
||||||
|
|
||||||
# kvm-all.c
|
# kvm-all.c
|
||||||
kvm_ioctl(int type, void *arg) "type 0x%x, arg %p"
|
kvm_ioctl(int type, void *arg) "type 0x%x, arg %p"
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "migration/qemu-file.h"
|
#include "migration/qemu-file.h"
|
||||||
#include "migration/vmstate.h"
|
#include "migration/vmstate.h"
|
||||||
#include "qemu/bitops.h"
|
#include "qemu/bitops.h"
|
||||||
|
#include "trace.h"
|
||||||
|
|
||||||
static void vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd,
|
static void vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
@ -73,6 +74,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
|
|||||||
|
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
trace_vmstate_load_field_error(field->name, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user