hw/nvram/fw_cfg: Store 'reboot-timeout' as little endian
[qemu/ar7.git] / qapi / qmp-event.c
blob81ddd5331f9f06e06268cfa68f5289938897a224
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 "qemu-common.h"
17 #include "qapi/qmp-event.h"
18 #include "qapi/qmp/qstring.h"
19 #include "qapi/qmp/qdict.h"
20 #include "qapi/qmp/qjson.h"
22 static void timestamp_put(QDict *qdict)
24 int err;
25 QDict *ts;
26 qemu_timeval tv;
28 err = qemu_gettimeofday(&tv);
29 /* Put -1 to indicate failure of getting host time */
30 ts = qdict_from_jsonf_nofail("{ 'seconds': %lld, 'microseconds': %lld }",
31 err < 0 ? -1LL : (long long)tv.tv_sec,
32 err < 0 ? -1LL : (long long)tv.tv_usec);
33 qdict_put(qdict, "timestamp", ts);
37 * Build a QDict, then fill event name and time stamp, caller should free the
38 * QDict after usage.
40 QDict *qmp_event_build_dict(const char *event_name)
42 QDict *dict = qdict_new();
43 qdict_put_str(dict, "event", event_name);
44 timestamp_put(dict);
45 return dict;