[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 07/12] hmp: add cryptodev info command
From: |
zhenwei pi |
Subject: |
[PATCH v3 07/12] hmp: add cryptodev info command |
Date: |
Sat, 28 Jan 2023 11:56:28 +0800 |
Example of this command:
# virsh qemu-monitor-command vm --hmp info cryptodev
cryptodev1: service=[akcipher|mac|hash|cipher]
queue 0: type=builtin
cryptodev0: service=[akcipher]
queue 0: type=lkcf
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
---
hmp-commands-info.hx | 14 ++++++++++++++
include/monitor/hmp.h | 1 +
monitor/hmp-cmds.c | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+)
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 754b1e8408..47d63d26db 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -993,3 +993,17 @@ SRST
``info virtio-queue-element`` *path* *queue* [*index*]
Display element of a given virtio queue
ERST
+
+ {
+ .name = "cryptodev",
+ .args_type = "",
+ .params = "",
+ .help = "show the crypto devices",
+ .cmd = hmp_info_cryptodev,
+ .flags = "p",
+ },
+
+SRST
+ ``info cryptodev``
+ Show the crypto devices.
+ERST
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index 1b3bdcb446..391a097ffd 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -151,5 +151,6 @@ void hmp_human_readable_text_helper(Monitor *mon,
HumanReadableText *(*qmp_handler)(Error
**));
void hmp_info_stats(Monitor *mon, const QDict *qdict);
void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict);
+void hmp_info_cryptodev(Monitor *mon, const QDict *qdict);
#endif
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 1dba973092..ed316f75c1 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -33,6 +33,7 @@
#include "qapi/qapi-commands-block.h"
#include "qapi/qapi-commands-char.h"
#include "qapi/qapi-commands-control.h"
+#include "qapi/qapi-commands-cryptodev.h"
#include "qapi/qapi-commands-machine.h"
#include "qapi/qapi-commands-migration.h"
#include "qapi/qapi-commands-misc.h"
@@ -2280,3 +2281,38 @@ void hmp_virtio_queue_element(Monitor *mon, const QDict
*qdict)
qapi_free_VirtioQueueElement(e);
}
+
+void hmp_info_cryptodev(Monitor *mon, const QDict *qdict)
+{
+ CryptodevInfoList *il;
+ QCryptodevBackendServiceTypeList *sl;
+ CryptodevBackendClientList *cl;
+
+ for (il = qmp_query_cryptodev(NULL); il; il = il->next) {
+ g_autofree char *services = NULL;
+ CryptodevInfo *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) {
+ CryptodevBackendClient *client = cl->value;
+ monitor_printf(mon, " queue %u: type=%s\n", client->queue,
+ QCryptodevBackendType_str(client->type));
+ }
+ }
+
+ qapi_free_CryptodevInfoList(il);
+}
--
2.34.1
- [PATCH v3 12/12] MAINTAINERS: add myself as the maintainer for cryptodev, (continued)
- [PATCH v3 12/12] MAINTAINERS: add myself as the maintainer for cryptodev, zhenwei pi, 2023/01/19
- Re: [PATCH v3 00/12] Refactor cryptodev, Michael S. Tsirkin, 2023/01/27
- [PATCH v3 00/12] Refactor cryptodev, zhenwei pi, 2023/01/27
- [PATCH v3 01/12] cryptodev: Introduce cryptodev.json, zhenwei pi, 2023/01/27
- [PATCH v3 02/12] cryptodev: Remove 'name' & 'model' fields, zhenwei pi, 2023/01/27
- [PATCH v3 03/12] cryptodev: Introduce cryptodev alg type in QAPI, zhenwei pi, 2023/01/27
- [PATCH v3 04/12] cryptodev: Introduce server type in QAPI, zhenwei pi, 2023/01/27
- [PATCH v3 05/12] cryptodev: Introduce 'query-cryptodev' QMP command, zhenwei pi, 2023/01/27
- [PATCH v3 06/12] cryptodev-builtin: Detect akcipher capability, zhenwei pi, 2023/01/27
- [PATCH v3 07/12] hmp: add cryptodev info command,
zhenwei pi <=
- [PATCH v3 08/12] cryptodev: Use CryptoDevBackendOpInfo for operation, zhenwei pi, 2023/01/27
- [PATCH v3 09/12] cryptodev: Account statistics, zhenwei pi, 2023/01/27
- [PATCH v3 10/12] cryptodev: support QoS, zhenwei pi, 2023/01/27
- [PATCH v3 11/12] cryptodev: Support query-stats QMP command, zhenwei pi, 2023/01/27
- [PATCH v3 12/12] MAINTAINERS: add myself as the maintainer for cryptodev, zhenwei pi, 2023/01/27
- Re: [PATCH v3 00/12] Refactor cryptodev, Michael S. Tsirkin, 2023/01/28