From patchwork Tue May 22 18:32:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 160715 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8E366B6FA5 for ; Wed, 23 May 2012 04:32:41 +1000 (EST) Received: from localhost ([::1]:43999 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWtss-0000VM-N3 for incoming@patchwork.ozlabs.org; Tue, 22 May 2012 14:32:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40081) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWtsg-0000UE-Uv for qemu-devel@nongnu.org; Tue, 22 May 2012 14:32:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SWtse-0007zT-VX for qemu-devel@nongnu.org; Tue, 22 May 2012 14:32:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44025) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWtse-0007zE-MZ for qemu-devel@nongnu.org; Tue, 22 May 2012 14:32:24 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4MIWHo7019595 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 22 May 2012 14:32:17 -0400 Received: from trasno.mitica (ovpn-116-82.ams2.redhat.com [10.36.116.82]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q4MIWDoa012834; Tue, 22 May 2012 14:32:16 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 22 May 2012 20:32:07 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: chegu_vinod@hp.com Subject: [Qemu-devel] [PATCH 1/7] Add spent time for migration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We add time spent for migration to the output of "info migrate" command. 'total_time' means time since the start fo migration if migration is 'active', and total time of migration if migration is completed. As we are also interested in transferred ram when migration completes, adding all ram statistics Signed-off-by: Juan Quintela Reviewed-by: Orit Wasserman --- hmp.c | 2 ++ migration.c | 11 +++++++++++ migration.h | 1 + qapi-schema.json | 12 +++++++++--- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/hmp.c b/hmp.c index bb0952e..25a128b 100644 --- a/hmp.c +++ b/hmp.c @@ -142,6 +142,8 @@ void hmp_info_migrate(Monitor *mon) info->ram->remaining >> 10); monitor_printf(mon, "total ram: %" PRIu64 " kbytes\n", info->ram->total >> 10); + monitor_printf(mon, "total time: %" PRIu64 " milliseconds\n", + info->ram->total_time); } if (info->has_disk) { diff --git a/migration.c b/migration.c index 3f485d3..599bb6c 100644 --- a/migration.c +++ b/migration.c @@ -131,6 +131,8 @@ MigrationInfo *qmp_query_migrate(Error **errp) info->ram->transferred = ram_bytes_transferred(); info->ram->remaining = ram_bytes_remaining(); info->ram->total = ram_bytes_total(); + info->ram->total_time = qemu_get_clock_ms(rt_clock) + - s->total_time; if (blk_mig_active()) { info->has_disk = true; @@ -143,6 +145,13 @@ MigrationInfo *qmp_query_migrate(Error **errp) case MIG_STATE_COMPLETED: info->has_status = true; info->status = g_strdup("completed"); + + info->has_ram = true; + info->ram = g_malloc0(sizeof(*info->ram)); + info->ram->transferred = ram_bytes_transferred(); + info->ram->remaining = 0; + info->ram->total = ram_bytes_total(); + info->ram->total_time = s->total_time; break; case MIG_STATE_ERROR: info->has_status = true; @@ -260,6 +269,7 @@ static void migrate_fd_put_ready(void *opaque) } else { migrate_fd_completed(s); } + s->total_time = qemu_get_clock_ms(rt_clock) - s->total_time; if (s->state != MIG_STATE_COMPLETED) { if (old_vm_running) { vm_start(); @@ -373,6 +383,7 @@ static MigrationState *migrate_init(int blk, int inc) s->bandwidth_limit = bandwidth_limit; s->state = MIG_STATE_SETUP; + s->total_time = qemu_get_clock_ms(rt_clock); return s; } diff --git a/migration.h b/migration.h index 2e9ca2e..165b27b 100644 --- a/migration.h +++ b/migration.h @@ -33,6 +33,7 @@ struct MigrationState void *opaque; int blk; int shared; + int64_t total_time; }; void process_incoming_migration(QEMUFile *f); diff --git a/qapi-schema.json b/qapi-schema.json index 2ca7195..c5a2e99 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -238,10 +238,15 @@ # # @total: total amount of bytes involved in the migration process # +# @total_time: tota0l amount of ms since migration started. If +# migration has ended, it returns the total migration +# time. (since 1.2) +# # Since: 0.14.0. ## { 'type': 'MigrationStats', - 'data': {'transferred': 'int', 'remaining': 'int', 'total': 'int' } } + 'data': {'transferred': 'int', 'remaining': 'int', 'total': 'int' , + 'total_time': 'int' } } ## # @MigrationInfo @@ -253,8 +258,9 @@ # 'cancelled'. If this field is not returned, no migration process # has been initiated # -# @ram: #optional @MigrationStats containing detailed migration status, -# only returned if status is 'active' +# @ram: #optional @MigrationStats containing detailed migration +# status, only returned if status is 'active' or +# 'completed'. 'comppleted' (since 1.2) # # @disk: #optional @MigrationStats containing detailed disk migration # status, only returned if status is 'active' and it is a block