Patchwork [v2,2/2] migration: add migrate_set_state(), add trace_migrate_set_state()

login
register
mail settings
Submitter Kazuya Saito
Date Feb. 20, 2013, 6:32 a.m.
Message ID <51246DFE.2080909@jp.fujitsu.com>
Download mbox | patch
Permalink /patch/221967/
State New
Headers show

Comments

Kazuya Saito - Feb. 20, 2013, 6:32 a.m.
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
+migrate_set_state(int new_state) "new state %d"
Paolo Bonzini - Feb. 20, 2013, 7:25 a.m.
Il 20/02/2013 07:32, Kazuya Saito ha scritto:
> Signed-off-by: Kazuya Saito <saito.kazuya@jp.fujitsu.com>

Unfortunately, this conflicts with my series to simplify migration.c
(branch migration-thread-20130115 in git://github.com/bonzini/qemu.git).

I'm not sure how to proceed here, because migrate_set_state doesn't
exist anymore.  Probably you need many different tracepoints.

Paolo

> ---
>  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..3d8b2a8 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 migrate_set_state(MigrationState *s, int new_state);
>  #endif
> diff --git a/migration.c b/migration.c
> index b1ebb01..c52d634 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
> 
> @@ -277,7 +278,7 @@ static int migrate_fd_cleanup(MigrationState *s)
>  void migrate_fd_error(MigrationState *s)
>  {
>      DPRINTF("setting error state\n");
> -    s->state = MIG_STATE_ERROR;
> +    migrate_set_state(s, MIG_STATE_ERROR);
>      notifier_list_notify(&migration_state_notifiers, s);
>      migrate_fd_cleanup(s);
>  }
> @@ -286,9 +287,9 @@ static void migrate_fd_completed(MigrationState *s)
>  {
>      DPRINTF("setting completed state\n");
>      if (migrate_fd_cleanup(s) < 0) {
> -        s->state = MIG_STATE_ERROR;
> +        migrate_set_state(s, MIG_STATE_ERROR);
>      } else {
> -        s->state = MIG_STATE_COMPLETED;
> +        migrate_set_state(s, MIG_STATE_COMPLETED);
>          runstate_set(RUN_STATE_POSTMIGRATE);
>      }
>      notifier_list_notify(&migration_state_notifiers, s);
> @@ -320,7 +321,7 @@ static void migrate_fd_cancel(MigrationState *s)
> 
>      DPRINTF("cancelling migration\n");
> 
> -    s->state = MIG_STATE_CANCELLED;
> +    migrate_set_state(s, MIG_STATE_CANCELLED);
>      notifier_list_notify(&migration_state_notifiers, s);
>      qemu_savevm_state_cancel();
> 
> @@ -381,7 +382,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;
> +    migrate_set_state(s, MIG_STATE_SETUP);
>      s->total_time = qemu_get_clock_ms(rt_clock);
> 
>      return s;
> @@ -769,7 +770,7 @@ static const QEMUFileOps buffered_file_ops = {
> 
>  void migrate_fd_connect(MigrationState *s)
>  {
> -    s->state = MIG_STATE_ACTIVE;
> +    migrate_set_state(s, MIG_STATE_ACTIVE);
>      s->bytes_xfer = 0;
>      s->buffer = NULL;
>      s->buffer_size = 0;
> @@ -784,3 +785,9 @@ void migrate_fd_connect(MigrationState *s)
>                         QEMU_THREAD_DETACHED);
>      notifier_list_notify(&migration_state_notifiers, s);
>  }
> +
> +void migrate_set_state(MigrationState *s, int new_state)
> +{
> +    s->state = new_state;
> +    trace_migrate_set_state(new_state);
> +}
> diff --git a/trace-events b/trace-events
> index bf508f0..1be907e 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)"
> +
> +# migration.c
> +migrate_set_state(int new_state) "new state %d"
>
Juan Quintela - Feb. 22, 2013, 9:50 a.m.
Paolo Bonzini <pbonzini@redhat.com> wrote:
> Il 20/02/2013 07:32, Kazuya Saito ha scritto:
>> Signed-off-by: Kazuya Saito <saito.kazuya@jp.fujitsu.com>
>
> Unfortunately, this conflicts with my series to simplify migration.c
> (branch migration-thread-20130115 in git://github.com/bonzini/qemu.git).
>
> I'm not sure how to proceed here, because migrate_set_state doesn't
> exist anymore.  Probably you need many different tracepoints.
>> +
>> +void migrate_set_state(MigrationState *s, int new_state)
>> +{
>> +    s->state = new_state;
>> +    trace_migrate_set_state(new_state);
>> +}

It was introduced with this very patch O:-)

I take them, and will integrate them on top of your series.

Later, Juan.
Paolo Bonzini - Feb. 22, 2013, 9:52 a.m.
Il 22/02/2013 10:50, Juan Quintela ha scritto:
> Paolo Bonzini <pbonzini@redhat.com> wrote:
>> Il 20/02/2013 07:32, Kazuya Saito ha scritto:
>>> Signed-off-by: Kazuya Saito <saito.kazuya@jp.fujitsu.com>
>>
>> Unfortunately, this conflicts with my series to simplify migration.c
>> (branch migration-thread-20130115 in git://github.com/bonzini/qemu.git).
>>
>> I'm not sure how to proceed here, because migrate_set_state doesn't
>> exist anymore.  Probably you need many different tracepoints.
>>> +
>>> +void migrate_set_state(MigrationState *s, int new_state)
>>> +{
>>> +    s->state = new_state;
>>> +    trace_migrate_set_state(new_state);
>>> +}
> 
> It was introduced with this very patch O:-)
> 
> I take them, and will integrate them on top of your series.

Kazuya already implemented this on top of my series, so I'll post his
patch together with my v2.

Paolo

Patch

diff --git a/include/migration/migration.h b/include/migration/migration.h
index a8c9639..3d8b2a8 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 migrate_set_state(MigrationState *s, int new_state);
 #endif
diff --git a/migration.c b/migration.c
index b1ebb01..c52d634 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

@@ -277,7 +278,7 @@  static int migrate_fd_cleanup(MigrationState *s)
 void migrate_fd_error(MigrationState *s)
 {
     DPRINTF("setting error state\n");
-    s->state = MIG_STATE_ERROR;
+    migrate_set_state(s, MIG_STATE_ERROR);
     notifier_list_notify(&migration_state_notifiers, s);
     migrate_fd_cleanup(s);
 }
@@ -286,9 +287,9 @@  static void migrate_fd_completed(MigrationState *s)
 {
     DPRINTF("setting completed state\n");
     if (migrate_fd_cleanup(s) < 0) {
-        s->state = MIG_STATE_ERROR;
+        migrate_set_state(s, MIG_STATE_ERROR);
     } else {
-        s->state = MIG_STATE_COMPLETED;
+        migrate_set_state(s, MIG_STATE_COMPLETED);
         runstate_set(RUN_STATE_POSTMIGRATE);
     }
     notifier_list_notify(&migration_state_notifiers, s);
@@ -320,7 +321,7 @@  static void migrate_fd_cancel(MigrationState *s)

     DPRINTF("cancelling migration\n");

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

@@ -381,7 +382,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;
+    migrate_set_state(s, MIG_STATE_SETUP);
     s->total_time = qemu_get_clock_ms(rt_clock);

     return s;
@@ -769,7 +770,7 @@  static const QEMUFileOps buffered_file_ops = {

 void migrate_fd_connect(MigrationState *s)
 {
-    s->state = MIG_STATE_ACTIVE;
+    migrate_set_state(s, MIG_STATE_ACTIVE);
     s->bytes_xfer = 0;
     s->buffer = NULL;
     s->buffer_size = 0;
@@ -784,3 +785,9 @@  void migrate_fd_connect(MigrationState *s)
                        QEMU_THREAD_DETACHED);
     notifier_list_notify(&migration_state_notifiers, s);
 }
+
+void migrate_set_state(MigrationState *s, int new_state)
+{
+    s->state = new_state;
+    trace_migrate_set_state(new_state);
+}
diff --git a/trace-events b/trace-events
index bf508f0..1be907e 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)"