From nobody Tue Feb 10 20:48:31 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=pass(p=none dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1677639226; cv=none; d=zohomail.com; s=zohoarc; b=ValCYgg3gvE3juj3V6ldB5OVgO/mTLFPQbi3fAk86eTnGy2lSLbpMVy7iQTmbblJ4z8sW2EEDZ8ScEfWft6O97ygQUHxwszL0VViY2dzl/HmT5L9AM9i8XXAwXr+o7iKxriVvakmzkLCyCLOi3li3STJbND2d8FJLSrFcNpnw/o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677639226; 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=hW0/TnVbaKXVVnYFWE4r3/RgtfUxjdrwB+uyh9EgFgI=; b=TplTSXPUv298S4d1Z5QxotykWFkPOSqX883ZRJFzpD/GEsZydsZajUbfWg7ks0xPV9HYiblXS9iMJwcCs1JaH5Llzt/5i+pz1mag8otL2pW/n2Qg/FwtvusSfAVIdDDvJK92tmbzu+NVCVNmyws1Bk05p0ww5K3KD3dcUKb4rQw= 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=pass 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 1677639226388110.72091625323867; Tue, 28 Feb 2023 18:53:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXCZX-0007t5-An; Tue, 28 Feb 2023 21:52:03 -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 1pXCZR-0007jm-Fu for qemu-devel@nongnu.org; Tue, 28 Feb 2023 21:51:58 -0500 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXCZP-0001ff-PS for qemu-devel@nongnu.org; Tue, 28 Feb 2023 21:51:57 -0500 Received: by mail-pj1-x1033.google.com with SMTP id m8-20020a17090a4d8800b002377bced051so15818220pjh.0 for ; Tue, 28 Feb 2023 18:51:55 -0800 (PST) Received: from libai.bytedance.net ([61.213.176.5]) by smtp.gmail.com with ESMTPSA id ix1-20020a170902f80100b0019ab58f47a6sm7218743plb.105.2023.02.28.18.51.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 18:51:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1677639115; 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=hW0/TnVbaKXVVnYFWE4r3/RgtfUxjdrwB+uyh9EgFgI=; b=E8H3miMVEdcYhb3G8BNVEUvhRUwP/DR6jrPUidud8osfIBKnKeTmI688nhcpbEReRV tx3717YB7hSD+fgLr2zeGpYvlOe2i9ZzyrCGryU6RRDaYpUbKjRbUs095OSzGYTBUxbw oBWOwJc1Eij/qWN/dprzrwH5ikE3WhZqhcrljxFIJzUJxn614t2IxtyrdKCVdsZ1qYtR XPq0eceQv3J0swnHcZ3C+nBLqI4OZnVELoLQngwIM5/RnXe3wKJ02tMpGlGwkcOjyd3X Tjdg/Yzdc40UuT3z+1jDLmnjmg3a0c/XnvQTRuZsO1rQwvHMJP3CAkqWOGf05iCKtUnJ DhWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677639115; 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=hW0/TnVbaKXVVnYFWE4r3/RgtfUxjdrwB+uyh9EgFgI=; b=yTVhG8ZMNnSQxQbqmJrKWElM+sM9EItddhj/ACi0ppQ02LJDbb8C4J8755IRzDz8lD QL+iSbB5Cj0/pWv0u4nhhQOfH7+pa3Snhmf7gi3E5EpbOqMIvvQOCs+lQNL8fv21ecZ/ atu8QR5N+t5qSfoMqFhnjLguWZYxn12fta0m/QrKDWYSEQTQ7t4mlsjbGQjR9dbem7OV jqYOlfAh3x7/OFlp/CTYd3FjO7Pp2b6v2kWmRcgQqC+dEMbp7xbtoQsfy8RI4xLSBLFL e1330hmibb+wYQcgZcYQhYXyGIDAv1NzSXX4gfJ3DehsuB76IXh/rkBPegTGeeqZYivA KgVg== X-Gm-Message-State: AO0yUKUB/2cdOocWLq6EYwF+mmqePDdhjtpYxkSrIy3zsAgf7PgsKcJh MU2rlGgs1Uj4pamwkRrQ+sVVtgT246RmG1uw X-Google-Smtp-Source: AK7set9F1O4p36QLhTELHV14u1Z4YzNJYUC3q6Cx8eSHZppf3sfxWYtaRUWCPbznOvD0AZgQHl+X3A== X-Received: by 2002:a17:902:f545:b0:19a:8304:21eb with SMTP id h5-20020a170902f54500b0019a830421ebmr16097479plf.6.1677639114690; Tue, 28 Feb 2023 18:51:54 -0800 (PST) From: zhenwei pi To: mst@redhat.com, arei.gonglei@huawei.com Cc: dgilbert@redhat.com, pbonzini@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, berrange@redhat.com, zhenwei pi Subject: [PATCH v5 07/12] hmp: add cryptodev info command Date: Wed, 1 Mar 2023 10:51:19 +0800 Message-Id: <20230301025124.3605557-8-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230301025124.3605557-1-pizhenwei@bytedance.com> References: <20230301025124.3605557-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::1033; envelope-from=pizhenwei@bytedance.com; helo=mail-pj1-x1033.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-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) X-ZM-MESSAGEID: 1677639226667100003 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 Acked-by: Dr. David Alan Gilbert Reviewed-by: Daniel P. Berrang=C3=A9 --- backends/cryptodev-hmp-cmds.c | 54 +++++++++++++++++++++++++++++++++++ backends/meson.build | 1 + hmp-commands-info.hx | 14 +++++++++ include/monitor/hmp.h | 1 + 4 files changed, 70 insertions(+) create mode 100644 backends/cryptodev-hmp-cmds.c diff --git a/backends/cryptodev-hmp-cmds.c b/backends/cryptodev-hmp-cmds.c new file mode 100644 index 0000000000..4f7220bb13 --- /dev/null +++ b/backends/cryptodev-hmp-cmds.c @@ -0,0 +1,54 @@ +/* + * HMP commands related to cryptodev + * + * Copyright (c) 2023 Bytedance.Inc + * + * Authors: + * zhenwei pi + * + * 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 =3D qmp_query_cryptodev(NULL); il; il =3D il->next) { + g_autofree char *services =3D NULL; + QCryptodevInfo *info =3D il->value; + char *tmp_services; + + /* build a string like 'service=3D[akcipher|mac|hash|cipher]' */ + for (sl =3D info->service; sl; sl =3D sl->next) { + const char *service =3D QCryptodevBackendServiceType_str(sl->v= alue); + + if (!services) { + services =3D g_strdup(service); + } else { + tmp_services =3D g_strjoin("|", services, service, NULL); + g_free(services); + services =3D tmp_services; + } + } + monitor_printf(mon, "%s: service=3D[%s]\n", info->id, services); + + for (cl =3D info->client; cl; cl =3D cl->next) { + QCryptodevBackendClient *client =3D cl->value; + monitor_printf(mon, " queue %" PRIu32 ": type=3D%s\n", + client->queue, + QCryptodevBackendType_str(client->type)); + } + } + + qapi_free_QCryptodevInfoList(il); +} diff --git a/backends/meson.build b/backends/meson.build index 954e658b25..b369e0a9d0 100644 --- a/backends/meson.build +++ b/backends/meson.build @@ -1,5 +1,6 @@ softmmu_ss.add([files( 'cryptodev-builtin.c', + 'cryptodev-hmp-cmds.c', 'cryptodev.c', 'hostmem-ram.c', 'hostmem.c', 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 2220f14fc9..e6cf0b7aa7 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -178,5 +178,6 @@ void hmp_ioport_read(Monitor *mon, const QDict *qdict); void hmp_ioport_write(Monitor *mon, const QDict *qdict); void hmp_boot_set(Monitor *mon, const QDict *qdict); void hmp_info_mtree(Monitor *mon, const QDict *qdict); +void hmp_info_cryptodev(Monitor *mon, const QDict *qdict); =20 #endif --=20 2.34.1