From nobody Mon May 6 23:42:58 2024 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; arc=pass (i=1dmarc=pass fromdomain=oracle.com); dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1616086530; cv=pass; d=zohomail.com; s=zohoarc; b=nw6SxrsUyZMXQhr1SL9JgsTldS3ivHPZdBZ5AgdJChE87dUYmoTlgVP8rCXWYkWaZ0vFoiCeZsP+wvV/dLhzQU3OgaiAjx7USgcgCd5faW8e5ergiKG4Fz3dA3krIGsnUPhleEN76RBSIdKXZzepwaPmlACfyoabf1GTELHWodU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616086530; h=Content-Type: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=zwS/DXX3103PjOuEw/S9ARUnCM7ShEqFN/zRCKhjRvY=; b=RRajRcEo82+3K02TRL/NSrVPlFzjFYMOmwdxXZrefNzT2h7vcWicKz3DWGUY20u/1cfy9pTVItG09lxDcyrQSi11ZVeVZK/11lm0T2eI2Le5MIDIpw9asBjcZuSmrnbarJrLi34i5pB9VLz8lLkNbix27piLlrO9UCR2xw/GYX0= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=oracle.com); dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616086530271215.6750251555178; Thu, 18 Mar 2021 09:55:30 -0700 (PDT) Received: from localhost ([::1]:35772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMvvk-0006XI-R7 for importer@patchew.org; Thu, 18 Mar 2021 12:55:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMvXx-00041p-G6; Thu, 18 Mar 2021 12:30:53 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:56722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMvXq-0008DC-9Q; Thu, 18 Mar 2021 12:30:53 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12IGTgB7085827; Thu, 18 Mar 2021 16:30:19 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 378p1p03ys-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Mar 2021 16:30:19 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12IGUAvB053881; Thu, 18 Mar 2021 16:30:19 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2176.outbound.protection.outlook.com [104.47.57.176]) by userp3030.oracle.com with ESMTP id 3797b352yq-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Mar 2021 16:30:18 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB4565.namprd10.prod.outlook.com (2603:10b6:510:31::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18; Thu, 18 Mar 2021 16:30:07 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::6819:aaf:9a92:c1db]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::6819:aaf:9a92:c1db%2]) with mapi id 15.20.3933.032; Thu, 18 Mar 2021 16:30:07 +0000 Received: from jonpalme-lnx.us.oracle.com (24.147.51.11) by SJ0PR05CA0079.namprd05.prod.outlook.com (2603:10b6:a03:332::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.10 via Frontend Transport; Thu, 18 Mar 2021 16:30:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=zwS/DXX3103PjOuEw/S9ARUnCM7ShEqFN/zRCKhjRvY=; b=kazpiSAGWLYqd3XOLuhJXCM2o0oJrL9itdVPsLSbZgSXBiYKtpVGToyH8lEI4ortwV4a s6GELWN8o4yjL6a5lIkCzNf3CtfG9LTv+R3Gsw5FnvpC9izE/agrQgzStmhwcScC6nU9 89XRvQyGqXGBu+rIH1pl30TDoUSL7spGXxClUgxoyQK0i00AePalBrLrBum7KCG4XElw eU4HkPC2J83zUpjsCwmSUJrLk1Z6bAL8sIhLn0GcyHNKg0JAGlwB4lZcmaW8RJ7U+QTd 3iJmOqq92B0/Ap5ByiGWGX97+Fzu8dwAOAyUntiib7A5etsqqKO+IUQ4XQr+5e6tkm7a 2w== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fhpQ+b5Uh9kDvnSY8Xwu4/nMeASlALKuZwDjkmL1sZXQvbkhEVUC1ok6jpdfURFKVELQVbImvVJV1y0Q9vn7E00Q+t+m+Qmr876Nqdm7EwXnAtdy/2pwWZYOrtKApTBXhTzdQ41bn+swrPOIUlqZljhwcQiYx33sL3mLxJTfFShzq793CfIOVT0ozuzTopcvcY9e+M0c7izF9QW3KBJqXhjHPtZdnPkKiESzb+uKPJm+7TT5BPYaAo7M+2l+6+8jqQQ8zYLmN37S3Q3RbwvuUeSHk0i5NHm0w77TXfSp/2JxSWuUlKUk9SayAmJTfIZlJfrQFSCfYr2WbwkYGBVC0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zwS/DXX3103PjOuEw/S9ARUnCM7ShEqFN/zRCKhjRvY=; b=kdMrtWgs4mO+9DLUt22zAWS9q+F/Xypu7/RYPO5FS/MTkFnsXF0QG+sLu9FprKRm84b9JYwozTEi1Nn0hr8Qj0de2h4q3mCuwUa9F1ryieN66z2kFfMuzDitx0AhVBKNTQzFphv+mSf7+Yj8voeM9LEIOeS7fcrAiAvE3IMIM3EETcDSpGWxkBsINNDoR6BVRw9s5Yt7edmPqQv3mdISLzV9Cw+fDRzdRpoxGfGtcapbT2PBT7yUPQQ2wnO5leRMUUdmp2DNNZ+zoOAJFDjp4As8qesBIEy867mIO15SjJzJM5L9a08nBQ7Ce/FHAipon4e7e4MeA8TtouhF09zmXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zwS/DXX3103PjOuEw/S9ARUnCM7ShEqFN/zRCKhjRvY=; b=jdn0yaGqibDGbIewex9gBKOxFKoMM06YmIyUvJn7qjYcNl8MLzrRHWhgD//nkZZwwB8Bo2P7OK7Gly0B0ewlPFDkwH7HIja+2CraAdc6w53Wc2v0UoTOOR8fTDCWG59gfgAbMdw+W76eJow38p3WzMphIEBu+RWWQcnlPM+Qsas= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [RFC v5 1/6] qmp: add QMP command x-debug-query-virtio Date: Thu, 18 Mar 2021 12:29:39 -0400 Message-Id: <1616084984-11263-2-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1616084984-11263-1-git-send-email-jonah.palmer@oracle.com> References: <1616084984-11263-1-git-send-email-jonah.palmer@oracle.com> X-Originating-IP: [24.147.51.11] X-ClientProxiedBy: SJ0PR05CA0079.namprd05.prod.outlook.com (2603:10b6:a03:332::24) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 645b639f-aeb4-47dd-963f-08d8ea2b174d X-MS-TrafficTypeDiagnostic: PH0PR10MB4565: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:215; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jI0KxncOBjNqpxlkRToB2FSMOyhl0Q7IAv5eHdrs3Is0LITbaMH3O/xd86aeXKGgq6REzd6ZLgAriT+SM0uXvHfemqJe1Wcozw4V05G9GbqaayO7XdAhXLN8JnIBdH/ZUd3w4qxLBwaqd4lyZYgr1QPbNgrB83HhmR5tDlyX2d6hVXy5oOU1+NVL06FN1ASIi1FrfZyR8TiO/SJ5efXXBNmCGwRZteE5B5J4vL9QzrDzkzxtHwWQY1fMssd4qQA7VZ9xpu/ueQFYzDHOhs4xFVUp9v6BLnt2UnyUDNywNq34uGvYgsvNp50fd1h6z/Kvm2FkyVrgWeaTZruwJpzRtJMhR29wzvSGVQ30szzmzrlxdRh3q5e+e3pn4J5mSFpIZkEomxAb4gEdl3zRP3JFbMf8Iq5yuYiZ2EmY1uImHEJXCapQDX75JTa5oCLpv+liKCAyNjx6kSFG4PVUWQ5H8oDhN3LUzeg3txStWp26rEYB6wuUSaPEf3s6OJE86cPQq73pIueXbx897iG2RdDPyn3lrrGT/DfHepUuKoP0Z7aKfivTOEgx9IzPLIEZQ93mwo9RzE2CbD0dewxn30RP6wevYMXO8qiPt26l7wKWk9Q= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR10MB4664.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(346002)(366004)(39860400002)(376002)(136003)(8676002)(66476007)(66556008)(66946007)(38100700001)(36756003)(186003)(5660300002)(2906002)(478600001)(86362001)(52116002)(7696005)(8936002)(316002)(16526019)(956004)(26005)(7416002)(6666004)(44832011)(83380400001)(2616005)(6916009)(107886003)(4326008)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?ZVgeH+6+rwXBjJfW7G0/wD8Nq/eFl3G5B9MDGraHlBprkGAdgQSuC3WlaqVU?= =?us-ascii?Q?QRMPZo+p07Be6yyZmaSmhG/6glGpdak0dcl2AzxiVlrQrmskkqyi4NdA3nOO?= =?us-ascii?Q?JmcI8yD0DKxPCNFN2Trp/s5w1l1NHj/NkQVFNNcP6rkHNWywCpItKHaqgU6R?= =?us-ascii?Q?oKCCROJV3tLQ/D+DNSWDLHuUzhI6OkfcOZ89rL/1Wc3gMoofx4oibyOQgnph?= =?us-ascii?Q?ab8HxOXaxiWHMUpoyuNyQJHWdIhVw3no5QegOEL5JyulW8VkNup1m71eZhKV?= =?us-ascii?Q?8nmBSF5YwtwkFfi8dvWBqQaAbyWAyf4BuWy48Xrf7o/EwCL+LozpFfcfP8GC?= =?us-ascii?Q?AZ8IMAH47yF36lXBcYMtk6gpQCi9EvHY9EMSOWOfm24ZGNnamsqNqvY1wuls?= =?us-ascii?Q?QYQwiWuT9y+ExPdTCAMVJ+dtE1p3Yz8eD5KEicKDxizYrpiscRaF9v5m6Eay?= =?us-ascii?Q?XNFg29hMdVUmSGxUIpPYOZ6p+y/DEuf9UWJ9LkEN4D1TltY6xB7/W2PWsYfo?= =?us-ascii?Q?BJpVcAB/aYjOV7dWooWpEx9WNUvhsuG2onDly4UKq4R2/IxLlcj5dhQjmhM/?= =?us-ascii?Q?IXHxG1DO+DmbRfGO6TBVtKB8Pho42+7M/dA91gQAdvhsL3rWSWYPMaIpBy3I?= =?us-ascii?Q?kq7j0b1BI7m7VnA6SmK3/DMV+3BVrHmBE4QM+3hg1vGNDIloMmHP1i08csMl?= =?us-ascii?Q?AAxIsSH0aPgwGgthNbLbR8LmhebMpLnx5PwAHzksB2Qw/QvlhyxwvSNzj7e1?= =?us-ascii?Q?Q5iYocBGz4hhymE6wwtT71t81gelxzmTqOOE4VMZZuQz9Hhb6VSxzI4zWy6K?= =?us-ascii?Q?1os9S+g42ABDLf82FzXhUlLa4Ojs5/4a7vErKK2q+DenMpUtXyPrU5CYZXa6?= =?us-ascii?Q?fHcagZEiDB8HJsmhTH67QykelJDHwHX7OSthF4JUPFz9JRHgNY+o/VERmV45?= =?us-ascii?Q?5NKKAJR/HZ+id5a1Qxqj/P1uCui6ioJ5B6mVOKhpYoiJQRZmpc/Bc8kOiVzo?= =?us-ascii?Q?Y8AUc+mk1vOPeK4kldA9cIBXxUupspmu76dXP/AGhXpYxbCD2JyujugaK2d/?= =?us-ascii?Q?O9DvqK3x62dy1i+4SBVD0DTy6ly/BmeMf9zn5TPcB43Mdn5vvwhpKbO0uAMN?= =?us-ascii?Q?EqtnEgeOphHPJFeqS5+ITbQKd2ZlevKd1b8lndSmkg3qdQBITX4W0Ex3St0i?= =?us-ascii?Q?OjNepwQgS4tJPqZ/mu+3VNh5jMdFsD68iBf0BW0gra52MlTG9QRofHt4IMMI?= =?us-ascii?Q?a9pcDgcAC5bwgNp2ZWryA0djVOCC8sLl2ciwOvp28rpYZnHJHslrkxc891US?= =?us-ascii?Q?YuMXjuSOdBcnQCLoVRzxY823?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 645b639f-aeb4-47dd-963f-08d8ea2b174d X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2021 16:30:06.9534 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7HJFfuZxZG8gP3Gl1j/dNY8d8n20gDpjGC8zhkPl6fBQUzcq2OXAPSBcwWKgbrho7YyvrYnZOfeu5H2xf+KfHg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4565 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9927 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103180116 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9927 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 suspectscore=0 adultscore=0 spamscore=0 clxscore=1015 phishscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103180116 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=156.151.31.85; envelope-from=jonah.palmer@oracle.com; helo=userp2120.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, marcandre.lureau@redhat.com, jonah.palmer@oracle.com, thuth@redhat.com, amit@kernel.org, michael.roth@amd.com, dgilbert@redhat.com, eric.auger@redhat.com, dmitrii.stepanov@cloud.ionos.com, stefanha@redhat.com, kwolf@redhat.com, laurent@vivier.eu, mreitz@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This new command lists all the instances of VirtIODevice with their path and virtio type Signed-off-by: Laurent Vivier Reviewed-by: Eric Blake Signed-off-by: Jonah Palmer --- hw/virtio/meson.build | 2 ++ hw/virtio/virtio-stub.c | 14 ++++++++++ hw/virtio/virtio.c | 28 +++++++++++++++++++ include/hw/virtio/virtio.h | 1 + qapi/meson.build | 1 + qapi/qapi-schema.json | 1 + qapi/virtio.json | 68 ++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qtest/qmp-cmd-test.c | 1 + 8 files changed, 116 insertions(+) create mode 100644 hw/virtio/virtio-stub.c create mode 100644 qapi/virtio.json diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index fbff9bc..81dc4c9 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -6,8 +6,10 @@ softmmu_virtio_ss.add(when: 'CONFIG_VHOST', if_false: file= s('vhost-stub.c')) =20 softmmu_ss.add_all(when: 'CONFIG_VIRTIO', if_true: softmmu_virtio_ss) softmmu_ss.add(when: 'CONFIG_VIRTIO', if_false: files('vhost-stub.c')) +softmmu_ss.add(when: 'CONFIG_VIRTIO', if_false: files('virtio-stub.c')) =20 softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-stub.c')) +softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('virtio-stub.c')) =20 virtio_ss =3D ss.source_set() virtio_ss.add(files('virtio.c')) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c new file mode 100644 index 0000000..d4a88f5 --- /dev/null +++ b/hw/virtio/virtio-stub.c @@ -0,0 +1,14 @@ +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-virtio.h" + +static void *qmp_virtio_unsupported(Error **errp) +{ + error_setg(errp, "Virtio is disabled"); + return NULL; +} + +VirtioInfoList *qmp_x_debug_query_virtio(Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 1fd1917..0e12561 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -13,6 +13,8 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-commands-virtio.h" +#include "qapi/qapi-visit-virtio.h" #include "cpu.h" #include "trace.h" #include "exec/address-spaces.h" @@ -30,6 +32,8 @@ #include "sysemu/runstate.h" #include "standard-headers/linux/virtio_ids.h" =20 +static QTAILQ_HEAD(, VirtIODevice) virtio_list; + /* * The alignment to use between consumer and producer parts of vring. * x86 pagesize again. This is the default, used by transports like PCI @@ -3673,6 +3677,7 @@ static void virtio_device_realize(DeviceState *dev, E= rror **errp) =20 vdev->listener.commit =3D virtio_memory_listener_commit; memory_listener_register(&vdev->listener, vdev->dma_as); + QTAILQ_INSERT_TAIL(&virtio_list, vdev, next); } =20 static void virtio_device_unrealize(DeviceState *dev) @@ -3687,6 +3692,7 @@ static void virtio_device_unrealize(DeviceState *dev) vdc->unrealize(dev); } =20 + QTAILQ_REMOVE(&virtio_list, vdev, next); g_free(vdev->bus_name); vdev->bus_name =3D NULL; } @@ -3844,6 +3850,8 @@ static void virtio_device_class_init(ObjectClass *kla= ss, void *data) vdc->stop_ioeventfd =3D virtio_device_stop_ioeventfd_impl; =20 vdc->legacy_features |=3D VIRTIO_LEGACY_FEATURES; + + QTAILQ_INIT(&virtio_list); } =20 bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev) @@ -3854,6 +3862,26 @@ bool virtio_device_ioeventfd_enabled(VirtIODevice *v= dev) return virtio_bus_ioeventfd_enabled(vbus); } =20 +VirtioInfoList *qmp_x_debug_query_virtio(Error **errp) +{ + VirtioInfoList *list =3D NULL; + VirtioInfoList *node; + VirtIODevice *vdev; + + QTAILQ_FOREACH(vdev, &virtio_list, next) { + DeviceState *dev =3D DEVICE(vdev); + node =3D g_new0(VirtioInfoList, 1); + node->value =3D g_new(VirtioInfo, 1); + node->value->path =3D g_strdup(dev->canonical_path); + node->value->type =3D qapi_enum_parse(&VirtioType_lookup, vdev->na= me, + VIRTIO_TYPE_UNKNOWN, NULL); + node->next =3D list; + list =3D node; + } + + return list; +} + static const TypeInfo virtio_device_info =3D { .name =3D TYPE_VIRTIO_DEVICE, .parent =3D TYPE_DEVICE, diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b7ece7a..2470e09 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -108,6 +108,7 @@ struct VirtIODevice bool use_guest_notifier_mask; AddressSpace *dma_as; QLIST_HEAD(, VirtQueue) *vector_queues; + QTAILQ_ENTRY(VirtIODevice) next; }; =20 struct VirtioDeviceClass { diff --git a/qapi/meson.build b/qapi/meson.build index 0652569..1ffad95 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -43,6 +43,7 @@ qapi_all_modules =3D [ 'sockets', 'trace', 'transaction', + 'virtio', 'yank', ] if have_system diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index 3441c9a..ed000ea 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -90,5 +90,6 @@ { 'include': 'misc.json' } { 'include': 'misc-target.json' } { 'include': 'audio.json' } +{ 'include': 'virtio.json' } { 'include': 'acpi.json' } { 'include': 'pci.json' } diff --git a/qapi/virtio.json b/qapi/virtio.json new file mode 100644 index 0000000..0fbe542 --- /dev/null +++ b/qapi/virtio.json @@ -0,0 +1,68 @@ +## +# =3D Virtio devices +## + +## +# @VirtioType: +# +# An enumeration of Virtio device types. +# +# Since: 6.0 +## +{ 'enum': 'VirtioType', + 'data': [ 'unknown', 'virtio-9p', 'virtio-blk', 'virtio-serial', + 'virtio-gpu', 'virtio-input', 'virtio-net', 'virtio-scsi', + 'vhost-user-fs', 'vhost-vsock', 'virtio-balloon', 'virtio-cryp= to', + 'virtio-iommu', 'virtio-pmem', 'virtio-rng' ] +} + +## +# @VirtioInfo: +# +# Information about a given VirtIODevice +# +# @path: VirtIO device canonical path. +# +# @type: VirtIO device type. +# +# Since: 6.0 +# +## +{ 'struct': 'VirtioInfo', + 'data': { + 'path': 'str', + 'type': 'VirtioType' + } +} + +## +# @x-debug-query-virtio: +# +# Return the list of all VirtIO devices +# +# Returns: list of @VirtioInfo +# +# Since: 6.0 +# +# Example: +# +# -> { "execute": "x-debug-query-virtio" } +# <- { "return": [ +# { +# "path": "/machine/peripheral-anon/device[3]/virtio-backend", +# "type": "virtio-net" +# }, +# { +# "path": "/machine/peripheral-anon/device[1]/virtio-backend", +# "type": "virtio-serial" +# }, +# { +# "path": "/machine/peripheral-anon/device[0]/virtio-backend", +# "type": "virtio-blk" +# } +# ] +# } +# +## + +{ 'command': 'x-debug-query-virtio', 'returns': ['VirtioInfo'] } diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c index 1c7186e..8f0ae20 100644 --- a/tests/qtest/qmp-cmd-test.c +++ b/tests/qtest/qmp-cmd-test.c @@ -95,6 +95,7 @@ static bool query_is_ignored(const char *cmd) "query-gic-capabilities", /* arm */ /* Success depends on target-specific build configuration: */ "query-pci", /* CONFIG_PCI */ + "x-debug-query-virtio", /* CONFIG_VIRTIO */ /* Success depends on launching SEV guest */ "query-sev-launch-measure", /* Success depends on Host or Hypervisor SEV support */ --=20 1.8.3.1 From nobody Mon May 6 23:42:58 2024 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; arc=pass (i=1dmarc=pass fromdomain=oracle.com); dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1616086449; cv=pass; d=zohomail.com; s=zohoarc; b=d79IOc4sB+6tf9cJOCsSNZEq0zjihM0Zp9gkfiE6lFRrsS4BPl1K15z5HOgiPnfsPk4xdA9U8Lh8HSAqx22xtt46LdY8ZhaxmhQfHoxA1BngoXupQrfopVqsLsORB76k3qPxYPouoVRgxyT6hOsvWgYtgXNxBOLrHQNtNJk12ac= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616086449; h=Content-Type: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=VsWqU1eg7lglppe+YUgBuvOoRHh0k1V4+YYTSssmORk=; b=UHaqSBf4+JpCxVMnk7SZcpTXduljI0gBg9RgSAaALV89zmv/cH/CRF5eJUNizUgXhYVL4LkTCgqeRv9sBQVSBcwSkJua2m4xZNX5gTv9ZWJDU1yUGSi6NqUtRKGzYd4jOZZ/8+f7eGYweyJFXtVIGN7RgWfO0+PWw87IDcy5fNE= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=oracle.com); dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616086449140986.3185307067548; Thu, 18 Mar 2021 09:54:09 -0700 (PDT) Received: from localhost ([::1]:33742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMvuR-0005gq-Vq for importer@patchew.org; Thu, 18 Mar 2021 12:54:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMvXv-0003y3-NQ; Thu, 18 Mar 2021 12:30:51 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:43780) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMvXo-0008At-Qi; Thu, 18 Mar 2021 12:30:51 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12IGU5A3167553; Thu, 18 Mar 2021 16:30:23 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 378jwbr7dt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Mar 2021 16:30:23 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12IGUAvE053881; Thu, 18 Mar 2021 16:30:22 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2176.outbound.protection.outlook.com [104.47.57.176]) by userp3030.oracle.com with ESMTP id 3797b352yq-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Mar 2021 16:30:22 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB4565.namprd10.prod.outlook.com (2603:10b6:510:31::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18; Thu, 18 Mar 2021 16:30:10 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::6819:aaf:9a92:c1db]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::6819:aaf:9a92:c1db%2]) with mapi id 15.20.3933.032; Thu, 18 Mar 2021 16:30:10 +0000 Received: from jonpalme-lnx.us.oracle.com (24.147.51.11) by SJ0PR05CA0079.namprd05.prod.outlook.com (2603:10b6:a03:332::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.10 via Frontend Transport; Thu, 18 Mar 2021 16:30:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=VsWqU1eg7lglppe+YUgBuvOoRHh0k1V4+YYTSssmORk=; b=SCU2a2WCmU/Qa/QGQpH0dQzp6rzbQ6cR0sxXKFclm6dcWcJqXyYxqcOl4dWFjkmjaZyP ppoI2OGN6HoynfDWosEjFtlC6g/wc+nU4OBmD/2Cm6MjnWNtboiPh7vA2grB3Cia0eGk MVvyqvneUFuxy+xopakrFUSYitnY/7x+ZqVhF9R5HhcLcYYyASFmJKmW4MUiwGS4QYr8 zUBRSdHMnB87isegzvM+FpPljcX1YrfJd7xroUs7Hy370iyGX65Vm/Bkwfw+ku6hWTVh Q1yC4R2wWGbmVoWmGzjZsTazTFIjrZyaV+z6b8pupHS10AgbES61QMVpAXi+E+bb+GMQ pQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SYijj27M/fLY+CMlWn5LlHBcKXASferTN38PlLdRe1gwsGaLew+/KBnhaub13PUTAcKwpn60693UeET3LSqWUaRHI5+3ZG2/u5TLM/Yy/XxHbJsytbxjB+TqS3CCp9pwsVWRnY3R1G8iWCpJxsr3uSO/uVzwTLb4u7807uQBikEVgWFXB/KIh2GV69cfmmbK+hhUz0zEEhtpPbVUCm2z7GXJC9h3vt2tsVgYkU6SxiMx9BiXykyQqQqadR3+qUbtWerU9tua+sJfmHWKDsKLlMZBNArX+SU1JGM669VbQGRght+5PA7kScQ6KZ7N7joe4Em0h0UZOQnYS1cAevlJTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VsWqU1eg7lglppe+YUgBuvOoRHh0k1V4+YYTSssmORk=; b=ca+PD8WCLe3rdUV9bqwBGnx1XDgwRIR1oeg4Zz0Dk9Yu4gpWjgzdK57AMRH9fcuQM/TpLJ7QIJscKc1GhjpTCHAfuirwQIgCylM3tjvemyxpCT1GHuRNAD+fkiccUKfi/dj1GaAsLR78yUj3faJlfVWcEr5Pu64F5R1hU5LRJoucC+k3RxLgbg3t7JeVlc67sArDHYYlxDt9YBfOd765NQIl6ABxH8yHBTXHx5hsV4karzDM/L8hhgpyHfnRIfy0eq+/QQG8OtNHmCGWT3ZvcRXLwh3mxtTFwPz4GEzE6jBCd2F+7b1ouWbWlA3ipAjzmeDGBUhoG/G5tCxAwnZ+pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VsWqU1eg7lglppe+YUgBuvOoRHh0k1V4+YYTSssmORk=; b=LFxHbH7rrlrLiEa09m60JhSkHbccEEhY+vYUp7XftdPfQ/vuBqr4SeBU2rXQMbHqOs2QzaOfzsmyUU9G/XSgnD/AXXjSENFgnDt2nsNYX0d7/90E2esLWQq+5lrqKNki/R9S80C347m1ZaHXv80C+rnx8GlZQoW1WCU893pXrG0= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [RFC v5 2/6] qmp: add QMP command x-debug-virtio-status Date: Thu, 18 Mar 2021 12:29:40 -0400 Message-Id: <1616084984-11263-3-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1616084984-11263-1-git-send-email-jonah.palmer@oracle.com> References: <1616084984-11263-1-git-send-email-jonah.palmer@oracle.com> X-Originating-IP: [24.147.51.11] X-ClientProxiedBy: SJ0PR05CA0079.namprd05.prod.outlook.com (2603:10b6:a03:332::24) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b67f2153-44ad-4888-7fe6-08d8ea2b1921 X-MS-TrafficTypeDiagnostic: PH0PR10MB4565: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:400; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F4i02n14/WvAHG/lnPPNZhLZ/5AtaciFsMu8jTGeIEmWF1BZYNntN0EdqsOliSI/LNtWVKj5dqPkTgd8WB20R2DQjcjh5NCTaMCWIHXSs4JYhAR33269MM5JGdKLMC7IoUo+5V8RNAZR7KN7UClYmQfx6+MdV92+QOBo0PfchMyduUJTjKrfQpqxYyo18dankaFIx6t+I8wJXE6J2CQdlWSaBgS4AF7cYxVGbQeIOt2dwujjhF0J4xzjSxUklkTk/s39QKTMM/0VMLQYzVXBQqwF874NRA/JhELgET7maClm6KTW37YWOGeW02MvRub43qeP2RDrUGBJJamjML0esWX2QaLP09odqfKloBdB6UvTUJS081eLTwCaDooJ/nYB6j8fSsN31Ec+MCus+QB07v366xmmHtafMpR+t/JfsLhwPMa6y1zwKPzWxeFBReU36MjMpaRHRrCo7nwvGy6Vhq+xYSobc8dGMLW0XRNC7mhCncmFxO556Uf7U9RiiqPfAR9Jnwdpp1QYEbQejF6bhWc95PrQmmIgjWel4Ek/YBhVOhmB0gGkXpUgggjURt/x3SBTKLblJgdXjFf03J7AQwNDWeJ+VxQgEzwnfnF05kE= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR10MB4664.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(346002)(366004)(39860400002)(376002)(136003)(8676002)(66476007)(66556008)(66946007)(38100700001)(36756003)(186003)(5660300002)(2906002)(478600001)(86362001)(52116002)(7696005)(8936002)(316002)(16526019)(956004)(26005)(7416002)(6666004)(44832011)(2616005)(6916009)(107886003)(4326008)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?vb3DC8kl0MN5MYbCvKiG8FUqXXbpIjhmk0I9Gu15NvN5U2C9s15tx6UbTjUG?= =?us-ascii?Q?u21bsb2kmUxhz80QYHL68A9Bo7zUqaNKn4bdUPm6gf3ZxbYKeRBFhF6yNFfw?= =?us-ascii?Q?L96atJliPpANbcxtTGLaRjalSBcAIHiOcw6aHgCJ32uHIziGv7Vhh82QnNEA?= =?us-ascii?Q?Tkc/kzlZy277vjf638yCvtw5Xs0cpQdnpMAYZPC0oaojUfyggotHuhtgmZuI?= =?us-ascii?Q?tAC36KD26xFms52QPDK8UDL9bPTGm3AtSmiPm3PJQoGtU9XvwrwFftZSg17D?= =?us-ascii?Q?Hjgmo78l7+FaPGedDuvRs9HJFJWoAF/+ZZY1gTEMosK/yrY/qbKI3Xi5AviI?= =?us-ascii?Q?hWPFA/IlXEGOP3nfHZNTIBCm7QSraoeWmcBGywg1kerLEBFZ4Y6xLTmjx1Cq?= =?us-ascii?Q?kf1zVcZTYvvoOSamkvqbkcKPKUHPIup4TtoL+75feD0QZkCOLTjhU2xbUUTJ?= =?us-ascii?Q?JwDTTB5odYBZO2ZKKVa7XW/e1HmJzNpoZ5ZPt7uZBgpWSsynewCYo18NPVcS?= =?us-ascii?Q?TgYvTHXsGoHdbuZLAl5aFOLO1DhPwU4v65ULN8N2xGJtMb4FInE5qjl9rp9Z?= =?us-ascii?Q?DRsTUPYKSasnppWvgi89Mxg81ipc1eafF5m9Q5Iy55cKUFbZgmg3660YbLkR?= =?us-ascii?Q?ymL0dRFVrx8HWo08MNL0g4WYeHHAEUkJP4H4JdJUClYyDp8r0ABK+qhFrmdl?= =?us-ascii?Q?mVPnt9fTZqA9GlRqu7q7+zkbSS6ITNcMhH7WKaOqljKE51NBzo5AwjeuswYL?= =?us-ascii?Q?3nB5rDrC4o6aMPX/uZ3ZVpPv5wx42lbPKf4lHPSvtgghyd6GI7Av9VSHVpgM?= =?us-ascii?Q?ZlCbYcVTeG6CySagKmAo+28XZGekDSwixIQecWyJSNnPaj5B9IAxSEzJLAfe?= =?us-ascii?Q?+avESJ84UqSGI5qqiLoYXR6EU1SVcWaLXkpTyE11/UQ8x2x673KWtR1Ga9f3?= =?us-ascii?Q?q06kuS6wnkGgBUuCtWWnbk6AzyKqBwavAjPDDXBL2HhutWNAB4JacaZtjZN9?= =?us-ascii?Q?v34EXU4jLz9Q2Yuf4sfDjqlcwD4uqdfkczNir0UYEXm3tmLWRugbnRrDAmSv?= =?us-ascii?Q?tVpnO83CnNF9fxMQXCUK+nxdhAizTqgVVFGWBAUwtr7zOEzSD5GWwTTyBwdO?= =?us-ascii?Q?TRCwswB9P3F6J63Nos4SLfQDc9qBzXvMmZU+VvZ188rsBrSm3J1IkNnaavfc?= =?us-ascii?Q?rxgtI8d6Fl1HoYL7O4EGBHmVbuGBfylzvYQHKGa6HPB/llBkQ49yqdPEOb15?= =?us-ascii?Q?trx67cirrxW6jLxBl3WmJypicaxfMi7iNSjyvV6SB9+Tkd4KEYXSHAqo9fxN?= =?us-ascii?Q?OOFt9RzD5FokPLKkp63tl1gX?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b67f2153-44ad-4888-7fe6-08d8ea2b1921 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2021 16:30:10.0965 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: myigQCXXCTg6IM3S/NTlazd6WsCYXw0hyM1lR9iIkBva4XvkhahptfMuR27snkBwiARHaibmNQGRHtppKGBJ3w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4565 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9927 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103180116 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9927 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 adultscore=0 phishscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103180116 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=141.146.126.79; envelope-from=jonah.palmer@oracle.com; helo=aserp2130.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, marcandre.lureau@redhat.com, jonah.palmer@oracle.com, thuth@redhat.com, amit@kernel.org, michael.roth@amd.com, dgilbert@redhat.com, eric.auger@redhat.com, dmitrii.stepanov@cloud.ionos.com, stefanha@redhat.com, kwolf@redhat.com, laurent@vivier.eu, mreitz@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This new command shows the status of a VirtIODevice (features, endianness and number of virtqueues) Next patch will improve output by decoding feature bits. Signed-off-by: Laurent Vivier Signed-off-by: Jonah Palmer --- hw/virtio/virtio-stub.c | 5 ++++ hw/virtio/virtio.c | 50 ++++++++++++++++++++++++++++++++ qapi/virtio.json | 76 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 131 insertions(+) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index d4a88f5..ddb592f 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -12,3 +12,8 @@ VirtioInfoList *qmp_x_debug_query_virtio(Error **errp) { return qmp_virtio_unsupported(errp); } + +VirtioStatus *qmp_x_debug_virtio_status(const char* path, Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 0e12561..69ef890 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3882,6 +3882,56 @@ VirtioInfoList *qmp_x_debug_query_virtio(Error **err= p) return list; } =20 +static VirtIODevice *virtio_device_find(const char *path) +{ + VirtIODevice *vdev; + + QTAILQ_FOREACH(vdev, &virtio_list, next) { + DeviceState *dev =3D DEVICE(vdev); + + if (strcmp(dev->canonical_path, path) !=3D 0) { + continue; + } + return vdev; + } + + return NULL; +} + +VirtioStatus *qmp_x_debug_virtio_status(const char* path, Error **errp) +{ + VirtIODevice *vdev; + VirtioStatus *status; + + vdev =3D virtio_device_find(path); + if (vdev =3D=3D NULL) { + error_setg(errp, "Path %s is not a VirtIO device", path); + return NULL; + } + + status =3D g_new0(VirtioStatus, 1); + status->guest_features =3D vdev->guest_features; + status->host_features =3D vdev->host_features; + status->backend_features =3D vdev->backend_features; + status->device_id =3D vdev->device_id; + + switch (vdev->device_endian) { + case VIRTIO_DEVICE_ENDIAN_LITTLE: + status->device_endian =3D VIRTIO_STATUS_ENDIANNESS_LITTLE; + break; + case VIRTIO_DEVICE_ENDIAN_BIG: + status->device_endian =3D VIRTIO_STATUS_ENDIANNESS_BIG; + break; + default: + status->device_endian =3D VIRTIO_STATUS_ENDIANNESS_UNKNOWN; + break; + } + + status->num_vqs =3D virtio_get_num_queues(vdev); + + return status; +} + static const TypeInfo virtio_device_info =3D { .name =3D TYPE_VIRTIO_DEVICE, .parent =3D TYPE_DEVICE, diff --git a/qapi/virtio.json b/qapi/virtio.json index 0fbe542..4af95a0 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -66,3 +66,79 @@ ## =20 { 'command': 'x-debug-query-virtio', 'returns': ['VirtioInfo'] } + +## +# @VirtioStatusEndianness: +# +# Enumeration of endianness for VirtioDevice +# +# Since: 6.0 +## +{ 'enum': 'VirtioStatusEndianness', + 'data': [ 'unknown', 'little', 'big' ] +} + +## +# @VirtioStatus: +# +# @device-id: VirtIODevice status +# +# @device-endian: VirtIODevice device_endian +# +# @guest-features: VirtIODevice guest_features +# +# @host-features: VirtIODevice host_features +# +# @backend-features: VirtIODevice backend_features +# +# @num-vqs: number of VirtIODevice queues +# +# Since: 6.0 +# +## + +{ 'struct': 'VirtioStatus', + 'data': { + 'device-id': 'int', + 'device-endian': 'VirtioStatusEndianness', + 'guest-features': 'uint64', + 'host-features': 'uint64', + 'backend-features': 'uint64', + 'num-vqs': 'uint16' + } +} + +## +# @x-debug-virtio-status: +# +# Return the status of virtio device +# +# @path: QOBject path of the VirtIODevice +# +# Returns: status of the VirtIODevice +# +# Since: 6.0 +# +# Example: +# +# -> { "execute": "x-debug-virtio-status", +# "arguments": { +# "path": "/machine/peripheral-anon/device[3]/virtio-backend" +# } +# } +# <- { "return": { +# "backend-features": 0, +# "guest-features": 5111807911, +# "num-vqs": 3, +# "host-features": 6337593319, +# "device-endian": "little", +# "device-id": 1 +# } +# } +# +## + +{ 'command': 'x-debug-virtio-status', + 'data': { 'path': 'str' }, + 'returns': 'VirtioStatus' +} --=20 1.8.3.1 From nobody Mon May 6 23:42:58 2024 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; arc=pass (i=1dmarc=pass fromdomain=oracle.com); dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1616086083; cv=pass; d=zohomail.com; s=zohoarc; b=lg3MNSsyUyxjRPMEVH+V0W3f//D1MTSOt11EnSwNW4ah8ZzFl6S/79UucmAWraaPwG4owOiYyKjFLeLMe5mErOzO8O8v1h500dOUVdINCKB3tBglJhxkQa3YwnEM5qr0Xtbbql7BK0GayiyjwQ/V65M82VRxoU/O4EJdFMIXa8Y= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616086083; h=Content-Type: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=37gU6bkNgJSnutJuCjJhbipREiG1Mx3KqpvX0YmuNb8=; b=kgvHTQ64spy18Te+bIvdP1FqXvOkbUuTTC/ZS3vlNIVjFA5yvguciRVoqxE5wYCZ0vk+xDjQfzejZx5W4DSWLUZCbW8JQKOP+OE5DC2CYSmUNOH7Ckb/LlvrBVrp+KY0+TJxw1xStEUp/rOsBXjCegwiqmMCQo7Vz0I5MWhdorA= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=oracle.com); dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616086083835320.5785206094437; Thu, 18 Mar 2021 09:48:03 -0700 (PDT) Received: from localhost ([::1]:47090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMvoY-0007l1-Ks for importer@patchew.org; Thu, 18 Mar 2021 12:48:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMvXt-0003tZ-SK; Thu, 18 Mar 2021 12:30:49 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:47278) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMvXo-0008Au-QT; Thu, 18 Mar 2021 12:30:49 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12IGT8Ab065485; Thu, 18 Mar 2021 16:30:25 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 378nbmg4yq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Mar 2021 16:30:24 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12IGUAvG053881; Thu, 18 Mar 2021 16:30:23 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2176.outbound.protection.outlook.com [104.47.57.176]) by userp3030.oracle.com with ESMTP id 3797b352yq-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Mar 2021 16:30:23 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB4565.namprd10.prod.outlook.com (2603:10b6:510:31::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18; Thu, 18 Mar 2021 16:30:13 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::6819:aaf:9a92:c1db]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::6819:aaf:9a92:c1db%2]) with mapi id 15.20.3933.032; Thu, 18 Mar 2021 16:30:13 +0000 Received: from jonpalme-lnx.us.oracle.com (24.147.51.11) by SJ0PR05CA0079.namprd05.prod.outlook.com (2603:10b6:a03:332::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.10 via Frontend Transport; Thu, 18 Mar 2021 16:30:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=37gU6bkNgJSnutJuCjJhbipREiG1Mx3KqpvX0YmuNb8=; b=0fxTHENf8RMfmlAvpuaFFJi9UKmYosYNH2KnSsCtjekBvN97Ub2zKP6P0TyvQr5DbY8A cFLLD3BkKdheZ7MlLcbE0Xdsqsm9uG5fB3i9NTGZ9/0oRukWNAcwlEB/2HbG3qHLAufd rhDrxwGNq7+F2sFdVVFrVzerLP3t+7Ij37QPt6f8WhmAv5FZJ8zigzVQKnk9O9MPQnDj eU4zBYDicjACwJV81Sy/W+KepJ3YGmHmU53WyRuon4cJhf8l/3LLZ9QrzUu8eTeg+t5B c1p3D44j+hdvGzVUDI7MQYUEC9e99EVCxwB9PGasencDjgb3SBiRhBqH7+FFQmU6tvjP sQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IKhnPq8L7CORMFTfVM3/ZHP996Gv4OdW04IFnst+qpJEVZs7wX42pguMpNAxAl4hdM7TMxKhcY3Mrppd2m9lcV+llIKQiMpDu5UVgJ4iKhRBmggrDGbetFQ1tafWixsX0JmY3fZTBuMZnk2mb2bnUkcL0MwbGEv8KyVHtEqL/6/c4fPfKZUCe60KvTVwD3fyFTpKnA5tnwfNyfCEWFURBXlMZOybbzNQojLbxoBkYzqNYtIg/KB9lB4koxB1nx4DuGYrBnklKZHrIxsIcgIX0MSuRNOTAMTstMHEhTAhlF5IURFymaa452BxQsdd1AdoILejwvRv7qFkttcKqKNmEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=37gU6bkNgJSnutJuCjJhbipREiG1Mx3KqpvX0YmuNb8=; b=jSSVnH/AnE+r2w4MOz9SNLsrFv6QSMWB9Md6c2WHqv6I5qRtn3mZlZfaJf2ISfyBomZnlBH/4ITCF2K6JWjTdDHjlMzSQQn+Ky7QaIGqgjvV0fxUWKunZKO0a9kQ1XFhNYYBkyDKt3aZfwZsPoXBLleTvO5hhUd01lK2CKzvMhY5ItwICTfEjAIrPdfPDauBNyjD+7+VtXt5ZqcgvqAlTVaA+wwKyKTknc3C5ksdNoVYas5O9rBtIvWysmeC1mNjXdgdMNkPV7IxyHIQ4YZg9ihZ75NuwGHhqEBOIFVRuniVAu5MuiTQPkfzsS7eeYJ4NeM3uFiwa+hh6pb7+VoQiw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=37gU6bkNgJSnutJuCjJhbipREiG1Mx3KqpvX0YmuNb8=; b=WUQz5sAm6AQmOan28Ui8zOjaK7w68VcER/WJgdvRJ1WGVNtLXDZsR1ocGDQzYgLXlAUBCuH2DL51cw9G6xC4iLqMMh841yNMpOvmJSOAty0ywcIGbAloxsZu0yyOHJyUmddQUYrlKuIAW2OG7eJDBPf43sM7p4Y3o8g0GevLpAg= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [RFC v5 3/6] qmp: decode feature bits in virtio-status Date: Thu, 18 Mar 2021 12:29:41 -0400 Message-Id: <1616084984-11263-4-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1616084984-11263-1-git-send-email-jonah.palmer@oracle.com> References: <1616084984-11263-1-git-send-email-jonah.palmer@oracle.com> X-Originating-IP: [24.147.51.11] X-ClientProxiedBy: SJ0PR05CA0079.namprd05.prod.outlook.com (2603:10b6:a03:332::24) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 75ae705a-0a1d-488c-7a97-08d8ea2b1b0e X-MS-TrafficTypeDiagnostic: PH0PR10MB4565: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:483; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GyaDEOq0sWLmpAwsvbf8huirBS2hXEmAL0Yj301R/uhEecSjmf3HkTksGmBY9VvHJLnOLmETRxY14lwEH/Lv9UaA7PQvc71AziLJuom/r0mcEynOQwQ2zCBeOMD/byG7FysNbh9nguRmZyvqW2AmC+AH0sEcZ/43uSOgHPPGZ6lzziq7nVFSWCPN8so8EcOD4r9kGLtPGL9vhe3AH5uO9e4nZ8goDzCPE+euB17Zhc/1/jhTbOpSgTDcROJX7iElclbM8GM3CGr/hb+EZZDTmu/A/Phu7XHd+LMpZkLsXYbzVmqvTYUXYAcdcvP3P4CUuRCkTRezSdsOpAVSYJuq+W/NrFZuRsZstSRlK6L0z7xcmOsDq405djKNoHSZIVwdaZW6jtGC8PkrZpkEPPxDPQjFwD4LOAjdKLN88bP4xWUi6/AiPd0tSHqsGdBfG4kakbtU23dqFw0VnGJ5hMS7Zid9eDho0TD8RyMBUKf0ZQBOyYyQfyVaFxpVLvVjPCIWipbpeE9xY3OaPWlGsiv/xmfbJWnH5KDcsPQ1F5DMejW/cBRtjbUtv0UGE7LatGzjH+4VfEnmNhgJGtAIp8VspEqsBw1USL1ohWOKDSDZoLE= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR10MB4664.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(346002)(366004)(39860400002)(376002)(136003)(8676002)(66476007)(66556008)(66946007)(38100700001)(36756003)(186003)(5660300002)(2906002)(478600001)(30864003)(86362001)(52116002)(7696005)(8936002)(316002)(16526019)(956004)(26005)(7416002)(6666004)(44832011)(83380400001)(2616005)(6916009)(107886003)(4326008)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?XoUdiupndV7d3VReCydqTO4JgLhD8NOQgHTTjJsg5yVAEYPSsRL8JFXOUKLM?= =?us-ascii?Q?swMAyKjd7IbyDzsuvH5lWTRLjcOs6hP8pxkoBmmuGJpJhhNxE4mS4+QEjmDJ?= =?us-ascii?Q?G73ae0UlP/sAgOx7/PW9CVH3voI5NOR6Ju5Zx4TxcUhQ++swMBuGu7DvpSmt?= =?us-ascii?Q?yzsUN7tPYtBi/+ScAMtNav35UB/9iPxKTb59axbepugSv8723mXF01UuvylV?= =?us-ascii?Q?kmv0zgj4l8XPue/v7jLw/lsHWNDxV3juE+nBA8Tdx34UNqBS0xpHFDBxDzWk?= =?us-ascii?Q?cBDUcK3o5uJixpQh1bnC4216AxXba0ljKqT1rtjP+qvNk9fGzhFGu3Q8NWJG?= =?us-ascii?Q?a/IKsbWOsSoTiHovp74njXi74FNHoV+DGnW7cBdXn7otKz5hzdEXFEFhAioj?= =?us-ascii?Q?9RqRyWwcCfrqz2wl7ReAoUo8tRbdmpHQ/ZeUAS0Ah5Sy79YwjSHYcf0DylNi?= =?us-ascii?Q?M5qdS90cwal9lB7rNMz6Vb3O2xTrD3DC7iWe0Br2na5XF7EKC1ewPLLmG4uL?= =?us-ascii?Q?Sh8UZStQ4+hjBv9k6TyUO9OD9z+9wnSphTk2KB6vuVvYZxFEBYJ6hRW6OzT1?= =?us-ascii?Q?MWm5cq3GkmTNjLpljV09tOMY5UnG675vHjQC+PZqP4Zr7UcSsl1/oKSuXE8R?= =?us-ascii?Q?HuHzatkZs8wSTz9tRvYv+Ns/OYuEd10/zF3TsGBkG9n40lkfCQLXEp0w1QzH?= =?us-ascii?Q?Gdn0QRpOvjogR1pq7jsLUyqYJRQHw+lA6UjMFqGNAI/PA95bI2SrxgmjkHwz?= =?us-ascii?Q?IXZMcvvaM2hiqSca0wDdi7dS35tjr3YLV1kMSb939xOvJIkvGff/SeDHqjOS?= =?us-ascii?Q?EFClVuGuygtOAnkZNGBzkeTS6lsXWXfNkwOgFtj8Im569mPJyQ8ctFEZfKgE?= =?us-ascii?Q?2zf43uxDK++EmZ3HwO9q9uOvOFofewGIeOnYGxuCHrkTum1Fk/89V3Jd4+sw?= =?us-ascii?Q?JcCtSqCn5ZPWF8PEnb2Qe9I/vX19qZKV+kxo0yl2vHpdBxHOFGxynY+lKI6R?= =?us-ascii?Q?xjH2gSwD2nP6cY4kyJ4IAzx++yPe9X3RmyibCB8CdIiSiWw3sA8JmEBkoVJ+?= =?us-ascii?Q?7YTO8WWep9IwRcM8mYAUp4TRqtnxJTA+DANvL66a1ZBmTUfuvep72W0xYyMx?= =?us-ascii?Q?9dLy6Ko9GzAwNJkx4jlKc/epl+wu1a1QqpBasflAiCqC8FzrKELbWcpHLSW6?= =?us-ascii?Q?/kaTiBUG+zOEf6TqQhnZXaqDugB5sQtxktjmWtUTqB9xnRnjk4TqowfECQCq?= =?us-ascii?Q?1tiiE2IMaZmZY4Xs7rTjKicvExJWmNTxqyumI0kUNBASQb2UerNKAv398yUu?= =?us-ascii?Q?KU4l2jqUYZ5zwTZ1tzYruA46?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75ae705a-0a1d-488c-7a97-08d8ea2b1b0e X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2021 16:30:13.2805 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2WO0AAI4hr3fV/iSU7eZFi7udZ8e7DZQQn9OPh5GWFMH2E8DHCGWcGIVvmXs1FN2eIjAEklIrQLNAERvU+y8aA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4565 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9927 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103180116 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9927 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 impostorscore=0 malwarescore=0 adultscore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 lowpriorityscore=0 phishscore=0 priorityscore=1501 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103180116 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=141.146.126.78; envelope-from=jonah.palmer@oracle.com; helo=aserp2120.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, marcandre.lureau@redhat.com, jonah.palmer@oracle.com, thuth@redhat.com, amit@kernel.org, michael.roth@amd.com, dgilbert@redhat.com, eric.auger@redhat.com, dmitrii.stepanov@cloud.ionos.com, stefanha@redhat.com, kwolf@redhat.com, laurent@vivier.eu, mreitz@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier Display feature names instead of a features bitmap for host, guest, and backend. Decode features according to device type, transport features are on the first line. Undecoded bits (if any) are stored in a separate field. Signed-off-by: Laurent Vivier Signed-off-by: Jonah Palmer --- hw/block/virtio-blk.c | 23 ++++ hw/char/virtio-serial-bus.c | 11 ++ hw/display/virtio-gpu-base.c | 12 ++ hw/net/virtio-net.c | 38 ++++++ hw/scsi/virtio-scsi.c | 12 ++ hw/virtio/virtio-balloon.c | 14 +++ hw/virtio/virtio-iommu.c | 14 +++ hw/virtio/virtio.c | 127 +++++++++++++++++++- include/hw/virtio/virtio.h | 13 ++ qapi/virtio.json | 280 +++++++++++++++++++++++++++++++++++++++= ++-- 10 files changed, 531 insertions(+), 13 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index e8600b0..c2858f8 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -13,6 +13,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/iov.h" #include "qemu/module.h" #include "qemu/error-report.h" @@ -48,6 +49,28 @@ static VirtIOFeature feature_sizes[] =3D { {} }; =20 +qmp_virtio_feature_map_t blk_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_BLK_F_##name, VIRTIO_BLK_FEATURE_##name } + FEATURE_ENTRY(SIZE_MAX), + FEATURE_ENTRY(SEG_MAX), + FEATURE_ENTRY(GEOMETRY), + FEATURE_ENTRY(RO), + FEATURE_ENTRY(BLK_SIZE), + FEATURE_ENTRY(TOPOLOGY), + FEATURE_ENTRY(MQ), + FEATURE_ENTRY(DISCARD), + FEATURE_ENTRY(WRITE_ZEROES), +#ifndef VIRTIO_BLK_NO_LEGACY + FEATURE_ENTRY(BARRIER), + FEATURE_ENTRY(SCSI), + FEATURE_ENTRY(FLUSH), + FEATURE_ENTRY(CONFIG_WCE), +#endif +#undef FEATURE_ENTRY + { -1, -1 } +}; + static void virtio_blk_set_config_size(VirtIOBlock *s, uint64_t host_featu= res) { s->config_size =3D MAX(VIRTIO_BLK_CFG_SIZE, diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index b200389..9791b1d 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -20,6 +20,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/iov.h" #include "qemu/main-loop.h" #include "qemu/module.h" @@ -33,6 +34,16 @@ #include "hw/virtio/virtio-serial.h" #include "hw/virtio/virtio-access.h" =20 +qmp_virtio_feature_map_t serial_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_CONSOLE_F_##name, VIRTIO_SERIAL_FEATURE_##name } + FEATURE_ENTRY(SIZE), + FEATURE_ENTRY(MULTIPORT), + FEATURE_ENTRY(EMERG_WRITE), +#undef FEATURE_ENTRY + { -1, -1 } +}; + static struct VirtIOSerialDevices { QLIST_HEAD(, VirtIOSerial) devices; } vserdevices; diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 4a57350..dd8e9e7 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -16,9 +16,21 @@ #include "hw/virtio/virtio-gpu.h" #include "migration/blocker.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/error-report.h" #include "trace.h" =20 +qmp_virtio_feature_map_t gpu_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_GPU_F_##name, VIRTIO_GPU_FEATURE_##name } + FEATURE_ENTRY(VIRGL), + FEATURE_ENTRY(EDID), + FEATURE_ENTRY(RESOURCE_UUID), + FEATURE_ENTRY(RESOURCE_BLOB), +#undef FEATURE_ENTRY + { -1, -1 } +}; + void virtio_gpu_base_reset(VirtIOGPUBase *g) { diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 5150f29..e405d82 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -35,6 +35,7 @@ #include "hw/qdev-properties.h" #include "qapi/qapi-types-migration.h" #include "qapi/qapi-events-migration.h" +#include "qapi/qapi-visit-virtio.h" #include "hw/virtio/virtio-access.h" #include "migration/misc.h" #include "standard-headers/linux/ethtool.h" @@ -89,6 +90,43 @@ VIRTIO_NET_RSS_HASH_TYPE_TCP_EX |= \ VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) =20 +qmp_virtio_feature_map_t net_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_NET_F_##name, VIRTIO_NET_FEATURE_##name } + FEATURE_ENTRY(CSUM), + FEATURE_ENTRY(GUEST_CSUM), + FEATURE_ENTRY(CTRL_GUEST_OFFLOADS), + FEATURE_ENTRY(MTU), + FEATURE_ENTRY(MAC), + FEATURE_ENTRY(GUEST_TSO4), + FEATURE_ENTRY(GUEST_TSO6), + FEATURE_ENTRY(GUEST_ECN), + FEATURE_ENTRY(GUEST_UFO), + FEATURE_ENTRY(HOST_TSO4), + FEATURE_ENTRY(HOST_TSO6), + FEATURE_ENTRY(HOST_ECN), + FEATURE_ENTRY(HOST_UFO), + FEATURE_ENTRY(MRG_RXBUF), + FEATURE_ENTRY(STATUS), + FEATURE_ENTRY(CTRL_VQ), + FEATURE_ENTRY(CTRL_RX), + FEATURE_ENTRY(CTRL_VLAN), + FEATURE_ENTRY(CTRL_RX_EXTRA), + FEATURE_ENTRY(GUEST_ANNOUNCE), + FEATURE_ENTRY(MQ), + FEATURE_ENTRY(CTRL_MAC_ADDR), + FEATURE_ENTRY(STANDBY), + FEATURE_ENTRY(SPEED_DUPLEX), + FEATURE_ENTRY(HASH_REPORT), + FEATURE_ENTRY(RSS), + FEATURE_ENTRY(RSC_EXT), +#ifndef VIRTIO_NET_NO_LEGACY + FEATURE_ENTRY(GSO), +#endif /* VIRTIO_NET_NO_LEGACY */ +#undef FEATURE_ENTRY + { -1, -1 } +}; + static VirtIOFeature feature_sizes[] =3D { {.flags =3D 1ULL << VIRTIO_NET_F_MAC, .end =3D endof(struct virtio_net_config, mac)}, diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 99ff261..904e297 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -15,6 +15,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "standard-headers/linux/virtio_ids.h" #include "hw/virtio/virtio-scsi.h" #include "migration/qemu-file-types.h" @@ -29,6 +30,17 @@ #include "hw/virtio/virtio-access.h" #include "trace.h" =20 +qmp_virtio_feature_map_t scsi_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_SCSI_F_##name, VIRTIO_SCSI_FEATURE_##name } + FEATURE_ENTRY(INOUT), + FEATURE_ENTRY(HOTPLUG), + FEATURE_ENTRY(CHANGE), + FEATURE_ENTRY(T10_PI), +#undef FEATURE_ENTRY + { -1, -1 } +}; + static inline int virtio_scsi_get_lun(uint8_t *lun) { return ((lun[2] << 8) | lun[3]) & 0x3FFF; diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index e770955..11a32ad 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -27,6 +27,7 @@ #include "qapi/error.h" #include "qapi/qapi-events-machine.h" #include "qapi/visitor.h" +#include "qapi/qapi-visit-virtio.h" #include "trace.h" #include "qemu/error-report.h" #include "migration/misc.h" @@ -34,6 +35,19 @@ #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" =20 +qmp_virtio_feature_map_t balloon_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_BALLOON_F_##name, VIRTIO_BALLOON_FEATURE_##name } + FEATURE_ENTRY(MUST_TELL_HOST), + FEATURE_ENTRY(STATS_VQ), + FEATURE_ENTRY(DEFLATE_ON_OOM), + FEATURE_ENTRY(FREE_PAGE_HINT), + FEATURE_ENTRY(PAGE_POISON), + FEATURE_ENTRY(REPORTING), +#undef FEATURE_ENTRY + { -1, -1 } +}; + #define BALLOON_PAGE_SIZE (1 << VIRTIO_BALLOON_PFN_SHIFT) =20 typedef struct PartiallyBalloonedPage { diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index c2883a2..1b7c202 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -25,6 +25,7 @@ #include "hw/virtio/virtio.h" #include "sysemu/kvm.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/error-report.h" #include "trace.h" =20 @@ -36,6 +37,19 @@ #include "hw/pci/pci_bus.h" #include "hw/pci/pci.h" =20 +qmp_virtio_feature_map_t iommu_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_IOMMU_F_##name, VIRTIO_IOMMU_FEATURE_##name } + FEATURE_ENTRY(INPUT_RANGE), + FEATURE_ENTRY(DOMAIN_RANGE), + FEATURE_ENTRY(MAP_UNMAP), + FEATURE_ENTRY(BYPASS), + FEATURE_ENTRY(PROBE), + FEATURE_ENTRY(MMIO), +#undef FEATURE_ENTRY + { -1, -1 } +}; + /* Max size */ #define VIOMMU_DEFAULT_QUEUE_SIZE 256 #define VIOMMU_PROBE_SIZE 512 diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 69ef890..08ca635 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -31,9 +31,30 @@ #include "sysemu/dma.h" #include "sysemu/runstate.h" #include "standard-headers/linux/virtio_ids.h" +#include CONFIG_DEVICES =20 static QTAILQ_HEAD(, VirtIODevice) virtio_list; =20 +static qmp_virtio_feature_map_t transport_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_F_##name, VIRTIO_TRANSPORT_FEATURE_##name } + FEATURE_ENTRY(NOTIFY_ON_EMPTY), + FEATURE_ENTRY(ANY_LAYOUT), + FEATURE_ENTRY(VERSION_1), + FEATURE_ENTRY(IOMMU_PLATFORM), + FEATURE_ENTRY(RING_PACKED), + FEATURE_ENTRY(ORDER_PLATFORM), + FEATURE_ENTRY(SR_IOV), + FEATURE_ENTRY(BAD_FEATURE), +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VIRTIO_RING_F_##name, VIRTIO_TRANSPORT_FEATURE_##name } + FEATURE_ENTRY(INDIRECT_DESC), + FEATURE_ENTRY(EVENT_IDX), +#undef FEATURE_ENTRY + { -1, -1 } +}; + /* * The alignment to use between consumer and producer parts of vring. * x86 pagesize again. This is the default, used by transports like PCI @@ -3898,6 +3919,103 @@ static VirtIODevice *virtio_device_find(const char = *path) return NULL; } =20 +#define CONVERT_FEATURES(type, map) \ + ({ \ + type *list =3D NULL; \ + type *node; \ + for (i =3D 0; map[i].virtio_bit !=3D -1; i++) {\ + bit =3D 1ULL << map[i].virtio_bit; \ + if ((bitmap & bit) =3D=3D 0) { \ + continue; \ + } \ + node =3D g_new0(type, 1); \ + node->value =3D map[i].qapi_virtio_enum; \ + node->next =3D list; \ + list =3D node; \ + bitmap ^=3D bit; \ + } \ + list; \ + }) + +static VirtioDeviceFeatures *qmp_decode_features(const char *name, + uint64_t bitmap) +{ + VirtioDeviceFeatures *features; + uint64_t bit; + int i; + + features =3D g_new0(VirtioDeviceFeatures, 1); + + /* transport features */ + features->transport =3D CONVERT_FEATURES(VirtioTransportFeatureList, \ + transport_map); + + /* device features */ + features->type =3D qapi_enum_parse(&VirtioType_lookup, + name, -1, NULL); + switch (features->type) { +#ifdef CONFIG_VIRTIO_SERIAL + case VIRTIO_TYPE_VIRTIO_SERIAL: + features->u.virtio_serial.features =3D + CONVERT_FEATURES(VirtioSerialFeatureList, serial= _map); + break; +#endif +#ifdef CONFIG_VIRTIO_BLK + case VIRTIO_TYPE_VIRTIO_BLK: + features->u.virtio_blk.features =3D + CONVERT_FEATURES(VirtioBlkFeatureList, blk= _map); + break; +#endif +#ifdef CONFIG_VIRTIO_GPU + case VIRTIO_TYPE_VIRTIO_GPU: + features->u.virtio_gpu.features =3D + CONVERT_FEATURES(VirtioGpuFeatureList, gpu= _map); + break; +#endif +#ifdef CONFIG_VIRTIO_NET + case VIRTIO_TYPE_VIRTIO_NET: + features->u.virtio_net.features =3D + CONVERT_FEATURES(VirtioNetFeatureList, net= _map); + break; +#endif +#ifdef CONFIG_VIRTIO_SCSI + case VIRTIO_TYPE_VIRTIO_SCSI: + features->u.virtio_scsi.features =3D + CONVERT_FEATURES(VirtioScsiFeatureList, scsi= _map); + break; +#endif +#ifdef CONFIG_VIRTIO_BALLOON + case VIRTIO_TYPE_VIRTIO_BALLOON: + features->u.virtio_balloon.features =3D + CONVERT_FEATURES(VirtioBalloonFeatureList, balloon= _map); + break; +#endif +#ifdef CONFIG_VIRTIO_IOMMU + case VIRTIO_TYPE_VIRTIO_IOMMU: + features->u.virtio_iommu.features =3D + CONVERT_FEATURES(VirtioIommuFeatureList, iommu= _map); + break; +#endif + /* No features */ + case VIRTIO_TYPE_VIRTIO_9P: + case VIRTIO_TYPE_VIRTIO_INPUT: + case VIRTIO_TYPE_VHOST_USER_FS: + case VIRTIO_TYPE_VHOST_VSOCK: + case VIRTIO_TYPE_VIRTIO_CRYPTO: + case VIRTIO_TYPE_VIRTIO_PMEM: + case VIRTIO_TYPE_VIRTIO_RNG: + break; + default: + g_assert_not_reached(); + } + features->has_unknown_features =3D bitmap !=3D 0; + if (features->has_unknown_features) { + features->unknown_features =3D bitmap; + } + + return features; +} + VirtioStatus *qmp_x_debug_virtio_status(const char* path, Error **errp) { VirtIODevice *vdev; @@ -3910,9 +4028,12 @@ VirtioStatus *qmp_x_debug_virtio_status(const char* = path, Error **errp) } =20 status =3D g_new0(VirtioStatus, 1); - status->guest_features =3D vdev->guest_features; - status->host_features =3D vdev->host_features; - status->backend_features =3D vdev->backend_features; + status->guest_features =3D qmp_decode_features(vdev->name, + vdev->guest_features); + status->host_features =3D qmp_decode_features(vdev->name, + vdev->host_features); + status->backend_features =3D qmp_decode_features(vdev->name, + vdev->backend_features); status->device_id =3D vdev->device_id; =20 switch (vdev->device_endian) { diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 2470e09..6fcb5e0 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -163,6 +163,19 @@ struct VirtioDeviceClass { bool (*primary_unplug_pending)(void *opaque); }; =20 +typedef struct { + int virtio_bit; + int qapi_virtio_enum; +} qmp_virtio_feature_map_t; + +extern qmp_virtio_feature_map_t serial_map[]; +extern qmp_virtio_feature_map_t blk_map[]; +extern qmp_virtio_feature_map_t gpu_map[]; +extern qmp_virtio_feature_map_t net_map[]; +extern qmp_virtio_feature_map_t scsi_map[]; +extern qmp_virtio_feature_map_t balloon_map[]; +extern qmp_virtio_feature_map_t iommu_map[]; + void virtio_instance_init_common(Object *proxy_obj, void *data, size_t vdev_size, const char *vdev_name); =20 diff --git a/qapi/virtio.json b/qapi/virtio.json index 4af95a0..8b5785f 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -79,6 +79,253 @@ } =20 ## +# @VirtioTransportFeature: +# +# An enumeration of Virtio device transport features, including virtio-ring +# +# Since: 6.0 +## + +{ 'enum': 'VirtioTransportFeature', + 'data': [ 'notify-on-empty', 'any-layout', 'version-1', 'iommu-platform', + 'ring-packed', 'order-platform', 'sr-iov', 'indirect-desc', + 'event-idx', 'bad-feature' ] +} + +## +# @VirtioSerialFeature: +# +# An enumeration of Virtio serial features +# +# Since: 6.0 +## + +{ 'enum': 'VirtioSerialFeature', + 'data': [ 'size', 'multiport', 'emerg-write' ] +} + +## +# @VirtioBlkFeature: +# +# An enumeration of Virtio block features +# +# Since: 6.0 +## + +{ 'enum': 'VirtioBlkFeature', + 'data': [ 'size-max', 'seg-max', 'geometry', 'ro', 'blk-size', 'topology= ', + 'mq', 'discard', 'write-zeroes', 'barrier', 'scsi', 'flush', + 'config-wce' ] +} + +## +# @VirtioGpuFeature: +# +# An enumeration of Virtio gpu features +# +# Since: 6.0 +## + +{ 'enum': 'VirtioGpuFeature', + 'data': [ 'virgl', 'edid', 'resource-uuid', 'resource-blob' ] +} + +## +# @VirtioNetFeature: +# +# An enumeration of Virtio net features +# +# Since: 6.0 +## + +{ 'enum': 'VirtioNetFeature', + 'data': [ 'csum', 'guest-csum', 'ctrl-guest-offloads', 'mtu', 'mac', + 'guest-tso4', 'guest-tso6', 'guest-ecn', 'guest-ufo', + 'host-tso4', 'host-tso6', 'host-ecn', 'host-ufo', 'mrg-rxbuf', + 'status', 'ctrl-vq', 'ctrl-rx', 'ctrl-vlan', 'ctrl-rx-extra', + 'guest-announce', 'mq', 'ctrl-mac-addr', 'standby', + 'speed-duplex', 'gso', 'hash-report', 'rss', 'rsc-ext' ] +} + +## +# @VirtioScsiFeature: +# +# An enumeration of Virtio scsi features +# +# Since: 6.0 +## + +{ 'enum': 'VirtioScsiFeature', + 'data': [ 'inout', 'hotplug', 'change', 't10-pi' ] +} + +## +# @VirtioBalloonFeature: +# +# An enumeration of Virtio balloon features +# +# Since: 6.0 +## + +{ 'enum': 'VirtioBalloonFeature', + 'data': [ 'must-tell-host', 'stats-vq', 'deflate-on-oom', 'free-page-hin= t', + 'page-poison', 'reporting' ] +} + +## +# @VirtioIommuFeature: +# +# An enumeration of Virtio iommu features +# +# Since: 6.0 +## + +{ 'enum': 'VirtioIommuFeature', + 'data': [ 'input-range', 'domain-range', 'map-unmap', 'bypass', 'probe', + 'mmio' ] +} + +## +# @VirtioDeviceFeaturesBase: +# +# The common fields that apply to all Virtio devices +# +# @type: virtio device type +# @transport: the list of transport features of the virtio device +# @unknown-features: virtio device features bitmap that have not been deco= ded +# +# Since: 6.0 +## + +{ 'struct': 'VirtioDeviceFeaturesBase', + 'data': { + 'type': 'VirtioType', + 'transport': [ 'VirtioTransportFeature' ], + '*unknown-features': 'uint64' + } +} + +## +# @VirtioDeviceFeaturesOptionsSerial: +# +# The options that apply to Virtio serial device +# +# @features: List of the device features +# +# Since: 6.0 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsSerial', + 'data': { 'features': [ 'VirtioSerialFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsBlk: +# +# The options that apply to Virtio block device +# +# @features: List of the device features +# +# Since: 6.0 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsBlk', + 'data': { 'features': [ 'VirtioBlkFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsGpu: +# +# The options that apply to Virtio GPU device +# +# @features: List of the device features +# +# Since: 6.0 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsGpu', + 'data': { 'features': [ 'VirtioGpuFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsNet: +# +# The options that apply to Virtio net device +# +# @features: List of the device features +# +# Since: 6.0 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsNet', + 'data': { 'features': [ 'VirtioNetFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsScsi: +# +# The options that apply to Virtio SCSI device +# +# @features: List of the device features +# +# Since: 6.0 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsScsi', + 'data': { 'features': [ 'VirtioScsiFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsBalloon: +# +# The options that apply to Virtio balloon device +# +# @features: List of the device features +# +# Since: 6.0 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsBalloon', + 'data': { 'features': [ 'VirtioBalloonFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsIommu: +# +# The options that apply to Virtio IOMMU device +# +# @features: List of the device features +# +# Since: 6.0 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsIommu', + 'data': { 'features': [ 'VirtioIommuFeature' ] } +} + +## +# @VirtioDeviceFeatures: +# +# A union to define the list of features for a virtio device +# +# Since: 6.0 +## + +{ 'union': 'VirtioDeviceFeatures', + 'base': 'VirtioDeviceFeaturesBase', + 'discriminator': 'type', + 'data': { + 'virtio-serial': 'VirtioDeviceFeaturesOptionsSerial', + 'virtio-blk': 'VirtioDeviceFeaturesOptionsBlk', + 'virtio-gpu': 'VirtioDeviceFeaturesOptionsGpu', + 'virtio-net': 'VirtioDeviceFeaturesOptionsNet', + 'virtio-scsi': 'VirtioDeviceFeaturesOptionsScsi', + 'virtio-balloon': 'VirtioDeviceFeaturesOptionsBalloon', + 'virtio-iommu': 'VirtioDeviceFeaturesOptionsIommu' + } +} + +## # @VirtioStatus: # # @device-id: VirtIODevice status @@ -101,9 +348,9 @@ 'data': { 'device-id': 'int', 'device-endian': 'VirtioStatusEndianness', - 'guest-features': 'uint64', - 'host-features': 'uint64', - 'backend-features': 'uint64', + 'guest-features': 'VirtioDeviceFeatures', + 'host-features': 'VirtioDeviceFeatures', + 'backend-features': 'VirtioDeviceFeatures', 'num-vqs': 'uint16' } } @@ -123,18 +370,31 @@ # # -> { "execute": "x-debug-virtio-status", # "arguments": { -# "path": "/machine/peripheral-anon/device[3]/virtio-backend" +# "path": "/machine/peripheral-anon/device[1]/virtio-backend" # } # } # <- { "return": { -# "backend-features": 0, -# "guest-features": 5111807911, -# "num-vqs": 3, -# "host-features": 6337593319, # "device-endian": "little", -# "device-id": 1 +# "device-id": 3, +# "backend-features": { +# "transport": [], +# "type": "virtio-serial", +# "features": [] +# }, +# "num-vqs": 64, +# "guest-features": { +# "transport": [ "event-idx", "indirect-desc", "version-1" ], +# "type": "virtio-serial", +# "features": [ "multiport" ] +# }, +# "host-features": { +# "transport": [ "event-idx", "indirect-desc", "bad-feature", +# "version-1", "any-layout", "notify-on-empty"= ], +# "type": "virtio-serial", +# "features": [ "emerg-write", "multiport" ] +# } # } -# } +# } # ## =20 --=20 1.8.3.1 From nobody Mon May 6 23:42:58 2024 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; arc=pass (i=1dmarc=pass fromdomain=oracle.com); dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1616086274; cv=pass; d=zohomail.com; s=zohoarc; b=R3u/NrCwU2bDZdCSyygFXZXmcu+psezILO54aKBBztMOdDsvwDmidtPxgtxre50tfEogO4BOiC61JugEJXI/soEiHuXKa3VWSKww4UkqREuLBWTMgtOZ9EDlEMzg84jk7vPx6oUodungHpNRu41Ai1ThNHtnsUesuwqIeZTGlv8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616086274; h=Content-Type: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=oKrqGRQ5rQ0M5uFzhyOa6btpAVcjAeUEEAgAfSBqEM4=; b=c3+rGcHPhSwFGB0EicVUdWbKbNJTtVtOaqPJDX/GPkB+/r3IDIsAxq8VCYc1lYTYd/Xxbpm+gKpHwe6fcbNAHdeEzXVgmY1jxbCtwgR0wrlo9cWJOadmTGY13W4zZtozE3nHZL5NM4ay4kyUjuy6CUpWr19tW6eZY/6z+ngzGLY= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=oracle.com); dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616086274337257.9083903148064; Thu, 18 Mar 2021 09:51:14 -0700 (PDT) Received: from localhost ([::1]:54808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMvrd-0002gz-7B for importer@patchew.org; Thu, 18 Mar 2021 12:51:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMvXu-0003ty-5W; Thu, 18 Mar 2021 12:30:50 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:43782) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMvXo-0008Aw-QU; Thu, 18 Mar 2021 12:30:49 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12IGTuFX167180; Thu, 18 Mar 2021 16:30:26 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 378jwbr7e4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Mar 2021 16:30:26 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12IGQm2G051906; Thu, 18 Mar 2021 16:30:25 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by aserp3030.oracle.com with ESMTP id 3796ywdjeq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Mar 2021 16:30:25 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB4565.namprd10.prod.outlook.com (2603:10b6:510:31::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18; Thu, 18 Mar 2021 16:30:16 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::6819:aaf:9a92:c1db]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::6819:aaf:9a92:c1db%2]) with mapi id 15.20.3933.032; Thu, 18 Mar 2021 16:30:16 +0000 Received: from jonpalme-lnx.us.oracle.com (24.147.51.11) by SJ0PR05CA0079.namprd05.prod.outlook.com (2603:10b6:a03:332::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.10 via Frontend Transport; Thu, 18 Mar 2021 16:30:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=oKrqGRQ5rQ0M5uFzhyOa6btpAVcjAeUEEAgAfSBqEM4=; b=lf0n5ploF0wx4F4i7sEoBjQI3Pg/lL6QcgKYo055BZ+Cynop1ZPr9nNc+XYhccFUHg7x diNdvHtT9DyxfBtRjQHbiZJ5v25KyzacPagwqJre3Q0VcFgQpBpVGCOP+agsKjFngKNo cIesmoAaSzXYBOcKMa2DJeASaNxQLWSQqgRpPp94iVCXLVwPYYxXTb9nOLlxdD49Bjnh XTmVNyY77WiGVjSLddLla7sfSpsqhMBskI8EqrFHw6GDVBkeA6KlCFgJtV4BwCtHUYhd DIM0z/x5enhPzwdGyYQcdfIKAwVdMsu65L8CDOj/uhFcOZaXMNb1NmoGQ4JXErAxO4nr jw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XxgQ90f4kq5RSTSoo7zPfuwn+otMLrCAv+KzG5TweCEtktLEHBT3R0jj92DdkgGQcojprZUnhnFfsqjLbe8LpWIvRomen5S3uFKIBwAmoPm75mqsGrKUgGUNREuy6exeVCWVOp8Spr+fdTJEnfFwLhyr7cnld1/uUosiFBxenjLHtXg5hLTLg20jYwAcwOZ5CMqRQak49WB2F1ytwuiBZm9dhNzyVxXYKqrr7LFKibZkZ8KHg9G0r04Y/CUSI4UuBqYa3b8uRni4Rvd91iOZlkAAWFqi1ICGzHzURaFVTfkNVCU/YXAaESNzQfSkqR/MniQGd9wEG0yzXItAXw9FiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oKrqGRQ5rQ0M5uFzhyOa6btpAVcjAeUEEAgAfSBqEM4=; b=mrvo1Xyf/7A5fKyoXr4HOHdVumDturOubXASN34bzE/oQkeRzhRW2A5Cl8k8DKkV/bPTDkLzz/nYVhDJF2QJjIzFLmT3/AqDWFVCFA9ZMDY1/XuRA5BP7mTWSz/YdTPnWPXtICglssFJp3CJdBNdFntXpDXAdLMCoCIrhq/HeiYnXxjdd2pcskIEFUXB7/uGXQFy4T6Sz7VnFxbdMM5hxeNbKF87/honkdd1vTEfZJW09fb8vVO2hY38J5nZGeN8h3saiIvM5rDsY5vBCczOadvEK+0YYzLYHKPYMYOQu1vir4Hvq802tskAzQ13khkJqhygubx14l+JxyTjV7JmeA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oKrqGRQ5rQ0M5uFzhyOa6btpAVcjAeUEEAgAfSBqEM4=; b=HVNY66bpp07S+GPmO9c3QPgD2Q1l0hxjlKHbwneKu4ZAjbBogTWQHU8Qyz5gwxk9upCOET9aWOTlESxXXWx1J5flvbq40glbRVqsGqWfuQZ/3Ly2k/ys/uolkl8n99Dy+gG7yUn6XwMKNdKkCBIcWl7eaOXM7sRkG+9DgUVcMDk= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [RFC v5 4/6] qmp: add QMP command x-debug-virtio-queue-status Date: Thu, 18 Mar 2021 12:29:42 -0400 Message-Id: <1616084984-11263-5-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1616084984-11263-1-git-send-email-jonah.palmer@oracle.com> References: <1616084984-11263-1-git-send-email-jonah.palmer@oracle.com> X-Originating-IP: [24.147.51.11] X-ClientProxiedBy: SJ0PR05CA0079.namprd05.prod.outlook.com (2603:10b6:a03:332::24) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ceabc087-1dd2-46d4-e2cc-08d8ea2b1ce5 X-MS-TrafficTypeDiagnostic: PH0PR10MB4565: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2399; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ke0seZs13pbkKrvwTu8GNjmhM+RRZO3JbWWOrRhqz6tfetl+nUh2RDWul65oCOYDfLfz2xT52Wlxu8QVfJb2vVHxydy8mUkNZu76XUVyxSs3mhLy8L4rfNmlE8vc7B6eZtU9ycXn48vK+gYy+6gw+J3pt7UE7ZU49/n3j47M6qgAFS0GT6gIJ58mIimrO2kjMDOMDUN3EnsBc8Z/5Ns8E3CtR8MDcHa1MlQw68G7vkwuJjsMFyWpPaPHAC/1ZA0t5BleTHj7eLF+dMgW/Gjz3eBCQpTt/WK2QBPnkUHfCClzTTELIisbRatVzzybsXwuprA8aUFtQkOVufqtQUU39XEdVOpvQwkRsazTWl3pjeCYIzLsN/mhuPDdvdZhaYMhdc9hGRFmXIHT9JY69FxAkF6+JkkSk7wytJ4kGDtxpc6KRT8kRM30VQD85Q0t/qFb9GnkWu86X38nGsUERnK1G5hZFumdJyeIUGY5Gw+L6QV+nnYM9zhoZr3QQVD+DJ7Upqp15bKxHGmmj1lfES5ci0ZoCs+ogDTZtWAIaIYqYkxMz91TD9cISSl8RtMDqmxbmBYHP/CqJKaw+11GlSDYDZzKb2x9asfFW6k1v4npT5Y= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR10MB4664.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(346002)(366004)(39860400002)(376002)(136003)(8676002)(66476007)(66556008)(66946007)(38100700001)(36756003)(186003)(5660300002)(2906002)(478600001)(86362001)(52116002)(7696005)(8936002)(316002)(16526019)(956004)(26005)(7416002)(6666004)(44832011)(2616005)(6916009)(107886003)(4326008)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?7LX2AQyJdG/UnRYJeMTW6hQC80S9KXnZAOeCg+BfTmTTh7wI5RQRkS8yyL4y?= =?us-ascii?Q?rDfazJJoyM0lqBlFnALoy44AGRqvBZeFIPsJ+9W/coTeU7xNpIPYvTRhp89R?= =?us-ascii?Q?zf1frXkBH7hTy3YYqgewa2ym1SdpOn27X99pQ+k5KTXTSiM+FVQE6b4DLyER?= =?us-ascii?Q?n7XjrjfUqOlyqpmcal/iJZ8A3danS2rZ0A8KvH5nKx6hsA7c8yw9mWOg+PMn?= =?us-ascii?Q?yBwGIGxZPBxit7n+12L0LrO4H5UQD76EawXE57ZYBLUjW9A4bVJpSNBuGUJ+?= =?us-ascii?Q?rUwp6+UnOJlP75dmjpXJ8jRE1xnaUkd95emlJRQ0WfPejPZm5CW54Q4mzONy?= =?us-ascii?Q?u396nxEihbYmdf3mx2mpj8VBPf9HeF+8Gytx1X+6hp6ZYo3lmt91SIS5GMR8?= =?us-ascii?Q?is+GoIMJCLaolwrZU1Ht8S/3rxKX9xyKisMJxwJjItEFCj9rLT9lhWb3sfVh?= =?us-ascii?Q?0/WLO81uiBfz+rjVW3XKk63VwZSW4KgAsnTI+JF4lpNExm1I9aQhH09qXBmk?= =?us-ascii?Q?wp810t4Z6+ozPaBSLAZuNdtwU4ccw85xSgP8QbaEfhr99Iej03IKIynkEgy7?= =?us-ascii?Q?T376478TmHQy74W4uLmS1a6Tauo/u+B9VIvj7P5z58JBblgoaN94SQ4ddv67?= =?us-ascii?Q?zjcmdmPyz+mIQ0azX6dYHI83JrHuT+p9Sd+FU2uoV89X9z7yBfTIgZggafSi?= =?us-ascii?Q?cXKJihYsuD4e5U4GPZ+t317/HSDpONZ10gyv9RAxZpFCqW/hgVetxCSU4HJI?= =?us-ascii?Q?2g9EV4rQXEdDj9vH7G+IrRbGSftHOGkcHzzq8WZi7s+uNl0F4V142K7ctO6h?= =?us-ascii?Q?6CPKkASY1s4WaWqeaK+RtD9G1mhctGC9VtYgOieMRSXHe8Q4ZzkTnVKI/SYD?= =?us-ascii?Q?jBAIxh2A2TAi2VB07Y97uxVsKiflh75hnExeDMizJ7WufXl/dK1NpkoMFKY5?= =?us-ascii?Q?uAcqexrlD4YOPEhuFFFMJdd5+XAUnjQBDNmtj3J5M5lSsEvF7Hl9QLAzUbAK?= =?us-ascii?Q?NiraZTttxE0G8UNeIBp8w7YszIfdw8OwIX5foeftT27C8WFr45ZW69S6y2A0?= =?us-ascii?Q?ZS72iWj0yggf3kN891EawA4wbOYN+USEVj/V9IWlfuklErzDZwRj/XC0Br4k?= =?us-ascii?Q?Iuz9hAyqsVbj6LtSYIJlJzvaC1RXwn8j20kifoM2wGou4c1Rqwv/JmtkTOqx?= =?us-ascii?Q?l07CSz7DzjQgiBK0EcyaAdWkIEBAZnID3tDAXJE3lZiJWqyT0cRa81fgGipf?= =?us-ascii?Q?6PZA0OD4gghpIT4X2zaULDTYgydoQBC3r8LaJbFhHesBodacRxwj8zLckMOr?= =?us-ascii?Q?TPBzJFbDMIlbmsUCq8y2r4z+?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ceabc087-1dd2-46d4-e2cc-08d8ea2b1ce5 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2021 16:30:16.3341 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: A8w2znpLv3yvL84iO4emlgjpwbRlHzYAmtPoSeRpGjo+ng9tFketyQXuTDvaPSk0OnfzjFtGX0p+J1I9LCjcRA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4565 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9927 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103180115 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9927 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 adultscore=0 phishscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103180116 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=141.146.126.79; envelope-from=jonah.palmer@oracle.com; helo=aserp2130.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, marcandre.lureau@redhat.com, jonah.palmer@oracle.com, thuth@redhat.com, amit@kernel.org, michael.roth@amd.com, dgilbert@redhat.com, eric.auger@redhat.com, dmitrii.stepanov@cloud.ionos.com, stefanha@redhat.com, kwolf@redhat.com, laurent@vivier.eu, mreitz@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This new command shows internal status of a VirtQueue. (vrings and indexes). [Jonah: Added 'device-type' field to VirtQueueStatus and qmp command x-debug-virtio-queue-status.] Signed-off-by: Laurent Vivier Signed-off-by: Jonah Palmer --- hw/virtio/virtio-stub.c | 6 +++ hw/virtio/virtio.c | 37 ++++++++++++++++++ qapi/virtio.json | 102 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 145 insertions(+) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index ddb592f..3c1bf17 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -17,3 +17,9 @@ VirtioStatus *qmp_x_debug_virtio_status(const char* path,= Error **errp) { return qmp_virtio_unsupported(errp); } + +VirtQueueStatus *qmp_x_debug_virtio_queue_status(const char *path, + uint16_t queue, Error **e= rrp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 08ca635..d9b5734 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3919,6 +3919,43 @@ static VirtIODevice *virtio_device_find(const char *= path) return NULL; } =20 +VirtQueueStatus *qmp_x_debug_virtio_queue_status(const char *path, + uint16_t queue, Error **e= rrp) +{ + VirtIODevice *vdev; + VirtQueueStatus *status; + + vdev =3D virtio_device_find(path); + if (vdev =3D=3D NULL) { + error_setg(errp, "Path %s is not a VirtIO device", path); + return NULL; + } + + if (queue >=3D VIRTIO_QUEUE_MAX || !virtio_queue_get_num(vdev, queue))= { + error_setg(errp, "Invalid virtqueue number %d", queue); + return NULL; + } + + status =3D g_new0(VirtQueueStatus, 1); + status->device_type =3D qapi_enum_parse(&VirtioType_lookup, vdev->name, + VIRTIO_TYPE_UNKNOWN, NULL); + status->queue_index =3D vdev->vq[queue].queue_index; + status->inuse =3D vdev->vq[queue].inuse; + status->vring_num =3D vdev->vq[queue].vring.num; + status->vring_num_default =3D vdev->vq[queue].vring.num_default; + status->vring_align =3D vdev->vq[queue].vring.align; + status->vring_desc =3D vdev->vq[queue].vring.desc; + status->vring_avail =3D vdev->vq[queue].vring.avail; + status->vring_used =3D vdev->vq[queue].vring.used; + status->last_avail_idx =3D vdev->vq[queue].last_avail_idx; + status->shadow_avail_idx =3D vdev->vq[queue].shadow_avail_idx; + status->used_idx =3D vdev->vq[queue].used_idx; + status->signalled_used =3D vdev->vq[queue].signalled_used; + status->signalled_used_valid =3D vdev->vq[queue].signalled_used_valid; + + return status; +} + #define CONVERT_FEATURES(type, map) \ ({ \ type *list =3D NULL; \ diff --git a/qapi/virtio.json b/qapi/virtio.json index 8b5785f..ab94263 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -402,3 +402,105 @@ 'data': { 'path': 'str' }, 'returns': 'VirtioStatus' } + +## +# @VirtQueueStatus: +# +# Status of a VirtQueue +# +# @device-type: VirtIO device type +# +# @queue-index: VirtQueue queue_index +# +# @inuse: VirtQueue inuse +# +# @vring-num: VirtQueue vring.num +# +# @vring-num-default: VirtQueue vring.num_default +# +# @vring-align: VirtQueue vring.align +# +# @vring-desc: VirtQueue vring.desc +# +# @vring-avail: VirtQueue vring.avail +# +# @vring-used: VirtQueue vring.used +# +# @last-avail-idx: VirtQueue last_avail_idx +# +# @shadow-avail-idx: VirtQueue shadow_avail_idx +# +# @used-idx: VirtQueue used_idx +# +# @signalled-used: VirtQueue signalled_used +# +# @signalled-used-valid: VirtQueue signalled_used_valid +# +# Since: 6.0 +# +## + +{ 'struct': 'VirtQueueStatus', + 'data': { + 'device-type': 'VirtioType', + 'queue-index': 'uint16', + 'inuse': 'uint32', + 'vring-num': 'int', + 'vring-num-default': 'int', + 'vring-align': 'int', + 'vring-desc': 'uint64', + 'vring-avail': 'uint64', + 'vring-used': 'uint64', + 'last-avail-idx': 'uint16', + 'shadow-avail-idx': 'uint16', + 'used-idx': 'uint16', + 'signalled-used': 'uint16', + 'signalled-used-valid': 'uint16' + } +} + +## +# @x-debug-virtio-queue-status: +# +# Return the status of a given VirtQueue +# +# @path: QOBject path of the VirtIODevice +# +# @queue: queue number to examine +# +# Returns: Status of the VirtQueue +# +# Since: 6.0 +# +# Example: +# +# -> { "execute": "x-debug-virtio-queue-status", +# "arguments": { +# "path": "/machine/peripheral-anon/device[3]/virtio-backend", +# "queue": 0 +# } +# } +# <- { "return": { +# "signalled-used": 373, +# "inuse": 0, +# "vring-align": 4096, +# "vring-desc": 864411648, +# "signalled-used-valid": 0, +# "vring-num-default": 256, +# "vring-avail": 864415744, +# "queue-index": 0, +# "last-avail-idx": 373, +# "vring-used": 864416320, +# "used-idx": 373, +# "device-type": "virtio-net", +# "shadow-avail-idx": 619, +# "vring-num": 256 +# } +# } +# +## + +{ 'command': 'x-debug-virtio-queue-status', + 'data': { 'path': 'str', 'queue': 'uint16' }, + 'returns': 'VirtQueueStatus' +} --=20 1.8.3.1 From nobody Mon May 6 23:42:58 2024 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; arc=pass (i=1dmarc=pass fromdomain=oracle.com); dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1616086138; cv=pass; d=zohomail.com; s=zohoarc; b=hgw0wauxGVy+rH9iu8M+l41EdlzsLTbK8NlwQaftva0yXQNx2XaMbH1ocTxXal7XtTOi6JArJQ4zVtfBrcE2zzPLFkdphN+nV/q0Oqg1AqbZoSBcAkHWin0+5nXNYQO0SkmemBZLEILAsEiEPdsIDl9ES9s2T3+25U3BjGobGd0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616086138; h=Content-Type: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=cG98HZq6jU19hwZJ9CZnbJWoTWBaYwXtkKZuoNKojxw=; b=YWfLRI7UYaMAdTBDV47NvXYBOR1uJJgGBr1ThHAxcBR2I6SjJALFh3WVxZLdNDuq77LO5VM2Jdy97zsOEBJd8aGQMlC5xXIRCi1ZvfkGpxlGtEmkkcolGgIgE98PZUqgf2T4pqJxfER6Ao5buJImaorqpK0W6t8glyFqNHIN5YM= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=oracle.com); dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161608613889073.22992043966133; Thu, 18 Mar 2021 09:48:58 -0700 (PDT) Received: from localhost ([::1]:49650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMvpR-0000Ud-Od for importer@patchew.org; Thu, 18 Mar 2021 12:48:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMvXs-0003qN-EN; Thu, 18 Mar 2021 12:30:48 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:43776) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMvXo-0008As-Qy; Thu, 18 Mar 2021 12:30:47 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12IGU2Uq167521; Thu, 18 Mar 2021 16:30:27 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 378jwbr7e7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Mar 2021 16:30:27 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12IGQm2H051906; Thu, 18 Mar 2021 16:30:26 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by aserp3030.oracle.com with ESMTP id 3796ywdjeq-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Mar 2021 16:30:26 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB4565.namprd10.prod.outlook.com (2603:10b6:510:31::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18; Thu, 18 Mar 2021 16:30:19 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::6819:aaf:9a92:c1db]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::6819:aaf:9a92:c1db%2]) with mapi id 15.20.3933.032; Thu, 18 Mar 2021 16:30:19 +0000 Received: from jonpalme-lnx.us.oracle.com (24.147.51.11) by SJ0PR05CA0079.namprd05.prod.outlook.com (2603:10b6:a03:332::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.10 via Frontend Transport; Thu, 18 Mar 2021 16:30:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=cG98HZq6jU19hwZJ9CZnbJWoTWBaYwXtkKZuoNKojxw=; b=AfnlO3m3NfD7skhzrELZ9GdBEyf3B6FJ3YTmYUO21lfLwFvG16ds3hO51lSUn9+l4/k3 RbsQf7jOpTDbhg9Mx+liZ/psycavdlE1hA4oB2pxmDCv4R5ueLsmYt92FI+U55FEVcD1 tn5vNupBj6L+UIsWy6s+qayqZEcT74WhfYfRKqhPcENoHhNsf1kPHd24L+dvhsdsziyW gqefwAng4GJcxaXGDOHKK9yeyfFPqBm0qzZNH/ZYwRjBnxyFWej7fiZahwg058a5BxAR mP2rWWCZovAqtfMMREsW6QzzYXn0/sV16gSSFjUtojAee3FZCzMJVhRRkAGv3vevgMIT +Q== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=imaCWKykL09k/bdhb4/BOPiO5mlALAREC5t/ssJy26LGkFnsf4HtijHpuHZmRpv4nTnX7ti3wQVkVN6ipJQxVVzPoeglkf5OyQr/SvGW8R0V7Fl59zJSNoTwIEurC/0pS2j5w7rGiD9ipJGTuF5J/qmODjgYwib6eK1jXnMk8EsmxgxjLoYzdiob2Gl8wXIoFPgo7qPuqzUgPjSCxoTrDgTXx0rJztnhr0C+5sHQPGKsNp9eFmA/4njnVZmQJzGJ0FG6+sHFT7sKM5MqcaKfso58xOk6b0aKi2A4lBtyA7C9LMC+H6kOjnm42FOhwajSdqgeww01Xl/GMmBPWA1xQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cG98HZq6jU19hwZJ9CZnbJWoTWBaYwXtkKZuoNKojxw=; b=ltSxbxDcTKY5h/4mZNnlclG5v7JpDabW5DGK5UYiVFtxiUwxEgtLbnlidBr+pfXHR/VMyFvK02D1+fIvXmxey0GaJztwrKy2L1FGeZoBjvJ1+S7P6/ouMSAPzZ4tQoQUZy+flFkc4x3F3+F/XVRYb57VeO3tz9eZEBoYFcrLCZpSQTfy/TOU/A6t17efZytE6LLQvcjsaf+KLu6NXLqclJ8tGJrkVAFXsR7QVtIgK3VENaD30hWT8IRn6YsEXzH2WsvSX44L8vLmq0oubFrwwqAYfreaT0TFMLwcEn2u+39MeIIpQXBz07c5eV2LGDVjYTtyPcBkg4bTbKI0LDzMBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cG98HZq6jU19hwZJ9CZnbJWoTWBaYwXtkKZuoNKojxw=; b=MpFe6bl1KYO9ZtdnQqVZkc/4OZ9Kz8XsoOjZpqwSZWEGQCMs2dPN366F9MQQC5tT2H7j3L17qws+ae6tQW2RdOpJkEu0LdpofFDmdZedXL7sgF6Q2jrJZCCx96bzltkitW+Cl3O/KgJgxbi0l3Sn0vFdtfAAqXwdt4IX3z7TUec= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [RFC v5 5/6] qmp: add QMP command x-debug-virtio-queue-element Date: Thu, 18 Mar 2021 12:29:43 -0400 Message-Id: <1616084984-11263-6-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1616084984-11263-1-git-send-email-jonah.palmer@oracle.com> References: <1616084984-11263-1-git-send-email-jonah.palmer@oracle.com> X-Originating-IP: [24.147.51.11] X-ClientProxiedBy: SJ0PR05CA0079.namprd05.prod.outlook.com (2603:10b6:a03:332::24) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fb58c109-c3d2-457a-f6bd-08d8ea2b1ebe X-MS-TrafficTypeDiagnostic: PH0PR10MB4565: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:883; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KkHf6/abJE34wfw+l03PCgRt0KcM5+6j5jOXK4PqDcck1xwu+CAMkITOgGh3jEWtE4h9T7JLNKaAQjlVTDebg6jVvXG4pmPhG88xE9X+43ft2ADCtdJpD12yxPRbJknnzx1HGtfK8En8ydd2s0RoBE30m8KyWlt64QUhj4GwI8JBt2V6KtKK+JMZE8L5xRtlrRKS3IpGUoKG/rK5HGPpbmkqzzXWvHW9SUTzB2xRL+anaPPagR1fAWN+02zAPED5D0+SfyPEiq7NQYEzlUk6o5WKoJ1WdxX/5CfQfDBnFa8/8T9ec+6+e/XeNI+D+tTiT8zfgQ/Jq34nnvidchByqU7KcAQny9tqcBVB4xFS5tcR7PhEB/l6XRBybJlZQe7tlajiwTH2s2rvHV92OrK/Jf0v/IWMT8Y+If/bb+kYmUZbKs4IWSzrCHUlVDxqmp8W7DVmvFewjmLHSoCVr7rRm3fnZyiQ2kiVELlUivRszZJVKrUfY0KxRrWa+JLeS6qJzW4B/DWAXz9OmiKTPA8vrOfYl42Iphv5b0NspS9O8ijZOANR2WsLMPsIJ3Je3LFtggUk7R3tjxL0XXSvQ3KgjdKfb6AYKE6dTnWdaz1iMZU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR10MB4664.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(346002)(366004)(39860400002)(376002)(136003)(8676002)(66476007)(66556008)(66946007)(38100700001)(36756003)(186003)(5660300002)(2906002)(478600001)(86362001)(52116002)(7696005)(8936002)(316002)(16526019)(956004)(26005)(7416002)(6666004)(44832011)(83380400001)(2616005)(6916009)(107886003)(4326008)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?tKAyVbDCDaUXi1ldeiFvmyeLr8sPg5nntepXAMIdFoyQ+9Zw4ZRWz7gPvpfa?= =?us-ascii?Q?aumzT5XFF0brHQfhpXKaBWIOUnz9IYQdzhHR9ZJDW4upX7ICAKFBJYkAj/08?= =?us-ascii?Q?DrJEmVogvFQdvxEwmlwdsmjebhhFTnpNDAUQcXe1fjiKiXFVDNiVxvZgHkQ2?= =?us-ascii?Q?phG1+qqRBfi8x/HQmQ5RZvWPGPPv/hw+9T+l3hIUBp6BNYSdSXoy4ksy3alh?= =?us-ascii?Q?aHr30JnnMRsdjjGGDSvAIWKpZei4R2OElGM1oBsr8J5Qb59TKtai6VJf6Pgi?= =?us-ascii?Q?nypJXuTHytYL7pFjym/uNKo8PZyhrckuTm8L6I96ICO0EEqLrHtghn0fkAxu?= =?us-ascii?Q?X5uFMIIuD1VkhII+F60hXwFadcOzdHWrR3NNg3xxvf8bxmgbpjQGJt8x2ekV?= =?us-ascii?Q?mlco+1y8E0z+gAyUUoiipQEAWL4azTGmxJEI8U9CJrdvH9jzMPho4Kn664FG?= =?us-ascii?Q?WOTLOYUPshOn5t7RnO73LAI5w5jrvEuZGKz58q+uoICviANRQGsuD87hj36v?= =?us-ascii?Q?tXAyc7CTuU2X/qeNEj8NBtos+rJtWGlfHDmTETZYVM+CgVVpT7R1tgpHMuCi?= =?us-ascii?Q?Fiaj9JPzqeFBz7yAkEBsFsJg+hlMsAsl2DicDsLOhAklxUzY9eOd9AzXvr9f?= =?us-ascii?Q?fILsnJ7zAZgqm/C+pINdgIU14liSy/GpX7jS2TBoNzDxwwxJ2Yxg8RBIBENn?= =?us-ascii?Q?eb/CrDhgqaF8RqJvw0/Nv4tvCtPwID6bwLuREY47dWwFIT/+RyiIjvhK+grJ?= =?us-ascii?Q?27o3JwdyFh/07XwkCsdDDya1eRcMO/PduUq8f1Dd2Fdt4LmS9mHjCYy8e0mW?= =?us-ascii?Q?DGs5rQx1GXshZ86CHBC4H+aZeRMemxmH+d3wLAbaFnvKpLp2PTIGyBg5OpVv?= =?us-ascii?Q?VZh3Z+FDKRe8mxN/Tidpw3ZyKLF5gs2wwIgIc5i2PaNkdo1Sbhs0xqLdiA5K?= =?us-ascii?Q?YihuL1VUeunU9hiTBa7xJtUIYmre1oF90UdimMLzr5KPb9V98S+E8VufWFZW?= =?us-ascii?Q?7i3RT7NQBCdA9NwLMfCY874/GMuRuiuVAhPDENzb0XC35g0jfxVZCBVr6wTw?= =?us-ascii?Q?2JU2FNlOIi3oRbaU7UZHVwLhVlbGrY9tHpp7QZqfubH9JnNXqPCAlvgW0RKW?= =?us-ascii?Q?TFGaY5qiYi0cdPzsvltzPED+aJL9Hec2kIzmKqvWOOPckVmaP7pq6uSXtsfs?= =?us-ascii?Q?GbqyPLkEb9E1LyBff5odFkoNcn/5EoLBkGDab1joxgkqyN/mRVKBAbYue39D?= =?us-ascii?Q?868ov+E86XNS7/0wkcIJ7jN7fxvuoFo8BMtK6ElwXBVjaA9QkPHq50bhnkaf?= =?us-ascii?Q?VHegKHg4jZN3BU+oBhyVAABw?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb58c109-c3d2-457a-f6bd-08d8ea2b1ebe X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2021 16:30:19.4414 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rmH4M78LHiSebXq72st6vYFx83mptTk0VXnrCAXNqwyOPruGaIrv2McZ55kEUb9WoKJOVA1QKflyZPdEXIVooA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4565 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9927 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103180115 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9927 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 adultscore=0 phishscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103180116 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=141.146.126.79; envelope-from=jonah.palmer@oracle.com; helo=aserp2130.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, marcandre.lureau@redhat.com, jonah.palmer@oracle.com, thuth@redhat.com, amit@kernel.org, michael.roth@amd.com, dgilbert@redhat.com, eric.auger@redhat.com, dmitrii.stepanov@cloud.ionos.com, stefanha@redhat.com, kwolf@redhat.com, laurent@vivier.eu, mreitz@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This new command shows the information of a VirtQueue element. Signed-off-by: Laurent Vivier Signed-off-by: Jonah Palmer --- hw/virtio/virtio-stub.c | 9 ++++ hw/virtio/virtio.c | 135 ++++++++++++++++++++++++++++++++++++++++++++= ++++ qapi/virtio.json | 94 +++++++++++++++++++++++++++++++++ 3 files changed, 238 insertions(+) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index 3c1bf17..8275e31 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -23,3 +23,12 @@ VirtQueueStatus *qmp_x_debug_virtio_queue_status(const c= har *path, { return qmp_virtio_unsupported(errp); } + +VirtioQueueElement *qmp_x_debug_virtio_queue_element(const char* path, + uint16_t queue, + bool has_index, + uint16_t index, + Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index d9b5734..735a6ae 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -4090,6 +4090,141 @@ VirtioStatus *qmp_x_debug_virtio_status(const char*= path, Error **errp) return status; } =20 +static VirtioRingDescFlagsList *qmp_decode_vring_desc_flags(uint16_t flags) +{ + VirtioRingDescFlagsList *list =3D NULL; + VirtioRingDescFlagsList *node; + int i; + struct { + uint16_t flag; + VirtioRingDescFlags value; + } map[] =3D { + { VRING_DESC_F_NEXT, VIRTIO_RING_DESC_FLAGS_NEXT }, + { VRING_DESC_F_WRITE, VIRTIO_RING_DESC_FLAGS_WRITE }, + { VRING_DESC_F_INDIRECT, VIRTIO_RING_DESC_FLAGS_INDIRECT }, + { 1 << VRING_PACKED_DESC_F_AVAIL, VIRTIO_RING_DESC_FLAGS_AVAIL }, + { 1 << VRING_PACKED_DESC_F_USED, VIRTIO_RING_DESC_FLAGS_USED }, + { 0, -1 } + }; + + for (i =3D 0; map[i].flag; i++) { + if ((map[i].flag & flags) =3D=3D 0) { + continue; + } + node =3D g_malloc0(sizeof(VirtioRingDescFlagsList)); + node->value =3D map[i].value; + node->next =3D list; + list =3D node; + } + + return list; +} + +VirtioQueueElement *qmp_x_debug_virtio_queue_element(const char* path, + uint16_t queue, + bool has_index, + uint16_t index, + Error **errp) +{ + VirtIODevice *vdev; + VirtQueue *vq; + VirtioQueueElement *element =3D NULL; + + vdev =3D virtio_device_find(path); + if (vdev =3D=3D NULL) { + error_setg(errp, "Path %s is not a VirtIO device", path); + return NULL; + } + + if (queue >=3D VIRTIO_QUEUE_MAX || !virtio_queue_get_num(vdev, queue))= { + error_setg(errp, "Invalid virtqueue number %d", queue); + return NULL; + } + vq =3D &vdev->vq[queue]; + + if (virtio_vdev_has_feature(vdev, VIRTIO_F_RING_PACKED)) { + error_setg(errp, "Packed ring not supported"); + return NULL; + } else { + unsigned int head, i, max; + VRingMemoryRegionCaches *caches; + MemoryRegionCache indirect_desc_cache =3D MEMORY_REGION_CACHE_INVA= LID; + MemoryRegionCache *desc_cache; + VRingDesc desc; + VirtioRingDescList *list =3D NULL; + VirtioRingDescList *node; + int rc; + + RCU_READ_LOCK_GUARD(); + + max =3D vq->vring.num; + + if (!has_index) { + head =3D vring_avail_ring(vq, vq->last_avail_idx % vq->vring.n= um); + } else { + head =3D vring_avail_ring(vq, index % vq->vring.num); + } + i =3D head; + + caches =3D vring_get_region_caches(vq); + if (!caches) { + error_setg(errp, "Region caches not initialized"); + return NULL; + } + + if (caches->desc.len < max * sizeof(VRingDesc)) { + error_setg(errp, "Cannot map descriptor ring"); + return NULL; + } + + desc_cache =3D &caches->desc; + vring_split_desc_read(vdev, &desc, desc_cache, i); + if (desc.flags & VRING_DESC_F_INDIRECT) { + int64_t len; + + len =3D address_space_cache_init(&indirect_desc_cache, vdev->d= ma_as, + desc.addr, desc.len, false); + desc_cache =3D &indirect_desc_cache; + if (len < desc.len) { + error_setg(errp, "Cannot map indirect buffer"); + goto done; + } + max =3D desc.len / sizeof(VRingDesc); + i =3D 0; + vring_split_desc_read(vdev, &desc, desc_cache, i); + } + + element =3D g_new0(VirtioQueueElement, 1); + element->index =3D head; + element->ndescs =3D 0; + + do { + /* A buggy driver may produce an infinite loop */ + if (element->ndescs >=3D max) { + break; + } + node =3D g_new0(VirtioRingDescList, 1); + node->value =3D g_new0(VirtioRingDesc, 1); + node->value->addr =3D desc.addr; + node->value->len =3D desc.len; + node->value->flags =3D qmp_decode_vring_desc_flags(desc.flags); + node->next =3D list; + list =3D node; + + element->ndescs++; + + rc =3D virtqueue_split_read_next_desc(vdev, &desc, desc_cache, + max, &i); + } while (rc =3D=3D VIRTQUEUE_READ_DESC_MORE); + + element->descs =3D list; +done: + address_space_cache_destroy(&indirect_desc_cache); + } + + return element; +} + static const TypeInfo virtio_device_info =3D { .name =3D TYPE_VIRTIO_DEVICE, .parent =3D TYPE_DEVICE, diff --git a/qapi/virtio.json b/qapi/virtio.json index ab94263..3d4ba1f 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -504,3 +504,97 @@ 'data': { 'path': 'str', 'queue': 'uint16' }, 'returns': 'VirtQueueStatus' } + +## +# @VirtioRingDescFlags: +# +# An enumeration of the virtio ring descriptor flags +# +# Since: 6.0 +# +## + +{ 'enum': 'VirtioRingDescFlags', + 'data': [ 'next', 'write', 'indirect', 'avail', 'used' ] +} + +## +# @VirtioRingDesc: +# +# @addr: guest physical address of the descriptor data +# +# @len: length of the descriptor data +# +# @flags: descriptor flags +# +# Since: 6.0 +# +## + +{ 'struct': 'VirtioRingDesc', + 'data': { + 'addr': 'uint64', + 'len': 'uint32', + 'flags': [ 'VirtioRingDescFlags' ] + } +} + +## +# @VirtioQueueElement: +# +# @index: index of the element in the queue +# +# @ndescs: number of descriptors +# +# @descs: list of the descriptors +# +# Since: 6.0 +# +## + +{ 'struct': 'VirtioQueueElement', + 'data': { + 'index': 'uint32', + 'ndescs': 'uint32', + 'descs': ['VirtioRingDesc'] + } +} + +## +# @x-debug-virtio-queue-element: +# +# Return the information about an element queue (by default head) +# +# @path: QOBject path of the VirtIODevice +# +# @queue: queue number to examine +# +# @index: the index in the queue, by default head +# +# Returns: the element information +# +# Since: 6.0 +# +# Example: +# +# -> { "execute": "x-debug-virtio-queue-element", +# "arguments": { +# "path": "/machine/peripheral-anon/device[3]/virtio-backend", +# "queue": 0 +# } +# } +# -> { "return": { +# "index": 24, +# "ndescs": 1, +# "descs": [ +# { "flags": ["write"], "len": 1536, "addr": 2027557376 } +# ] +# } +# } +# +## + +{ 'command': 'x-debug-virtio-queue-element', + 'data': { 'path': 'str', 'queue': 'uint16', '*index': 'uint16' }, + 'returns': 'VirtioQueueElement' +} --=20 1.8.3.1 From nobody Mon May 6 23:42:58 2024 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; arc=pass (i=1dmarc=pass fromdomain=oracle.com); dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1616085702; cv=pass; d=zohomail.com; s=zohoarc; b=J5aYMa3urbPWzk0pEMIw8FDHsjWXtc5XPUlZUTNkSBCKfjQIdjXpW2cEq7RJRag30sXvUxT7FBkv/zKthTs64uw8OHaEN/yTxBxiJEHTqIE8UDG0wMPm+TQvChP6D64OfyoKBswrWVPmWnzEtSh0nGnwbuzd/zewQ7LAuMc6uvQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616085702; h=Content-Type: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=FFg7qsgdrWPcUAjQkcqWSUbZr1E5r+/wQ+Hw4KRYrwY=; b=iZ90xhEWSocs/0tgc1uBhV4gtBB8UxwTxNB+UfO0laHgnrvkvb+qEmvPqLTeQLPX+TmIvcbmJ+Ex1G0ksRd5y0bsAHgINXmocpJSi94KsCm3FwBAad1jPTTDIzjaPLEBOenwph+Oq3F4tklt45IF1Qquf1Zre1a9xeFKlwXkL38= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=oracle.com); dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616085702712644.822560638505; Thu, 18 Mar 2021 09:41:42 -0700 (PDT) Received: from localhost ([::1]:36548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMviJ-0002sg-Mv for importer@patchew.org; Thu, 18 Mar 2021 12:41:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMvXx-00040z-0J; Thu, 18 Mar 2021 12:30:53 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:56650) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMvXo-0008Ar-LU; Thu, 18 Mar 2021 12:30:52 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12IGU773086324; Thu, 18 Mar 2021 16:30:27 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 378p1p0408-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Mar 2021 16:30:27 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12IGQnDE052002; Thu, 18 Mar 2021 16:30:26 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2175.outbound.protection.outlook.com [104.47.56.175]) by aserp3030.oracle.com with ESMTP id 3796ywdjea-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Mar 2021 16:30:25 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB4727.namprd10.prod.outlook.com (2603:10b6:510:3f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18; Thu, 18 Mar 2021 16:30:22 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::6819:aaf:9a92:c1db]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::6819:aaf:9a92:c1db%2]) with mapi id 15.20.3933.032; Thu, 18 Mar 2021 16:30:22 +0000 Received: from jonpalme-lnx.us.oracle.com (24.147.51.11) by SJ0PR05CA0079.namprd05.prod.outlook.com (2603:10b6:a03:332::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.10 via Frontend Transport; Thu, 18 Mar 2021 16:30:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=FFg7qsgdrWPcUAjQkcqWSUbZr1E5r+/wQ+Hw4KRYrwY=; b=G9uldt6eV1lN7ZVFEngbip9763i5VfJylgC4K5AsmlIDbwA4uob2RwintvEDAqJE2ri+ YZrGA7fx1vCyaW0MFFZUdyU6v6ytTm3r9PeoJCIY+AIWKnfeA9vxX1pPXBfUD2bOeMav IqxJQPzppFvFjRCGEQSYUzdsQhfbtCH/V6mc4EzHnalwtEtKm+kQnhJshV6fQntfZX98 677U8FSFKYxzXE4slQvyPNs1v2seoKtF2uGA9zvHyOKUwMcHMzio+xJGJeXIF1E592P0 iMIYbDRTCIIsYCFXSbEC2pG2Xk5CpOrxlZyETbUAd9Gl8+waUloNecMA+qcy0ax03xlX nA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I1qcjcu8kyKGa4b3Zfb4zdswFGKRrQomPChuNLaQfUdgzX7TmmD7nrNIh4oblP2gypibkFQHks/Cmkihv4LOKn4a+8ZmkH7lYVBg9m+gm/2Z+lUrud1z7hMmx2rOmUrlDmLLNz7IKycXqFPbLLsFVMpwFmCVo3ftanxAqx9qLF2zjlQwdMN+MV6lxGOZOSO1dl/dgFXmdD7zRWpPOXzcfsdMBb3qSlVOuQ/rL2sogApcC6gqAZO0nM2qMTB63kGX1xbGhHhEGv1S96m2rXBDAym15e9dPrX6RRfc5aBuxKAiBhOadn5iqGKdn3lQ90xs715TO0i1J8qdoemT+jk9Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FFg7qsgdrWPcUAjQkcqWSUbZr1E5r+/wQ+Hw4KRYrwY=; b=AAQhPkKQyMO2gKkuEK1psGQvjsqPVv4nDYt9AFphui4IUCIy7bMSLzQr5cchepMEuZ/bRT3dGjWG5LEnsoEjlvjNW4pzomUnZKAABzFgieS3yqXQqfqYzhgxXFdJcs+JiNqNtwEKHn56bFSNOVvsvrK2x7U5QinrAVpFSoiAZ8bZ+ZEAkHIu5LF4ZlA2gKDVV2dZdmZUC3QhFmz+kXjuOcjGq2V+/zAzASKdEbXQ3+zhOJgHjXvE63koq8Q896kWvm4TmQ8hzBE9wd2i475TiFXkWkZYl+M5h7fYzC51NzwteEBclTG7bNmglJeacSk8KY1Yw1eSHn0MijDARnuRsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FFg7qsgdrWPcUAjQkcqWSUbZr1E5r+/wQ+Hw4KRYrwY=; b=VS9V2vhMDpWA5E8SSJt8dn+eCOF+2KaWb8US75GcxWyOdBiyk8s6kKX3PqlbEJSFzNq0VOs4ho70ZMMv4DBuVaoFfCxBDTXsZIqZgkwaet6aWxQAEGfZdi5mwuAEAUszTMgRWL1xkYOeNfJyhimB6+8OCa7SVZHJbxR4ZD56540= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [RFC v5 6/6] hmp: add virtio commands Date: Thu, 18 Mar 2021 12:29:44 -0400 Message-Id: <1616084984-11263-7-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1616084984-11263-1-git-send-email-jonah.palmer@oracle.com> References: <1616084984-11263-1-git-send-email-jonah.palmer@oracle.com> X-Originating-IP: [24.147.51.11] X-ClientProxiedBy: SJ0PR05CA0079.namprd05.prod.outlook.com (2603:10b6:a03:332::24) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 88d9d17b-8a3c-495e-62b4-08d8ea2b20a7 X-MS-TrafficTypeDiagnostic: PH0PR10MB4727: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:312; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HPcZHlm8co7B0eF/kQHmcdwRojeiI+KTDM1JNcZjWlGsnSjpbJm6qFKLj1z42G3Jo6rPUxyx6j/FCsxlKWxXtKI16uPTTsFQUD2pMkvJpSvwfmihLLNj6mFiHNs5vPL4Lui/oDFMxovg3W2fViBhfANHPDbJH5Af8+of4W+WqDnnDAimxtWj5eFljBOv+XYdZddziGXFjqTYW5GYwDGKRAbZz8RR8eiWrFLprRAPK7EJp4zCoOwmSrc+ORSSrAsaqwcOARSBxP0/0YJLCVMX3pm4XqRVfcY+lNAzKbxM2NTYkEFwU8XgU3BbM2iYnV96hUva9v77RjxOKNGecwv1+THUNAR71vDZcNF45gPLH7KbIo4U+iohXo10INUNAydTxt9DM0WD2ebU6bf7DkWqbzbzBxVUNvMA99Lc/eDM5izW/WI5rf5DCbGLVxgv0B66OrJ9vMUg8/dTDOgvRe7rUGM7mJVoQ4nTaqV/Lc2aMJHqjL/KitFFS2fnBmcPySUtdPsHQQ483mGi7BeIiF0rWWFCY0e26aKpeJpOACY9Y7dgp8oK/Y6Mx1vjoWPwuSSNZCd6fATj9D7GXpZOz1uGbVBePby4vZNOWwx9N5CfYAhgvUU1J9b5cvIAb1gBRc1Q X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR10MB4664.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(346002)(366004)(39860400002)(136003)(396003)(2906002)(107886003)(36756003)(4326008)(7696005)(7416002)(5660300002)(186003)(316002)(38100700001)(66556008)(956004)(83380400001)(30864003)(52116002)(66946007)(8676002)(6666004)(478600001)(44832011)(6486002)(2616005)(26005)(86362001)(8936002)(66476007)(6916009)(16526019); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?D+2zzGgOpnE/5qPL8R09Nm5tiVhXEjg1VnM6HfAQH4DLFwZQhEsu8S0ZEMf8?= =?us-ascii?Q?gLEC25n/g66h9X0tx9jPqEvLZPPXzaAD2+QOqIXY2D9wiHUQrDYcCPcv1Oeq?= =?us-ascii?Q?pSv/y8I9P9spcEgvHkT59H2rWuJLmJ3KVVVafvy0hPw15l26/ty9oWUKLKmW?= =?us-ascii?Q?JW6IRAEfJF5eiot/6L4sKHVSSEu7sbIFSDQ9J37QKpl6ysWsoZI05tFlFo12?= =?us-ascii?Q?uwRvBkXWOOfS7uq1yUO0qhhf5/TjQQKLwJuuZ33FPD6d7XOR+lsRDmWNPCIu?= =?us-ascii?Q?NdnwtEmhJZgX2rIHK9z51O9ezppSypQxCmroKdI6oEYXd7Ty30jwzd8HZrFr?= =?us-ascii?Q?4Y0G6fqJuLxyKs28h5vOq9SGgrMdJXtzh1mO8aPazK7GzudwFY4s3+8divQo?= =?us-ascii?Q?AiIMPhAOyaBSTxxq8WUbrzZC2f04o9AGbzhyzSILIhZBgq4QzdFf+GyQX8MW?= =?us-ascii?Q?SAlW6awfu6vH46L5veVh1tVpabwMsYBmXFIeqcM2OflEHKqChr6fY8nRelhZ?= =?us-ascii?Q?Q3KyGtSz3dYHGEcZxnS5QOxGJ4mbb1t+S+7rdrUUkSbXu5fFC5EqwM7BL022?= =?us-ascii?Q?SdWfAYSe4YuOcqNyca8gkfmSCxpIcozo+Qm6BhUDFrU9sTWNCJd9Q61Rb37R?= =?us-ascii?Q?PW04geXiq/1er/Kvbg0ot0HrKsWpMwim5uRwXs2cG6NlzXi8P6C3NsrE0jAk?= =?us-ascii?Q?jbHlBCguicwng/BK+SnKAO5A4vR0iqKksDNUlgIXKXCdMRHJjIpa4ZJfccPT?= =?us-ascii?Q?SX8Ek4R5lhWj8oMaPFHmyFas9wmr+0/XjdjjzKaUc3uwlLqAEfH66YBlS/vd?= =?us-ascii?Q?WsvVthd45T9qFRE3cdfxIZfDp8glxuq54vsCofisR5KWc1Av7J8iGJpkBW15?= =?us-ascii?Q?m31UDA6W50a113n/nW8QWCIxFcdNPYHOpANS/TR1cMtuu8Hh7/fS2A0T+a3W?= =?us-ascii?Q?1N8dOdZLscx0hxVpz6K/QuLPgAtmDS3Ehs/H+BfFufn0t05ad2vzaCTCQRl/?= =?us-ascii?Q?xJXXyoC6ID9hSyLFuTtX1RftxX1P/6I2gypJZ8orTlk7abBwMOQxfMFHDSRE?= =?us-ascii?Q?XIHL1rS6AfPpV6peUGMP33oY4C4fWK94Ak6RbKLHRGtxnVnkKPSEH2oL8qaE?= =?us-ascii?Q?rDN/H2qWnoPemWtiYBviH1rVrDM1DiLqolEkuBN7lVwVc7Hwt6SZMiix+v19?= =?us-ascii?Q?+3SwajgUDo0635CTUKtKdrYBxk0uZsezwvOCXXhxKte6tgVtDBcKtH6B0ilC?= =?us-ascii?Q?Q+ocI+kuDTTkcpP9Cb8bd604RafRyLKv8+e73WIXqZaNeAOcCeFj/XRh0MiB?= =?us-ascii?Q?hwfLN2bVZJWsbxJLRqUpy05V?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88d9d17b-8a3c-495e-62b4-08d8ea2b20a7 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2021 16:30:22.6941 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rkcJJQHh/Zaso6jZJArdoanYa5U3HQynyFMWy9Y9GeK1R4L7FTCqQC4etXKE4WoKDCdD+BAmKAoLWSxJZxWqtQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9927 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103180115 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9927 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 suspectscore=0 adultscore=0 spamscore=0 clxscore=1015 phishscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103180116 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=156.151.31.85; envelope-from=jonah.palmer@oracle.com; helo=userp2120.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, marcandre.lureau@redhat.com, jonah.palmer@oracle.com, thuth@redhat.com, amit@kernel.org, michael.roth@amd.com, dgilbert@redhat.com, eric.auger@redhat.com, dmitrii.stepanov@cloud.ionos.com, stefanha@redhat.com, kwolf@redhat.com, laurent@vivier.eu, mreitz@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This patch implements HMP version of the virtio QMP commands [Jonah: Added relative indicies, device type, and used index in HMP virtio queue-status command.] Signed-off-by: Laurent Vivier Signed-off-by: Jonah Palmer --- docs/system/monitor.rst | 2 + hmp-commands-virtio.hx | 162 ++++++++++++++++++++++++++++++++++++++ hmp-commands.hx | 10 +++ hw/virtio/virtio.c | 204 ++++++++++++++++++++++++++++++++++++++++++++= +++- include/monitor/hmp.h | 4 + meson.build | 1 + monitor/misc.c | 17 ++++ 7 files changed, 399 insertions(+), 1 deletion(-) create mode 100644 hmp-commands-virtio.hx diff --git a/docs/system/monitor.rst b/docs/system/monitor.rst index ff5c434..10418fc 100644 --- a/docs/system/monitor.rst +++ b/docs/system/monitor.rst @@ -21,6 +21,8 @@ The following commands are available: =20 .. hxtool-doc:: hmp-commands.hx =20 +.. hxtool-doc:: hmp-commands-virtio.hx + .. hxtool-doc:: hmp-commands-info.hx =20 Integer expressions diff --git a/hmp-commands-virtio.hx b/hmp-commands-virtio.hx new file mode 100644 index 0000000..0ef01b9 --- /dev/null +++ b/hmp-commands-virtio.hx @@ -0,0 +1,162 @@ +HXCOMM Use DEFHEADING() to define headings in both help text and rST. +HXCOMM Text between SRST and ERST is copied to the rST version and +HXCOMM discarded from C version. +HXCOMM DEF(command, args, callback, arg_string, help) is used to construct +HXCOMM monitor info commands +HXCOMM HXCOMM can be used for comments, discarded from both rST and C. +HXCOMM +HXCOMM In this file, generally SRST fragments should have two extra +HXCOMM spaces of indent, so that the documentation list item for "virtio c= md" +HXCOMM appears inside the documentation list item for the top level +HXCOMM "virtio" documentation entry. The exception is the first SRST +HXCOMM fragment that defines that top level entry. + +SRST +``virtio`` *subcommand* + Show various information about virtio. + + Example: + + List all sub-commands:: + + (qemu) virtio + virtio query -- List all available virtio devices + virtio status path -- Display status of a given virtio device + virtio queue-status path queue -- Display status of a given virtio que= ue + virtio queue-element path queue [index] -- Display element of a given = virtio queue + +ERST + + { + .name =3D "query", + .args_type =3D "", + .params =3D "", + .help =3D "List all available virtio devices", + .cmd =3D hmp_virtio_query, + .flags =3D "p", + }, + +SRST + ``virtio query`` + List all available virtio devices + + Example: + + List all available virtio devices in the machine:: + + (qemu) virtio query + /machine/peripheral-anon/device[3]/virtio-backend [virtio-net] + /machine/peripheral-anon/device[1]/virtio-backend [virtio-serial] + /machine/peripheral-anon/device[0]/virtio-backend [virtio-blk] + +ERST + + { + .name =3D "status", + .args_type =3D "path:s", + .params =3D "path", + .help =3D "Display status of a given virtio device", + .cmd =3D hmp_virtio_status, + .flags =3D "p", + }, + +SRST + ``virtio status`` *path* + Display status of a given virtio device + + Example: + + Dump the status of the first virtio device:: + + (qemu) virtio status /machine/peripheral-anon/device[3]/virtio-backe= nd + /machine/peripheral-anon/device[3]/virtio-backend: + Device Id: 1 + Guest features: event-idx, indirect-desc, version-1 + ctrl-mac-addr, guest-announce, ctrl-vlan, ctrl-r= x, ctrl-vq, status, mrg-rxbuf, host-ufo, host-ecn, host-tso6, host-tso4, gu= est-ufo, guest-ecn, guest-tso6, guest-tso4, mac, ctrl-guest-offloads, guest= -csum, csum + Host features: event-idx, indirect-desc, bad-feature, version-1= , any-layout, notify-on-empty + gso, ctrl-mac-addr, guest-announce, ctrl-rx-extr= a, ctrl-vlan, ctrl-rx, ctrl-vq, status, mrg-rxbuf, host-ufo, host-ecn, host= -tso6, host-tso4, guest-ufo, guest-ecn, guest-tso6, guest-tso4, mac, ctrl-g= uest-offloads, guest-csum, csum + Backend features: + Endianness: little + VirtQueues: 3 + +ERST + + { + .name =3D "queue-status", + .args_type =3D "path:s,queue:i", + .params =3D "path queue", + .help =3D "Display status of a given virtio queue", + .cmd =3D hmp_virtio_queue_status, + .flags =3D "p", + }, + +SRST + ``virtio queue-status`` *path* *queue* + Display status of a given virtio queue + + Example: + + Dump the status of the first queue of the first virtio device:: + + (qemu) virtio queue-status /machine/peripheral-anon/device[3]/virtio= -backend 0 + /machine/peripheral-anon/device[3]/virtio-backend: + device_type: virtio-net + index: 0 + inuse: 0 + last_avail_idx: 61 (61 % 256) + shadow_avail_idx: 292 (36 % 256) + used_idx: 61 (61 % 256) + signalled_used: 61 (61 % 256) + signalled_used_valid: 1 + VRing: + num: 256 + num_default: 256 + align: 4096 + desc: 0x000000006c352000 + avail: 0x000000006c353000 + used: 0x000000006c353240 + +ERST + + { + .name =3D "queue-element", + .args_type =3D "path:s,queue:i,index:i?", + .params =3D "path queue [index]", + .help =3D "Display element of a given virtio queue", + .cmd =3D hmp_virtio_queue_element, + .flags =3D "p", + }, + +SRST + ``virtio queue-element`` *path* *queue* [*index*] + Display element of a given virtio queue + + Example: + + Dump the information of the head element of the first queue of + the first virtio device:: + + (qemu) virtio queue-element/machine/peripheral-anon/device[3]/virtio= -backend 0 + index: 67 + ndescs: 1 + descs: addr 0x6fe69800 len 1536 (write) + + (qemu) xp/128bx 0x6fe69800 + 000000006fe69800: 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00 + 000000006fe69808: 0x00 0x00 0x01 0x00 0x52 0x54 0x00 0x12 + 000000006fe69810: 0x34 0x56 0x52 0x54 0x00 0x09 0x51 0xde + 000000006fe69818: 0x08 0x00 0x45 0x00 0x00 0x4c 0x8f 0x32 + + device[3] is a virtio-net device and we can see in the element buffer = the + MAC address of the card:: + + [root@localhost ~]# ip link show ens4 + 2: ens4: mtu 1500 qdisc fq_codel s= tate UP m0 + link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff + + and the MAC address of the gateway:: + + [root@localhost ~]# arp -a + _gateway (192.168.122.1) at 52:54:00:09:51:de [ether] on ens4 + +ERST diff --git a/hmp-commands.hx b/hmp-commands.hx index d4001f9..19674bf 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1852,6 +1852,16 @@ SRST ERST =20 { + .name =3D "virtio", + .args_type =3D "name:S?", + .params =3D "[cmd]", + .help =3D "show various information about virtio", + .cmd =3D hmp_virtio_help, + .sub_table =3D hmp_virtio_cmds, + .flags =3D "p", + }, + + { .name =3D "info", .args_type =3D "item:s?", .params =3D "[subcommand]", diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 735a6ae..0836c6d 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -32,6 +32,9 @@ #include "sysemu/runstate.h" #include "standard-headers/linux/virtio_ids.h" #include CONFIG_DEVICES +#include "monitor/hmp.h" +#include "monitor/monitor.h" +#include "qapi/qmp/qdict.h" =20 static QTAILQ_HEAD(, VirtIODevice) virtio_list; =20 @@ -3903,6 +3906,32 @@ VirtioInfoList *qmp_x_debug_query_virtio(Error **err= p) return list; } =20 +void hmp_virtio_query(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + VirtioInfoList *list =3D qmp_x_debug_query_virtio(&err); + VirtioInfoList *node; + + if (err !=3D NULL) { + hmp_handle_error(mon, err); + return; + } + + if (list =3D=3D NULL) { + monitor_printf(mon, "No VirtIO devices\n"); + return; + } + + node =3D list; + while (node) { + monitor_printf(mon, "%s [%s]\n", node->value->path, + VirtioType_str(node->value->type)); + node =3D node->next; + } + + qapi_free_VirtioInfoList(list); +} + static VirtIODevice *virtio_device_find(const char *path) { VirtIODevice *vdev; @@ -3956,8 +3985,48 @@ VirtQueueStatus *qmp_x_debug_virtio_queue_status(con= st char *path, return status; } =20 +void hmp_virtio_queue_status(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + const char *path =3D qdict_get_try_str(qdict, "path"); + int queue =3D qdict_get_int(qdict, "queue"); + VirtQueueStatus *s =3D qmp_x_debug_virtio_queue_status(path, queue, &e= rr); + + if (err !=3D NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " device_type: %s\n", + VirtioType_str(s->device_type)); + monitor_printf(mon, " index: %d\n", s->queue_index); + monitor_printf(mon, " inuse: %d\n", s->inuse); + monitor_printf(mon, " last_avail_idx: %d (%"PRId64" %% %"PRId64= ")\n", + s->last_avail_idx, s->last_avail_idx % s->vring_num, + s->vring_num); + monitor_printf(mon, " shadow_avail_idx: %d (%"PRId64" %% %"PRId64= ")\n", + s->shadow_avail_idx, s->shadow_avail_idx % s->vring_num, + s->vring_num); + monitor_printf(mon, " used_idx: %d (%"PRId64" %% %"PRId64= ")\n", + s->used_idx, s->used_idx % s->vring_num, s->vring_num); + monitor_printf(mon, " signalled_used: %d (%"PRId64" %% %"PRId64= ")\n", + s->signalled_used, s->signalled_used % s->vring_num, + s->vring_num); + monitor_printf(mon, " signalled_used_valid: %d\n", s->signalled_used_= valid); + monitor_printf(mon, " VRing:\n"); + monitor_printf(mon, " num: %"PRId64"\n", s->vring_num); + monitor_printf(mon, " num_default: %"PRId64"\n", s->vring_num_defau= lt); + monitor_printf(mon, " align: %"PRId64"\n", s->vring_align); + monitor_printf(mon, " desc: 0x%016"PRIx64"\n", s->vring_desc= ); + monitor_printf(mon, " avail: 0x%016"PRIx64"\n", s->vring_avai= l); + monitor_printf(mon, " used: 0x%016"PRIx64"\n", s->vring_used= ); + + qapi_free_VirtQueueStatus(s); +} + #define CONVERT_FEATURES(type, map) \ - ({ \ + ({ \ type *list =3D NULL; \ type *node; \ for (i =3D 0; map[i].virtio_bit !=3D -1; i++) {\ @@ -4090,6 +4159,93 @@ VirtioStatus *qmp_x_debug_virtio_status(const char* = path, Error **errp) return status; } =20 +#define DUMP_FEATURES(type, field) = \ + do { = \ + type##FeatureList * list =3D features->u.field.features; = \ + if (list) { = \ + monitor_printf(mon, " "); = \ + while (list) { = \ + monitor_printf(mon, "%s", type##Feature_str(list->value));= \ + list =3D list->next; = \ + if (list !=3D NULL) { = \ + monitor_printf(mon, ", "); = \ + } = \ + } = \ + monitor_printf(mon, "\n"); = \ + } = \ + } while (0) + +static void hmp_virtio_dump_features(Monitor *mon, + VirtioDeviceFeatures *features) +{ + VirtioTransportFeatureList *transport_list =3D features->transport; + while (transport_list) { + monitor_printf(mon, "%s", + VirtioTransportFeature_str(transport_list->value)); + transport_list =3D transport_list->next; + if (transport_list !=3D NULL) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, "\n"); + switch (features->type) { + case VIRTIO_TYPE_VIRTIO_SERIAL: + DUMP_FEATURES(VirtioSerial, virtio_serial); + break; + case VIRTIO_TYPE_VIRTIO_BLK: + DUMP_FEATURES(VirtioBlk, virtio_blk); + break; + case VIRTIO_TYPE_VIRTIO_GPU: + DUMP_FEATURES(VirtioGpu, virtio_gpu); + break; + case VIRTIO_TYPE_VIRTIO_NET: + DUMP_FEATURES(VirtioNet, virtio_net); + break; + case VIRTIO_TYPE_VIRTIO_SCSI: + DUMP_FEATURES(VirtioScsi, virtio_scsi); + break; + case VIRTIO_TYPE_VIRTIO_BALLOON: + DUMP_FEATURES(VirtioBalloon, virtio_balloon); + break; + case VIRTIO_TYPE_VIRTIO_IOMMU: + DUMP_FEATURES(VirtioIommu, virtio_iommu); + break; + default: + g_assert_not_reached(); + } + if (features->has_unknown_features) { + monitor_printf(mon, " " + "unknown-features(0x%016"PRIx64")\n", + features->unknown_features); + } +} + +void hmp_virtio_status(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + const char *path =3D qdict_get_try_str(qdict, "path"); + VirtioStatus *s =3D qmp_x_debug_virtio_status(path, &err); + + if (err !=3D NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " Device Id: %"PRId64"\n", s->device_id); + monitor_printf(mon, " Guest features: "); + hmp_virtio_dump_features(mon, s->guest_features); + monitor_printf(mon, " Host features: "); + hmp_virtio_dump_features(mon, s->host_features); + monitor_printf(mon, " Backend features: "); + hmp_virtio_dump_features(mon, s->backend_features); + monitor_printf(mon, " Endianness: %s\n", + VirtioStatusEndianness_str(s->device_endian)); + monitor_printf(mon, " VirtQueues: %d\n", s->num_vqs); + + qapi_free_VirtioStatus(s); +} + static VirtioRingDescFlagsList *qmp_decode_vring_desc_flags(uint16_t flags) { VirtioRingDescFlagsList *list =3D NULL; @@ -4225,6 +4381,52 @@ done: return element; } =20 +void hmp_virtio_queue_element(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + const char *path =3D qdict_get_try_str(qdict, "path"); + int queue =3D qdict_get_int(qdict, "queue"); + int index =3D qdict_get_try_int(qdict, "index", -1); + VirtioQueueElement *element; + VirtioRingDescList *list; + + element =3D qmp_x_debug_virtio_queue_element(path, queue, index !=3D -= 1, + index, &err); + if (err !=3D NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "index: %d\n", element->index); + monitor_printf(mon, "ndescs: %d\n", element->ndescs); + monitor_printf(mon, "descs: "); + + list =3D element->descs; + while (list) { + monitor_printf(mon, "addr 0x%"PRIx64" len %d", list->value->addr, + list->value->len); + if (list->value->flags) { + VirtioRingDescFlagsList *flag =3D list->value->flags; + monitor_printf(mon, " ("); + while (flag) { + monitor_printf(mon, "%s", VirtioRingDescFlags_str(flag->va= lue)); + flag =3D flag->next; + if (flag) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, ")"); + } + list =3D list->next; + if (list) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, "\n"); + + qapi_free_VirtioQueueElement(element); +} + static const TypeInfo virtio_device_info =3D { .name =3D TYPE_VIRTIO_DEVICE, .parent =3D TYPE_DEVICE, diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index ed2913f..7a63744 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -98,6 +98,10 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict); void hmp_qom_get(Monitor *mon, const QDict *qdict); void hmp_qom_set(Monitor *mon, const QDict *qdict); void hmp_info_qom_tree(Monitor *mon, const QDict *dict); +void hmp_virtio_query(Monitor *mon, const QDict *qdict); +void hmp_virtio_status(Monitor *mon, const QDict *qdict); +void hmp_virtio_queue_status(Monitor *mon, const QDict *qdict); +void hmp_virtio_queue_element(Monitor *mon, const QDict *qdict); void object_add_completion(ReadLineState *rs, int nb_args, const char *str= ); void object_del_completion(ReadLineState *rs, int nb_args, const char *str= ); void device_add_completion(ReadLineState *rs, int nb_args, const char *str= ); diff --git a/meson.build b/meson.build index a923f24..2d836b9 100644 --- a/meson.build +++ b/meson.build @@ -1695,6 +1695,7 @@ if have_system hx_headers +=3D [ ['hmp-commands.hx', 'hmp-commands.h'], ['hmp-commands-info.hx', 'hmp-commands-info.h'], + ['hmp-commands-virtio.hx', 'hmp-commands-virtio.h'], ] endif foreach d : hx_headers diff --git a/monitor/misc.c b/monitor/misc.c index a7650ed..69542df 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -23,6 +23,7 @@ */ =20 #include "qemu/osdep.h" +#include CONFIG_DEVICES #include "monitor-internal.h" #include "cpu.h" #include "monitor/qdev.h" @@ -220,6 +221,15 @@ static void hmp_info_help(Monitor *mon, const QDict *q= dict) help_cmd(mon, "info"); } =20 +static void hmp_virtio_help(Monitor *mon, const QDict *qdict) +{ +#if defined(CONFIG_VIRTIO) + help_cmd(mon, "virtio"); +#else + monitor_printf(mon, "Virtio is disabled\n"); +#endif +} + static void monitor_init_qmp_commands(void) { /* @@ -1654,6 +1664,13 @@ static HMPCommand hmp_info_cmds[] =3D { { NULL, NULL, }, }; =20 +static HMPCommand hmp_virtio_cmds[] =3D { +#if defined(CONFIG_VIRTIO) +#include "hmp-commands-virtio.h" +#endif + { NULL, NULL, }, +}; + /* hmp_cmds and hmp_info_cmds would be sorted at runtime */ HMPCommand hmp_cmds[] =3D { #include "hmp-commands.h" --=20 1.8.3.1