qapi: introduce x-query-rdma QMP command

This is a counterpart to the HMP "info rdma" command. It is being
added with an "x-" prefix because this QMP command is intended as an
adhoc debugging tool and will thus not be modelled in QAPI as fully
structured data, nor will it have long term guaranteed stability.
The existing HMP command is rewritten to call the QMP command.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé
2021-09-08 10:35:43 +01:00
parent fc30920731
commit 8dbbca5c05
8 changed files with 114 additions and 96 deletions

View File

@ -40,6 +40,7 @@
#include "qapi/qmp/qerror.h"
#include "hw/mem/memory-device.h"
#include "hw/acpi/acpi_dev_interface.h"
#include "hw/rdma/rdma.h"
NameInfo *qmp_query_name(Error **errp)
{
@ -382,3 +383,34 @@ HumanReadableText *qmp_x_query_profile(Error **errp)
return NULL;
}
#endif
static int qmp_x_query_rdma_foreach(Object *obj, void *opaque)
{
RdmaProvider *rdma;
RdmaProviderClass *k;
GString *buf = opaque;
if (object_dynamic_cast(obj, INTERFACE_RDMA_PROVIDER)) {
rdma = RDMA_PROVIDER(obj);
k = RDMA_PROVIDER_GET_CLASS(obj);
if (k->format_statistics) {
k->format_statistics(rdma, buf);
} else {
g_string_append_printf(buf,
"RDMA statistics not available for %s.\n",
object_get_typename(obj));
}
}
return 0;
}
HumanReadableText *qmp_x_query_rdma(Error **errp)
{
g_autoptr(GString) buf = g_string_new("");
object_child_foreach_recursive(object_get_root(),
qmp_x_query_rdma_foreach, buf);
return human_readable_text_from_str(buf);
}