nvme: Drop pointless .bdrv_co_get_block_status()
[qemu/ar7.git] / qapi / qmp-event.c
blob9d7e88e84a28e22842f07a7fa9f5d805a9b58938
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 QMPEventFuncEmit qmp_emit;
24 void qmp_event_set_func_emit(QMPEventFuncEmit emit)
26 qmp_emit = emit;
29 QMPEventFuncEmit qmp_event_get_func_emit(void)
31 return qmp_emit;
34 static void timestamp_put(QDict *qdict)
36 int err;
37 QObject *obj;
38 qemu_timeval tv;
40 err = qemu_gettimeofday(&tv);
41 /* Put -1 to indicate failure of getting host time */
42 obj = qobject_from_jsonf("{ 'seconds': %lld, 'microseconds': %lld }",
43 err < 0 ? -1LL : (long long)tv.tv_sec,
44 err < 0 ? -1LL : (long long)tv.tv_usec);
45 qdict_put_obj(qdict, "timestamp", obj);
49 * Build a QDict, then fill event name and time stamp, caller should free the
50 * QDict after usage.
52 QDict *qmp_event_build_dict(const char *event_name)
54 QDict *dict = qdict_new();
55 qdict_put_str(dict, "event", event_name);
56 timestamp_put(dict);
57 return dict;