Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MwbEy-000801-3g for qemu-devel@nongnu.org; Sat, 10 Oct 2009 08:40:04 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MwbEt-0007uX-FM for qemu-devel@nongnu.org; Sat, 10 Oct 2009 08:40:03 -0400 Received: from [199.232.76.173] (port=40657 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MwbEt-0007uO-CH for qemu-devel@nongnu.org; Sat, 10 Oct 2009 08:39:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29002) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MwbEs-0001Gn-QH for qemu-devel@nongnu.org; Sat, 10 Oct 2009 08:39:59 -0400 Subject: Re: [Qemu-devel] [PATCH 07/10] monitor: Convert do_info_migrate() to QObject References: <1255037747-3340-1-git-send-email-lcapitulino@redhat.com> <1255037747-3340-8-git-send-email-lcapitulino@redhat.com> From: Markus Armbruster Date: Sat, 10 Oct 2009 14:11:03 +0200 In-Reply-To: <1255037747-3340-8-git-send-email-lcapitulino@redhat.com> (Luiz Capitulino's message of "Thu\, 8 Oct 2009 18\:35\:44 -0300") Message-ID: <87hbu71maw.fsf@pike.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org Luiz Capitulino 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"); > } > } > [...]