mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
QAPI patches patches for 2020-12-19
-----BEGIN PGP SIGNATURE----- iQJGBAABCAAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAl/dynUSHGFybWJydUBy ZWRoYXQuY29tAAoJEDhwtADrkYZT3igP/3bWwsKR5vKVsDUTmMfrhcgaFvQiaYoG F29Bond8Xy0Zd0gl7OWh/5jKL0vGlrEVPrKfYLUjMnfkeRec/pOkIB2oOmIxpnPs 9zi4kh2hQ3dEoRBuvSnnZzedetYPTuCpWMIjlztkgfxgcimqm8TPNVSxRaSApjC3 Y8108wGwBWVf2C0rhKO9E2xA51uo6khy05i1psUtqUlC+PuDQ/OwzQHM2dnWdDB6 kUwBDK17nhL6WwsYqCyKLSiDModReYfDiY8GS5MDLo74dzwXiatEefCR7+sbM4xq eX/SBoqoeS1jLPNuCryNeGNKvNA2KAbEJTnbQA2NxBXHgZ9/1SxVZFxuPp4nDMSQ N7BDuDI8YtJE479RjT/ZzRG65xadGBSe/HXkXM9mZwh1zitop8SVZ9fArFBHvNzw Y5zAv3fQd54+87psffg4dYFK0wGmqTabLEEuVzM8KIVqcAdYA2yC2b2EHy+vsxuq GMkr0WaA6Sq2gthXmzdTjmUPuHdan/NIhuV6d66SbPNH2oH31piptFxuznyFWSKV isciFFdUrkg5QrF8DSt2nmdwMFf8QGbszqP8QIGMzhJCCS9GXIiGG8f149++q8X8 HO1lFAdLQJdrDwCYmfx36tOvi2rS/rcoTGgvg66UX3xKko1ruoxR1ZWcS54obJN6 vEQDZ+PxubDg =vGLy -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2020-12-19' into staging QAPI patches patches for 2020-12-19 # gpg: Signature made Sat 19 Dec 2020 09:40:05 GMT # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2020-12-19: (33 commits) qobject: Make QString immutable block: Use GString instead of QString to build filenames keyval: Use GString to accumulate value strings json: Use GString instead of QString to accumulate strings migration: Replace migration's JSON writer by the general one qobject: Factor JSON writer out of qobject_to_json() qobject: Factor quoted_str() out of to_json() qobject: Drop qstring_get_try_str() qobject: Drop qobject_get_try_str() Revert "qobject: let object_property_get_str() use new API" block: Avoid qobject_get_try_str() qmp: Fix tracing of non-string command IDs qobject: Move internals to qobject-internal.h hw/rdma: Replace QList by GQueue Revert "qstring: add qstring_free()" qobject: Change qobject_to_json()'s value to GString qobject: Use GString instead of QString to accumulate JSON qobject: Make qobject_to_json_pretty() take a pretty argument monitor: Use GString instead of QString for output buffer hmp: Simplify how qmp_human_monitor_command() gets output ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
1f7c02797f
105 changed files with 975 additions and 1263 deletions
|
@ -1255,7 +1255,8 @@ void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict)
|
|||
const char *cap = qdict_get_str(qdict, "capability");
|
||||
bool state = qdict_get_bool(qdict, "state");
|
||||
Error *err = NULL;
|
||||
MigrationCapabilityStatusList *caps = g_malloc0(sizeof(*caps));
|
||||
MigrationCapabilityStatusList *caps = NULL;
|
||||
MigrationCapabilityStatus *value;
|
||||
int val;
|
||||
|
||||
val = qapi_enum_parse(&MigrationCapability_lookup, cap, -1, &err);
|
||||
|
@ -1263,14 +1264,14 @@ void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict)
|
|||
goto end;
|
||||
}
|
||||
|
||||
caps->value = g_malloc0(sizeof(*caps->value));
|
||||
caps->value->capability = val;
|
||||
caps->value->state = state;
|
||||
caps->next = NULL;
|
||||
value = g_malloc0(sizeof(*value));
|
||||
value->capability = val;
|
||||
value->state = state;
|
||||
QAPI_LIST_PREPEND(caps, value);
|
||||
qmp_migrate_set_capabilities(caps, &err);
|
||||
qapi_free_MigrationCapabilityStatusList(caps);
|
||||
|
||||
end:
|
||||
qapi_free_MigrationCapabilityStatusList(caps);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
|
|
|
@ -136,11 +136,7 @@ char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,
|
|||
handle_hmp_command(&hmp, command_line);
|
||||
|
||||
WITH_QEMU_LOCK_GUARD(&hmp.common.mon_lock) {
|
||||
if (qstring_get_length(hmp.common.outbuf) > 0) {
|
||||
output = g_strdup(qstring_get_str(hmp.common.outbuf));
|
||||
} else {
|
||||
output = g_strdup("");
|
||||
}
|
||||
output = g_strdup(hmp.common.outbuf->str);
|
||||
}
|
||||
|
||||
out:
|
||||
|
@ -1434,33 +1430,26 @@ FdsetInfoList *qmp_query_fdsets(Error **errp)
|
|||
|
||||
QEMU_LOCK_GUARD(&mon_fdsets_lock);
|
||||
QLIST_FOREACH(mon_fdset, &mon_fdsets, next) {
|
||||
FdsetInfoList *fdset_info = g_malloc0(sizeof(*fdset_info));
|
||||
FdsetFdInfoList *fdsetfd_list = NULL;
|
||||
FdsetInfo *fdset_info = g_malloc0(sizeof(*fdset_info));
|
||||
|
||||
fdset_info->value = g_malloc0(sizeof(*fdset_info->value));
|
||||
fdset_info->value->fdset_id = mon_fdset->id;
|
||||
fdset_info->fdset_id = mon_fdset->id;
|
||||
|
||||
QLIST_FOREACH(mon_fdset_fd, &mon_fdset->fds, next) {
|
||||
FdsetFdInfoList *fdsetfd_info;
|
||||
FdsetFdInfo *fdsetfd_info;
|
||||
|
||||
fdsetfd_info = g_malloc0(sizeof(*fdsetfd_info));
|
||||
fdsetfd_info->value = g_malloc0(sizeof(*fdsetfd_info->value));
|
||||
fdsetfd_info->value->fd = mon_fdset_fd->fd;
|
||||
fdsetfd_info->fd = mon_fdset_fd->fd;
|
||||
if (mon_fdset_fd->opaque) {
|
||||
fdsetfd_info->value->has_opaque = true;
|
||||
fdsetfd_info->value->opaque = g_strdup(mon_fdset_fd->opaque);
|
||||
fdsetfd_info->has_opaque = true;
|
||||
fdsetfd_info->opaque = g_strdup(mon_fdset_fd->opaque);
|
||||
} else {
|
||||
fdsetfd_info->value->has_opaque = false;
|
||||
fdsetfd_info->has_opaque = false;
|
||||
}
|
||||
|
||||
fdsetfd_info->next = fdsetfd_list;
|
||||
fdsetfd_list = fdsetfd_info;
|
||||
QAPI_LIST_PREPEND(fdset_info->fds, fdsetfd_info);
|
||||
}
|
||||
|
||||
fdset_info->value->fds = fdsetfd_list;
|
||||
|
||||
fdset_info->next = fdset_list;
|
||||
fdset_list = fdset_info;
|
||||
QAPI_LIST_PREPEND(fdset_list, fdset_info);
|
||||
}
|
||||
|
||||
return fdset_list;
|
||||
|
|
|
@ -105,7 +105,7 @@ struct Monitor {
|
|||
* Members that are protected by the per-monitor lock
|
||||
*/
|
||||
QLIST_HEAD(, mon_fd_t) fds;
|
||||
QString *outbuf;
|
||||
GString *outbuf;
|
||||
guint out_watch;
|
||||
/* Read under either BQL or mon_lock, written with BQL+mon_lock. */
|
||||
int mux_out;
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "qapi/qapi-emit-events.h"
|
||||
#include "qapi/qapi-visit-control.h"
|
||||
#include "qapi/qmp/qdict.h"
|
||||
#include "qapi/qmp/qstring.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qemu/option.h"
|
||||
#include "sysemu/qtest.h"
|
||||
|
@ -181,22 +180,19 @@ static void monitor_flush_locked(Monitor *mon)
|
|||
return;
|
||||
}
|
||||
|
||||
buf = qstring_get_str(mon->outbuf);
|
||||
len = qstring_get_length(mon->outbuf);
|
||||
buf = mon->outbuf->str;
|
||||
len = mon->outbuf->len;
|
||||
|
||||
if (len && !mon->mux_out) {
|
||||
rc = qemu_chr_fe_write(&mon->chr, (const uint8_t *) buf, len);
|
||||
if ((rc < 0 && errno != EAGAIN) || (rc == len)) {
|
||||
/* all flushed or error */
|
||||
qobject_unref(mon->outbuf);
|
||||
mon->outbuf = qstring_new();
|
||||
g_string_truncate(mon->outbuf, 0);
|
||||
return;
|
||||
}
|
||||
if (rc > 0) {
|
||||
/* partial write */
|
||||
QString *tmp = qstring_from_str(buf + rc);
|
||||
qobject_unref(mon->outbuf);
|
||||
mon->outbuf = tmp;
|
||||
g_string_erase(mon->outbuf, 0, rc);
|
||||
}
|
||||
if (mon->out_watch == 0) {
|
||||
mon->out_watch =
|
||||
|
@ -223,9 +219,9 @@ int monitor_puts(Monitor *mon, const char *str)
|
|||
for (i = 0; str[i]; i++) {
|
||||
c = str[i];
|
||||
if (c == '\n') {
|
||||
qstring_append_chr(mon->outbuf, '\r');
|
||||
g_string_append_c(mon->outbuf, '\r');
|
||||
}
|
||||
qstring_append_chr(mon->outbuf, c);
|
||||
g_string_append_c(mon->outbuf, c);
|
||||
if (c == '\n') {
|
||||
monitor_flush_locked(mon);
|
||||
}
|
||||
|
@ -602,7 +598,7 @@ void monitor_data_init(Monitor *mon, bool is_qmp, bool skip_flush,
|
|||
}
|
||||
qemu_mutex_init(&mon->mon_lock);
|
||||
mon->is_qmp = is_qmp;
|
||||
mon->outbuf = qstring_new();
|
||||
mon->outbuf = g_string_new(NULL);
|
||||
mon->skip_flush = skip_flush;
|
||||
mon->use_io_thread = use_io_thread;
|
||||
}
|
||||
|
@ -616,7 +612,7 @@ void monitor_data_destroy(Monitor *mon)
|
|||
} else {
|
||||
readline_free(container_of(mon, MonitorHMP, common)->rs);
|
||||
}
|
||||
qobject_unref(mon->outbuf);
|
||||
g_string_free(mon->outbuf, true);
|
||||
qemu_mutex_destroy(&mon->mon_lock);
|
||||
}
|
||||
|
||||
|
|
|
@ -138,18 +138,18 @@ EventInfoList *qmp_query_events(Error **errp)
|
|||
* QAPIEvent_str() and QAPIEvent_lookup[]. When the command goes,
|
||||
* they should go, too.
|
||||
*/
|
||||
EventInfoList *info, *ev_list = NULL;
|
||||
EventInfoList *ev_list = NULL;
|
||||
QAPIEvent e;
|
||||
|
||||
for (e = 0 ; e < QAPI_EVENT__MAX ; e++) {
|
||||
const char *event_name = QAPIEvent_str(e);
|
||||
EventInfo *info;
|
||||
|
||||
assert(event_name != NULL);
|
||||
info = g_malloc0(sizeof(*info));
|
||||
info->value = g_malloc0(sizeof(*info->value));
|
||||
info->value->name = g_strdup(event_name);
|
||||
info->name = g_strdup(event_name);
|
||||
|
||||
info->next = ev_list;
|
||||
ev_list = info;
|
||||
QAPI_LIST_PREPEND(ev_list, info);
|
||||
}
|
||||
|
||||
return ev_list;
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "qapi/qmp/qdict.h"
|
||||
#include "qapi/qmp/qjson.h"
|
||||
#include "qapi/qmp/qlist.h"
|
||||
#include "qapi/qmp/qstring.h"
|
||||
#include "trace.h"
|
||||
|
||||
struct QMPRequest {
|
||||
|
@ -110,15 +109,15 @@ static void monitor_qmp_cleanup_queue_and_resume(MonitorQMP *mon)
|
|||
void qmp_send_response(MonitorQMP *mon, const QDict *rsp)
|
||||
{
|
||||
const QObject *data = QOBJECT(rsp);
|
||||
QString *json;
|
||||
GString *json;
|
||||
|
||||
json = mon->pretty ? qobject_to_json_pretty(data) : qobject_to_json(data);
|
||||
json = qobject_to_json_pretty(data, mon->pretty);
|
||||
assert(json != NULL);
|
||||
|
||||
qstring_append_chr(json, '\n');
|
||||
monitor_puts(&mon->common, qstring_get_str(json));
|
||||
g_string_append_c(json, '\n');
|
||||
monitor_puts(&mon->common, json->str);
|
||||
|
||||
qobject_unref(json);
|
||||
g_string_free(json, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -276,9 +275,15 @@ void coroutine_fn monitor_qmp_dispatcher_co(void *data)
|
|||
mon->qmp_requests->length == QMP_REQ_QUEUE_LEN_MAX - 1;
|
||||
qemu_mutex_unlock(&mon->qmp_queue_lock);
|
||||
if (req_obj->req) {
|
||||
QDict *qdict = qobject_to(QDict, req_obj->req);
|
||||
QObject *id = qdict ? qdict_get(qdict, "id") : NULL;
|
||||
trace_monitor_qmp_cmd_in_band(qobject_get_try_str(id) ?: "");
|
||||
if (trace_event_get_state(TRACE_MONITOR_QMP_CMD_IN_BAND)) {
|
||||
QDict *qdict = qobject_to(QDict, req_obj->req);
|
||||
QObject *id = qdict ? qdict_get(qdict, "id") : NULL;
|
||||
GString *id_json;
|
||||
|
||||
id_json = id ? qobject_to_json(id) : g_string_new(NULL);
|
||||
trace_monitor_qmp_cmd_in_band(id_json->str);
|
||||
g_string_free(id_json, true);
|
||||
}
|
||||
monitor_qmp_dispatch(mon, req_obj->req);
|
||||
} else {
|
||||
assert(req_obj->err);
|
||||
|
@ -308,26 +313,27 @@ void coroutine_fn monitor_qmp_dispatcher_co(void *data)
|
|||
static void handle_qmp_command(void *opaque, QObject *req, Error *err)
|
||||
{
|
||||
MonitorQMP *mon = opaque;
|
||||
QObject *id = NULL;
|
||||
QDict *qdict;
|
||||
QDict *qdict = qobject_to(QDict, req);
|
||||
QMPRequest *req_obj;
|
||||
|
||||
assert(!req != !err);
|
||||
|
||||
qdict = qobject_to(QDict, req);
|
||||
if (qdict) {
|
||||
id = qdict_get(qdict, "id");
|
||||
} /* else will fail qmp_dispatch() */
|
||||
|
||||
if (req && trace_event_get_state_backends(TRACE_HANDLE_QMP_COMMAND)) {
|
||||
QString *req_json = qobject_to_json(req);
|
||||
trace_handle_qmp_command(mon, qstring_get_str(req_json));
|
||||
qobject_unref(req_json);
|
||||
GString *req_json = qobject_to_json(req);
|
||||
trace_handle_qmp_command(mon, req_json->str);
|
||||
g_string_free(req_json, true);
|
||||
}
|
||||
|
||||
if (qdict && qmp_is_oob(qdict)) {
|
||||
/* OOB commands are executed immediately */
|
||||
trace_monitor_qmp_cmd_out_of_band(qobject_get_try_str(id) ?: "");
|
||||
if (trace_event_get_state(TRACE_MONITOR_QMP_CMD_OUT_OF_BAND)) {
|
||||
QObject *id = qdict_get(qdict, "id");
|
||||
GString *id_json;
|
||||
|
||||
id_json = id ? qobject_to_json(id) : g_string_new(NULL);
|
||||
trace_monitor_qmp_cmd_out_of_band(id_json->str);
|
||||
g_string_free(id_json, true);
|
||||
}
|
||||
monitor_qmp_dispatch(mon, req);
|
||||
qobject_unref(req);
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue