diff options
author | Daniel P. Berrangé | 2021-10-08 16:09:00 +0200 |
---|---|---|
committer | Daniel P. Berrangé | 2021-11-02 16:55:13 +0100 |
commit | f9429c6790ce0c9f737d318eeff5c4a24f641ec2 (patch) | |
tree | 418362075b55a83a80e77fea1180434379b6f82d /qapi/qapi-type-helpers.c | |
parent | docs/devel: update error handling guidance for HMP commands (diff) | |
download | qemu-f9429c6790ce0c9f737d318eeff5c4a24f641ec2.tar.gz qemu-f9429c6790ce0c9f737d318eeff5c4a24f641ec2.tar.xz qemu-f9429c6790ce0c9f737d318eeff5c4a24f641ec2.zip |
monitor: introduce HumanReadableText and HMP support
This provides a foundation on which to convert simple HMP commands to
use QMP. The QMP implementation will generate formatted text targeted
for human consumption, returning it in the HumanReadableText data type.
The HMP command handler will simply print out the formatted string
within the HumanReadableText data type. Since this will be an entirely
formulaic action in the case of HMP commands taking no arguments, a
custom command handler is provided.
Thus instead of registering a 'cmd' callback for the HMP command, a
'cmd_info_hrt' callback is provided, which will simply be a pointer
to the QMP implementation.
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'qapi/qapi-type-helpers.c')
-rw-r--r-- | qapi/qapi-type-helpers.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/qapi/qapi-type-helpers.c b/qapi/qapi-type-helpers.c new file mode 100644 index 0000000000..f76b34f647 --- /dev/null +++ b/qapi/qapi-type-helpers.c @@ -0,0 +1,23 @@ +/* + * QAPI common helper functions + * + * This file provides helper functions related to types defined + * in the QAPI schema. + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. + * See the COPYING.LIB file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qapi/type-helpers.h" + +HumanReadableText *human_readable_text_from_str(GString *str) +{ + HumanReadableText *ret = g_new0(HumanReadableText, 1); + + ret->human_readable_text = g_steal_pointer(&str->str); + + return ret; +} |