From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
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
Date: Tue, 1 Dec 2015 21:28:47 +0800 [thread overview]
Message-ID: <1448976530-15984-9-git-send-email-peterx@redhat.com> (raw)
In-Reply-To: <1448976530-15984-1-git-send-email-peterx@redhat.com>
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 <peterx@redhat.com>
---
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 <zlib.h>
#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)
--
2.4.3
next prev parent reply other threads:[~2015-12-01 13:30 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-01 13:28 [Qemu-devel] [PATCH v4 00/11] Add basic "detach" support for dump-guest-memory Peter Xu
2015-12-01 13:28 ` [Qemu-devel] [PATCH v4 01/11] dump-guest-memory: cleanup: removing dump_{error|cleanup}() Peter Xu
2015-12-02 0:37 ` Fam Zheng
2015-12-02 2:50 ` Peter Xu
2015-12-01 13:28 ` [Qemu-devel] [PATCH v4 02/11] dump-guest-memory: add "detach" flag for QMP/HMP interfaces Peter Xu
2015-12-01 13:28 ` [Qemu-devel] [PATCH v4 03/11] dump-guest-memory: using static DumpState, add DumpStatus Peter Xu
2015-12-02 0:46 ` Fam Zheng
2015-12-02 3:00 ` Peter Xu
2015-12-01 13:28 ` [Qemu-devel] [PATCH v4 04/11] dump-guest-memory: add dump_in_progress() helper function Peter Xu
2015-12-01 13:28 ` [Qemu-devel] [PATCH v4 05/11] dump-guest-memory: introduce dump_process() " Peter Xu
2015-12-02 0:50 ` Fam Zheng
2015-12-01 13:28 ` [Qemu-devel] [PATCH v4 06/11] dump-guest-memory: disable dump when in INMIGRATE state Peter Xu
2015-12-02 0:50 ` Fam Zheng
2015-12-02 6:50 ` Peter Xu
2015-12-01 13:28 ` [Qemu-devel] [PATCH v4 07/11] dump-guest-memory: add "detach" support Peter Xu
2015-12-01 13:28 ` Peter Xu [this message]
2015-12-02 1:11 ` [Qemu-devel] [PATCH v4 08/11] dump-guest-memory: add qmp event DUMP_COMPLETED Fam Zheng
2015-12-02 8:20 ` Peter Xu
2015-12-02 9:57 ` Fam Zheng
2015-12-02 14:45 ` Eric Blake
2015-12-02 15:21 ` Peter Xu
2015-12-02 16:01 ` Eric Blake
2015-12-03 1:28 ` Peter Xu
2015-12-01 13:28 ` [Qemu-devel] [PATCH v4 09/11] DumpState: adding total_size and written_size fields Peter Xu
2015-12-02 1:32 ` Fam Zheng
2015-12-02 8:49 ` Peter Xu
2015-12-02 9:49 ` Fam Zheng
2015-12-02 10:41 ` Peter Xu
2015-12-02 12:51 ` Fam Zheng
2015-12-02 14:14 ` Peter Xu
2015-12-01 13:28 ` [Qemu-devel] [PATCH v4 10/11] Dump: add qmp command "query-dump" Peter Xu
2015-12-01 13:28 ` [Qemu-devel] [PATCH v4 11/11] Dump: add hmp command "info dump" Peter Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1448976530-15984-9-git-send-email-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=armbru@redhat.com \
--cc=drjones@redhat.com \
--cc=famz@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=lersek@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).