From patchwork Tue Dec 1 13:28:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 550863 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B91C6140291 for ; Wed, 2 Dec 2015 00:34:31 +1100 (AEDT) Received: from localhost ([::1]:52647 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3l4f-0001hW-IN for incoming@patchwork.ozlabs.org; Tue, 01 Dec 2015 08:34:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3l1C-000341-FC for qemu-devel@nongnu.org; Tue, 01 Dec 2015 08:30:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3l17-00046a-80 for qemu-devel@nongnu.org; Tue, 01 Dec 2015 08:30:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48260) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3l16-00046Q-UI for qemu-devel@nongnu.org; Tue, 01 Dec 2015 08:30:49 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id A7CCCA3D22 for ; Tue, 1 Dec 2015 13:30:48 +0000 (UTC) Received: from pxdev.xzpeter.org.com (vpn1-5-36.pek2.redhat.com [10.72.5.36]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tB1DSvaV010968; Tue, 1 Dec 2015 08:30:39 -0500 From: Peter Xu To: qemu-devel@nongnu.org Date: Tue, 1 Dec 2015 21:28:47 +0800 Message-Id: <1448976530-15984-9-git-send-email-peterx@redhat.com> In-Reply-To: <1448976530-15984-1-git-send-email-peterx@redhat.com> References: <1448976530-15984-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: drjones@redhat.com, lersek@redhat.com, armbru@redhat.com, peterx@redhat.com, lcapitulino@redhat.com, famz@redhat.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH v4 08/11] dump-guest-memory: add qmp event DUMP_COMPLETED 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 One new QMP event DUMP_COMPLETED is added. When a dump finishes, one DUMP_COMPLETED event will occur to notify the user. Signed-off-by: Peter Xu --- docs/qmp-events.txt | 16 ++++++++++++++++ dump.c | 11 +++++------ qapi-schema.json | 3 ++- qapi/event.json | 13 +++++++++++++ qmp-commands.hx | 5 +++-- util/error.c | 6 +++++- 6 files changed, 44 insertions(+), 10 deletions(-) diff --git a/docs/qmp-events.txt b/docs/qmp-events.txt index d2f1ce4..1f79588 100644 --- a/docs/qmp-events.txt +++ b/docs/qmp-events.txt @@ -220,6 +220,22 @@ Data: }, "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } +DUMP_COMPLETED +-------------- + +Emitted when the guest has finished one memory dump. + +Data: + +- "error": Error message when dump failed. This is only a + human-readable string provided when dump failed. It should not be + parsed in any way (json-string, optional) + +Example: + +{ "event": "DUMP_COMPLETED", + "data": {} } + GUEST_PANICKED -------------- diff --git a/dump.c b/dump.c index c86bc2d..5b040b7 100644 --- a/dump.c +++ b/dump.c @@ -25,6 +25,7 @@ #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "qmp-commands.h" +#include "qapi-event.h" #include #ifdef CONFIG_LZO @@ -1612,6 +1613,9 @@ static void dump_process(DumpState *s, Error **errp) s->status = DUMP_STATUS_COMPLETED; } + /* send DUMP_COMPLETED message (unconditionally) */ + qapi_event_send_dump_completed(!!(*errp), error_get_pretty(*errp), + &error_abort); dump_cleanup(s); } @@ -1619,13 +1623,8 @@ static void *dump_thread(void *data) { Error *err = NULL; DumpState *s = (DumpState *)data; - dump_process(s, &err); - - if (err) { - /* TODO: notify user the error */ - error_free(err); - } + error_free(err); return NULL; } diff --git a/qapi-schema.json b/qapi-schema.json index 691a130..f0d3c4a 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2116,7 +2116,8 @@ # is the fd's name. # # @detach: #optional if true, QMP will return immediately rather than -# waiting for the dump to finish. (since 2.6). +# waiting for the dump to finish. A DUMP_COMPLETED event will +# occur at the end. (since 2.6). # # @begin: #optional if specified, the starting physical address. # diff --git a/qapi/event.json b/qapi/event.json index f0cef01..9b7f714 100644 --- a/qapi/event.json +++ b/qapi/event.json @@ -356,3 +356,16 @@ ## { 'event': 'MEM_UNPLUG_ERROR', 'data': { 'device': 'str', 'msg': 'str' } } + +## +# @DUMP_COMPLETED +# +# Emitted when background dump has completed +# +# @error: #optional human-readable error string that provides +# hint on why dump failed. +# +# Since: 2.6 +## +{ 'event': 'DUMP_COMPLETED' , + 'data': { '*error': 'str' } } diff --git a/qmp-commands.hx b/qmp-commands.hx index 6b51585..7b6f915 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -857,8 +857,9 @@ Arguments: - "paging": do paging to get guest's memory mapping (json-bool) - "protocol": destination file(started with "file:") or destination file descriptor (started with "fd:") (json-string) -- "detach": if specified, command will return immediately, without waiting - for the dump to finish (json-bool) +- "detach": if specified, command will return immediately rather than waiting + for the dump completion. A DUMP_COMPLETED event will occur at + the end. (json-bool) - "begin": the starting physical address. It's optional, and should be specified with length together (json-int) - "length": the memory size, in bytes. It's optional, and should be specified diff --git a/util/error.c b/util/error.c index 80c89a2..645b9af 100644 --- a/util/error.c +++ b/util/error.c @@ -197,7 +197,11 @@ ErrorClass error_get_class(const Error *err) const char *error_get_pretty(Error *err) { - return err->msg; + if (err) { + return err->msg; + } else { + return NULL; + } } void error_report_err(Error *err)