Patchwork [2/2] Add tracepoint for state of migration transition

login
register
mail settings
Submitter Kazuya Saito
Date Feb. 6, 2013, 6:38 a.m.
Message ID <5111FA67.20106@jp.fujitsu.com>
Download mbox | patch
Permalink /patch/218778/
State New
Headers show

Comments

Kazuya Saito - Feb. 6, 2013, 6:38 a.m.
This patch enables us to know state of migration (MigrationState.state)
transition. We added migstate_set() to make it easier to trace state
transition, and added a tracepoint in this function.


Signed-off-by: Kazuya Saito <saito.kazuya@jp.fujitsu.com>
---
 include/migration/migration.h |    2 ++
 migration.c                   |   19 +++++++++++++------
 trace-events                  |    3 +++
 3 files changed, 18 insertions(+), 6 deletions(-)

+
+# migration.c
+migstate_set(int new_state) "new state %d"
Stefan Hajnoczi - Feb. 8, 2013, 8:42 a.m.
On Wed, Feb 06, 2013 at 03:38:31PM +0900, Kazuya Saito wrote:
> This patch enables us to know state of migration (MigrationState.state)
> transition. We added migstate_set() to make it easier to trace state
> transition, and added a tracepoint in this function.
> 
> 
> Signed-off-by: Kazuya Saito <saito.kazuya@jp.fujitsu.com>
> ---
>  include/migration/migration.h |    2 ++
>  migration.c                   |   19 +++++++++++++------
>  trace-events                  |    3 +++
>  3 files changed, 18 insertions(+), 6 deletions(-)
> 
> diff --git a/include/migration/migration.h b/include/migration/migration.h
> index a8c9639..df89e27 100644
> --- a/include/migration/migration.h
> +++ b/include/migration/migration.h
> @@ -132,4 +132,6 @@ int migrate_use_xbzrle(void);
>  int64_t migrate_xbzrle_cache_size(void);
> 
>  int64_t xbzrle_cache_resize(int64_t new_size);
> +
> +void migstate_set(MigrationState *s, int new_state);

I would stick with the common "migrate_" prefix: migrate_set_state().
But it's up to Juan whether it's worth fixing this.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

Patch

diff --git a/include/migration/migration.h b/include/migration/migration.h
index a8c9639..df89e27 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -132,4 +132,6 @@  int migrate_use_xbzrle(void);
 int64_t migrate_xbzrle_cache_size(void);

 int64_t xbzrle_cache_resize(int64_t new_size);
+
+void migstate_set(MigrationState *s, int new_state);
 #endif
diff --git a/migration.c b/migration.c
index 77c1971..ccb72ed 100644
--- a/migration.c
+++ b/migration.c
@@ -23,6 +23,7 @@ 
 #include "migration/block.h"
 #include "qemu/thread.h"
 #include "qmp-commands.h"
+#include "trace.h"

 //#define DEBUG_MIGRATION

@@ -285,7 +286,7 @@  static int migrate_fd_cleanup(MigrationState *s)
 void migrate_fd_error(MigrationState *s)
 {
     DPRINTF("setting error state\n");
-    s->state = MIG_STATE_ERROR;
+    migstate_set(s, MIG_STATE_ERROR);
     notifier_list_notify(&migration_state_notifiers, s);
     migrate_fd_cleanup(s);
 }
@@ -294,9 +295,9 @@  static void migrate_fd_completed(MigrationState *s)
 {
     DPRINTF("setting completed state\n");
     if (migrate_fd_cleanup(s) < 0) {
-        s->state = MIG_STATE_ERROR;
+        migstate_set(s, MIG_STATE_ERROR);
     } else {
-        s->state = MIG_STATE_COMPLETED;
+        migstate_set(s, MIG_STATE_COMPLETED);
         runstate_set(RUN_STATE_POSTMIGRATE);
     }
     notifier_list_notify(&migration_state_notifiers, s);
@@ -328,7 +329,7 @@  static void migrate_fd_cancel(MigrationState *s)

     DPRINTF("cancelling migration\n");

-    s->state = MIG_STATE_CANCELLED;
+    migstate_set(s, MIG_STATE_CANCELLED);
     notifier_list_notify(&migration_state_notifiers, s);
     qemu_savevm_state_cancel();

@@ -389,7 +390,7 @@  static MigrationState *migrate_init(const
MigrationParams *params)
     s->xbzrle_cache_size = xbzrle_cache_size;

     s->bandwidth_limit = bandwidth_limit;
-    s->state = MIG_STATE_SETUP;
+    migstate_set(s, MIG_STATE_SETUP);
     s->total_time = qemu_get_clock_ms(rt_clock);

     return s;
@@ -777,7 +778,7 @@  static const QEMUFileOps buffered_file_ops = {

 void migrate_fd_connect(MigrationState *s)
 {
-    s->state = MIG_STATE_ACTIVE;
+    migstate_set(s, MIG_STATE_ACTIVE);
     s->bytes_xfer = 0;
     s->buffer = NULL;
     s->buffer_size = 0;
@@ -792,3 +793,9 @@  void migrate_fd_connect(MigrationState *s)
                        QEMU_THREAD_DETACHED);
     notifier_list_notify(&migration_state_notifiers, s);
 }
+
+void migstate_set(MigrationState *s, int new_state)
+{
+    s->state = new_state;
+    trace_migstate_set(new_state);
+}
diff --git a/trace-events b/trace-events
index bf508f0..7046bb6 100644
--- a/trace-events
+++ b/trace-events
@@ -1091,3 +1091,6 @@  css_io_interrupt(int cssid, int ssid, int schid,
uint32_t intparm, uint8_t isc,
 # hw/s390x/virtio-ccw.c
 virtio_ccw_interpret_ccw(int cssid, int ssid, int schid, int cmd_code)
"VIRTIO-CCW: %x.%x.%04x: interpret command %x"
 virtio_ccw_new_device(int cssid, int ssid, int schid, int devno, const
char *devno_mode) "VIRTIO-CCW: add subchannel %x.%x.%04x, devno %04x (%s)"