qapi: allow unions to contain further unions
[qemu/armbru.git] / backends / cryptodev-hmp-cmds.c
blob4f7220bb13375f287e57a71578de8e949bc206d5
1 /*
2 * HMP commands related to cryptodev
4 * Copyright (c) 2023 Bytedance.Inc
6 * Authors:
7 * zhenwei pi<pizhenwei@bytedance.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or
10 * (at your option) any later version.
13 #include "qemu/osdep.h"
14 #include "monitor/hmp.h"
15 #include "monitor/monitor.h"
16 #include "qapi/qapi-commands-cryptodev.h"
17 #include "qapi/qmp/qdict.h"
20 void hmp_info_cryptodev(Monitor *mon, const QDict *qdict)
22 QCryptodevInfoList *il;
23 QCryptodevBackendServiceTypeList *sl;
24 QCryptodevBackendClientList *cl;
26 for (il = qmp_query_cryptodev(NULL); il; il = il->next) {
27 g_autofree char *services = NULL;
28 QCryptodevInfo *info = il->value;
29 char *tmp_services;
31 /* build a string like 'service=[akcipher|mac|hash|cipher]' */
32 for (sl = info->service; sl; sl = sl->next) {
33 const char *service = QCryptodevBackendServiceType_str(sl->value);
35 if (!services) {
36 services = g_strdup(service);
37 } else {
38 tmp_services = g_strjoin("|", services, service, NULL);
39 g_free(services);
40 services = tmp_services;
43 monitor_printf(mon, "%s: service=[%s]\n", info->id, services);
45 for (cl = info->client; cl; cl = cl->next) {
46 QCryptodevBackendClient *client = cl->value;
47 monitor_printf(mon, " queue %" PRIu32 ": type=%s\n",
48 client->queue,
49 QCryptodevBackendType_str(client->type));
53 qapi_free_QCryptodevInfoList(il);