qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 07/10] monitor: Convert do_info_migrate() to QOb


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH 07/10] monitor: Convert do_info_migrate() to QObject
Date: Sat, 10 Oct 2009 14:11:03 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux)

Luiz Capitulino <address@hidden> writes:

> Return a QDict, which may contain another QDict if the migration
> process is active.
>
> The main QDict contains the following:
>
> - "status": migration status
> - "ram": only present if "status" is "active", it is a QDict with the
>    following information (in bytes):
>         - "transferred": amount of RAM transferred
>         - "remaining": amount of RAM remaining
>         - "total": total RAM
>
> IMPORTANT: as a QInt stores a int64_t integer, those RAM values
> are going to stored as int64_t and not as uint64_t as they are
> today. If this is a problem QInt will have to be changed.
>
> This commit should not change user output, the following is an
> example of the returned QDict:
>
> { "status": "active", "ram":
>    { "transferred": 885030912, "remaining": 198529024, "total": 1082392576 } }
[...]
> diff --git a/migration.c b/migration.c
> index 112a5b6..b3bf00f 100644
> --- a/migration.c
> +++ b/migration.c
[...]
> @@ -158,29 +159,79 @@ void do_migrate_set_downtime(Monitor *mon, const QDict 
> *qdict)
[...]
> +/**
> + * do_info_migrate(): Show migration status
> + *
> + * Return a QDict. If migration is active there will be another
> + * QDict with RAM information.
> + *
> + * The main QDict contains the following:
> + *
> + * - "status": migration status
> + * - "ram": only present if "status" is "active", it is a QDict with the
> + *   following information (in bytes):
> + *          - "transferred": amount of RAM transferred
> + *          - "remaining": amount of RAM remaining
> + *          - "total": total RAM
> + *
> + * Examples:
> + *
> + * 1. If migration is "completed", "error" or "cancelled":
> + *
> + * { "status": "completed" }

This suggests that a failed or cancelled migration is reported with
"completed", which is wrong.  Since it's just an example, you could
leave out the ', "error" or "cancelled"' part.

> + *
> + * 2. If migration is "active":
> + *
> + * { "status": "active", "ram":
> + *             { "transferred": 123, "remaining": 123, "total": 246 } }
> + */
> +void do_info_migrate(Monitor *mon, QObject **ret_data)
>  {
>      MigrationState *s = current_migration;
>  
>      if (s) {
> -        monitor_printf(mon, "Migration status: ");
>          switch (s->get_status(s)) {
>          case MIG_STATE_ACTIVE:
> -            monitor_printf(mon, "active\n");
> -            monitor_printf(mon, "transferred ram: %" PRIu64 " kbytes\n", 
> ram_bytes_transferred() >> 10);
> -            monitor_printf(mon, "remaining ram: %" PRIu64 " kbytes\n", 
> ram_bytes_remaining() >> 10);
> -            monitor_printf(mon, "total ram: %" PRIu64 " kbytes\n", 
> ram_bytes_total() >> 10);
> +            *ret_data = qobject_from_fmt("{ s: s, s: { s: i, s: i, s: i } }",
> +                                         "status", "active",
> +                                         "ram",
> +                                         "transferred", 
> ram_bytes_transferred(),
> +                                         "remaining", ram_bytes_remaining(),
> +                                         "total", ram_bytes_total());
>              break;
>          case MIG_STATE_COMPLETED:
> -            monitor_printf(mon, "completed\n");
> +            *ret_data = qobject_from_fmt("{ s: s }", "status", "completed");
>              break;
>          case MIG_STATE_ERROR:
> -            monitor_printf(mon, "failed\n");
> +            *ret_data = qobject_from_fmt("{ s: s }", "status", "failed");
>              break;
>          case MIG_STATE_CANCELLED:
> -            monitor_printf(mon, "cancelled\n");
> +            *ret_data = qobject_from_fmt("{ s: s }", "status", "cancelled");
>              break;
>          }
> +        if (*ret_data == NULL)
> +            monitor_printf(mon, "Migration: could not build QObject\n");
>      }
>  }
>  
[...]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]