aboutsummaryrefslogtreecommitdiff
path: root/backends/cryptodev-hmp-cmds.c
blob: 4f7220bb13375f287e57a71578de8e949bc206d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * HMP commands related to cryptodev
 *
 * Copyright (c) 2023 Bytedance.Inc
 *
 * Authors:
 *    zhenwei pi<pizhenwei@bytedance.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or
 * (at your option) any later version.
 */

#include "qemu/osdep.h"
#include "monitor/hmp.h"
#include "monitor/monitor.h"
#include "qapi/qapi-commands-cryptodev.h"
#include "qapi/qmp/qdict.h"


void hmp_info_cryptodev(Monitor *mon, const QDict *qdict)
{
    QCryptodevInfoList *il;
    QCryptodevBackendServiceTypeList *sl;
    QCryptodevBackendClientList *cl;

    for (il = qmp_query_cryptodev(NULL); il; il = il->next) {
        g_autofree char *services = NULL;
        QCryptodevInfo *info = il->value;
        char *tmp_services;

        /* build a string like 'service=[akcipher|mac|hash|cipher]' */
        for (sl = info->service; sl; sl = sl->next) {
            const char *service = QCryptodevBackendServiceType_str(sl->value);

            if (!services) {
                services = g_strdup(service);
            } else {
                tmp_services = g_strjoin("|", services, service, NULL);
                g_free(services);
                services = tmp_services;
            }
        }
        monitor_printf(mon, "%s: service=[%s]\n", info->id, services);

        for (cl = info->client; cl; cl = cl->next) {
            QCryptodevBackendClient *client = cl->value;
            monitor_printf(mon, "    queue %" PRIu32 ": type=%s\n",
                           client->queue,
                           QCryptodevBackendType_str(client->type));
        }
    }

    qapi_free_QCryptodevInfoList(il);
}