From nobody Wed Feb 11 01:09:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1668149690; cv=none; d=zohomail.com; s=zohoarc; b=Gs5PiRV3bQdV1h3MwxC/vHSa7anDB7Xy4u8jfvDh1Z16/tBHCgh5lL/2V57htpg4IeT9h5mb840zUw3I0arkGA3oKLndMqCIcAXySa+ikG9q+VOUj3GvIjbtLyutQ2wpP8jnjTcBFlujsooIM+X7yj/HlSF50kU90YUJaWqYQRE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668149690; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LIesySo8KfoPYYuDv0hxnDo5m8+fU1mYrZHcG45Uhwg=; b=oG03967JL2WNyPuYtv+yLZuvFZ0+Lt5pvTZI7Fy/Cqp01WF/xQ94DqG8iRmvmsDs85z33qD88b/6LYxFY5X6jqRZDhJWW7zVZyJLuOukXFoCdpd5HJjAIj2uoHbrFkUicZXO2bhGegLyDoveXISxr4ZHVs2iednrXVoRgeuFlqA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668149690343622.8471997607325; Thu, 10 Nov 2022 22:54:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otNpD-0006cl-Oz; Fri, 11 Nov 2022 01:47:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otNpA-0006bI-Fh for qemu-devel@nongnu.org; Fri, 11 Nov 2022 01:47:36 -0500 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otNp8-0008IF-PP for qemu-devel@nongnu.org; Fri, 11 Nov 2022 01:47:36 -0500 Received: by mail-pg1-x52a.google.com with SMTP id q1so3688902pgl.11 for ; Thu, 10 Nov 2022 22:47:34 -0800 (PST) Received: from always-x1.bytedance.net ([63.216.146.186]) by smtp.gmail.com with ESMTPSA id u10-20020a170902e5ca00b0017f64ab80e5sm841022plf.179.2022.11.10.22.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 22:47:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LIesySo8KfoPYYuDv0hxnDo5m8+fU1mYrZHcG45Uhwg=; b=DvxJSz3/wEEDnYyPM11np5qTIqJRVVKV5lO4npjlMzcxeJj4dJ/zRUfILwgUoVEVKB LC+LJBkEU3ZCyiI3uvRskb/tnKEuEDmpKRrVH0aGitrV2ZDlysDvgZugB3QcGb96vW0Q /jy3/aIVq8jyZMfLk18coxAFVLR+b91vSf1u8pTbw3V/ApT1qoGVEUf7U9pAvN8VLTMF aPHZrMoBMkrwq6/gMzT5Dc89fanSMq//LxhxIzzhlcwPjOCmbWhJhXAvWDarbYn0sK5z pTIHqwkQpD+an9lBK/CUuJnOhaE5nflpoXzNmOMK4u84JTdzydVrvlN9EbtO1QyUtoUt 5FFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LIesySo8KfoPYYuDv0hxnDo5m8+fU1mYrZHcG45Uhwg=; b=m05BA6LChY90lhUfFJ08GiY+jD1YxoMJTfF0aVBZ4yFyXD8eIK0gCueg3ZdfJySzI7 bH4IY5rmDbwjWGp0M/uxOOmE415+L12+fVN+kGliHVASJuYmhXop4kFL8GmXUTwjI5CU IQPvz4HlZR4A8x9Ff9zEGso2kSvIEysfgaYGp5zYesPK14wlMccMggqGKU9qXW4wn8pc ZTcRkWSduj+bSBwD9LNvBW9Ae7UGpxRU+ptp3l9nrlWN9QVqRd2Lth7CFE9Fj+78O8L4 RYKK2o1paMGOPleSGRrBwKCGHwCA4Q3bakuXWdKPbW70byT8SrNBAxYTiyaZ5KpgmEMZ nILQ== X-Gm-Message-State: ANoB5pmEe8zfAzig0HAuhsdnKVqIpuLEGlNzv2WtmXJ0zMVgLoobmPYZ YdlAnyzpplhyANq2mqSHlY86BA== X-Google-Smtp-Source: AA0mqf5/X0Em3V8ifIs2J93d/ILyfxzdwhf2FYzSr+0t/l42WHc+BzTwWqjiJKAQjGRUM7Z3LyomTw== X-Received: by 2002:a63:2210:0:b0:458:6031:ba1 with SMTP id i16-20020a632210000000b0045860310ba1mr447725pgi.524.1668149253343; Thu, 10 Nov 2022 22:47:33 -0800 (PST) From: zhenwei pi To: arei.gonglei@huawei.com, dgilbert@redhat.com, mst@redhat.com, eblake@redhat.com, armbru@redhat.com, michael.roth@amd.com Cc: qemu-devel@nongnu.org, zhenwei pi Subject: [PATCH for 8.0 8/8] hmp: add cryptodev info command Date: Fri, 11 Nov 2022 14:45:53 +0800 Message-Id: <20221111064553.246932-9-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221111064553.246932-1-pizhenwei@bytedance.com> References: <20221111064553.246932-1-pizhenwei@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=pizhenwei@bytedance.com; helo=mail-pg1-x52a.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bytedance-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1668149692551100003 Content-Type: text/plain; charset="utf-8" Example of this command: # virsh qemu-monitor-command vm --hmp info cryptodev cryptodev1: service=3D[akcipher|mac|hash|cipher] queue 0: type=3Dbuiltin cryptodev0: service=3D[akcipher] queue 0: type=3Dlkcf Signed-off-by: zhenwei pi --- 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 =3D "cryptodev", + .args_type =3D "", + .params =3D "", + .help =3D "show the crypto devices", + .cmd =3D hmp_info_cryptodev, + .flags =3D "p", + }, + +SRST + ``info cryptodev`` + Show the crypto devices. +ERST diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index dfbc0c9a2f..b6b2b49202 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -143,5 +143,6 @@ void hmp_info_vcpu_dirty_limit(Monitor *mon, const QDic= t *qdict); void hmp_human_readable_text_helper(Monitor *mon, HumanReadableText *(*qmp_handler)(Erro= r **)); void hmp_info_stats(Monitor *mon, const QDict *qdict); +void hmp_info_cryptodev(Monitor *mon, const QDict *qdict); =20 #endif diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 01b789a79e..3f1054aa1e 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" @@ -2761,3 +2762,38 @@ void hmp_virtio_queue_element(Monitor *mon, const QD= ict *qdict) =20 qapi_free_VirtioQueueElement(e); } + +void hmp_info_cryptodev(Monitor *mon, const QDict *qdict) +{ + CryptodevInfoList *info_list; + CryptodevInfo *info; + QCryptodevBackendServiceTypeList *service_list; + CryptodevBackendClientList *client_list; + CryptodevBackendClient *client; + char services[128] =3D {}; + int len; + + info_list =3D qmp_query_cryptodev(NULL); + for ( ; info_list; info_list =3D info_list->next) { + info =3D info_list->value; + + service_list =3D info->service; + for (len =3D 0; service_list; service_list =3D service_list->next)= { + len +=3D snprintf(services + len, sizeof(services) - len, "%s|= ", + QCryptodevBackendServiceType_str(service_list->value)); + } + if (len) { + services[len - 1] =3D '\0'; /* strip last char '|' */ + } + monitor_printf(mon, "%s: service=3D[%s]\n", info->id, services); + + client_list =3D info->client; + for ( ; client_list; client_list =3D client_list->next) { + client =3D client_list->value; + monitor_printf(mon, " queue %ld: type=3D%s\n", client->queu= e, + QCryptodevBackendType_str(client->type)); + } + } + + qapi_free_CryptodevInfoList(info_list); +} --=20 2.20.1