Merge tag 'v9.0.0-rc3'
[qemu/ar7.git] / qapi / qmp-event.c
blob0fe0d0a5a6e5abdf318046dcd7a7f9d55921d144
1 /*
2 * QMP Event related
4 * Copyright (c) 2014 Wenchao Xia
6 * Authors:
7 * Wenchao Xia <wenchaoqemu@gmail.com>
9 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
10 * See the COPYING.LIB file in the top-level directory.
14 #include "qemu/osdep.h"
16 #include "qapi/qmp-event.h"
17 #include "qapi/qmp/qstring.h"
18 #include "qapi/qmp/qdict.h"
19 #include "qapi/qmp/qjson.h"
21 static void timestamp_put(QDict *qdict)
23 QDict *ts;
24 int64_t rt = g_get_real_time();
26 ts = qdict_from_jsonf_nofail("{ 'seconds': %lld, 'microseconds': %lld }",
27 (long long)rt / G_USEC_PER_SEC,
28 (long long)rt % G_USEC_PER_SEC);
29 qdict_put(qdict, "timestamp", ts);
33 * Build a QDict, then fill event name and time stamp, caller should free the
34 * QDict after usage.
36 QDict *qmp_event_build_dict(const char *event_name)
38 QDict *dict = qdict_new();
39 qdict_put_str(dict, "event", event_name);
40 timestamp_put(dict);
41 return dict;