qapi: Convert query-chardev
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Tested-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
efab767eaa
commit
c5a415a0af
13
hmp.c
13
hmp.c
@ -80,3 +80,16 @@ void hmp_info_uuid(Monitor *mon)
|
|||||||
monitor_printf(mon, "%s\n", info->UUID);
|
monitor_printf(mon, "%s\n", info->UUID);
|
||||||
qapi_free_UuidInfo(info);
|
qapi_free_UuidInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hmp_info_chardev(Monitor *mon)
|
||||||
|
{
|
||||||
|
ChardevInfoList *char_info, *info;
|
||||||
|
|
||||||
|
char_info = qmp_query_chardev(NULL);
|
||||||
|
for (info = char_info; info; info = info->next) {
|
||||||
|
monitor_printf(mon, "%s: filename=%s\n", info->value->label,
|
||||||
|
info->value->filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
qapi_free_ChardevInfoList(char_info);
|
||||||
|
}
|
||||||
|
1
hmp.h
1
hmp.h
@ -22,5 +22,6 @@ void hmp_info_version(Monitor *mon);
|
|||||||
void hmp_info_kvm(Monitor *mon);
|
void hmp_info_kvm(Monitor *mon);
|
||||||
void hmp_info_status(Monitor *mon);
|
void hmp_info_status(Monitor *mon);
|
||||||
void hmp_info_uuid(Monitor *mon);
|
void hmp_info_uuid(Monitor *mon);
|
||||||
|
void hmp_info_chardev(Monitor *mon);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
11
monitor.c
11
monitor.c
@ -2783,8 +2783,7 @@ static const mon_cmd_t info_cmds[] = {
|
|||||||
.args_type = "",
|
.args_type = "",
|
||||||
.params = "",
|
.params = "",
|
||||||
.help = "show the character devices",
|
.help = "show the character devices",
|
||||||
.user_print = qemu_chr_info_print,
|
.mhandler.info = hmp_info_chardev,
|
||||||
.mhandler.info_new = qemu_chr_info,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "block",
|
.name = "block",
|
||||||
@ -3072,14 +3071,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
|
|||||||
.user_print = monitor_user_noop,
|
.user_print = monitor_user_noop,
|
||||||
.mhandler.info_new = do_info_commands,
|
.mhandler.info_new = do_info_commands,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
.name = "chardev",
|
|
||||||
.args_type = "",
|
|
||||||
.params = "",
|
|
||||||
.help = "show the character devices",
|
|
||||||
.user_print = qemu_chr_info_print,
|
|
||||||
.mhandler.info_new = qemu_chr_info,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
.name = "block",
|
.name = "block",
|
||||||
.args_type = "",
|
.args_type = "",
|
||||||
|
@ -176,3 +176,29 @@
|
|||||||
##
|
##
|
||||||
{ 'command': 'query-uuid', 'returns': 'UuidInfo' }
|
{ 'command': 'query-uuid', 'returns': 'UuidInfo' }
|
||||||
|
|
||||||
|
##
|
||||||
|
# @ChardevInfo:
|
||||||
|
#
|
||||||
|
# Information about a character device.
|
||||||
|
#
|
||||||
|
# @label: the label of the character device
|
||||||
|
#
|
||||||
|
# @filename: the filename of the character device
|
||||||
|
#
|
||||||
|
# Notes: @filename is encoded using the QEMU command line character device
|
||||||
|
# encoding. See the QEMU man page for details.
|
||||||
|
#
|
||||||
|
# Since: 0.14.0
|
||||||
|
##
|
||||||
|
{ 'type': 'ChardevInfo', 'data': {'label': 'str', 'filename': 'str'} }
|
||||||
|
|
||||||
|
##
|
||||||
|
# @query-chardev:
|
||||||
|
#
|
||||||
|
# Returns information about current character devices.
|
||||||
|
#
|
||||||
|
# Returns: a list of @ChardevInfo
|
||||||
|
#
|
||||||
|
# Since: 0.14.0
|
||||||
|
##
|
||||||
|
{ 'command': 'query-chardev', 'returns': ['ChardevInfo'] }
|
||||||
|
35
qemu-char.c
35
qemu-char.c
@ -31,7 +31,7 @@
|
|||||||
#include "hw/usb.h"
|
#include "hw/usb.h"
|
||||||
#include "hw/baum.h"
|
#include "hw/baum.h"
|
||||||
#include "hw/msmouse.h"
|
#include "hw/msmouse.h"
|
||||||
#include "qemu-objects.h"
|
#include "qmp-commands.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -2650,35 +2650,22 @@ void qemu_chr_delete(CharDriverState *chr)
|
|||||||
g_free(chr);
|
g_free(chr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qemu_chr_qlist_iter(QObject *obj, void *opaque)
|
ChardevInfoList *qmp_query_chardev(Error **errp)
|
||||||
{
|
{
|
||||||
QDict *chr_dict;
|
ChardevInfoList *chr_list = NULL;
|
||||||
Monitor *mon = opaque;
|
|
||||||
|
|
||||||
chr_dict = qobject_to_qdict(obj);
|
|
||||||
monitor_printf(mon, "%s: filename=%s\n", qdict_get_str(chr_dict, "label"),
|
|
||||||
qdict_get_str(chr_dict, "filename"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void qemu_chr_info_print(Monitor *mon, const QObject *ret_data)
|
|
||||||
{
|
|
||||||
qlist_iter(qobject_to_qlist(ret_data), qemu_chr_qlist_iter, mon);
|
|
||||||
}
|
|
||||||
|
|
||||||
void qemu_chr_info(Monitor *mon, QObject **ret_data)
|
|
||||||
{
|
|
||||||
QList *chr_list;
|
|
||||||
CharDriverState *chr;
|
CharDriverState *chr;
|
||||||
|
|
||||||
chr_list = qlist_new();
|
|
||||||
|
|
||||||
QTAILQ_FOREACH(chr, &chardevs, next) {
|
QTAILQ_FOREACH(chr, &chardevs, next) {
|
||||||
QObject *obj = qobject_from_jsonf("{ 'label': %s, 'filename': %s }",
|
ChardevInfoList *info = g_malloc0(sizeof(*info));
|
||||||
chr->label, chr->filename);
|
info->value = g_malloc0(sizeof(*info->value));
|
||||||
qlist_append_obj(chr_list, obj);
|
info->value->label = g_strdup(chr->label);
|
||||||
|
info->value->filename = g_strdup(chr->filename);
|
||||||
|
|
||||||
|
info->next = chr_list;
|
||||||
|
chr_list = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ret_data = QOBJECT(chr_list);
|
return chr_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
CharDriverState *qemu_chr_find(const char *name)
|
CharDriverState *qemu_chr_find(const char *name)
|
||||||
|
@ -1120,6 +1120,12 @@ Example:
|
|||||||
|
|
||||||
EQMP
|
EQMP
|
||||||
|
|
||||||
|
{
|
||||||
|
.name = "query-chardev",
|
||||||
|
.args_type = "",
|
||||||
|
.mhandler.cmd_new = qmp_marshal_input_query_chardev,
|
||||||
|
},
|
||||||
|
|
||||||
SQMP
|
SQMP
|
||||||
query-block
|
query-block
|
||||||
-----------
|
-----------
|
||||||
|
Loading…
Reference in New Issue
Block a user