cryptodev-hmp-cmds.c 1.6 KB

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