From patchwork Wed Nov 10 10:23:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 1553348 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2021-07-09 header.b=fRtffDCk; dkim=pass (1024-bit key; unprotected) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-oracle-onmicrosoft-com header.b=FzNZpbCb; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hq1F90xLjz9sRK for ; Wed, 10 Nov 2021 21:24:59 +1100 (AEDT) Received: from localhost ([::1]:35444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mkkmm-0002LX-4H for incoming@patchwork.ozlabs.org; Wed, 10 Nov 2021 05:24:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkklw-0002L2-Np; Wed, 10 Nov 2021 05:24:05 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:11436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkkls-0005AO-Cq; Wed, 10 Nov 2021 05:24:03 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AA9SpV6032545; Wed, 10 Nov 2021 10:23:45 GMT 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-2021-07-09; bh=jmuPGQCzo0qO9/C4auRdEeatXS21mGscdelM8Ve5Ytg=; b=fRtffDCkHrjd2GCG7SCuAm8JdQC1iGK6FIpn2XQoS8eho2sS9KxIUKiYNikednygniKh 0is+UwwtTnuRCtE8a92S5COjSi4UMNOrAOBlBD6mMUEhvq2agVGFXFYLW2/lk7SyOWNQ 9OS4AtNUd5uj+CcFqFTGF2+gak3pxBXKBxXtYEvFsxyiylxsUEOWvy+NIm0pOLvCGHYo pMEdJCdMkWCbkTFWaVHwM9y9yvLP0P02sJzsY4zJo6D8x9pwAhGAQCh7pe+8sxXToLJd UakLvDzibf9KLyOsSVBg6hhTRjZlIAiJlsTz+dF5WnB1WIeI3euVPmPXXG4GNCUDEx8U bA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3c82vgap7f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Nov 2021 10:23:45 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AAAG1m6191438; Wed, 10 Nov 2021 10:23:44 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2169.outbound.protection.outlook.com [104.47.73.169]) by userp3030.oracle.com with ESMTP id 3c842c1j49-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Nov 2021 10:23:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EcQda4BIVowp/KJibbjNMyalFLwAYnazOgrylw2Rvhlrt3/ikwBZSg+ASI2z/iNWeCk2LGdu049b4gy4jGYskkuTsQYub3LY+mk1i1syqz30NuCSwY3UuznfAB5AUt44TPnzGpxJiJikQ1JyRfHqxKB5lNOEnOPzg/iKGGBrYYsmNLCfM4vFKawVySth6LwgM+Ext6xBjXqE9EE3t6lbf4QgKvixOoX/RPSi9nxJdUmG/t5rggx62jXYaKE5BP6reICyIbi6G43Xiwm9SekH/6JnSp8xt39FZAsP3U8nDe1KZ2nt8wxB1jelAer9UFqYzXVXXa8iCyW12yCHrq7fAw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jmuPGQCzo0qO9/C4auRdEeatXS21mGscdelM8Ve5Ytg=; b=mHn7ctlHUf5GW+HVEPcGoDxET/k69KZfuihYDMoD+TTp8vN2wY4IDVxvsa7OPQoUeyYls/3/xm5BR/TxG9eG90+8qYpISqE16JcjT+QASq/1fJFwsgoe8gzae3l7dNuvGiwO09l6jatn7BUQoLlhD8GCoWqrFMa8ioeJ9CcUkMHA7OjnbqyJvEYBKEUGTHOHVGZgzISsC3HcmtgzKdnS8LIR0qaR5/R8hcZM5gp5Zdgs+Tq4zEZPQCX2iv06S/SPfgVCu2SutoHsUUfrGrSu128CHG2yBhQJzMMgXj0aDVnf4Jm2Tc1hke5MO9O6RJn/CsFdrcFayC+stvLM3eObFg== 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=jmuPGQCzo0qO9/C4auRdEeatXS21mGscdelM8Ve5Ytg=; b=FzNZpbCbsPDm+9p7T3RMkDYzIOXQsNZbZOUz+Tr6pDbHsXSTn8YATTFRWzqPw2n+PpP0yuFGo2/oGWHt1p3x4VUBtN9G1rrTkF3ryc5WEGAG4QaS/OxODnA38f5lzU+c381FbTqUED24sE9/NrdAIIn+VR2gq02U65i9DWZ+0kg= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; 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.4669.13; Wed, 10 Nov 2021 10:23:41 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%5]) with mapi id 15.20.4669.016; Wed, 10 Nov 2021 10:23:41 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v9 1/8] virtio: drop name parameter for virtio_init() Date: Wed, 10 Nov 2021 05:23:05 -0500 Message-Id: <1636539792-20967-2-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1636539792-20967-1-git-send-email-jonah.palmer@oracle.com> References: <1636539792-20967-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SN4PR0501CA0112.namprd05.prod.outlook.com (2603:10b6:803:42::29) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 Received: from jonpalme-lnx.us.oracle.com (209.17.40.43) by SN4PR0501CA0112.namprd05.prod.outlook.com (2603:10b6:803:42::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.5 via Frontend Transport; Wed, 10 Nov 2021 10:23:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2cdac075-0d27-4b61-9c14-08d9a4342ac3 X-MS-TrafficTypeDiagnostic: PH0PR10MB4727: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1728; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hMhsquJAJxBj3IrrYADLbUw5qJnOBbWS94Je5/zi28F3wo8LegTwf+rK9eY19xyTrons4OgRMayD/YneYCp+mM992FLTTY5G9dX/yCajcJW6jklh9bGRfKsTT5jqcI+FTAmQVrBTf2wzq7SP8rlr4muNsxb3xrTzJZO+/Ve4LgKgPvau/Y6RLou4AtBvbpKt8DI4uxQyrzgY6LjDs+fgCVxzvAp+jsKJtpmS/TOZkvxRo8Phft0DkJsMxYq9l8/AxIBZnQB3qNSr/VjrrA6ILbbCVNaCLqiX4ZJZ4vRZU6/Rvn6DxsORtAaqNMah64lBejcgYVWjga6LmzYriavWx4uw0S7Rb845Js27s6v5kejq3dyMGy2Y2sTuna/GAMnTHJPCP/HfVDGoEe70+6fgIBpdePeJNf9wfm2x4vg/9Fk6U1Ecr7hGWeLPDK4E/6Al25tN6gMMhd3SeOFqDzbEFx5uT9EP05rAiN8yZoMJUBDD/8gm6Zt93GtdTBDkgQ+3PzCd8MpRp39pVX6NroxRPm2RqgzHkmb7JY33PV+BMBN+MRG+gQZ7TK1Qk4O3ZsPzvV64u+99xF5LENmCWvbHNQnH/R61rP9xKg/GFHtZIB44wC+FvU1vhYFsmmR8oNLF2MSWPPWn92kVPKwayoh2WqThnS7OkhTJ/3BluSXjdIcs329VMOp2iCUGCD/93jxfnxTODA2LKbVlsIQqIPbIDw== 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:(366004)(30864003)(36756003)(66556008)(8676002)(7416002)(6486002)(66476007)(26005)(5660300002)(66946007)(83380400001)(186003)(4326008)(44832011)(86362001)(7696005)(38100700002)(38350700002)(6916009)(52116002)(2906002)(508600001)(8936002)(956004)(6666004)(2616005)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 42oVVkKC7tX7QASSJA5zKyww2T3+QsfNEt8QOeRovuafjCFwyZAK3XqgE8GVQFFeQXrm8U/rZXiTzVVIBzecDq5AwJ2C//3wcPCoZd7jvDJupKKqx2NgDczL8HwvQWlZ0gL3jvP4GxA8jV7aTkTQijykcfARqf15gEXHmbCOWA52MYI7uAj89NM7SXOi+veMrDMJoZISS2VdJK1evb9cXI4Xfn7v/dRrMU5UnZEvWCHQRrHv/YImqDoECJZJhsb2Iy1V6hUme/5RY1QX4Jn8hi50F52T3kRNF498oO+to/alCLr32UoyvcZIa3egUeDt+xYGG3LP5smvHXgaNfEci2NiGvivGRkcOX3CcjlTgrtwx5TYlGPuPK0HayeSNZldyEUG6SOYewiSEvgCUTb5im/2RZTvOAui4SF+6YtF/7odxgdrALb/X38F+5TymoIQtUTsb5V8gE7HBpVLyxF19efCfgmxSNLRz1/VL1nHsQ8yBAmNinyzdjYpw9FrVzJv2KyV/7OVbc1+HaI0DNl8ECL6rgRckN+0+IsXyE+zhyRI06WD0j+bNpX9Ox5txb8Tlcn9VEc6xKuPrUsmp6JvvTnReLWP48J+wiabmlKT1CLqxSs+we0yaNpHoY2zaE/442P8+8c4Gd5WIGHTXZCoq3qUZ6HVcg0ZNvol474BkPvyI2r5SVx/zhoe8FYuruzDBfGdSlP/KulqBDB7bb6Q0Me7vyHUAulrtSmZapoS4xZ0Fa+WxWSKQDdOsO+g0Z5sD+dQz8UcmaFNaIciuwV0yJ5c5fX0YQsePk0kvDBzmv1YWHW0lX5mPFVFmxzBA9RWyl31YrF4OIcadSjoL/0017PBn1ogKsXo2hwmFuAujbosMNptV8FCCij0fs4jW05W3yW5wWVbq+UtpzjFTnHXbZY+kTd4kQgPqBtei2KEwvbGIXPksvbq4iSUX0Huz9dd3g1/jIACHxHdVGSc9YT5IoU+y9jWHT0MAqByDg/FDwZB0UFloYGmxMBjEl7letM9g8MZ+XaPF7oQyMSXBrmvhC0/nC7aLPxvhoR7MF7eO1bxovO/Is9937Mc3CuikAkl7irnACKysRp8iqN+UrImgWGMVELJFp896qPJnWSS0lWsXp5gNaOMyQ6/6d5R+A1NkXwijT47bVe2qaymnXpZnT0nYjceZ4QchxsrPh+tj0GwOxPu0YBlehxtWVHDdcxxCpGy7ditK+n315OfgRhuM2eRV8UXulfvYfwhphy36gl2ZOzc15LX2RtplgUwltK4Uu0IGMsmOJx+KBLmQ4L5oqdQDs+hZ1zSTyhFqWgUORYLZPuuywb5LrEHvmZJH3qMksl+91xvd7u+Rc6ACBGB0yDl5CfLe0WbjsfUm3KxDHf0RwMZ92DZ/k9LuiObq4k2/pDBb/OFulGMljBlI8mtVJEIK3E1VHATSJK6AmrMyuNqpBK8zC3EweeW6bUwz+scNvES8FFmzva0VvFz3BHrK/BZGsvuTgfbZfnQuN5VDnM2c9wEskLvdwkPFPowjqk/i7zuZhprBQ1Ogr911cRTJNsXJv1g/O0yM6QMvS1aFU9lPBdvSzksYi8pDH9rMuazgDvyI+HjrY+i8VFLFFtKU6RY6L/ymsvXlMBj8iR0QIs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2cdac075-0d27-4b61-9c14-08d9a4342ac3 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2021 10:23:41.3717 (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: AvXITyVAO4VLsl0ZdfDJwzVDqsK9WOtr1d/kAWleC5x/fktE2EZiKhDalL/Ngcd2RThVz43OUjOM1vqTQcvV6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10163 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111100056 X-Proofpoint-ORIG-GUID: FeL8yNDo4oWytgvsrbnEf9CVKJ5pCtCe X-Proofpoint-GUID: FeL8yNDo4oWytgvsrbnEf9CVKJ5pCtCe Received-SPF: pass client-ip=205.220.177.32; envelope-from=jonah.palmer@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch drops the name parameter for the virtio_init function. The pair between the numeric device ID and the string device ID (name) of a virtio device already exists, but not in a way that lets us map between them. This patch will let us do this and removes the need for the name parameter in virtio_init(). Signed-off-by: Jonah Palmer --- hw/9pfs/virtio-9p-device.c | 2 +- hw/block/vhost-user-blk.c | 2 +- hw/block/virtio-blk.c | 2 +- hw/char/virtio-serial-bus.c | 4 +-- hw/display/virtio-gpu-base.c | 2 +- hw/input/virtio-input.c | 3 +- hw/net/virtio-net.c | 2 +- hw/scsi/virtio-scsi.c | 3 +- hw/virtio/vhost-user-fs.c | 3 +- hw/virtio/vhost-user-i2c.c | 6 +--- hw/virtio/vhost-user-rng.c | 2 +- hw/virtio/vhost-user-vsock.c | 2 +- hw/virtio/vhost-vsock-common.c | 4 +-- hw/virtio/vhost-vsock.c | 2 +- hw/virtio/virtio-balloon.c | 3 +- hw/virtio/virtio-crypto.c | 2 +- hw/virtio/virtio-iommu.c | 3 +- hw/virtio/virtio-mem.c | 3 +- hw/virtio/virtio-pmem.c | 3 +- hw/virtio/virtio-rng.c | 2 +- hw/virtio/virtio.c | 45 +++++++++++++++++++++++++++-- include/hw/virtio/vhost-vsock-common.h | 2 +- include/hw/virtio/virtio-gpu.h | 3 +- include/hw/virtio/virtio.h | 3 +- include/standard-headers/linux/virtio_ids.h | 1 + 25 files changed, 68 insertions(+), 41 deletions(-) diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index 54ee93b..5f522e6 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -216,7 +216,7 @@ static void virtio_9p_device_realize(DeviceState *dev, Error **errp) } v->config_size = sizeof(struct virtio_9p_config) + strlen(s->fsconf.tag); - virtio_init(vdev, "virtio-9p", VIRTIO_ID_9P, v->config_size); + virtio_init(vdev, VIRTIO_ID_9P, v->config_size); v->vq = virtio_add_queue(vdev, MAX_REQ, handle_9p_output); } diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index ba13cb8..f61f8c1 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -490,7 +490,7 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp) return; } - virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, + virtio_init(vdev, VIRTIO_ID_BLOCK, sizeof(struct virtio_blk_config)); s->virtqs = g_new(VirtQueue *, s->num_queues); diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index f139cd7..505e574 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1213,7 +1213,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp) virtio_blk_set_config_size(s, s->host_features); - virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, s->config_size); + virtio_init(vdev, VIRTIO_ID_BLOCK, s->config_size); s->blk = conf->conf.blk; s->rq = NULL; diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index f01ec21..232f4c9 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -1044,8 +1044,8 @@ static void virtio_serial_device_realize(DeviceState *dev, Error **errp) VIRTIO_CONSOLE_F_EMERG_WRITE)) { config_size = offsetof(struct virtio_console_config, emerg_wr); } - virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE, - config_size); + + virtio_init(vdev, VIRTIO_ID_CONSOLE, config_size); /* Spawn a new virtio-serial bus on which the ports will ride as devices */ qbus_init(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS, diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index c8da480..5411a7b 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -170,7 +170,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev, } g->virtio_config.num_scanouts = cpu_to_le32(g->conf.max_outputs); - virtio_init(VIRTIO_DEVICE(g), "virtio-gpu", VIRTIO_ID_GPU, + virtio_init(VIRTIO_DEVICE(g), VIRTIO_ID_GPU, sizeof(struct virtio_gpu_config)); if (virtio_gpu_virgl_enabled(g->conf)) { diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c index 54bcb46..5b5398b 100644 --- a/hw/input/virtio-input.c +++ b/hw/input/virtio-input.c @@ -257,8 +257,7 @@ static void virtio_input_device_realize(DeviceState *dev, Error **errp) vinput->cfg_size += 8; assert(vinput->cfg_size <= sizeof(virtio_input_config)); - virtio_init(vdev, "virtio-input", VIRTIO_ID_INPUT, - vinput->cfg_size); + virtio_init(vdev, VIRTIO_ID_INPUT, vinput->cfg_size); vinput->evt = virtio_add_queue(vdev, 64, virtio_input_handle_evt); vinput->sts = virtio_add_queue(vdev, 64, virtio_input_handle_sts); } diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index f2014d5..b275acf 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3383,7 +3383,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) } virtio_net_set_config_size(n, n->host_features); - virtio_init(vdev, "virtio-net", VIRTIO_ID_NET, n->config_size); + virtio_init(vdev, VIRTIO_ID_NET, n->config_size); /* * We set a lower limit on RX queue size to what it always was. diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 51fd095..ce71939 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -972,8 +972,7 @@ void virtio_scsi_common_realize(DeviceState *dev, VirtIOSCSICommon *s = VIRTIO_SCSI_COMMON(dev); int i; - virtio_init(vdev, "virtio-scsi", VIRTIO_ID_SCSI, - sizeof(VirtIOSCSIConfig)); + virtio_init(vdev, VIRTIO_ID_SCSI, sizeof(VirtIOSCSIConfig)); if (s->conf.num_queues == VIRTIO_SCSI_AUTO_NUM_QUEUES) { s->conf.num_queues = 1; diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index c595957..b875640 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -219,8 +219,7 @@ static void vuf_device_realize(DeviceState *dev, Error **errp) return; } - virtio_init(vdev, "vhost-user-fs", VIRTIO_ID_FS, - sizeof(struct virtio_fs_config)); + virtio_init(vdev, VIRTIO_ID_FS, sizeof(struct virtio_fs_config)); /* Hiprio queue */ fs->hiprio_vq = virtio_add_queue(vdev, fs->conf.queue_size, vuf_handle_output); diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c index d172632..efc6fc0 100644 --- a/hw/virtio/vhost-user-i2c.c +++ b/hw/virtio/vhost-user-i2c.c @@ -14,10 +14,6 @@ #include "qemu/error-report.h" #include "standard-headers/linux/virtio_ids.h" -/* Remove this once the header is updated in Linux kernel */ -#ifndef VIRTIO_ID_I2C_ADAPTER -#define VIRTIO_ID_I2C_ADAPTER 34 -#endif static void vu_i2c_start(VirtIODevice *vdev) { @@ -220,7 +216,7 @@ static void vu_i2c_device_realize(DeviceState *dev, Error **errp) return; } - virtio_init(vdev, "vhost-user-i2c", VIRTIO_ID_I2C_ADAPTER, 0); + virtio_init(vdev, VIRTIO_ID_I2C_ADAPTER, 0); i2c->vhost_dev.nvqs = 1; i2c->vq = virtio_add_queue(vdev, 4, vu_i2c_handle_output); diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index 209ee5b..08bccba 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -203,7 +203,7 @@ static void vu_rng_device_realize(DeviceState *dev, Error **errp) return; } - virtio_init(vdev, "vhost-user-rng", VIRTIO_ID_RNG, 0); + virtio_init(vdev, VIRTIO_ID_RNG, 0); rng->req_vq = virtio_add_queue(vdev, 4, vu_rng_handle_output); if (!rng->req_vq) { diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 52bd682..0f8ff99 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -107,7 +107,7 @@ static void vuv_device_realize(DeviceState *dev, Error **errp) return; } - vhost_vsock_common_realize(vdev, "vhost-user-vsock"); + vhost_vsock_common_realize(vdev); vhost_dev_set_config_notifier(&vvc->vhost_dev, &vsock_ops); diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 3f37712..e8f6249 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -220,11 +220,11 @@ int vhost_vsock_common_post_load(void *opaque, int version_id) return 0; } -void vhost_vsock_common_realize(VirtIODevice *vdev, const char *name) +void vhost_vsock_common_realize(VirtIODevice *vdev) { VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); - virtio_init(vdev, name, VIRTIO_ID_VSOCK, + virtio_init(vdev, VIRTIO_ID_VSOCK, sizeof(struct virtio_vsock_config)); /* Receive and transmit queues belong to vhost */ diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 478c0c9..3d4ede9 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -166,7 +166,7 @@ static void vhost_vsock_device_realize(DeviceState *dev, Error **errp) qemu_set_nonblock(vhostfd); } - vhost_vsock_common_realize(vdev, "vhost-vsock"); + vhost_vsock_common_realize(vdev); ret = vhost_dev_init(&vvc->vhost_dev, (void *)(uintptr_t)vhostfd, VHOST_BACKEND_TYPE_KERNEL, 0, errp); diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index c6962fc..641a394 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -885,8 +885,7 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp) VirtIOBalloon *s = VIRTIO_BALLOON(dev); int ret; - virtio_init(vdev, "virtio-balloon", VIRTIO_ID_BALLOON, - virtio_balloon_config_size(s)); + virtio_init(vdev, VIRTIO_ID_BALLOON, virtio_balloon_config_size(s)); ret = qemu_add_balloon_handler(virtio_balloon_to_target, virtio_balloon_stat, s); diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 54f9bbb..cca5237 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -810,7 +810,7 @@ static void virtio_crypto_device_realize(DeviceState *dev, Error **errp) return; } - virtio_init(vdev, "virtio-crypto", VIRTIO_ID_CRYPTO, vcrypto->config_size); + virtio_init(vdev, VIRTIO_ID_CRYPTO, vcrypto->config_size); vcrypto->curr_queues = 1; vcrypto->vqs = g_malloc0(sizeof(VirtIOCryptoQueue) * vcrypto->max_queues); for (i = 0; i < vcrypto->max_queues; i++) { diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 1b23e8e..92c5eb7 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -973,8 +973,7 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtIOIOMMU *s = VIRTIO_IOMMU(dev); - virtio_init(vdev, "virtio-iommu", VIRTIO_ID_IOMMU, - sizeof(struct virtio_iommu_config)); + virtio_init(vdev, VIRTIO_ID_IOMMU, sizeof(struct virtio_iommu_config)); memset(s->iommu_pcibus_by_bus_num, 0, sizeof(s->iommu_pcibus_by_bus_num)); diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index d5a5781..e217520 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -769,8 +769,7 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp) vmem->block_size; vmem->bitmap = bitmap_new(vmem->bitmap_size); - virtio_init(vdev, TYPE_VIRTIO_MEM, VIRTIO_ID_MEM, - sizeof(struct virtio_mem_config)); + virtio_init(vdev, VIRTIO_ID_MEM, sizeof(struct virtio_mem_config)); vmem->vq = virtio_add_queue(vdev, 128, virtio_mem_handle_request); host_memory_backend_set_mapped(vmem->memdev, true); diff --git a/hw/virtio/virtio-pmem.c b/hw/virtio/virtio-pmem.c index d1aeb90..8cbbd78 100644 --- a/hw/virtio/virtio-pmem.c +++ b/hw/virtio/virtio-pmem.c @@ -123,8 +123,7 @@ static void virtio_pmem_realize(DeviceState *dev, Error **errp) } host_memory_backend_set_mapped(pmem->memdev, true); - virtio_init(vdev, TYPE_VIRTIO_PMEM, VIRTIO_ID_PMEM, - sizeof(struct virtio_pmem_config)); + virtio_init(vdev, VIRTIO_ID_PMEM, sizeof(struct virtio_pmem_config)); pmem->rq_vq = virtio_add_queue(vdev, 128, virtio_pmem_flush); } diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c index cc8e9f7..7e12fc0 100644 --- a/hw/virtio/virtio-rng.c +++ b/hw/virtio/virtio-rng.c @@ -215,7 +215,7 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp) return; } - virtio_init(vdev, "virtio-rng", VIRTIO_ID_RNG, 0); + virtio_init(vdev, VIRTIO_ID_RNG, 0); vrng->vq = virtio_add_queue(vdev, 8, handle_input); vrng->quota_remaining = vrng->conf.max_bytes; diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index cc69a9b..be98b4d 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -133,6 +133,45 @@ struct VirtQueue QLIST_ENTRY(VirtQueue) node; }; +const char *virtio_device_names[] = { + [VIRTIO_ID_NET] = "virtio-net", + [VIRTIO_ID_BLOCK] = "virtio-blk", + [VIRTIO_ID_CONSOLE] = "virtio-serial", + [VIRTIO_ID_RNG] = "virtio-rng", + [VIRTIO_ID_BALLOON] = "virtio-balloon", + [VIRTIO_ID_IOMEM] = "virtio-iomem", + [VIRTIO_ID_RPMSG] = "virtio-rpmsg", + [VIRTIO_ID_SCSI] = "virtio-scsi", + [VIRTIO_ID_9P] = "virtio-9p", + [VIRTIO_ID_MAC80211_WLAN] = "virtio-mac-wlan", + [VIRTIO_ID_RPROC_SERIAL] = "virtio-rproc-serial", + [VIRTIO_ID_CAIF] = "virtio-caif", + [VIRTIO_ID_MEMORY_BALLOON] = "virtio-mem-balloon", + [VIRTIO_ID_GPU] = "virtio-gpu", + [VIRTIO_ID_CLOCK] = "virtio-clk", + [VIRTIO_ID_INPUT] = "virtio-input", + [VIRTIO_ID_VSOCK] = "vhost-vsock", + [VIRTIO_ID_CRYPTO] = "virtio-crypto", + [VIRTIO_ID_SIGNAL_DIST] = "virtio-signal", + [VIRTIO_ID_PSTORE] = "virtio-pstore", + [VIRTIO_ID_IOMMU] = "virtio-iommu", + [VIRTIO_ID_MEM] = "virtio-mem", + [VIRTIO_ID_SOUND] = "virtio-sound", + [VIRTIO_ID_FS] = "vhost-user-fs", + [VIRTIO_ID_PMEM] = "virtio-pmem", + [VIRTIO_ID_MAC80211_HWSIM] = "virtio-mac-hwsim", + [VIRTIO_ID_I2C_ADAPTER] = "vhost-user-i2c", + [VIRTIO_ID_BT] = "virtio-bluetooth" +}; + +static const char *virtio_id_to_name(uint16_t device_id) +{ + assert(device_id < G_N_ELEMENTS(virtio_device_names)); + const char *name = virtio_device_names[device_id]; + assert(name != NULL); + return name; +} + /* Called within call_rcu(). */ static void virtio_free_region_cache(VRingMemoryRegionCaches *caches) { @@ -3235,8 +3274,8 @@ void virtio_instance_init_common(Object *proxy_obj, void *data, qdev_alias_all_properties(vdev, proxy_obj); } -void virtio_init(VirtIODevice *vdev, const char *name, - uint16_t device_id, size_t config_size) +void virtio_init(VirtIODevice *vdev, uint16_t device_id, + size_t config_size) { BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); @@ -3265,7 +3304,7 @@ void virtio_init(VirtIODevice *vdev, const char *name, vdev->vq[i].host_notifier_enabled = false; } - vdev->name = name; + vdev->name = virtio_id_to_name(device_id); vdev->config_len = config_size; if (vdev->config_len) { vdev->config = g_malloc0(config_size); diff --git a/include/hw/virtio/vhost-vsock-common.h b/include/hw/virtio/vhost-vsock-common.h index d8b565b..076b7ab 100644 --- a/include/hw/virtio/vhost-vsock-common.h +++ b/include/hw/virtio/vhost-vsock-common.h @@ -44,7 +44,7 @@ int vhost_vsock_common_start(VirtIODevice *vdev); void vhost_vsock_common_stop(VirtIODevice *vdev); int vhost_vsock_common_pre_save(void *opaque); int vhost_vsock_common_post_load(void *opaque, int version_id); -void vhost_vsock_common_realize(VirtIODevice *vdev, const char *name); +void vhost_vsock_common_realize(VirtIODevice *vdev); void vhost_vsock_common_unrealize(VirtIODevice *vdev); uint64_t vhost_vsock_common_get_features(VirtIODevice *vdev, uint64_t features, Error **errp); diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index acfba7c..ac487d2 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -22,6 +22,7 @@ #include "sysemu/vhost-user-backend.h" #include "standard-headers/linux/virtio_gpu.h" +#include "standard-headers/linux/virtio_ids.h" #include "qom/object.h" #define TYPE_VIRTIO_GPU_BASE "virtio-gpu-base" @@ -37,8 +38,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUGL, VIRTIO_GPU_GL) #define TYPE_VHOST_USER_GPU "vhost-user-gpu" OBJECT_DECLARE_SIMPLE_TYPE(VhostUserGPU, VHOST_USER_GPU) -#define VIRTIO_ID_GPU 16 - struct virtio_gpu_simple_resource { uint32_t resource_id; uint32_t width; diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 8bab9cf..bfc73ec 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -165,8 +165,7 @@ struct VirtioDeviceClass { void virtio_instance_init_common(Object *proxy_obj, void *data, size_t vdev_size, const char *vdev_name); -void virtio_init(VirtIODevice *vdev, const char *name, - uint16_t device_id, size_t config_size); +void virtio_init(VirtIODevice *vdev, uint16_t device_id, size_t config_size); void virtio_cleanup(VirtIODevice *vdev); void virtio_error(VirtIODevice *vdev, const char *fmt, ...) GCC_FMT_ATTR(2, 3); diff --git a/include/standard-headers/linux/virtio_ids.h b/include/standard-headers/linux/virtio_ids.h index 4fe842c..3957d11 100644 --- a/include/standard-headers/linux/virtio_ids.h +++ b/include/standard-headers/linux/virtio_ids.h @@ -55,6 +55,7 @@ #define VIRTIO_ID_FS 26 /* virtio filesystem */ #define VIRTIO_ID_PMEM 27 /* virtio pmem */ #define VIRTIO_ID_MAC80211_HWSIM 29 /* virtio mac80211-hwsim */ +#define VIRTIO_ID_I2C_ADAPTER 34 /* virtio I2C adapater */ #define VIRTIO_ID_BT 40 /* virtio bluetooth */ #endif /* _LINUX_VIRTIO_IDS_H */ From patchwork Wed Nov 10 10:23:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 1553352 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2021-07-09 header.b=WvR6zT7L; dkim=pass (1024-bit key; unprotected) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-oracle-onmicrosoft-com header.b=yO0w1FRR; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hq1LG0xkqz9sCD for ; Wed, 10 Nov 2021 21:29:26 +1100 (AEDT) Received: from localhost ([::1]:43982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mkkr5-0008BX-Us for incoming@patchwork.ozlabs.org; Wed, 10 Nov 2021 05:29:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkkm3-0002Pg-5H; Wed, 10 Nov 2021 05:24:11 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:25124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkkly-0005Ba-Jl; Wed, 10 Nov 2021 05:24:09 -0500 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AA9TZoV023556; Wed, 10 Nov 2021 10:23:48 GMT 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-2021-07-09; bh=EDyhOHnSSI0eU3CG7KUElf1bCePkvnpBTxbzpPGgmUY=; b=WvR6zT7Lo05QTO/QW4PCb3/FjipHFFn9w76cxgF8F3VSxar6hswTZkkWcLFv1zDR1dEA EyV3GSmqf3YTysEUpeYAs03pNGXKHOY0e2vFM0WlImjfEJ1pZ2xhwXHJSi/LPGQ0mhj4 Vxbg6sRl/sLtkuPHOm7f67Bej1mhh8eqQ9PiwfFx3lejj6RMqNboG6Y/8cLnPwSvLVBG CIlH/b0fWFQqWUBKQ0GzWDbMoKVh1PchWf1etk4eejm2nFZ/2LH1lmP2bNVYFpyy0qet wpXfjb3rHJ8nNyETtU+AMpFV0mcDUF0qwyQJhR3KylOgvbxFL0WehYlcwxrE9WSLbCwk Fw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3c7yq7bubd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Nov 2021 10:23:48 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AAAH1fF156494; Wed, 10 Nov 2021 10:23:46 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2176.outbound.protection.outlook.com [104.47.73.176]) by userp3020.oracle.com with ESMTP id 3c63fuebu2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Nov 2021 10:23:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e/EyUxmfK9B5WrpSPQcUfk0sYQf232Ag6T/o2fE71QHZTLw98XCvwyC0jGsAkQG5bIT8tjs8AxJFg5KQRaGnpxWxiK/ORXxj+I2/XDW+Dfb5oKgL3XcgS7ER9UMGizX0zunxCd2ukc/A0zbvaVm/dEXdOReLjHwaTEvWPPueYJ2CDpZ3GR0M2hh1vfFHgUz2bCZlrIOCVQSCAzs5NmWepEfdOdlb6MeEzQsnn578X4nAclxE/LnZv396/jswmFL1g8ijgtdIA83XJNmEuR/opcFrfCam/ogMreCT+sJmVOMe3U6QlNkj7Xt3ljEOBaCUbyRftavZDTzXjRLuHzp/oQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EDyhOHnSSI0eU3CG7KUElf1bCePkvnpBTxbzpPGgmUY=; b=bqQ5xKXX2I2Ade52Z/UyxJU/qHdJJ3yQn436BeIoGNa0m2HE1AyeeblBPrwb2prA2nZ80s3D2X1LvS/b8uMP/TMfnym3c/eqKgvQd6Wmpxtb2c9/9Pe1axqiqHzI9Y/yE5Y8H48tJiEhrate2bNgvg/OMi/ij93KSfoFWh4VPrAGgYOIThqkKntBxyx/aAFlwl6jtJRCgyhAj09fSPY98c4Nd1wWJTo5E7TtMPrRpdTBfuVqswgN5+DaAiGrXh5bR/+mnxEswqGwtc31v63dr5qTckbzgmxvax3Ge7nBTmO44PYN4L0PAuVNkGj4Xla1sX/HQJq7HUabn0Kl0R9MpQ== 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=EDyhOHnSSI0eU3CG7KUElf1bCePkvnpBTxbzpPGgmUY=; b=yO0w1FRRmCRyxKmKTCN0s57EHTK8D8mL7oPw3fhNGCBFFXPPNTeJG5hl+7hOMSUHVSdWFJO6hIiRhgs1k1i9cWMgbFG9WJjaEirp8acgzakqtRs9eKw192j1oTlZw7jGav33Kyqr9bDsUn7AS8hF/B9gVVarN2gCUWp7G6xsHkE= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; 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.4669.13; Wed, 10 Nov 2021 10:23:44 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%5]) with mapi id 15.20.4669.016; Wed, 10 Nov 2021 10:23:43 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v9 2/8] virtio: add vhost support for virtio devices Date: Wed, 10 Nov 2021 05:23:06 -0500 Message-Id: <1636539792-20967-3-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1636539792-20967-1-git-send-email-jonah.palmer@oracle.com> References: <1636539792-20967-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SN4PR0501CA0112.namprd05.prod.outlook.com (2603:10b6:803:42::29) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 Received: from jonpalme-lnx.us.oracle.com (209.17.40.43) by SN4PR0501CA0112.namprd05.prod.outlook.com (2603:10b6:803:42::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.5 via Frontend Transport; Wed, 10 Nov 2021 10:23:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b0a65d82-f6a5-4b36-1140-08d9a4342c3c X-MS-TrafficTypeDiagnostic: PH0PR10MB4727: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1122; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BAN0flc+JuR422WoGmwwQvUHlIg5XMwCgt17EYSpUyHcFFLIgb1bGrGjilxCF71QnW5PCDGhgqWDRwvgAb1nuf0WMxAN3wtKN67DG2TKCOFOKg5Y906P/UjP7epMAD+9LuWWtqe575wp4t1dN4ajjxy67CaOOMAT/yMqM1YgET8k5Wlrt9WT0tRAkR6SUKY6nXe1QUYjzVptBDv0QBs4gNEseGtiLzlf8nk+u5BYCBI5RyMKmkRlnTMcTTP44ozV1fKFXK4pr0A1vQ+eXZcOnNB2BdedP1YAJesiFN54GREZ25lAbFRJFQRuGwzURs9/dPT8/5feNANTPbihj6gu1BWMbR/LqTN24BExGviVzKMBXe1nqq6TF2P8MhLTPCqCWD7Vq8R8WjEPIFT+fhomksWqc2jkjDijewJbl20Ui7AoIEZTVkTWg41cr7/MVBrfeJkJRCrVKGLguw6toraLAYLjAbeeI0xgUTPsmK7s43+4FFlnJfUf/f5c2r/djhepPPzmPRWk1Hs0tOgPJrFyYpqGbvXBIkii9FGXnTGMJt++HrW/XPm3PeAf4Ppf0EWp+V3X8GbJBOjApesIQhz6oxYSL1T+v0MZulQCyZQz7OooHMHN5SLoAr+cEooFpEQBFcGQznbLa012jvLsDK20oVDcdsQbWO7wQKeK/ln1+xL4tym9IPJ2T5i0nGcW78CzDRgk1GfOLz0+pXLjgaSC5A== 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:(366004)(30864003)(36756003)(66556008)(8676002)(7416002)(6486002)(66476007)(26005)(5660300002)(66946007)(83380400001)(186003)(4326008)(44832011)(86362001)(7696005)(38100700002)(38350700002)(6916009)(52116002)(2906002)(508600001)(8936002)(956004)(6666004)(2616005)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9qPI6jYgxAyi8KEtKOAcouoWHTMiVYI4in31QahQc+3gvloA43/iyb+ySxnbu63w/D6nMGF3xndva10ipa/gEHZECgCGTNpeJDsGM+EFv8jwEOP+a+brlLOO3ergSCfe50wxCQFG3H4t/4YHD81EuG3dZCgPMT+tykz6RI9aUR5PpKl1g9L5UrkOyeksVon4U5bRsjRwanPTBN6NcYmXhZ9gnxOAM59EZ9JHn76Apk2wCjWZXPJQfdZo9FLZabaxdEzHVumN21cNxyE+jq6s2n68wZE2XvZW3RyaSGt8CUJt5XlnUuNN0aTxUvSeAUkqYzcg1YtiKJhg4gUz9fUSw8Bfa0AMZYz6qRW319GnI2ga2TzO97RIFKgAbQ9IzrkDX238KPhLSAL105H7GqbA3n2EBRRPnli4zO3/vo7T2jh10+XvIzUU/ibNnclj0MgJCVpoqho+Rt0GTLuH44fRE5i89O7JmS8VzjIoqQ0ChewIbygLqyGmY4NqXtCm5in1OGqzA0JSTBpmrM6zC2tDE82iA59duNIo2qLhIzqLvRRLZipCJbZG61YVL1J1pVfOGK/q9GzcSnuFXQWsMe80trZGgDghFaFS+oDIQVOzeZVGlETj1um4KwkyHoE1Q1R7BkbnS4lOdOoTaUJEE0sstVyNIEeIOOeCb3dk7Dc4xFYvHdLXQCIhoZDhcIKQDub6eI2l8Sq0dVoExWe6swEujbLJFS9bjbYThXve6FkqyFwi2tyPEVZJALFClhgBfikqElIR5NhfP4bx3Kwc3bO190WEyHRi+Vv1Uuwjf6qbb9NH/npOVaRXSdLvo5pchQ30Cefk+hT8CG7TmEmlb319L8TRPa9qfJPa1IHpOeZAZk4EFB7B8U504lonJqMAtMJVayPQcRwhHkPEe7MSHhX//GcteaH1nDBwNU+WJDR2HzNwLbJAvyuSnwOxwC/chcUQ2OGLRxkLXg7ZzFy8M1uzk+ZgcFYJFnvn1acHxQt5tuX9+4Obi2DIDUG99VN6SN0MifPc1BgbCB+ZceGCPE4ZWr9pdboamhakyYQ06sEz+pDrUMa2hlLIGm39tmNLXjKeUKH51EtteydL8dbmRPSXe/xdqAvD5V664mH84fj/N0CrUks3DdiLwQDcnNBep8mfcQ8jZg29JWm/UAu0b/r/Mn1/uj/evwbiRSIV7J0aj4PM0loayI/78JGVs5c4drxsm87SpOHbyS2KdhabOMt+C1hzr3733oYOD3lHLOGzm/fI/JYkAQJAEmW/6bGyBo2MgZVfjm0tsTujA4rkUI8rFRBOuhwoRuv8mf7WNzJoI+kVESDkkusZO3Bau1eGj/zCvzvi5CQntjfcdhuZKF29UrhvAG5XI5ZSo8n1umTkz3LjZlcB8Zub0WEvzZyBAe+kI3/HNJDzEaWimvrJAxcc58EydVSD+O9nvEYYQGTloqctCP+Sr2L2AGIR3P0ziLhMaWskcWZeiUSgaMTg1nCYX3GlMixqLsb9n+4MJ3tRAQOJDsCWthtoNkB7qk6MGVP1OTjwVm/1XOmLQl7qv+W9O301V8PZ9kjU6k2dWF6O9NdhByEQ/YI4mmy0SxXKw0gn1e8pgPN8+R1d1kLXslOOzrQkgj+f/mShWGMxqW/duRU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0a65d82-f6a5-4b36-1140-08d9a4342c3c X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2021 10:23:43.8488 (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: yvUmlPkQSN6tqmJ8OzvN0ea/9KVHH7ANmuAIE1yVOz6YMFkb2/OwyW3ANk57A0C49MnBAi1hoGN4NMFCuN4WjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10163 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 suspectscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111100056 X-Proofpoint-GUID: 89xipiC_Ku3AMpMZ_eFnT2A28QpHjGnq X-Proofpoint-ORIG-GUID: 89xipiC_Ku3AMpMZ_eFnT2A28QpHjGnq Received-SPF: pass client-ip=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch adds a get_vhost() callback function for VirtIODevices that returns the device's corresponding vhost_dev structure if the vhost device is running. This patch also adds a vhost_started flag for VirtIODevices. Previously, a VirtIODevice wouldn't be able to tell if its corresponding vhost device was active or not. Signed-off-by: Jonah Palmer --- hw/block/vhost-user-blk.c | 7 +++++++ hw/display/vhost-user-gpu.c | 7 +++++++ hw/input/vhost-user-input.c | 7 +++++++ hw/net/virtio-net.c | 9 +++++++++ hw/scsi/vhost-scsi.c | 8 ++++++++ hw/virtio/vhost-user-fs.c | 7 +++++++ hw/virtio/vhost-user-rng.c | 7 +++++++ hw/virtio/vhost-vsock-common.c | 7 +++++++ hw/virtio/vhost.c | 3 +++ hw/virtio/virtio-crypto.c | 10 ++++++++++ hw/virtio/virtio.c | 1 + include/hw/virtio/virtio.h | 3 +++ 12 files changed, 76 insertions(+) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index f61f8c1..b059da1 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -568,6 +568,12 @@ static void vhost_user_blk_instance_init(Object *obj) "/disk@0,0", DEVICE(obj)); } +static struct vhost_dev *vhost_user_blk_get_vhost(VirtIODevice *vdev) +{ + VHostUserBlk *s = VHOST_USER_BLK(vdev); + return &s->dev; +} + static const VMStateDescription vmstate_vhost_user_blk = { .name = "vhost-user-blk", .minimum_version_id = 1, @@ -602,6 +608,7 @@ static void vhost_user_blk_class_init(ObjectClass *klass, void *data) vdc->get_features = vhost_user_blk_get_features; vdc->set_status = vhost_user_blk_set_status; vdc->reset = vhost_user_blk_reset; + vdc->get_vhost = vhost_user_blk_get_vhost; } static const TypeInfo vhost_user_blk_info = { diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 49df56c..6e93b46 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -565,6 +565,12 @@ vhost_user_gpu_device_realize(DeviceState *qdev, Error **errp) g->vhost_gpu_fd = -1; } +static struct vhost_dev *vhost_user_gpu_get_vhost(VirtIODevice *vdev) +{ + VhostUserGPU *g = VHOST_USER_GPU(vdev); + return &g->vhost->dev; +} + static Property vhost_user_gpu_properties[] = { VIRTIO_GPU_BASE_PROPERTIES(VhostUserGPU, parent_obj.conf), DEFINE_PROP_END_OF_LIST(), @@ -586,6 +592,7 @@ vhost_user_gpu_class_init(ObjectClass *klass, void *data) vdc->guest_notifier_pending = vhost_user_gpu_guest_notifier_pending; vdc->get_config = vhost_user_gpu_get_config; vdc->set_config = vhost_user_gpu_set_config; + vdc->get_vhost = vhost_user_gpu_get_vhost; device_class_set_props(dc, vhost_user_gpu_properties); } diff --git a/hw/input/vhost-user-input.c b/hw/input/vhost-user-input.c index 273e96a..43d2ff3 100644 --- a/hw/input/vhost-user-input.c +++ b/hw/input/vhost-user-input.c @@ -79,6 +79,12 @@ static void vhost_input_set_config(VirtIODevice *vdev, virtio_notify_config(vdev); } +static struct vhost_dev *vhost_input_get_vhost(VirtIODevice *vdev) +{ + VHostUserInput *vhi = VHOST_USER_INPUT(vdev); + return &vhi->vhost->dev; +} + static const VMStateDescription vmstate_vhost_input = { .name = "vhost-user-input", .unmigratable = 1, @@ -93,6 +99,7 @@ static void vhost_input_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_vhost_input; vdc->get_config = vhost_input_get_config; vdc->set_config = vhost_input_set_config; + vdc->get_vhost = vhost_input_get_vhost; vic->realize = vhost_input_realize; vic->change_active = vhost_input_change_active; } diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index b275acf..2449b9c 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3610,6 +3610,14 @@ static bool dev_unplug_pending(void *opaque) return vdc->primary_unplug_pending(dev); } +static struct vhost_dev *virtio_net_get_vhost(VirtIODevice *vdev) +{ + VirtIONet *n = VIRTIO_NET(vdev); + NetClientState *nc = qemu_get_queue(n->nic); + struct vhost_net *net = get_vhost_net(nc->peer); + return &net->dev; +} + static const VMStateDescription vmstate_virtio_net = { .name = "virtio-net", .minimum_version_id = VIRTIO_NET_VM_VERSION, @@ -3712,6 +3720,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data) vdc->post_load = virtio_net_post_load_virtio; vdc->vmsd = &vmstate_virtio_net_device; vdc->primary_unplug_pending = primary_unplug_pending; + vdc->get_vhost = virtio_net_get_vhost; } static const TypeInfo virtio_net_info = { diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 039caf2..b0a9c45 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -264,6 +264,13 @@ static void vhost_scsi_unrealize(DeviceState *dev) virtio_scsi_common_unrealize(dev); } +static struct vhost_dev *vhost_scsi_get_vhost(VirtIODevice *vdev) +{ + VHostSCSI *s = VHOST_SCSI(vdev); + VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s); + return &vsc->dev; +} + static Property vhost_scsi_properties[] = { DEFINE_PROP_STRING("vhostfd", VirtIOSCSICommon, conf.vhostfd), DEFINE_PROP_STRING("wwpn", VirtIOSCSICommon, conf.wwpn), @@ -298,6 +305,7 @@ static void vhost_scsi_class_init(ObjectClass *klass, void *data) vdc->get_features = vhost_scsi_common_get_features; vdc->set_config = vhost_scsi_common_set_config; vdc->set_status = vhost_scsi_set_status; + vdc->get_vhost = vhost_scsi_get_vhost; fwc->get_dev_path = vhost_scsi_common_get_fw_dev_path; } diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index b875640..e513e4f 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -276,6 +276,12 @@ static void vuf_device_unrealize(DeviceState *dev) fs->vhost_dev.vqs = NULL; } +static struct vhost_dev *vuf_get_vhost(VirtIODevice *vdev) +{ + VHostUserFS *fs = VHOST_USER_FS(vdev); + return &fs->vhost_dev; +} + static const VMStateDescription vuf_vmstate = { .name = "vhost-user-fs", .unmigratable = 1, @@ -313,6 +319,7 @@ static void vuf_class_init(ObjectClass *klass, void *data) vdc->set_status = vuf_set_status; vdc->guest_notifier_mask = vuf_guest_notifier_mask; vdc->guest_notifier_pending = vuf_guest_notifier_pending; + vdc->get_vhost = vuf_get_vhost; } static const TypeInfo vuf_info = { diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index 08bccba..3a7bf8e 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -247,6 +247,12 @@ static void vu_rng_device_unrealize(DeviceState *dev) vhost_user_cleanup(&rng->vhost_user); } +static struct vhost_dev *vu_rng_get_vhost(VirtIODevice *vdev) +{ + VHostUserRNG *rng = VHOST_USER_RNG(vdev); + return &rng->vhost_dev; +} + static const VMStateDescription vu_rng_vmstate = { .name = "vhost-user-rng", .unmigratable = 1, @@ -272,6 +278,7 @@ static void vu_rng_class_init(ObjectClass *klass, void *data) vdc->set_status = vu_rng_set_status; vdc->guest_notifier_mask = vu_rng_guest_notifier_mask; vdc->guest_notifier_pending = vu_rng_guest_notifier_pending; + vdc->get_vhost = vu_rng_get_vhost; } static const TypeInfo vu_rng_info = { diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index e8f6249..665a0df 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -261,6 +261,12 @@ static Property vhost_vsock_common_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static struct vhost_dev *vhost_vsock_common_get_vhost(VirtIODevice *vdev) +{ + VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); + return &vvc->vhost_dev; +} + static void vhost_vsock_common_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -270,6 +276,7 @@ static void vhost_vsock_common_class_init(ObjectClass *klass, void *data) set_bit(DEVICE_CATEGORY_MISC, dc->categories); vdc->guest_notifier_mask = vhost_vsock_common_guest_notifier_mask; vdc->guest_notifier_pending = vhost_vsock_common_guest_notifier_pending; + vdc->get_vhost = vhost_vsock_common_get_vhost; } static const TypeInfo vhost_vsock_common_info = { diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 437347a..96b15a1 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1745,6 +1745,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) /* should only be called after backend is connected */ assert(hdev->vhost_ops); + vdev->vhost_started = true; hdev->started = true; hdev->vdev = vdev; @@ -1821,6 +1822,7 @@ fail_mem: fail_features: hdev->started = false; + vdev->vhost_started = false; return r; } @@ -1850,6 +1852,7 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev) } vhost_log_put(hdev, true); hdev->started = false; + vdev->vhost_started = false; hdev->vdev = NULL; } diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index cca5237..7d63b8c 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -961,6 +961,15 @@ static bool virtio_crypto_guest_notifier_pending(VirtIODevice *vdev, int idx) return cryptodev_vhost_virtqueue_pending(vdev, queue, idx); } +static struct vhost_dev *virtio_crypto_get_vhost(VirtIODevice *vdev) +{ + VirtIOCrypto *vcrypto = VIRTIO_CRYPTO(vdev); + CryptoDevBackend *b = vcrypto->cryptodev; + CryptoDevBackendClient *cc = b->conf.peers.ccs[0]; + CryptoDevBackendVhost *vhost_crypto = cryptodev_get_vhost(cc, b, 0); + return &vhost_crypto->dev; +} + static void virtio_crypto_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -977,6 +986,7 @@ static void virtio_crypto_class_init(ObjectClass *klass, void *data) vdc->set_status = virtio_crypto_set_status; vdc->guest_notifier_mask = virtio_crypto_guest_notifier_mask; vdc->guest_notifier_pending = virtio_crypto_guest_notifier_pending; + vdc->get_vhost = virtio_crypto_get_vhost; } static void virtio_crypto_instance_init(Object *obj) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index be98b4d..7050bd5 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3289,6 +3289,7 @@ void virtio_init(VirtIODevice *vdev, uint16_t device_id, vdev->start_on_kick = false; vdev->started = false; + vdev->vhost_started = false; vdev->device_id = device_id; vdev->status = 0; qatomic_set(&vdev->isr, 0); diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index bfc73ec..105b98c 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -22,6 +22,7 @@ #include "standard-headers/linux/virtio_config.h" #include "standard-headers/linux/virtio_ring.h" #include "qom/object.h" +#include "hw/virtio/vhost.h" /* A guest should never accept this. It implies negotiation is broken. */ #define VIRTIO_F_BAD_FEATURE 30 @@ -102,6 +103,7 @@ struct VirtIODevice bool started; bool start_on_kick; /* when virtio 1.0 feature has not been negotiated */ bool disable_legacy_check; + bool vhost_started; VMChangeStateEntry *vmstate; char *bus_name; uint8_t device_endian; @@ -160,6 +162,7 @@ struct VirtioDeviceClass { int (*post_load)(VirtIODevice *vdev); const VMStateDescription *vmsd; bool (*primary_unplug_pending)(void *opaque); + struct vhost_dev *(*get_vhost)(VirtIODevice *vdev); }; void virtio_instance_init_common(Object *proxy_obj, void *data, From patchwork Wed Nov 10 10:23:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 1553349 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2021-07-09 header.b=iz6cL/r6; dkim=pass (1024-bit key; unprotected) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-oracle-onmicrosoft-com header.b=Xu9stA1D; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hq1F91HxXz9sRN for ; Wed, 10 Nov 2021 21:24:59 +1100 (AEDT) Received: from localhost ([::1]:35520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mkkmm-0002P3-EZ for incoming@patchwork.ozlabs.org; Wed, 10 Nov 2021 05:24:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkkm0-0002Nr-89; Wed, 10 Nov 2021 05:24:08 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:22096) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkklw-0005BH-Rj; Wed, 10 Nov 2021 05:24:06 -0500 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AA9SuFC014454; Wed, 10 Nov 2021 10:23:52 GMT 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-2021-07-09; bh=xB/u4eff3tHLTtnkwq3PcXI97TvW1x3wVPuSti8zOCY=; b=iz6cL/r6UF2IcDT9rnvdP2I2qgg2PrwZera74LCHTshzqYiC9D3FvcfE2Y0qt1DXddew ayO1c5XCdB2JIZFbxHdjyVAy4ZoNmubo4eVK8+nCl1oNN/dHFi8Wd95TyPOLNY5G6WmH 9t6ejVy7RfJ9zhYynKtnc0R1OX1z7ydD5CJ/YUddwgLxn/Hzi9Ev5yT7gYTQLhm4Kc/B 5spTz8ndW3iC7gDaBl1ShaF108E9hiSzo7ee/bMTv1rpe+kn3E5bk4tnYy9LbiiVrJB0 Dsv26tWazZv1b2BTfu5U0xoEk7Vuqb4kUkoaYP6WetCtX/3S2Qk/XwkFBIRG3Fb7FQYw aQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3c85nsa221-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Nov 2021 10:23:51 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AAAGPg7034863; Wed, 10 Nov 2021 10:23:49 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2173.outbound.protection.outlook.com [104.47.73.173]) by aserp3030.oracle.com with ESMTP id 3c5frfd2ub-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Nov 2021 10:23:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O3QvMqKgiAloC3QpcztNeUZPU4/VDHE2qWrL4WbCAPfXkzTZNCMnN8dR82O2s4mcC6G/9svALz1z0+yZbs5ztq11cHpTfT3KzTesY17NLzjL/JS147fEIFi0+M7V+fL3ohyuJJAV8bwgOMnp8JFWMfjRug6wumlFAEcM/SaWQgqsnrw/rkVFXxotSl2MYvlv4ePHnPo6uidb6SEWe0xqW2bkUDncCqttwJJD3Y78yzGN2GmdflfsCwLvIOBBkfb6b/QOa5J9qVAUFpgVFy3vqir4aXiGxWWv5c7ei4/yqZi6X7M3Nhbga/Kl6GU+di73AoyVCflUb5KtmGoDT/XXBA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xB/u4eff3tHLTtnkwq3PcXI97TvW1x3wVPuSti8zOCY=; b=QEM0IPJhUyYDh/UhWszvh4canynyuiOfVIiGpx/sjO6C6ZxUOnH4yric0xKtgEebvvWnXUARUdsVqq6BRnOilHuLbAuELRtHRbrjzqETZvzdZmFa2ylAUpQI8spM/sH8O+ODNj2/Jk0uQwfXcRlRHnDKqR02VTtJ+SPhOPsTA6GIRG4OhmR8f+3ZsOUSf7HlPbeSfiX9frhXeA/4YWUt/tz3I9U2MdDWZKYs/EBFwvc/zrktAFgTIxzS3ZzDl5GINAoD8A40H4hK4QornFxwtrWrHyT84qOC6KAnKsoDOD01Zs4Wb+8MeVXjy8HgqHNYqifbYyNCSI2ivV7f0Ya2Uw== 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=xB/u4eff3tHLTtnkwq3PcXI97TvW1x3wVPuSti8zOCY=; b=Xu9stA1DrYonLOvFk3zT8o+KHa+dbdeAKxIlLD7nwptwNH33O94L6wYIkddB6T4/JeGJ0MYGk5HuGT5EbrL9+w29znSTdcZbnhGWgVePwJANYwyPViTDFKhUfq6QlQzydsDEAuSxMklHWfkGi3nT/BUJNbjtqhTHEDjkFfKU+nM= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; 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.4669.13; Wed, 10 Nov 2021 10:23:46 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%5]) with mapi id 15.20.4669.016; Wed, 10 Nov 2021 10:23:46 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v9 3/8] qmp: add QMP command x-query-virtio Date: Wed, 10 Nov 2021 05:23:07 -0500 Message-Id: <1636539792-20967-4-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1636539792-20967-1-git-send-email-jonah.palmer@oracle.com> References: <1636539792-20967-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SN4PR0501CA0112.namprd05.prod.outlook.com (2603:10b6:803:42::29) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 Received: from jonpalme-lnx.us.oracle.com (209.17.40.43) by SN4PR0501CA0112.namprd05.prod.outlook.com (2603:10b6:803:42::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.5 via Frontend Transport; Wed, 10 Nov 2021 10:23:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: af78dc3b-f632-4b40-52c0-08d9a4342db8 X-MS-TrafficTypeDiagnostic: PH0PR10MB4727: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:549; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ErXp1qqxTBXqnUBEL58YHRvZ0ll7eaP872NDYkpDXXW+U+62VwPvG+EkjvoqaBQSob6BWD/2NW84hf7YmQb07Li26PQpG5Xok7R+qAmfC6vB2OKg2Zd3evIoVWyAI1ROqEGRk0L7mWPvWYTdohobqmqXFtav4DxECYsdnE/1bCyFLZSAxxc3HVf+l6Kk7z+sBLLw3YFDVTaMZ7OgU5wtpWV0/pUzgRPEMoQUaBKdcmeJwyIWqeaq8zKKHUg1+kAyUbigwdeq/9Wsql6FmKC+tYJK7iv7Fhg5cDjAUQO7mvVQFS7GxM4VfEvzmjLV3sxbtrsjuALR3EWV+DDq8JNf9GOl/wkZ3wnSgRCI/S9yOYRmdWOZgMXr5AgNc8iRaB0mWCgXOjN4RnT3JCECGFsMEZnRotstHVQbl6Xou6Q7QzQmmofQJy+o5XXfgHS7StHy5DEigq82b3mK3y4cG+T3/28QDK18QyGHSR9+PXj/OFMqUH8W6uK1kMHsqYiAiBHcwRO5ytBc82kA6WcrTQw5ck+FXMjBSdgopNxX3On+I4etvuIvpJsTO5jOFW3y4Q1hoRvoAf2kkxOxnoYWH1mzwtHzZEWXsJ5rnI/fSrBnFUzsOQUGbvWWAVKeribscKyeY1yXyxPrHPLiGxSZbuUS9uOrGD5AzPQpcW7SgSz9Y7ogc6BU2Ac25yyt+khpYedur+0Wxm6QGXtWyLIC6LS9Bg== 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:(366004)(36756003)(66556008)(8676002)(7416002)(6486002)(66476007)(26005)(5660300002)(66946007)(83380400001)(186003)(4326008)(44832011)(86362001)(7696005)(38100700002)(38350700002)(6916009)(52116002)(2906002)(508600001)(8936002)(956004)(6666004)(2616005)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2sBoYdYvhkS2haIKbJ9KFFTZ/fjQuTbFq3Qspme5FiQ5lsoljsYJ4oIm0MV6iMLoLTakXJCBIvVIcV4FCBfYZUJxD+7ZFfErMzgHIImrA4Qq8t/9Ta3fy8TOiJBylnhPpmqFvJFsrQ4deTw7x0EKOaRATTYhn35UJYad3ubtMYYQf5FAKKwCiduBwz4hzFR+BC1+FCL8thTKeWYyw4gOly95E3pQlHbovXJidtkEqmo21ewcpsU2CrOSLOjifLjkXwPSKyA0B8cpEEGDO5eYOAUyVGO06Bw5Zk+RH6pCUkiGB4ShRgQt6ksjVXKfCR2FH4BfiErPsFHPJriiLR1q8iwZSiXf5p/NGVwCvN/Hqd6tnrS27fXm+hRNWqHPdL3n+5D0ME8BbdwfDKxdqz7j0a6+HQV4UpknfGWC/I9v1UG5S5FDCs79HJS3bSOLm4K7z/zejUV+bpXMPUzISzVnGNWLjuE9qKDpIZMsA8pKGXDFyjJsTxnwB1vknjoe1INTzoPvJnmQK/2vAbzri2wV6ricFaDKXunO1G/4SCVjqRU6IAOm2d/sAQF/Hf1uhUOWKnTEcqxVdSOb1Tc9AEbd8hJ8+okdlNl3hppW8QoWK67E3+gnrfaElylxIZdzCJm1F1op/HlMm6i/P/Zsqqpn+pamFv1/nKUI0SXRi4bPNMDULYdpqQolf0fx6TvkVl52pv41sA/4tmWmZZvpDw8awZc03cJiWLOCaOyiMX7lxkxWYbXTEoOp3GW7bvpdDlkyTtlt0c3uBEMY8FAN11q+xDdFUvdZc6/spmqrqhk70ZTSI+KXWCqrsxLSBo9bg/yUActh275BZSmFp5gsT3n96o0s/kY07APuqXdrFt/F3kc/GxjYVj2WHYZqB5/fb525Wflp/o+Wp5ySx0RpqKz6mMoRwVUM1C84XbRX/WbwSov5xAIIeOQqjdMQoFRbXEUCVI2Z5Nb/qkKTS9Sre2OXJf/5jUqhDwl2QqBWJGyjx1JU46+zTba+9DwazYX+UcXvih8rYzo9YNFZh+kNCzZFarO54UymSmwFbegvyUMTMECLzcKPAF7Sw/Y/dEjiAj9oJfqyLzH+v3NLU4LQRwfNenEg1uzcmvREBR/cSPH+0QzXlFxFfZxjVT2uaWrwJiWHR8EkG/H84zGfk03asJ3pcSWpnghXGnydTJF00uV1cQFyklT0cLo3g6k9gZLAXDj4iLWqHQ07usBphQIeSscuhsLkhwKsJ/VsmyZytgxS/8Hto0kND7Ski5YSUVvjUIkNjLXaQS4wpGzQo8DcIZc/PStrVaaTXLCvz+skwNGUDHa46wG9K3uZ95wtAQh9Uob2anCNUaUMdUBaF28c7l0YyjKRnG06tdTYNr3m8vON1/XLVfhEfXfNyOAYZpLpo68txA8ixk0nfgVarY1X2jc03FBKaGx6h6TrCOgavs9dBdU/xPJwM3CCgYXSOjze2P3wJ9v7HwB0in7qy9SldVTi0ZpyTqG2aQLvFvllGygwVL//TqTm6ipV0JVrNcUgZ8CqnFdVxSV0BTBVbprS57PVD4FFii9Sidqou4Fjqi8QJcx8IMu17QodEkC77D5vAf5W2IcAGA3kxEJBza7W11R+b36ONwW0cq2u5CtUgnDhoZ8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: af78dc3b-f632-4b40-52c0-08d9a4342db8 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2021 10:23:46.3727 (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: CejssRi/YAeQ8UDHZXzOalFq7prbII+/16GtBjM8NLiX2l/UVVE65zp1m5dCczzMTqmiLcoVbTAuNXxP5X9aZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10163 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 suspectscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111100056 X-Proofpoint-GUID: mGup5oUgm9s5RlZoEFrYntEO8CADJIT6 X-Proofpoint-ORIG-GUID: mGup5oUgm9s5RlZoEFrYntEO8CADJIT6 Received-SPF: pass client-ip=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier This new command lists all the instances of VirtIODevice with their QOM paths and virtio type/name. Signed-off-by: Jonah Palmer --- hw/virtio/meson.build | 2 ++ hw/virtio/virtio-stub.c | 14 ++++++++++++ hw/virtio/virtio.c | 27 +++++++++++++++++++++++ include/hw/virtio/virtio.h | 1 + qapi/meson.build | 1 + qapi/qapi-schema.json | 1 + qapi/virtio.json | 55 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qtest/qmp-cmd-test.c | 1 + 8 files changed, 102 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 521f7d6..d893f5f 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -6,8 +6,10 @@ softmmu_virtio_ss.add(when: 'CONFIG_VHOST', if_false: files('vhost-stub.c')) 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')) softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-stub.c')) +softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('virtio-stub.c')) virtio_ss = 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..05a81ed --- /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_query_virtio(Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 7050bd5..aad554b 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -13,6 +13,8 @@ #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 "qemu/error-report.h" @@ -29,6 +31,9 @@ #include "sysemu/runstate.h" #include "standard-headers/linux/virtio_ids.h" +/* QAPI list of VirtIODevices */ +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 @@ -3709,6 +3714,7 @@ static void virtio_device_realize(DeviceState *dev, Error **errp) vdev->listener.commit = virtio_memory_listener_commit; vdev->listener.name = "virtio"; memory_listener_register(&vdev->listener, vdev->dma_as); + QTAILQ_INSERT_TAIL(&virtio_list, vdev, next); } static void virtio_device_unrealize(DeviceState *dev) @@ -3723,6 +3729,7 @@ static void virtio_device_unrealize(DeviceState *dev) vdc->unrealize(dev); } + QTAILQ_REMOVE(&virtio_list, vdev, next); g_free(vdev->bus_name); vdev->bus_name = NULL; } @@ -3896,6 +3903,8 @@ static void virtio_device_class_init(ObjectClass *klass, void *data) vdc->stop_ioeventfd = virtio_device_stop_ioeventfd_impl; vdc->legacy_features |= VIRTIO_LEGACY_FEATURES; + + QTAILQ_INIT(&virtio_list); } bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev) @@ -3906,6 +3915,24 @@ bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev) return virtio_bus_ioeventfd_enabled(vbus); } +VirtioInfoList *qmp_x_query_virtio(Error **errp) +{ + VirtioInfoList *list = NULL; + VirtioInfoList *node; + VirtIODevice *vdev; + + QTAILQ_FOREACH(vdev, &virtio_list, next) { + DeviceState *dev = DEVICE(vdev); + node = g_new0(VirtioInfoList, 1); + node->value = g_new(VirtioInfo, 1); + node->value->path = g_strdup(dev->canonical_path); + node->value->type = g_strdup(vdev->name); + QAPI_LIST_PREPEND(list, node->value); + } + + return list; +} + static const TypeInfo virtio_device_info = { .name = TYPE_VIRTIO_DEVICE, .parent = TYPE_DEVICE, diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 105b98c..eceaafc 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -110,6 +110,7 @@ struct VirtIODevice bool use_guest_notifier_mask; AddressSpace *dma_as; QLIST_HEAD(, VirtQueue) *vector_queues; + QTAILQ_ENTRY(VirtIODevice) next; }; struct VirtioDeviceClass { diff --git a/qapi/meson.build b/qapi/meson.build index c0c49c1..e332f28 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -48,6 +48,7 @@ qapi_all_modules = [ 'sockets', 'trace', 'transaction', + 'virtio', 'yank', ] if have_system diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index 4912b97..1512ada 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -93,3 +93,4 @@ { 'include': 'audio.json' } { 'include': 'acpi.json' } { 'include': 'pci.json' } +{ 'include': 'virtio.json' } diff --git a/qapi/virtio.json b/qapi/virtio.json new file mode 100644 index 0000000..324ba8c --- /dev/null +++ b/qapi/virtio.json @@ -0,0 +1,55 @@ +# -*- Mode: Python -*- +# vim: filetype=python +# + +## +# = Virtio devices +## + +## +# @VirtioInfo: +# +# Basic information about a given VirtIODevice +# +# @path: the device's canonical QOM path +# +# @type: VirtIO device name +# +# Since: 6.3 +# +## +{ 'struct': 'VirtioInfo', + 'data': { 'path': 'str', + 'type': 'str' } } + +## +# @x-query-virtio: +# +# Returns a list of all realized VirtIO devices +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: list of gathered @VirtioInfo devices +# +# Since: 6.3 +# +# Example: +# +# -> { "execute": "x-query-virtio" } +# <- { "return": [ { "path": "/machine/peripheral-anon/device[4]/virtio-backend", +# "type": "virtio-input" }, +# { "path": "/machine/peripheral/crypto0/virtio-backend", +# "type": "virtio-crypto" }, +# { "path": "/machine/peripheral-anon/device[2]/virtio-backend", +# "type": "virtio-scsi" }, +# { "path": "/machine/peripheral-anon/device[1]/virtio-backend", +# "type": "virtio-net" }, +# { "path": "/machine/peripheral-anon/device[0]/virtio-backend", +# "type": "virtio-serial" } +# ] } +# +## + +{ 'command': 'x-query-virtio', 'returns': ['VirtioInfo'], + 'features': [ 'unstable' ] } diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c index 7f103ea..fd00ee2 100644 --- a/tests/qtest/qmp-cmd-test.c +++ b/tests/qtest/qmp-cmd-test.c @@ -103,6 +103,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-query-virtio", /* CONFIG_VIRTIO */ /* Success depends on launching SEV guest */ "query-sev-launch-measure", /* Success depends on Host or Hypervisor SEV support */ From patchwork Wed Nov 10 10:23:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 1553353 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2021-07-09 header.b=lawXM+YY; dkim=pass (1024-bit key; unprotected) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-oracle-onmicrosoft-com header.b=JccLY1m9; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hq1LP0sG9z9sCD for ; Wed, 10 Nov 2021 21:29:33 +1100 (AEDT) Received: from localhost ([::1]:44694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mkkrC-0000Bu-Sz for incoming@patchwork.ozlabs.org; Wed, 10 Nov 2021 05:29:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkkm9-0002T7-UK; Wed, 10 Nov 2021 05:24:18 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:30580) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkkm4-0005CH-GK; Wed, 10 Nov 2021 05:24:17 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AA9SunC032063; Wed, 10 Nov 2021 10:23:53 GMT 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-2021-07-09; bh=3ja9FUXs697vEIVbQ9OtJheeAZGn6AB2dzQRg0YijUQ=; b=lawXM+YYGHtMT/iyDqHL6lA/N7yNMBDLKi8DtTaJz2Zk7zkbej6/Bmjfhpv8XzpJDR3V 4aNVnUeIC1Tj4a/R2Y2LP46oUFEnLQVAbx39aWXVrE2AIWVhs6lmmRCys6g7cOWguKm2 hyROYc2owrNycysvUiNKqWU5ynaHPmnmkm+I+nGtKR14GsgCeKMWjAe5ktu6kGF/DeDX PNUuosXyNkdEOlV4So5iyzm6X6Ybe3zSnekwMk88LvpRHdXPRQDBmvMpgs+LWT1G0pZP v716lYmzZDsoHC0GbFRwfexcQ2xU7IFJUAeZX3Xvz12yXRdQjMwhs82ZV6OHdI0Y63DC 1Q== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3c89bq934c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Nov 2021 10:23:53 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AAAH1tF156484; Wed, 10 Nov 2021 10:23:51 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2176.outbound.protection.outlook.com [104.47.59.176]) by userp3020.oracle.com with ESMTP id 3c63fuebwh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Nov 2021 10:23:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oNzcevx6XmzBJ8sGgiCEw4pz6mAAdkn5r4EG8abT20vOKic1jxNtuWPAE6vtICysi19wumtxQ6e+86+/b3SY4XaS7EFJm9vl15fSCgagYDsm1PH2U00sW8TbC5Dl3bb4utKC5lhElynY3VqFcvP7+hEJOgxIGNaHjjAzujI0HiyhSiiAD5qC5BAzpLsOMf/XagJWv/GxuXLuen1Qc3JOokfGHc1EkzEvy67X/Hv4Si4pMLkXHVhCCEslU4AOwHDDDJ1gxit3nCfltsc56gxxaQkh32a4UBAjfxkSbnKp1ekO6G9NoIU5tMutlvO5SFsDV3GDhRbEt6HjLoq0BkenGw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3ja9FUXs697vEIVbQ9OtJheeAZGn6AB2dzQRg0YijUQ=; b=VuMaszRwaseXmBP7OFxgDjG9kkuQ/RkZb4AmzQBVevP3aU+9FssW256GwA8mG9MXIJ5aIkWk++pLBGSq4jvxNfzlcFdxqbDC8wIvn1og0f8wr+Zg+Ot/zEJbryzvMQMnBnxp8VL0j+GT7+PwrEL9qCuH8CBgtPV/a5IuAVeuCh1RIkLX59NrzhoDx/WL9ZKwCSt/NDz6RNckQbCo30SImA0ya6Nqd8mCvaysQPIT1xzZAygUJOMt3DWYVcR+nAqS42E+lH9aTGvfJ/sQhBtwF/EKRS6InwEU1jFju3wue0CK7uvfbyU9RiVTqKm0VYbV7FPC5sfT9BXJZphlQEiIQQ== 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=3ja9FUXs697vEIVbQ9OtJheeAZGn6AB2dzQRg0YijUQ=; b=JccLY1m9r2oaukz0S3Z/i2tshpZEcZ4gM6NEgtjRypwy9vzgr0gCRcd2cYDcB9wtAWSgH0P85pMAIOnOzYF2erZeZmXccMA60Jyqy4rZu4JHX6b9JdHa+edV4tejnTL8xP0rRkm9ptAHcjRTt8RJv8ziJjiqSwrXUFI/s+QYOtI= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB5895.namprd10.prod.outlook.com (2603:10b6:510:14c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.16; Wed, 10 Nov 2021 10:23:49 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%5]) with mapi id 15.20.4669.016; Wed, 10 Nov 2021 10:23:49 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v9 4/8] qmp: add QMP command x-query-virtio-status Date: Wed, 10 Nov 2021 05:23:08 -0500 Message-Id: <1636539792-20967-5-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1636539792-20967-1-git-send-email-jonah.palmer@oracle.com> References: <1636539792-20967-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SN4PR0501CA0112.namprd05.prod.outlook.com (2603:10b6:803:42::29) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 Received: from jonpalme-lnx.us.oracle.com (209.17.40.43) by SN4PR0501CA0112.namprd05.prod.outlook.com (2603:10b6:803:42::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.5 via Frontend Transport; Wed, 10 Nov 2021 10:23:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 55813121-d119-4e59-dc16-08d9a4342f42 X-MS-TrafficTypeDiagnostic: PH0PR10MB5895: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:338; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VnwNltRZNJ1EZYhgYDsH2aCAW4rbsuY+JocZwSdYxulf8ASm7LTDlmH9kdd66gsJVLo2BXhjwZVbbaE2trRBMIW7POKZamlcpQhbi20FZbQnNxfOw8nycglkClh0f3Hokk+ud4MRwnmg8j/xJZ8fz4/BwwZNglJaBava4co39hFWHJBnL7fY2zEV8Ue/nNnkKy1rFVPzGZqV38IvHwDljSErcmRyLObkrbXDQhJPXYpy8eS002/LVg7Ob4D3+K9fC6wwcP9vwl8wSuUafSgxmbeNnnLWD/MtGdGt5IKfVTKqH1Jt2+l63KURLt70nAXCcyjWb5BGiBXBywJ+pkg9zjFbTLdRO8mv4DBiu+fS6l6hwv1pPoaClBIry6f3rlqpZaiBlX7CqOyecQSuh9Sv5A51YmaaQhhoMu+qVvKobr1u2t1MkbzXu4W5oDE7vCQ/545brk6Iq7sYg4AzrSd/1GGP4nv4v77ycmypv+ZunLLXbOv6GMrx/WOl8paL20KSkjjB9yrsQ9SPW9mTihe5tu3sFq4QHciGniFabsrTsRy0DSl8MHjVPRZi4X2rHU7nPlr9cDcDFyr2L8q+Jj/woj8YS9hJTpT7bpw6Sqh+3FhZqq1DvzUO0uyQQXXUdZdqbamW6qKBQ+OSZj63I3sfuU230MNd4G5UwQVwUGL+ISyUpf5+Bzxq9LQlsl4/jPl3ZKwGO894cHm2X3Z3FceXng== 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:(366004)(316002)(7696005)(44832011)(83380400001)(956004)(2616005)(7416002)(5660300002)(6666004)(36756003)(2906002)(26005)(186003)(30864003)(86362001)(4326008)(8676002)(38100700002)(8936002)(52116002)(6916009)(38350700002)(6486002)(66556008)(508600001)(66476007)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7wp9OY6AhkbHyReKfh0Xg3lD77iAod63N/onBDP5YHnouRLCZmnz8piaKZbOXngM/tH0a/jKYBE7id8KnmElJfGq7byK1fvIZTxpj6eDGz2n3d9M+9VuZjkKSATt6EuJ1Zn9+pWjM+8J3uq36YlToqXyKKUeouJexErMJ6ImsFCA+C5nxEtJl1sxFJcx8elh1AwKWfOzSVrxlImxO9bkZJJbb0KBgg+5Hphoh7e3iyM7NmmP2xNT62/F1W2aXE8J/v+bzkmDzVC0IYaHD5e4A6aUQSc1RDAIGSf+ewqRtL0MjurRlEW41i5CZ8bEco25Xq5M0ByzYmehzH/5+ZN7GyCcoCMBgmAwhjfnJ5ZsS15Jcn5FlE7CCupSVRPWoV+qzemZfMdpp1k22NDG0jf77CqMr5eZ8x3EshqQJOn4PaL/KZG9AIB9eI4KGIJwt8RJtIWbj0wLBWG3+HsM5h0H/zprvky0kJzo6/ubivkoi7nly7wy+jqj0gKtAMWbCoOXXVUn/fXDeCTWitKJd6tMEz4/MfUvpbwMFLTDYK9+DX1SQKOAtCJAmqfdMYt3JH0G95T568XIh5RoLAlh0/BPbuFPW3b3pDn1pLTeANd8U6sU7uQWrJAFKKgajGN1op+NXaLhDol9ySfY97zpOh207a9S6jXyU2Tel1TwqatO2x5QnBGkZWWABRRtc9XLon3hpO1kOInrhp46tqqcF65svRYjZsRT9ruPe2jEHYVgjqLXIxNj07dweWAjISf1V4JHtne89GQbOGmL2bmRNSS11Q2ixZwKfi/gcitvBI7I++N6S3Rf5O4/vJJmDwnvsACdwKh92UkVV5hYuVosOKgSv487T+Ojkp/JT+vHl5D8GZqr0nEkpcflEFhGRrHt/+xRdqVpAwChJND9lwXNBwvuDK2lRdAO5JwBwdh/OOUWzq1RSleqSc63GwaJ5QMEmjOTZlphvOiYAm3j7+QdzCudWKQcIro+5+/C8PVrT1lCAF7f2Z7hVa9scHZdzOQMUpec7S+aCKcX2XHBFxNhyi3QFUj8mbCgW0lkDfMOeNASVdU74aF+vXTBxsH3HiMRLOMA5ECYMruPDvPOaIjhejU4/KeEI5Rmjd/Edh2V/DRToHrthsPKETPLSVNl8gaRkpKNOKSiR6fz5rMF4V2QnhkHkDP0jLxj1xZ2eUBtyrbqt5JP0Wd13dcHL8obaCLPmuzX2RKQ19omabJYBjeUUaTnQ8V2Nm/hE0nLJnUOQH/HxSzYTlt6ZBFshEYjU959NihRQ2aHYrqdU++qGOC0Po4QRXxgMG5WGTwsoBmktntjpzGiGoFJJ89TTQVNBxUigQ9Yw15uAeJft/m8uQ/zHbZApS8qxeQ+ChRemhTS+EvA5z+oRb8Hf+mUdB1s/EDW2Y+sGnq4meS27NG82+kNEhdYJ2wBQWzCBEX+FEmfc8Cya5lzhugoomomU2HIHZLTU2Ri60WGG/iHSx2iEXv8ECk2xohpiZbIdhZX/uYQxTPAcjl8KAiM2d3IMRJHKvGnYx5Xl0doWxFtctQQrEC8WPqlEHRv92i6BKOxZW60kVxrC9kpkCOZS4KCOnnRprubd75hpBKOB0rce+j8bcxNHFHyDSpIDeGKTpwOMXluNrih13Y= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55813121-d119-4e59-dc16-08d9a4342f42 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2021 10:23:48.9583 (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: grhqQnYTa5nuMDxroUcjCnMuqp2FoHT/FWmmTTVGqxluzquGBlRn1bPsMBfcQUdP12+RfTkirN3oXwD6QuFXqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5895 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10163 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 suspectscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111100056 X-Proofpoint-GUID: TciSTCmSGJG51CEnfe1jXe0Pe-akY2_P X-Proofpoint-ORIG-GUID: TciSTCmSGJG51CEnfe1jXe0Pe-akY2_P Received-SPF: pass client-ip=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier This new command shows the status of a VirtIODevice, including its corresponding vhost device status (if active). Next patch will improve output by decoding feature bits, including vhost device's feature bits (backend, protocol, acked, and features). Also will decode status bits of a VirtIODevice. Next patch will also suppress the vhost device field from displaying if no vhost device is active for a given VirtIODevice. Signed-off-by: Jonah Palmer --- hw/virtio/virtio-stub.c | 5 + hw/virtio/virtio.c | 96 +++++++++++++++++++ qapi/virtio.json | 246 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 347 insertions(+) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index 05a81ed..acd4148 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -12,3 +12,8 @@ VirtioInfoList *qmp_x_query_virtio(Error **errp) { return qmp_virtio_unsupported(errp); } + +VirtioStatus *qmp_x_query_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 aad554b..580d9a8 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3933,6 +3933,102 @@ VirtioInfoList *qmp_x_query_virtio(Error **errp) return list; } +static VirtIODevice *virtio_device_find(const char *path) +{ + VirtIODevice *vdev; + + QTAILQ_FOREACH(vdev, &virtio_list, next) { + DeviceState *dev = DEVICE(vdev); + + if (strcmp(dev->canonical_path, path) != 0) { + continue; + } + return vdev; + } + + return NULL; +} + +VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) +{ + VirtIODevice *vdev; + VirtioStatus *status; + + vdev = virtio_device_find(path); + if (vdev == NULL) { + error_setg(errp, "Path %s is not a VirtIO device", path); + return NULL; + } + + status = g_new0(VirtioStatus, 1); + status->vhost_dev = g_new0(VhostStatus, 1); + status->name = g_strdup(vdev->name); + status->device_id = vdev->device_id; + status->vhost_started = vdev->vhost_started; + status->guest_features = vdev->guest_features; + status->host_features = vdev->host_features; + status->backend_features = vdev->backend_features; + + switch (vdev->device_endian) { + case VIRTIO_DEVICE_ENDIAN_LITTLE: + status->device_endian = VIRTIO_STATUS_ENDIANNESS_LITTLE; + break; + case VIRTIO_DEVICE_ENDIAN_BIG: + status->device_endian = VIRTIO_STATUS_ENDIANNESS_BIG; + break; + default: + status->device_endian = VIRTIO_STATUS_ENDIANNESS_UNKNOWN; + break; + } + + status->num_vqs = virtio_get_num_queues(vdev); + status->status = vdev->status; + status->isr = vdev->isr; + status->queue_sel = vdev->queue_sel; + status->vm_running = vdev->vm_running; + status->broken = vdev->broken; + status->disabled = vdev->disabled; + status->use_started = vdev->use_started; + status->started = vdev->started; + status->start_on_kick = vdev->start_on_kick; + status->disable_legacy_check = vdev->disable_legacy_check; + status->bus_name = g_strdup(vdev->bus_name); + status->use_guest_notifier_mask = vdev->use_guest_notifier_mask; + + if (vdev->vhost_started) { + VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); + struct vhost_dev *hdev = vdc->get_vhost(vdev); + + status->vhost_dev->n_mem_sections = hdev->n_mem_sections; + status->vhost_dev->n_tmp_sections = hdev->n_tmp_sections; + status->vhost_dev->nvqs = hdev->nvqs; + status->vhost_dev->vq_index = hdev->vq_index; + status->vhost_dev->features = hdev->features; + status->vhost_dev->acked_features = hdev->acked_features; + status->vhost_dev->backend_features = hdev->backend_features; + status->vhost_dev->protocol_features = hdev->protocol_features; + status->vhost_dev->max_queues = hdev->max_queues; + status->vhost_dev->backend_cap = hdev->backend_cap; + status->vhost_dev->log_enabled = hdev->log_enabled; + status->vhost_dev->log_size = hdev->log_size; + } else { + status->vhost_dev->n_mem_sections = 0; + status->vhost_dev->n_tmp_sections = 0; + status->vhost_dev->nvqs = 0; + status->vhost_dev->vq_index = 0; + status->vhost_dev->features = 0; + status->vhost_dev->acked_features = 0; + status->vhost_dev->backend_features = 0; + status->vhost_dev->protocol_features = 0; + status->vhost_dev->max_queues = 0; + status->vhost_dev->backend_cap = 0; + status->vhost_dev->log_enabled = false; + status->vhost_dev->log_size = 0; + } + + return status; +} + static const TypeInfo virtio_device_info = { .name = TYPE_VIRTIO_DEVICE, .parent = TYPE_DEVICE, diff --git a/qapi/virtio.json b/qapi/virtio.json index 324ba8c..54212f2 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -53,3 +53,249 @@ { 'command': 'x-query-virtio', 'returns': ['VirtioInfo'], 'features': [ 'unstable' ] } + +## +# @VirtioStatusEndianness: +# +# Enumeration of endianness for VirtioDevice +# +# Since: 6.3 +## + +{ 'enum': 'VirtioStatusEndianness', + 'data': [ 'unknown', 'little', 'big' ] +} + +## +# @VhostStatus: +# +# Information about a vhost device. This information will only be +# displayed if the vhost device is active. +# +# @n-mem-sections: vhost_dev n_mem_sections +# +# @n-tmp-sections: vhost_dev n_tmp_sections +# +# @nvqs: vhost_dev nvqs. This is the number of virtqueues being used +# by the vhost device. +# +# @vq-index: vhost_dev vq_index +# +# @features: vhost_dev features +# +# @acked-features: vhost_dev acked_features +# +# @backend-features: vhost_dev backend_features +# +# @protocol-features: vhost_dev protocol_features +# +# @max-queues: vhost_dev max_queues +# +# @backend-cap: vhost_dev backend_cap +# +# @log-enabled: vhost_dev log_enabled flag +# +# @log-size: vhost_dev log_size +# +# Since: 6.3 +# +## + +{ 'struct': 'VhostStatus', + 'data': { 'n-mem-sections': 'int', + 'n-tmp-sections': 'int', + 'nvqs': 'uint32', + 'vq-index': 'int', + 'features': 'uint64', + 'acked-features': 'uint64', + 'backend-features': 'uint64', + 'protocol-features': 'uint64', + 'max-queues': 'uint64', + 'backend-cap': 'uint64', + 'log-enabled': 'bool', + 'log-size': 'uint64' } } + +## +# @VirtioStatus: +# +# Full status of the virtio device with most VirtIODevice members. +# Also includes the full status of the corresponding vhost device +# if the vhost device is active. +# +# @name: VirtIODevice name +# +# @device-id: VirtIODevice ID +# +# @vhost-started: VirtIODevice vhost_started flag +# +# @guest-features: VirtIODevice guest_features +# +# @host-features: VirtIODevice host_features +# +# @backend-features: VirtIODevice backend_features +# +# @device-endian: VirtIODevice device_endian +# +# @num-vqs: VirtIODevice virtqueue count. This is the number of active +# virtqueues being used by the VirtIODevice. +# +# @status: VirtIODevice configuration status (e.g. DRIVER_OK, +# FEATURES_OK, DRIVER, etc.) +# +# @isr: VirtIODevice ISR +# +# @queue-sel: VirtIODevice queue_sel +# +# @vm-running: VirtIODevice vm_running flag +# +# @broken: VirtIODevice broken flag +# +# @disabled: VirtIODevice disabled flag +# +# @use-started: VirtIODevice use_started flag +# +# @started: VirtIODevice started flag +# +# @start-on-kick: VirtIODevice start_on_kick flag +# +# @disable-legacy-check: VirtIODevice disabled_legacy_check flag +# +# @bus-name: VirtIODevice bus_name +# +# @use-guest-notifier-mask: VirtIODevice use_guest_notifier_mask flag +# +# @vhost-dev: corresponding vhost device info for a given VirtIODevice +# +# Since: 6.3 +# +## + +{ 'struct': 'VirtioStatus', + 'data': { 'name': 'str', + 'device-id': 'uint16', + 'vhost-started': 'bool', + 'guest-features': 'uint64', + 'host-features': 'uint64', + 'backend-features': 'uint64', + 'device-endian': 'VirtioStatusEndianness', + 'num-vqs': 'int', + 'status': 'uint8', + 'isr': 'uint8', + 'queue-sel': 'uint16', + 'vm-running': 'bool', + 'broken': 'bool', + 'disabled': 'bool', + 'use-started': 'bool', + 'started': 'bool', + 'start-on-kick': 'bool', + 'disable-legacy-check': 'bool', + 'bus-name': 'str', + 'use-guest-notifier-mask': 'bool', + 'vhost-dev': 'VhostStatus' } } + +## +# @x-query-virtio-status: +# +# Poll for a comprehensive status of a given virtio device +# +# @path: Canonical QOM path of the VirtIODevice +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: VirtioStatus of the virtio device +# +# Since: 6.3 +# +# Examples: +# +# 1. Poll for the status of virtio-crypto (no vhost-crypto active) +# +# -> { "execute": "x-query-virtio-status", +# "arguments": { "path": "/machine/peripheral/crypto0/virtio-backend" } +# } +# <- { "return": { +# "device-endian": "little", +# "bus-name": "", +# "disable-legacy-check": false, +# "name": "virtio-crypto", +# "started": true, +# "device-id": 20, +# "vhost-dev": { +# "n-tmp-sections": 0, +# "n-mem-sections": 0, +# "max-queues": 0, +# "backend-cap": 0, +# "log-size": 0, +# "backend-features": 0, +# "nvqs": 0, +# "protocol-features": 0, +# "vq-index": 0, +# "log-enabled": false, +# "acked-features": 0, +# "features": 0 +# }, +# "backend-features": 0, +# "start-on-kick": false, +# "isr": 1, +# "broken": false, +# "status": 15, +# "num-vqs": 2, +# "guest-features": 5100273664, +# "host-features": 6325010432, +# "use-guest-notifier-mask": true, +# "vm-running": true, +# "queue-sel": 1, +# "disabled": false, +# "vhost-started": false, +# "use-started": true +# } +# } +# +# 2. Poll for the status of virtio-net (vhost-net is active) +# +# -> { "execute": "x-query-virtio-status", +# "arguments": { "path": "/machine/peripheral-anon/device[1]/virtio-backend" } +# } +# <- { "return": { +# "device-endian": "little", +# "bus-name": "", +# "disabled-legacy-check": false, +# "name": "virtio-net", +# "started": true, +# "device-id": 1, +# "vhost-dev": { +# "n-tmp-sections": 4, +# "n-mem-sections": 4, +# "max-queues": 1, +# "backend-cap": 2, +# "log-size": 0, +# "backend-features": 0, +# "nvqs": 2, +# "protocol-features": 0, +# "vq-index": 0, +# "log-enabled": false, +# "acked-features": 5100306432, +# "features": 13908344832 +# }, +# "backend-features": 6337593319, +# "start-on-kick": false, +# "isr": 1, +# "broken": false, +# "status": 15, +# "num-vqs": 3, +# "guest-features": 5111807911, +# "host-features": 6337593319, +# "use-guest-notifier-mask": true, +# "vm-running": true, +# "queue-sel": 2, +# "disabled": false, +# "vhost-started": true, +# "use-started": true +# } +# } +# +## + +{ 'command': 'x-query-virtio-status', 'data': { 'path': 'str' }, + 'returns': 'VirtioStatus', 'features': [ 'unstable' ] } From patchwork Wed Nov 10 10:23:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 1553357 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2021-07-09 header.b=hF0Ng7qI; dkim=pass (1024-bit key; unprotected) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-oracle-onmicrosoft-com header.b=BKs0sEBT; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hq1R53Xrkz9sCD for ; Wed, 10 Nov 2021 21:33:37 +1100 (AEDT) Received: from localhost ([::1]:56338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mkkv9-0000Jo-9j for incoming@patchwork.ozlabs.org; Wed, 10 Nov 2021 05:33:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkkmG-0002cf-Vw; Wed, 10 Nov 2021 05:24:25 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:36902) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkkmB-0005Ex-Kj; Wed, 10 Nov 2021 05:24:24 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AA9Sx5b002048; Wed, 10 Nov 2021 10:23:55 GMT 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-2021-07-09; bh=Xl9Z4HnN3zsmjcnUDPVbIFGY/THLbGE4VE9vFt5wPiQ=; b=hF0Ng7qIvfIpfQZMqwqHbJiFAlxcacxMO/xdgwe0xEDq3V2ZPNLVuRZBVAZ0beQVZ3rL 2mRl98a/kfSPtQIopWfZvxrj69cQy4eFdMq42lMXELDbR6KBNSOEnZFx5drNEtm2Ux4o pUcK2ZAuqFPutA8aKm2cwpCWi5cOR/Dj49PN/r5z9hyKQfNKXni+3/1cccNEfaO6nsGT 1dqJiQiZP/dgpxfyXp4IO9jVITL1XHC6G2FcOVTwwNh4Pk3pUP9EYd6vEeL1tSIjojKI YkSLB0WncIPU8eFNm+W8CsIeS5rBWDYBHH8XfqzYxGUtYUy9zg0yBRtCLSTn5/Y6WSDM Qw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3c880rsemq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Nov 2021 10:23:55 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AAAGOCU034660; Wed, 10 Nov 2021 10:23:54 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by aserp3030.oracle.com with ESMTP id 3c5frfd2wh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Nov 2021 10:23:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rxq1DqV7Te2wOWnu+X6xx03ua2ILOLccAefYCAk2eYo8MvB68ypnq/cqwL0q8QiGnneioZLGzgNgb8HTTWBRaGgdKeTWvki+aAGKR7QcTOEe0Zu3qL4T422iMtpUFOaiUf5B6+Gxl4XE7V6cqAtb4KsY7NPec/JuiJPeHrVkY8U77bSlm10k2taa9jkeoGQL+HVa2AFhFse1wl7oeSHC0FLNswGWcp8p4bnNxFovlxanxFCqKfRMSR43+lt5YfFkUC4jwzrSLOwcxzxY1JDfPF5yb414YEiGuxtgJPlcwTzPZZYVU5KIba6AEMSEAhU0PQCWAHVjwU4FCX4RZtiIIg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Xl9Z4HnN3zsmjcnUDPVbIFGY/THLbGE4VE9vFt5wPiQ=; b=Y5TFk43ynZ+iqceWI2yJ+6U63rZpb0tOFEK+zrBIrYcgishYcmFayyUyVyOKK46qG86T/vw6x6mDfITwC2pjig6zZCSMVSbdVxhmgS6KmDgrPbTRQUhq+DElUHXOxLSq0FNR5tmw/Wg28M6Oru9Thh3f1ijpHNKEN8OsuXsTPOzgAmMTrD4bVnH3kk+WDNzCwsD/eRduFQxrwXRTR2maZmhbT33VX87sXxMEaQP6MX4HTfXGDK7c6lo1SNxTvV3YaPIX0iYnRFyPQSS7bJk7+vQx54phk41XKIHwbgjXdUY47JtjtwwV1A4ygQEGTxc1wt65PiyytP6LlZ7eHUbaDQ== 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=Xl9Z4HnN3zsmjcnUDPVbIFGY/THLbGE4VE9vFt5wPiQ=; b=BKs0sEBT3hxxt3DXzUTsqbf5bOqRn+Dgn0FqDIa2WY08aodcW7r0sBWyPBbJY4/vzZov3trMk6f9T8NGiYGqgCBtaXFzphIcKp4Z95y7FNdz7SEuXivysBFdvg9ifOVY2DEkj4aqJKY/LHc6b7oraJ7PPb65g9nWVVyZUaYvaqA= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB5895.namprd10.prod.outlook.com (2603:10b6:510:14c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.16; Wed, 10 Nov 2021 10:23:51 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%5]) with mapi id 15.20.4669.016; Wed, 10 Nov 2021 10:23:51 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v9 5/8] qmp: decode feature & status bits in virtio-status Date: Wed, 10 Nov 2021 05:23:09 -0500 Message-Id: <1636539792-20967-6-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1636539792-20967-1-git-send-email-jonah.palmer@oracle.com> References: <1636539792-20967-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SN4PR0501CA0112.namprd05.prod.outlook.com (2603:10b6:803:42::29) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 Received: from jonpalme-lnx.us.oracle.com (209.17.40.43) by SN4PR0501CA0112.namprd05.prod.outlook.com (2603:10b6:803:42::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.5 via Frontend Transport; Wed, 10 Nov 2021 10:23:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9d51235c-4b19-476a-276b-08d9a43430c2 X-MS-TrafficTypeDiagnostic: PH0PR10MB5895: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:114; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aTvXsM7iG+7n/l8yU5+UmA4amE6mvXTSXF5o4rIDm8lHI4YvNtc9yryT3BGLI+LQ9wvdvLwMa+Gpv8Y3Y8cyGzeALfXHJHfe9gju0wTwYd5LHBlvh/LEfJzxT0VVAN7++shI7mmDOZkFVV/pQPL4MpGRajG/hHWAFLgZCvGjMujI5pvsdND+DpF5yQKhkmYJQSDxVE5ngyh9PiaUGccKAgoImjQnRIC5V/y5AOPpCwq+9GsVj84lMCJwm2dgs6oNl/oyuum4V5oAa1lqo7FP9I2OKPesxV0dcqUi+yRMDBSiqmVlG/yAfuf5W0j7r+QYDEAc2MdhfTiH0gFC3quQ11SzxLalCOtIUQvSyxxYOni1rpxubHRCMEQhD7UIuLio086/Mce6l3Ll80hb9+eTyPfOKpDJCe0Cf4UoOAIJvu39G88uQA3jAkW1afCb2lowqbh/tXqbLPwWCK68VLVvl8J3VqZQphTtpZIDczrdz7/QFbWVThQWu3wgp8NdrMg7bPCs2yHrJQUMYzVoUha4xc/3XKCJqoaQkrYSB2D5KSAmIZPTzz4pPvlNKLjZFEKlaAW6er1DhzLyR04i4NA8SDZCR7R+LEYFwl9I779PwRKkfOoYcmtqUbewWUZoAA9PG2fhSSFDoaAeOB9080ghpUysLifGtP2aESUhPuI2rP17PKIgZqzIqFQBqcqse5cOQLeQR+hdTenIUusoGl3qaw== 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:(366004)(316002)(7696005)(44832011)(83380400001)(956004)(2616005)(7416002)(5660300002)(6666004)(36756003)(2906002)(26005)(186003)(30864003)(86362001)(4326008)(8676002)(38100700002)(8936002)(52116002)(6916009)(38350700002)(6486002)(66556008)(508600001)(66476007)(66946007)(579004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sfkolZKOHj+Lc4FId5sUf/+Mapaijft6DMaGrtp6wzvVsXWsNgEkKv9e7yT1y3Wjck7NySIt2jJ77jJJPX5I/DTBzXINUavGq51VMuH2j+BDSv6NaJNqWu7vxFf4PJThLiAIlC+TshHAoVsaZZIp/iCLzooFLFUrF6ux+Tj6U1uiN3jbDjWK452en6Kbvmu49vkJdrWT95qJkkEYhya/09+i5P2FQeO/cdNWVzUVHPMJJk/iI8mg4zSNIsgEHbMhCEzmr1PnZl/i9nmYZKs13vHCf1zK0r6+8NsTyvAeBhwRWvttxswqqDaPg7tS79qRoNFUPtYddgnQRgcbbZGj2GCvSgW4Gc7cwXmMysGJI+2inPPmsSotXrBoAFl+Otpu6qtxkD0Y2iLw7/UzoSa7nbBywaZygZh9963c+d+5K7Cr9U5ouRa43AkfShkY45iIMqIjOpAngwUlWE8/1NYg3cPjiYK7PqIMxNYu6VSZG4G4l/gYGZcq6TrEt1SWjydvUpgnrqrOJQCv8ggmiQ6s7wM5Gm0nX3LXPfUZ7kBEuolGzI8pa47TjprM7DTSAMimCmPZ9hfzEDxHQ9eSetNKjjduubpnR3GipIGuGfhVWYwaAG74UBZfG1X6sI32zrCpo8oKOUkxxMLjh87apzpuJU5WE48zw4OZ67muE+WUTGyLcWXExZzHZ/D4n45MBMcP5B9Xds7l2KBzSBPdeA0v5klknzZZT/WN/7u+sqFYE0HDr4zuO4HgX49Sc9dxLA6z4QwkIT9ZHsudretEvcEO71VLIsNLNcJhwhpxsMX4uP5vAPF8ShOVdWKzZ+QVqb1rDtyQnnM4w+3+4K0xmW6zZdDzRAq/C3B8xgRGsOgwPoKbkThPc0BhpH1WbW2j+Je/jwK3Q7n6zzZ8nuGvgSEgQyPPRyiGGwsL6kaDYHinKlHHY+C0KzKlXulUdI3ooYVUszcTc0r0qcmzTxPl1Gt82KtTogw87HruKf2VOzvr1DTeokKXaa5p3giuPk0Ieh9GZkbX1pY558YTLD7NX+DUZ+grTWS/P1m0GclWfdrASIhpS/e751EWwhrclu2eyTFlYWT99jumyoxl0e//kZOKUjJyiBGOk2A4Opfj/gYL3rQs+vD7pUTa4FEBd55XpCKR7fWQqhk7NcHzs6ZhzbwEcwZ8NkVTzd4SgCv+8s3zdWkAj4DZv+542lqEE3fv2UlqyQgNowZ2so3Mf1nWKnFXaureP9n5bioPOqfzcXOKAxKW9r8TP0SSgpJOwXRJVm8NBarwuwqv3hh5q2G5ew2fdprPutxgRKtvnySyCwwFoTVRqculWgalE/fyr/MwDVhM3oWqSThDQQLHpfVmwffBVE4p3z+7l/SW9W3ZbT1tifKVnLS+pCtdgnkqLvHNUd7uzU+32/i9qGv7j9ypOlCpJXaJJD257Wy5ax4MKZKqT7EEDP9OJaMVxOcg+L08tj1GtwUJdYxcLLHyVGBxRzqRyAfihLnCDGtuynQeURI6DuRCraBq9I69U9rIbt0vxF4q/O8uu/Uf1HN4bWjzt8FLOjb7sBH5s/3XqSjfh08Pkhi1SkT4hFApCpo88/lS07LyR3XMX2F3OKRujguJ31ype3d/sKwaqqbFgsy/+P+5Ox0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d51235c-4b19-476a-276b-08d9a43430c2 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2021 10:23:51.4484 (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: PD3Tq5JyRU/ynuZnEQwI3brrF3cmSxAdfmrPaPc6qx6zDFUGEiAxxxOaVcAX9eBH2AK9mDjulwuJFEzdrpgVVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5895 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10163 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 suspectscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111100056 X-Proofpoint-GUID: TVae1cjczjo3fm2mDLln1SvNiVhQ1veB X-Proofpoint-ORIG-GUID: TVae1cjczjo3fm2mDLln1SvNiVhQ1veB Received-SPF: pass client-ip=205.220.177.32; envelope-from=jonah.palmer@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier Display feature names instead of bitmaps for host, guest, and backend for VirtIODevice. Display status names instead of bitmaps for VirtIODevice. Display feature names instead of bitmaps for backend, protocol, acked, and features (hdev->features) for vhost devices. Decode features according to device type. Decode status according to configuration status bitmap (config_status_map). Decode vhost user protocol features according to vhost user protocol bitmap (vhost_user_protocol_map). Transport features are on the first line. Undecoded bits (if any) are stored in a separate field. Vhost device field wont show if there's no vhost active for a given VirtIODevice. Signed-off-by: Jonah Palmer --- hw/block/virtio-blk.c | 28 ++ hw/char/virtio-serial-bus.c | 11 + hw/display/virtio-gpu-base.c | 18 +- hw/input/virtio-input.c | 11 +- hw/net/virtio-net.c | 47 ++++ hw/scsi/virtio-scsi.c | 17 ++ hw/virtio/vhost-user-fs.c | 10 + hw/virtio/vhost-vsock-common.c | 10 + hw/virtio/virtio-balloon.c | 14 + hw/virtio/virtio-crypto.c | 10 + hw/virtio/virtio-iommu.c | 14 + hw/virtio/virtio-mem.c | 11 + hw/virtio/virtio.c | 278 +++++++++++++++++++- include/hw/virtio/vhost.h | 3 + include/hw/virtio/virtio.h | 18 ++ qapi/virtio.json | 580 ++++++++++++++++++++++++++++++++++++++--- 16 files changed, 1035 insertions(+), 45 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 505e574..c2e901f 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -13,6 +13,7 @@ #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" @@ -32,6 +33,7 @@ #include "hw/virtio/virtio-bus.h" #include "migration/qemu-file-types.h" #include "hw/virtio/virtio-access.h" +#include "standard-headers/linux/vhost_types.h" /* Config size before the discard support (hide associated config fields) */ #define VIRTIO_BLK_CFG_SIZE offsetof(struct virtio_blk_config, \ @@ -48,6 +50,32 @@ static const VirtIOFeature feature_sizes[] = { {} }; +qmp_virtio_feature_map_t blk_map[] = { +#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 /* !VIRTIO_BLK_NO_LEGACY */ +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, VIRTIO_BLK_FEATURE_##name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, -1 } +}; + static void virtio_blk_set_config_size(VirtIOBlock *s, uint64_t host_features) { s->config_size = MAX(VIRTIO_BLK_CFG_SIZE, diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 232f4c9..fa57059 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -20,6 +20,7 @@ #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" @@ -32,6 +33,16 @@ #include "hw/virtio/virtio-serial.h" #include "hw/virtio/virtio-access.h" +qmp_virtio_feature_map_t serial_map[] = { +#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 5411a7b..a322349 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -12,13 +12,29 @@ */ #include "qemu/osdep.h" - +#include "standard-headers/linux/vhost_types.h" #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" +qmp_virtio_feature_map_t gpu_map[] = { +#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 +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, VIRTIO_GPU_FEATURE_##name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, -1 } +}; + void virtio_gpu_base_reset(VirtIOGPUBase *g) { diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c index 5b5398b..b4562a3 100644 --- a/hw/input/virtio-input.c +++ b/hw/input/virtio-input.c @@ -6,6 +6,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/iov.h" #include "qemu/module.h" #include "trace.h" @@ -13,11 +14,19 @@ #include "hw/virtio/virtio.h" #include "hw/qdev-properties.h" #include "hw/virtio/virtio-input.h" - +#include "standard-headers/linux/vhost_types.h" #include "standard-headers/linux/input.h" #define VIRTIO_INPUT_VM_VERSION 1 +qmp_virtio_feature_map_t input_map[] = { +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, VIRTIO_INPUT_FEATURE_##name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, -1 } +}; + /* ----------------------------------------------------------------- */ void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 2449b9c..ece871a 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -35,9 +35,11 @@ #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" +#include "standard-headers/linux/vhost_types.h" #include "sysemu/sysemu.h" #include "trace.h" #include "monitor/qdev.h" @@ -89,6 +91,51 @@ VIRTIO_NET_RSS_HASH_TYPE_TCP_EX | \ VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) +qmp_virtio_feature_map_t net_map[] = { +#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(HASH_REPORT), + FEATURE_ENTRY(RSS), + FEATURE_ENTRY(RSC_EXT), + FEATURE_ENTRY(STANDBY), + FEATURE_ENTRY(SPEED_DUPLEX), +#ifndef VIRTIO_NET_NO_LEGACY + FEATURE_ENTRY(GSO), +#endif /* VIRTIO_NET_NO_LEGACY */ +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_NET_F_##name, VIRTIO_NET_FEATURE_##name } + FEATURE_ENTRY(VIRTIO_NET_HDR), +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, VIRTIO_NET_FEATURE_##name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, -1 } +}; + static const VirtIOFeature feature_sizes[] = { {.flags = 1ULL << VIRTIO_NET_F_MAC, .end = endof(struct virtio_net_config, mac)}, diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index ce71939..9a62d6e 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -15,7 +15,9 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "standard-headers/linux/virtio_ids.h" +#include "standard-headers/linux/vhost_types.h" #include "hw/virtio/virtio-scsi.h" #include "migration/qemu-file-types.h" #include "qemu/error-report.h" @@ -29,6 +31,21 @@ #include "hw/virtio/virtio-access.h" #include "trace.h" +qmp_virtio_feature_map_t scsi_map[] = { +#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 +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, VIRTIO_SCSI_FEATURE_##name } + FEATURE_ENTRY(LOG_ALL), +#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/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index e513e4f..092c3fa 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -15,6 +15,7 @@ #include #include "standard-headers/linux/virtio_fs.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" #include "hw/virtio/virtio-bus.h" @@ -23,6 +24,15 @@ #include "hw/virtio/vhost-user-fs.h" #include "monitor/monitor.h" #include "sysemu/sysemu.h" +#include "standard-headers/linux/vhost_types.h" + +qmp_virtio_feature_map_t fs_map[] = { +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, VHOST_USER_FS_FEATURE_##name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, -1 } +}; static const int user_feature_bits[] = { VIRTIO_F_VERSION_1, diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 665a0df..32feb69 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -11,12 +11,22 @@ #include "qemu/osdep.h" #include "standard-headers/linux/virtio_vsock.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "hw/virtio/virtio-access.h" #include "qemu/error-report.h" #include "hw/qdev-properties.h" #include "hw/virtio/vhost-vsock.h" #include "qemu/iov.h" #include "monitor/monitor.h" +#include "standard-headers/linux/vhost_types.h" + +qmp_virtio_feature_map_t vsock_map[] = { +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, VHOST_VSOCK_FEATURE_##name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, -1 } +}; const int feature_bits[] = { VIRTIO_VSOCK_F_SEQPACKET, diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 641a394..532016c 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" @@ -37,6 +38,19 @@ #define BALLOON_PAGE_SIZE (1 << VIRTIO_BALLOON_PFN_SHIFT) +qmp_virtio_feature_map_t balloon_map[] = { +#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 } +}; + typedef struct PartiallyBalloonedPage { ram_addr_t base_gpa; unsigned long *bitmap; diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 7d63b8c..f626ba8 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -16,6 +16,7 @@ #include "qemu/main-loop.h" #include "qemu/module.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/error-report.h" #include "hw/virtio/virtio.h" @@ -23,10 +24,19 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-access.h" #include "standard-headers/linux/virtio_ids.h" +#include "standard-headers/linux/vhost_types.h" #include "sysemu/cryptodev-vhost.h" #define VIRTIO_CRYPTO_VM_VERSION 1 +qmp_virtio_feature_map_t crypto_map[] = { +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, VIRTIO_CRYPTO_FEATURE_##name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, -1 } +}; + /* * Transfer virtqueue index to crypto queue index. * The control virtqueue is after the data virtqueues diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 92c5eb7..9a09293 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" @@ -40,6 +41,19 @@ #define VIOMMU_DEFAULT_QUEUE_SIZE 256 #define VIOMMU_PROBE_SIZE 512 +qmp_virtio_feature_map_t iommu_map[] = { +#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 } +}; + typedef struct VirtIOIOMMUDomain { uint32_t id; GTree *mappings; diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index e217520..eb62104 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -25,6 +25,7 @@ #include "hw/virtio/virtio-mem.h" #include "qapi/error.h" #include "qapi/visitor.h" +#include "qapi/qapi-visit-virtio.h" #include "exec/ram_addr.h" #include "migration/misc.h" #include "hw/boards.h" @@ -46,6 +47,16 @@ #define VIRTIO_MEM_DEFAULT_THP_SIZE VIRTIO_MEM_MIN_BLOCK_SIZE #endif +qmp_virtio_feature_map_t mem_map[] = { +#define FEATURE_ENTRY(name) \ + { VIRTIO_MEM_F_##name, VIRTIO_MEM_FEATURE_##name } +#ifndef CONFIG_ACPI + FEATURE_ENTRY(ACPI_PXM), +#endif /* CONFIG_ACPI */ +#undef FEATURE_ENTRY + { -1, -1 } +}; + /* * We want to have a reasonable default block size such that * 1. We avoid splitting THPs when unplugging memory, which degrades diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 580d9a8..b3b3578 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -30,11 +30,100 @@ #include "sysemu/dma.h" #include "sysemu/runstate.h" #include "standard-headers/linux/virtio_ids.h" +#include "standard-headers/linux/vhost_types.h" +#include CONFIG_DEVICES /* QAPI list of VirtIODevices */ static QTAILQ_HEAD(, VirtIODevice) virtio_list; /* + * Maximum size of virtio device config space + */ +#define VHOST_USER_MAX_CONFIG_SIZE 256 + +enum VhostUserProtocolFeature { + VHOST_USER_PROTOCOL_F_MQ = 0, + VHOST_USER_PROTOCOL_F_LOG_SHMFD = 1, + VHOST_USER_PROTOCOL_F_RARP = 2, + VHOST_USER_PROTOCOL_F_REPLY_ACK = 3, + VHOST_USER_PROTOCOL_F_NET_MTU = 4, + VHOST_USER_PROTOCOL_F_SLAVE_REQ = 5, + VHOST_USER_PROTOCOL_F_CROSS_ENDIAN = 6, + VHOST_USER_PROTOCOL_F_CRYPTO_SESSION = 7, + VHOST_USER_PROTOCOL_F_PAGEFAULT = 8, + VHOST_USER_PROTOCOL_F_CONFIG = 9, + VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD = 10, + VHOST_USER_PROTOCOL_F_HOST_NOTIFIER = 11, + VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD = 12, + VHOST_USER_PROTOCOL_F_RESET_DEVICE = 13, + VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS = 14, + VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS = 15, + VHOST_USER_PROTOCOL_F_MAX +}; + +static qmp_virtio_feature_map_t transport_map[] = { +#define FEATURE_ENTRY(name) \ + { VIRTIO_F_##name, VIRTIO_TRANSPORT_FEATURE_##name } +#ifndef VIRTIO_CONFIG_NO_LEGACY + FEATURE_ENTRY(NOTIFY_ON_EMPTY), + FEATURE_ENTRY(ANY_LAYOUT), +#endif /* VIRTIO_CONFIG_NO_LEGACY */ + FEATURE_ENTRY(VERSION_1), + FEATURE_ENTRY(IOMMU_PLATFORM), + FEATURE_ENTRY(RING_PACKED), + FEATURE_ENTRY(ORDER_PLATFORM), + FEATURE_ENTRY(SR_IOV), +#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 +#define FEATURE_ENTRY(name) \ + { VHOST_USER_F_##name, VIRTIO_TRANSPORT_FEATURE_##name } + FEATURE_ENTRY(PROTOCOL_FEATURES), +#undef FEATURE_ENTRY + { -1, -1 } +}; + +static qmp_virtio_feature_map_t vhost_user_protocol_map[] = { +#define FEATURE_ENTRY(name) \ + { VHOST_USER_PROTOCOL_F_##name, VHOST_PROTOCOL_FEATURE_##name } + FEATURE_ENTRY(MQ), + FEATURE_ENTRY(LOG_SHMFD), + FEATURE_ENTRY(RARP), + FEATURE_ENTRY(REPLY_ACK), + FEATURE_ENTRY(NET_MTU), + FEATURE_ENTRY(SLAVE_REQ), + FEATURE_ENTRY(CROSS_ENDIAN), + FEATURE_ENTRY(CRYPTO_SESSION), + FEATURE_ENTRY(PAGEFAULT), + FEATURE_ENTRY(CONFIG), + FEATURE_ENTRY(SLAVE_SEND_FD), + FEATURE_ENTRY(HOST_NOTIFIER), + FEATURE_ENTRY(INFLIGHT_SHMFD), + FEATURE_ENTRY(RESET_DEVICE), + FEATURE_ENTRY(INBAND_NOTIFICATIONS), + FEATURE_ENTRY(CONFIGURE_MEM_SLOTS), +#undef FEATURE_ENTRY + { -1, -1 } +}; + +/* virtio device configuration statuses */ +static qmp_virtio_feature_map_t config_status_map[] = { +#define STATUS_ENTRY(name) \ + { VIRTIO_CONFIG_S_##name, VIRTIO_CONFIG_STATUS_##name } + STATUS_ENTRY(DRIVER_OK), + STATUS_ENTRY(FEATURES_OK), + STATUS_ENTRY(DRIVER), + STATUS_ENTRY(NEEDS_RESET), + STATUS_ENTRY(FAILED), + STATUS_ENTRY(ACKNOWLEDGE), +#undef STATUS_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 * which don't provide a means for the guest to tell the host the alignment. @@ -3949,6 +4038,169 @@ static VirtIODevice *virtio_device_find(const char *path) return NULL; } +#define CONVERT_FEATURES(type, map, is_status) \ + ({ \ + type *list = NULL; \ + type *node; \ + for (i = 0; map[i].virtio_bit != -1; i++) { \ + if (is_status) { \ + bit = map[i].virtio_bit; \ + } \ + else { \ + bit = 1ULL << map[i].virtio_bit; \ + } \ + if ((bitmap & bit) == 0) { \ + continue; \ + } \ + node = g_new0(type, 1); \ + node->value = map[i].qapi_virtio_enum; \ + node->next = list; \ + list = node; \ + bitmap ^= bit; \ + } \ + list; \ + }) + +static VirtioDeviceStatus *qmp_decode_status(uint8_t bitmap) +{ + VirtioDeviceStatus *status; + uint8_t bit; + int i; + + status = g_new0(VirtioDeviceStatus, 1); + status->dev_status = CONVERT_FEATURES(VirtioConfigStatusList, \ + config_status_map, 1); + status->has_unknown_statuses = bitmap != 0; + if (status->has_unknown_statuses) { + status->unknown_statuses = bitmap; + } + + return status; +} + +static VhostDeviceProtocols *qmp_decode_protocols(uint64_t bitmap) +{ + VhostDeviceProtocols *vhu_protocols; + uint64_t bit; + int i; + + vhu_protocols = g_new0(VhostDeviceProtocols, 1); + vhu_protocols->features = + CONVERT_FEATURES(VhostProtocolFeatureList, + vhost_user_protocol_map, 0); + vhu_protocols->has_unknown_protocols = bitmap != 0; + if (vhu_protocols->has_unknown_protocols) { + vhu_protocols->unknown_protocols = bitmap; + } + + return vhu_protocols; +} + +static VirtioDeviceFeatures *qmp_decode_features(const char *name, + uint64_t bitmap) +{ + VirtioDeviceFeatures *features; + uint64_t bit; + int i; + + features = g_new0(VirtioDeviceFeatures, 1); + + /* transport features */ + features->transport = CONVERT_FEATURES(VirtioTransportFeatureList, \ + transport_map, 0); + /* device features */ + features->type = 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 = + CONVERT_FEATURES(VirtioSerialFeatureList, serial_map, 0); + break; +#endif +#ifdef CONFIG_VIRTIO_BLK + case VIRTIO_TYPE_VIRTIO_BLK: + features->u.virtio_blk.features = + CONVERT_FEATURES(VirtioBlkFeatureList, blk_map, 0); + break; +#endif +#ifdef CONFIG_VIRTIO_GPU + case VIRTIO_TYPE_VIRTIO_GPU: + features->u.virtio_gpu.features = + CONVERT_FEATURES(VirtioGpuFeatureList, gpu_map, 0); + break; +#endif +#ifdef CONFIG_VIRTIO_NET + case VIRTIO_TYPE_VIRTIO_NET: + features->u.virtio_net.features = + CONVERT_FEATURES(VirtioNetFeatureList, net_map, 0); + break; +#endif +#ifdef CONFIG_VIRTIO_SCSI + case VIRTIO_TYPE_VIRTIO_SCSI: + features->u.virtio_scsi.features = + CONVERT_FEATURES(VirtioScsiFeatureList, scsi_map, 0); + break; +#endif +#ifdef CONFIG_VIRTIO_BALLOON + case VIRTIO_TYPE_VIRTIO_BALLOON: + features->u.virtio_balloon.features = + CONVERT_FEATURES(VirtioBalloonFeatureList, balloon_map, 0); + break; +#endif +#ifdef CONFIG_VIRTIO_IOMMU + case VIRTIO_TYPE_VIRTIO_IOMMU: + features->u.virtio_iommu.features = + CONVERT_FEATURES(VirtioIommuFeatureList, iommu_map, 0); + break; +#endif +#ifdef CONFIG_VIRTIO_INPUT + case VIRTIO_TYPE_VIRTIO_INPUT: + features->u.virtio_input.features = + CONVERT_FEATURES(VirtioInputFeatureList, input_map, 0); + break; +#endif +#ifdef CONFIG_VHOST_USER_FS + case VIRTIO_TYPE_VHOST_USER_FS: + features->u.vhost_user_fs.features = + CONVERT_FEATURES(VhostUserFsFeatureList, fs_map, 0); + break; +#endif +#ifdef CONFIG_VHOST_VSOCK + case VIRTIO_TYPE_VHOST_VSOCK: + features->u.vhost_vsock.features = + CONVERT_FEATURES(VhostVsockFeatureList, vsock_map, 0); + break; +#endif +#ifdef CONFIG_VIRTIO_CRYPTO + case VIRTIO_TYPE_VIRTIO_CRYPTO: + features->u.virtio_crypto.features = + CONVERT_FEATURES(VirtioCryptoFeatureList, crypto_map, 0); + break; +#endif +#ifdef CONFIG_VIRTIO_MEM + case VIRTIO_TYPE_VIRTIO_MEM: + features->u.virtio_mem.features = + CONVERT_FEATURES(VirtioMemFeatureList, mem_map, 0); + break; +#endif + /* No features */ + case VIRTIO_TYPE_VIRTIO_9P: + case VIRTIO_TYPE_VIRTIO_PMEM: + case VIRTIO_TYPE_VIRTIO_RNG: + break; + default: + g_assert_not_reached(); + } + + features->has_unknown_features = bitmap != 0; + if (features->has_unknown_features) { + features->unknown_features = bitmap; + } + + return features; +} + VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) { VirtIODevice *vdev; @@ -3965,9 +4217,12 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) status->name = g_strdup(vdev->name); status->device_id = vdev->device_id; status->vhost_started = vdev->vhost_started; - status->guest_features = vdev->guest_features; - status->host_features = vdev->host_features; - status->backend_features = vdev->backend_features; + status->guest_features = qmp_decode_features(vdev->name, + vdev->guest_features); + status->host_features = qmp_decode_features(vdev->name, + vdev->host_features); + status->backend_features = qmp_decode_features(vdev->name, + vdev->backend_features); switch (vdev->device_endian) { case VIRTIO_DEVICE_ENDIAN_LITTLE: @@ -3982,7 +4237,7 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) } status->num_vqs = virtio_get_num_queues(vdev); - status->status = vdev->status; + status->status = qmp_decode_status(vdev->status); status->isr = vdev->isr; status->queue_sel = vdev->queue_sel; status->vm_running = vdev->vm_running; @@ -3995,7 +4250,8 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) status->bus_name = g_strdup(vdev->bus_name); status->use_guest_notifier_mask = vdev->use_guest_notifier_mask; - if (vdev->vhost_started) { + status->has_vhost_dev = vdev->vhost_started; + if (status->has_vhost_dev) { VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); struct vhost_dev *hdev = vdc->get_vhost(vdev); @@ -4003,10 +4259,14 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) status->vhost_dev->n_tmp_sections = hdev->n_tmp_sections; status->vhost_dev->nvqs = hdev->nvqs; status->vhost_dev->vq_index = hdev->vq_index; - status->vhost_dev->features = hdev->features; - status->vhost_dev->acked_features = hdev->acked_features; - status->vhost_dev->backend_features = hdev->backend_features; - status->vhost_dev->protocol_features = hdev->protocol_features; + status->vhost_dev->features = + qmp_decode_features(vdev->name, hdev->features); + status->vhost_dev->acked_features = + qmp_decode_features(vdev->name, hdev->acked_features); + status->vhost_dev->backend_features = + qmp_decode_features(vdev->name, hdev->backend_features); + status->vhost_dev->protocol_features = + qmp_decode_protocols(hdev->protocol_features); status->vhost_dev->max_queues = hdev->max_queues; status->vhost_dev->backend_cap = hdev->backend_cap; status->vhost_dev->log_enabled = hdev->log_enabled; diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 3fa0b55..2c34cff 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -5,6 +5,9 @@ #include "hw/virtio/virtio.h" #include "exec/memory.h" +#define VHOST_F_DEVICE_IOTLB 63 +#define VHOST_USER_F_PROTOCOL_FEATURES 30 + /* Generic structures common for any vhost based device. */ struct vhost_inflight { diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index eceaafc..b5f9c95 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -71,6 +71,24 @@ typedef struct VirtQueueElement #define TYPE_VIRTIO_DEVICE "virtio-device" OBJECT_DECLARE_TYPE(VirtIODevice, VirtioDeviceClass, VIRTIO_DEVICE) +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[]; +extern qmp_virtio_feature_map_t input_map[]; +extern qmp_virtio_feature_map_t fs_map[]; +extern qmp_virtio_feature_map_t vsock_map[]; +extern qmp_virtio_feature_map_t crypto_map[]; +extern qmp_virtio_feature_map_t mem_map[]; + enum virtio_device_endian { VIRTIO_DEVICE_ENDIAN_UNKNOWN, VIRTIO_DEVICE_ENDIAN_LITTLE, diff --git a/qapi/virtio.json b/qapi/virtio.json index 54212f2..6b11d52 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -67,6 +67,466 @@ } ## +# @VirtioType: +# +# An enumeration of Virtio device types (or names) +# +# Since: 6.3 +## + +{ 'enum': 'VirtioType', + 'data': [ 'virtio-net', 'virtio-blk', 'virtio-serial', 'virtio-rng', + 'virtio-balloon', 'virtio-iomem', 'virtio-rpmsg', + 'virtio-scsi', 'virtio-9p', 'virtio-mac-wlan', + 'virtio-rproc-serial', 'virtio-caif', 'virtio-mem-balloon', + 'virtio-gpu', 'virtio-clk', 'virtio-input', 'vhost-vsock', + 'virtio-crypto', 'virtio-signal', 'virtio-pstore', + 'virtio-iommu', 'virtio-mem', 'virtio-sound', 'vhost-user-fs', + 'virtio-pmem', 'virtio-mac-hwsim', 'vhost-user-i2c', + 'virtio-bluetooth' ] +} + +## +# @VirtioConfigStatus: +# +# An enumeration of Virtio device configuration statuses +# +# Since: 6.3 +## + +{ 'enum': 'VirtioConfigStatus', + 'data': [ 'driver-ok', 'features-ok', 'driver', 'needs-reset', + 'failed', 'acknowledge' ] +} + +## +# @VirtioDeviceStatus: +# +# A structure defined to list the configuration statuses of a virtio +# device +# +# @dev-status: List of decoded configuration statuses of the virtio +# device +# +# @unknown-statuses: virtio device statuses bitmap that have not been decoded +# +# Since: 6.3 +## + +{ 'struct': 'VirtioDeviceStatus', + 'data': { 'dev-status': [ 'VirtioConfigStatus' ], + '*unknown-statuses': 'uint8' } } + +## +# @VhostProtocolFeature: +# +# An enumeration of Vhost User protocol features +# +# Since: 6.3 +## + +{ 'enum': 'VhostProtocolFeature', + 'data': [ 'mq', 'log-shmfd', 'rarp', 'reply-ack', 'net-mtu', + 'slave-req', 'cross-endian', 'crypto-session', 'pagefault', + 'config', 'slave-send-fd', 'host-notifier', + 'inflight-shmfd', 'reset-device', 'inband-notifications', + 'configure-mem-slots' ] +} + +## +# @VhostDeviceProtocols: +# +# A structure defined to list the vhost user protocol features of a +# Vhost User device +# +# @features: List of decoded vhost user protocol features of a vhost +# user device +# +# @unknown-protocols: vhost user device protocol features bitmap that +# have not been decoded +# +# Since: 6.3 +## + +{ 'struct': 'VhostDeviceProtocols', + 'data': { 'features': [ 'VhostProtocolFeature' ], + '*unknown-protocols': 'uint64' } } + +## +# @VirtioTransportFeature: +# +# An enumeration of Virtio device transport features, including virtio-ring +# +# Since: 6.3 +## + +{ 'enum': 'VirtioTransportFeature', + 'data': [ 'notify-on-empty', 'any-layout', 'protocol-features', + 'version-1', 'iommu-platform', 'ring-packed', 'order-platform', + 'sr-iov', 'indirect-desc', 'event-idx' ] +} + +## +# @VirtioMemFeature: +# +# An enumeration of Virtio mem features +# +# Since: 6.3 +## + +{ 'enum': 'VirtioMemFeature', + 'data': [ 'acpi-pxm' ] +} + +## +# @VirtioSerialFeature: +# +# An enumeration of Virtio serial/console features +# +# Since: 6.3 +## + +{ 'enum': 'VirtioSerialFeature', + 'data': [ 'size', 'multiport', 'emerg-write' ] +} + +## +# @VirtioBlkFeature: +# +# An enumeration of Virtio block features +# +# Since: 6.3 +## + +{ 'enum': 'VirtioBlkFeature', + 'data': [ 'size-max', 'seg-max', 'geometry', 'ro', 'blk-size', + 'topology', 'mq', 'discard', 'write-zeroes', 'barrier', + 'scsi', 'flush', 'config-wce', 'log-all' ] +} + +## +# @VirtioGpuFeature: +# +# An enumeration of Virtio gpu features +# +# Since: 6.3 +## + +{ 'enum': 'VirtioGpuFeature', + 'data': [ 'virgl', 'edid', 'resource-uuid', 'resource-blob', + 'log-all' ] +} + +## +# @VirtioNetFeature: +# +# An enumeration of Virtio net features +# +# Since: 6.3 +## + +{ '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', + 'hash-report', 'rss', 'rsc-ext', 'standby', 'speed-duplex', + 'gso', 'virtio-net-hdr', 'log-all' ] +} + +## +# @VirtioScsiFeature: +# +# An enumeration of Virtio scsi features +# +# Since: 6.3 +## + +{ 'enum': 'VirtioScsiFeature', + 'data': [ 'inout', 'hotplug', 'change', 't10-pi', 'log-all' ] +} + +## +# @VirtioBalloonFeature: +# +# An enumeration of Virtio balloon features +# +# Since: 6.3 +## + +{ 'enum': 'VirtioBalloonFeature', + 'data': [ 'must-tell-host', 'stats-vq', 'deflate-on-oom', + 'free-page-hint', 'page-poison', 'reporting' ] +} + +## +# @VirtioIommuFeature: +# +# An enumeration of Virtio iommu features +# +# Since: 6.3 +## + +{ 'enum': 'VirtioIommuFeature', + 'data': [ 'input-range', 'domain-range', 'map-unmap', 'bypass', + 'probe', 'mmio' ] +} + +## +# @VirtioInputFeature: +# +# An enumeration of Virtio input features. Note that virtio-input +# has no device-specific features except when its vhost is active, +# then it may have the VHOST_F_LOG_ALL feature. +# +# Since: 6.3 +## + +{ 'enum': 'VirtioInputFeature', + 'data': [ 'log-all' ] +} + +## +# @VhostUserFsFeature: +# +# An enumeration of vhost user FS features. Note that vhost-user-fs +# has no device-specific features other than the vhost-common +# VHOST_F_LOG_ALL feature. +# +# Since: 6.3 +## + +{ 'enum': 'VhostUserFsFeature', + 'data': [ 'log-all' ] +} + +## +# @VhostVsockFeature: +# +# An enumeration of vhost vsock features. Note that vhost-vsock has +# no device-specific features other than the vhost-common +# VHOST_F_LOG_ALL feature. +# +# Since: 6.3 +## + +{ 'enum': 'VhostVsockFeature', + 'data': [ 'log-all' ] +} + +## +# @VirtioCryptoFeature: +# +# An enumeration of virtio crypto features. Not that virtio-crypto +# has no device-specific features other than when it is a vhost +# device, then it may have the VHOST_F_LOG_ALL feature. +# +# Since: 6.3 +## + +{ 'enum': 'VirtioCryptoFeature', + 'data': [ 'log-all' ] +} + +## +# @VirtioDeviceFeaturesBase: +# +# The common fields that apply to all Virtio devices +# +# @type: virtio device name +# @transport: the list of transport features of the virtio device +# @unknown-features: virtio device features bitmap that have not been decoded +# +# Since: 6.3 +## + +{ 'struct': 'VirtioDeviceFeaturesBase', + 'data': { 'type': 'VirtioType', + 'transport': [ 'VirtioTransportFeature' ], + '*unknown-features': 'uint64' } } + +## +# @VirtioDeviceFeaturesOptionsMem: +# +# The options that apply to Virtio mem devices +# +# @features: List of device features +# +# Since: 6.3 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsMem', + 'data': { 'features': [ 'VirtioMemFeature' ] } } + +## +# @VirtioDeviceFeaturesOptionsSerial: +# +# The options that apply to Virtio serial devices +# +# @features: List of device features +# +# Since: 6.3 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsSerial', + 'data': { 'features': [ 'VirtioSerialFeature' ] } } + +## +# @VirtioDeviceFeaturesOptionsBlk: +# +# The options that apply to Virtio block devices +# +# @features: List of device features +# +# Since: 6.3 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsBlk', + 'data': { 'features': [ 'VirtioBlkFeature' ] } } + +## +# @VirtioDeviceFeaturesOptionsGpu: +# +# The options that apply to Virtio GPU devices +# +# @features: List of device features +# +# Since: 6.3 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsGpu', + 'data': { 'features': [ 'VirtioGpuFeature' ] } } + +## +# @VirtioDeviceFeaturesOptionsNet: +# +# The options that apply to Virtio net devices +# +# @features: List of device features +# +# Since: 6.3 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsNet', + 'data': { 'features': [ 'VirtioNetFeature' ] } } + +## +# @VirtioDeviceFeaturesOptionsScsi: +# +# The options that apply to Virtio SCSI devices +# +# @features: List of device features +# +# Since: 6.3 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsScsi', + 'data': { 'features': [ 'VirtioScsiFeature' ] } } + +## +# @VirtioDeviceFeaturesOptionsBalloon: +# +# The options that apply to Virtio balloon devices +# +# @features: List of device features +# +# Since: 6.3 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsBalloon', + 'data': { 'features': [ 'VirtioBalloonFeature' ] } } + +## +# @VirtioDeviceFeaturesOptionsIommu: +# +# The options that apply to Virtio IOMMU devices +# +# @features: List of device features +# +# Since: 6.3 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsIommu', + 'data': { 'features': [ 'VirtioIommuFeature' ] } } + +## +# @VirtioDeviceFeaturesOptionsInput: +# +# The options that apply to Virtio input devices +# +# @features: List of device features +# +# Since: 6.3 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsInput', + 'data': { 'features': [ 'VirtioInputFeature' ] } } + +## +# @VhostDeviceFeaturesOptionsFs: +# +# The options that apply to vhost-user-fs devices +# +# @features: List of device features +# +# Since: 6.3 +## + +{ 'struct': 'VhostDeviceFeaturesOptionsFs', + 'data': { 'features': [ 'VhostUserFsFeature' ] } } + +## +# @VhostDeviceFeaturesOptionsVsock: +# +# The options that apply to vhost-vsock devices +# +# @features: List of device features +# +# Since: 6.3 +## + +{ 'struct': 'VhostDeviceFeaturesOptionsVsock', + 'data': { 'features': [ 'VhostVsockFeature' ] } } + +## +# @VirtioDeviceFeaturesOptionsCrypto: +# +# The options that apply to virtio-crypto devices +# +# @features: List of device features +# +# Since: 6.3 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsCrypto', + 'data': { 'features': [ 'VirtioCryptoFeature' ] } } + +## +# @VirtioDeviceFeatures: +# +# A union to define the list of features for a virtio device +# +# Since: 6.3 +## + +{ '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', + 'virtio-input': 'VirtioDeviceFeaturesOptionsInput', + 'vhost-user-fs': 'VhostDeviceFeaturesOptionsFs', + 'vhost-vsock': 'VhostDeviceFeaturesOptionsVsock', + 'virtio-crypto': 'VirtioDeviceFeaturesOptionsCrypto', + 'virtio-mem': 'VirtioDeviceFeaturesOptionsMem' } } + +## # @VhostStatus: # # Information about a vhost device. This information will only be @@ -106,10 +566,10 @@ 'n-tmp-sections': 'int', 'nvqs': 'uint32', 'vq-index': 'int', - 'features': 'uint64', - 'acked-features': 'uint64', - 'backend-features': 'uint64', - 'protocol-features': 'uint64', + 'features': 'VirtioDeviceFeatures', + 'acked-features': 'VirtioDeviceFeatures', + 'backend-features': 'VirtioDeviceFeatures', + 'protocol-features': 'VhostDeviceProtocols', 'max-queues': 'uint64', 'backend-cap': 'uint64', 'log-enabled': 'bool', @@ -174,12 +634,12 @@ 'data': { 'name': 'str', 'device-id': 'uint16', 'vhost-started': 'bool', - 'guest-features': 'uint64', - 'host-features': 'uint64', - 'backend-features': 'uint64', + 'guest-features': 'VirtioDeviceFeatures', + 'host-features': 'VirtioDeviceFeatures', + 'backend-features': 'VirtioDeviceFeatures', 'device-endian': 'VirtioStatusEndianness', 'num-vqs': 'int', - 'status': 'uint8', + 'status': 'VirtioDeviceStatus', 'isr': 'uint8', 'queue-sel': 'uint16', 'vm-running': 'bool', @@ -191,7 +651,7 @@ 'disable-legacy-check': 'bool', 'bus-name': 'str', 'use-guest-notifier-mask': 'bool', - 'vhost-dev': 'VhostStatus' } } + '*vhost-dev': 'VhostStatus' } } ## # @x-query-virtio-status: @@ -221,28 +681,31 @@ # "name": "virtio-crypto", # "started": true, # "device-id": 20, -# "vhost-dev": { -# "n-tmp-sections": 0, -# "n-mem-sections": 0, -# "max-queues": 0, -# "backend-cap": 0, -# "log-size": 0, -# "backend-features": 0, -# "nvqs": 0, -# "protocol-features": 0, -# "vq-index": 0, -# "log-enabled": false, -# "acked-features": 0, -# "features": 0 +# "backend-features": { +# "transport": [], +# "type": "virtio-crypto", +# "features": [] # }, -# "backend-features": 0, # "start-on-kick": false, # "isr": 1, # "broken": false, -# "status": 15, +# "status": { +# "dev-status": ["acknowledge", "driver", "features-ok", +# "driver-ok"] +# }, # "num-vqs": 2, -# "guest-features": 5100273664, -# "host-features": 6325010432, +# "guest-features": { +# "transport": ["event-idx", "indirect-desc", "version-1"], +# "type": "virtio-crypto", +# "features": [] +# }, +# "host-features": { +# "transport": ["protocol-features", "event-idx", +# "indirect-desc", "version-1", "any-layout", +# "notify-on-empty"], +# "type": "virtio-crypto", +# "features": [] +# }, # "use-guest-notifier-mask": true, # "vm-running": true, # "queue-sel": 1, @@ -270,22 +733,71 @@ # "max-queues": 1, # "backend-cap": 2, # "log-size": 0, -# "backend-features": 0, +# "backend-features": { +# "transport": [], +# "type": "virtio-net", +# "features": [] +# }, # "nvqs": 2, -# "protocol-features": 0, +# "protocol-features": { +# "features": [] +# }, # "vq-index": 0, # "log-enabled": false, -# "acked-features": 5100306432, -# "features": 13908344832 +# "acked-features": { +# "transport": ["event-idx", "indirect-desc", "version-1", +# "any-layout", "notify-on-empty"], +# "type": "virtio-net", +# "features": ["mrg-rxbuf"] +# }, +# "features": { +# "transport": ["event-idx", "indirect-desc", +# "iommu-platform", "version-1", "any-layout", +# "notify-on-empty"], +# "type": "virtio-net", +# "features": ["log-all", "mrg-rxbuf"] +# } +# }, +# "backend-features": { +# "transport": ["protocol-features", "event-idx", "indirect-desc", +# "version-1", "any-layout", "notify-on-empty"], +# "type": "virtio-net", +# "features": ["gso", "ctrl-mac-addr", "guest-announce", "ctrl-rx-extra", +# "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-guest-offloads", "guest-csum", "csum"] # }, -# "backend-features": 6337593319, # "start-on-kick": false, # "isr": 1, # "broken": false, -# "status": 15, +# "status": { +# "dev-status": ["acknowledge", "driver", "features-ok", "driver-ok"] +# }, # "num-vqs": 3, -# "guest-features": 5111807911, -# "host-features": 6337593319, +# "guest-features": { +# "transport": ["event-idx", "indirect-desc", "version-1"], +# "type": "virtio-net", +# "features": ["ctrl-mac-addr", "guest-announce", "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-guest-offloads", "guest-csum", "csum"] +# }, +# "host-features": { +# "transport": ["protocol-features", "event-idx", +# "indirect-desc", "version-1", "any-layout", +# "notify-on-empty"], +# "type": "virtio-net", +# "features": ["gso", "ctrl-mac-addr", "guest-announce", +# "ctrl-rx-extra", "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-guest-offloads", +# "guest-csum", "csum"] +# }, # "use-guest-notifier-mask": true, # "vm-running": true, # "queue-sel": 2, From patchwork Wed Nov 10 10:23:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 1553354 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2021-07-09 header.b=FL8W4C85; dkim=pass (1024-bit key; unprotected) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-oracle-onmicrosoft-com header.b=kHDELTf/; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hq1M26sdpz9sCD for ; Wed, 10 Nov 2021 21:30:05 +1100 (AEDT) Received: from localhost ([::1]:46366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mkkrh-0001Ku-Se for incoming@patchwork.ozlabs.org; Wed, 10 Nov 2021 05:30:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkkm7-0002Rn-OR; Wed, 10 Nov 2021 05:24:15 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:32282) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkkm3-0005Cg-SY; Wed, 10 Nov 2021 05:24:15 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AA9Suc0032052; Wed, 10 Nov 2021 10:23:57 GMT 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-2021-07-09; bh=kw81oluvVsTeHGSj3aHaoSMw4D7kyALKimNR6KDxFps=; b=FL8W4C85Frz8emSYvuRyJzMTJEp0BlOfWK+lCIOTRdJgrqeEb7H2hIAr3SagVD/3vPka BJKLS9/Ouz8l+IyaDbBtZXsjgaPwDm7oIzRRkkNs7k7B9SQcrDVcD0V7gQY5cdf8i8mA Iebc7Bkel/SE0Zi6ZznAMwn67/HTttwuT0i4sKwRDm3Hpkk1yPk749WCW8/FFc6hSuys CIdT3qy8ohxPb/ZOJhiKSWm41Zyw/Z+TzA+LDxCDRdylZLdYzmuKtIX8GV/YjTgOU4c1 eddYbAPXMS9lACAmSw9iNMjZ2gscVeH0MMtNtUyVCO2F0reU6JSmfZfjesgprcUgSYm5 tg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3c89bq934r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Nov 2021 10:23:56 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AAAGOCV034660; Wed, 10 Nov 2021 10:23:55 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by aserp3030.oracle.com with ESMTP id 3c5frfd2wh-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Nov 2021 10:23:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oU+hXQo8pzrNnQPabTHLYTbxgl5pD2l6Ynizq9K9o8cstnfZ4IM/NNRl17RaimdKAa2fLgcKm8q21JZJwYMA+K1cqJRznv5EfcZIFSIMvEFP6vAIuK2FuKHD03tWytrBMWMEQV68Rv6JUko6vnn1vH4NeNywn0Ixs+98CtAQtLyEf6u0aVyaGXpjmW++LcCT/fVUYu3HkkSCc3mQzhnc14YJCaYEdA+ilORe3Z08Xf8U+fd+8YjF1vZX89XKTzNzSg+UXQzdmACWoRwLKeGu61Gx1E1mHgYw0XUHDfjpGZwBpeHpssSerSvRjHK2Xt+ELMa0ClWHlrlMYgS6uWFsgA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kw81oluvVsTeHGSj3aHaoSMw4D7kyALKimNR6KDxFps=; b=HvAcUMW5RNn8IjbOogqEfPCTDzSO3+xX+z5J9ouE2lHMNNOz8Osm63Aael0tLird7J3MYPRA/hCR7HY+9OP2+0Cxq1vUgaAz6ugd7vyFUJNdrBgI+gPle3YHkk12TkLait3IB9okLds4LXsx1qWBo+bYjaDYqDqCH/in3au5qirdGWuCj6c6NwftwfV0IxvyUjpyucjYn4z26fuirwOI/k/2ALGTe6DskKFJuxpRZ4KjQutY6TafBeuUKCXYTbkpIR6aT8Jxm8O2xTIYipwQZt0/tmGBx4l9mx1UrQgPBEl+FeJlIwy8RNkT4jXS0yP2jvzZkHCSghHpxdIH9nG4Mg== 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=kw81oluvVsTeHGSj3aHaoSMw4D7kyALKimNR6KDxFps=; b=kHDELTf/0eF/Xm0VapqawYgB2sOzLWiifMiWNuWPgw17WSQJ171dnvWG7Cdj6KWFkSmEC+TY7DfGl2yicgigG9LGSRvy2+FRMOoOGC7CAzd4P82xV/QdHpmk62IlSNwW5yItT10XWvf8NkITknb0k4bw1gqpR8fuiHn9N7hyNzc= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB5895.namprd10.prod.outlook.com (2603:10b6:510:14c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.16; Wed, 10 Nov 2021 10:23:54 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%5]) with mapi id 15.20.4669.016; Wed, 10 Nov 2021 10:23:54 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v9 6/8] qmp: add QMP commands for virtio/vhost queue-status Date: Wed, 10 Nov 2021 05:23:10 -0500 Message-Id: <1636539792-20967-7-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1636539792-20967-1-git-send-email-jonah.palmer@oracle.com> References: <1636539792-20967-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SN4PR0501CA0112.namprd05.prod.outlook.com (2603:10b6:803:42::29) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 Received: from jonpalme-lnx.us.oracle.com (209.17.40.43) by SN4PR0501CA0112.namprd05.prod.outlook.com (2603:10b6:803:42::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.5 via Frontend Transport; Wed, 10 Nov 2021 10:23:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ff6660bc-6990-49bb-0802-08d9a4343244 X-MS-TrafficTypeDiagnostic: PH0PR10MB5895: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:206; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SRkLoNAoSDkc26EG4hGFlNaBMOJObPw1cGXyJrgDa9G0TWURxkjXpri9c+cVz5Y5+JPDdB2TcPgnFK2ynDBInbsaJ0AujJQXXZWCasvOc9skRKSlRCzdxoCh0Nm4uI3hota+alDXe2ZoPCIIOTC4Ap2sUUJtnNDz7vDdp0HzgQBw/NYv4vPV5xgmVzQTKmDuK8eOt2adrqbE1nbJVlfJyb2ni+BwXrJgREKhyaKSp8A7j9g+KB2mZKVL6fusWT6gavwcrD9O7J6hPs8rBpo6g1AOCc28mRZkQ6xexOXBL2laMe0dU2pCjLM1zDmPinjKEMF/XdqrGrmg/Sjl80c9gScL4/Iz/iBWgz1wqNya6/WXnSheOSNBxHTuV0VpJac3Z3IgmerM4ipPqC37anrUF36awYxSu4BraaQ5+abYW8KTgwzq6w/RBEmW6e7Wer6tVOY/6LBvLdUjkRBa4P0KngWuwaz7QRhlyG4rEAdcTz03HjjEcnIYiOKsgu5KT3VPpXgw9tDZJYZn9Fm/cre0MX9MkyDH+cHXss5C9hFGLPAZSQ+EGfQQ51EWmV8p7wlDJHk/htz1TpFIMy3erYFFBQBqf+lRyFPf2j5y7r3YtjKc9nBgageOUHNv8HVI7HiSCveSy2H2j/9kQSJPl29wYCYcjWuQYYUA2ZetOiHILWAQWAnxQY1P2oTt3PUOx3ZFAFFhvQp0P5PBhlwMjP4oSg== 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:(366004)(316002)(7696005)(44832011)(956004)(2616005)(7416002)(5660300002)(6666004)(36756003)(2906002)(26005)(186003)(30864003)(86362001)(4326008)(8676002)(38100700002)(8936002)(52116002)(6916009)(38350700002)(6486002)(66556008)(508600001)(66476007)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AZV+IRFeoUW45GGrTzN5s0ohgP+ASglsMPXulWV8CLRvk9qFvLOx3bRxmGpq+NNEEF6u9/xKfack8X/M09ouPYndGywdddcbNC+VQuw3dcoeo4stkmldP7g7JhYPy8U6ytS+WSX8sImCXtTmutfQZKRX31WH6ifPS+lXgxGFlQh5Gk30YkofYWNcAF5OUXWovYSPF8ZgtbJ37qZnOWCIFovYxEQdPmFFMByBsf0BS51F4i7XfMmywZx4dWK+6bEdetCEW2ihEFwhA0pTOK7YflqhbUgUfbkpz45W1f+CE6Gfb5Y5eQGB4ZLEfk18VXExyGXHUXJneaIkMtjDYY5lp90FYaJlpVEkw9EIoONy5Z/M9txIL/3ZOtFXuFoqB9paFzZ6MtTdAkuqHFgmJoSinh5w7JN8Ju+GCJZjJ6hNlhemwt5/5xhdt/tftZS/8t8+0IBMat+d3MidY9IZQVDCiW0Afk6b33q3Z9ybtz4mnkrPJmCtQ7gt0zECYRcy4oTk9sXPqTaJqrg3F7iru77nSn9oH1x52m6Few1miidsD2ToQVVV81m9Wj2WWkW0xvMe9JagpMsvKVoMshwIOeBYxbellk4x+JCY0VHdJkgF5m4eTbhBIR5qsu7x5ke+imlZMSQMvSUizANTk+nlmpvENvnNzWzePmXO9KoigBnSDiLPDx9PO5/rBapRbeCBj6CNlaqwO2rjtbXi5Pu/dfFrS0bAtGnBVm9H4tb/z1E4698EUTJjaoYLcmfL5DwOE96eGV/TcETyYZv0ij3mSi4v/Sahmv1agZxEoWT8fjRk7PEn+yU8h71vj6JyCdsTCkKmuBiWv3/gcfhj1Iqf87weRj7FNlwfOwx3N2t03d6yv2dThUdbLffzlCHWYkCAdvA7AT7U9wiBp6yzv4uAEGwxVQDQaS5CTjn9TL8wl3a/weDVOfyEyPm1SgLRm+T1nZahH0753IWN3p79eg04cT5M3oZXf5hnAdEulgjNRvrWlDaL9356WlUL9gsC12p0rSoXca6SHmBCdyYxXCnvbAPB2CUgeOTXP3ZSDB5IKtBDliOfyLElTxpM4DB7r0XuJJ9+YWUxAR8RwV7reXdUxO7lbKoCIKA3L9szAqjpWKLe8eVcTyd6ZE0/WQcer8+UEq8G2u8AUppTtoETRCS6xJUeMVLPH09Z0qL+iDFEl2CWHDDwpu98OV6oQaQDSd3oFnbOwTUbTt3xiqsUZeFLO2/xRr0pUJH5FaR23Cw/0sgHVL2jculuzk/RdmEX3sa186THR9osIzkpNYTn0VvdUTz9XfbnAcSnNpayM1Z2Lm/GgaS1YHekzPlTsG55lApydz2EI7t5Rtwi8/5sMYse1OhBoG3n8tR/PoGUhmN9XvFuu03ZFNkU1B84O6OPGHq1NR7pCjciC71hnLKHfFy2V3p68NecAaxa2IgFUJYMTqmTC/F3ma0NxH/QStJTgHCkTWl/hSuUeNC/Ai4uxNnAEEkz+8vb+hLw6eIDtdrty0zLnkgwGS/3KBpsY1q90Jp9WsXOY/ujOI/RdiYdn9Cqnmr1ZB6fAmSIjISbZQiObaJf4pC4gFIHsXB1FOJr8jLX/lfhqkH2jAV554ot1CNjaaeOPYsqSxoxPokcdi9P0LfayCI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff6660bc-6990-49bb-0802-08d9a4343244 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2021 10:23:54.0788 (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: Vbf2jwY66rPuxcN6yEYCLx/rliN03QKjxzxfq2lFQ1rhh/BS14MtWDXbunQb9DOJhUlLGAKYjESVPIG8NTyHPg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5895 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10163 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 suspectscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111100056 X-Proofpoint-GUID: mpLXD1VbLcmFHqtZ8C1DMwvo3pZ4VNcE X-Proofpoint-ORIG-GUID: mpLXD1VbLcmFHqtZ8C1DMwvo3pZ4VNcE Received-SPF: pass client-ip=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier These new commands show the internal status of a VirtIODevice's VirtQueue and a vhost device's vhost_virtqueue (if active). Signed-off-by: Jonah Palmer --- hw/virtio/virtio-stub.c | 14 +++ hw/virtio/virtio.c | 103 ++++++++++++++++++++ qapi/virtio.json | 250 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 367 insertions(+) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index acd4148..3484b1f 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -17,3 +17,17 @@ VirtioStatus *qmp_x_query_virtio_status(const char* path, Error **errp) { return qmp_virtio_unsupported(errp); } + +VirtVhostQueueStatus *qmp_x_query_virtio_vhost_queue_status(const char *path, + uint16_t queue, + Error **errp) +{ + return qmp_virtio_unsupported(errp); +} + +VirtQueueStatus *qmp_x_query_virtio_queue_status(const char *path, + uint16_t queue, + Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index b3b3578..160cc90 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -4289,6 +4289,109 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) return status; } +VirtVhostQueueStatus *qmp_x_query_virtio_vhost_queue_status(const char *path, + uint16_t queue, + Error **errp) +{ + VirtIODevice *vdev; + VirtVhostQueueStatus *status; + + vdev = virtio_device_find(path); + if (vdev == NULL) { + error_setg(errp, "Path %s is not a VirtIODevice", path); + return NULL; + } + + if (!vdev->vhost_started) { + error_setg(errp, "Error: vhost device has not started yet"); + return NULL; + } + + VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); + struct vhost_dev *hdev = vdc->get_vhost(vdev); + + if (queue < hdev->vq_index || queue >= hdev->vq_index + hdev->nvqs) { + error_setg(errp, "Invalid vhost virtqueue number %d", queue); + return NULL; + } + + status = g_new0(VirtVhostQueueStatus, 1); + status->device_name = g_strdup(vdev->name); + status->kick = hdev->vqs[queue].kick; + status->call = hdev->vqs[queue].call; + status->desc = (uint64_t)(unsigned long)hdev->vqs[queue].desc; + status->avail = (uint64_t)(unsigned long)hdev->vqs[queue].avail; + status->used = (uint64_t)(unsigned long)hdev->vqs[queue].used; + status->num = hdev->vqs[queue].num; + status->desc_phys = hdev->vqs[queue].desc_phys; + status->desc_size = hdev->vqs[queue].desc_size; + status->avail_phys = hdev->vqs[queue].avail_phys; + status->avail_size = hdev->vqs[queue].avail_size; + status->used_phys = hdev->vqs[queue].used_phys; + status->used_size = hdev->vqs[queue].used_size; + + return status; +} + +VirtQueueStatus *qmp_x_query_virtio_queue_status(const char *path, + uint16_t queue, + Error **errp) +{ + VirtIODevice *vdev; + VirtQueueStatus *status; + + vdev = virtio_device_find(path); + if (vdev == NULL) { + error_setg(errp, "Path %s is not a VirtIODevice", path); + return NULL; + } + + if (queue >= VIRTIO_QUEUE_MAX || !virtio_queue_get_num(vdev, queue)) { + error_setg(errp, "Invalid virtqueue number %d", queue); + return NULL; + } + + status = g_new0(VirtQueueStatus, 1); + status->device_name = g_strdup(vdev->name); + status->queue_index = vdev->vq[queue].queue_index; + status->inuse = vdev->vq[queue].inuse; + status->vring_num = vdev->vq[queue].vring.num; + status->vring_num_default = vdev->vq[queue].vring.num_default; + status->vring_align = vdev->vq[queue].vring.align; + status->vring_desc = vdev->vq[queue].vring.desc; + status->vring_avail = vdev->vq[queue].vring.avail; + status->vring_used = vdev->vq[queue].vring.used; + status->used_idx = vdev->vq[queue].used_idx; + status->signalled_used = vdev->vq[queue].signalled_used; + status->signalled_used_valid = vdev->vq[queue].signalled_used_valid; + + if (vdev->vhost_started) { + VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); + struct vhost_dev *hdev = vdc->get_vhost(vdev); + + /* check if vq index exists for vhost as well */ + if (queue >= hdev->vq_index && queue < hdev->vq_index + hdev->nvqs) { + status->has_last_avail_idx = true; + + int vhost_vq_index = + hdev->vhost_ops->vhost_get_vq_index(hdev, queue); + struct vhost_vring_state state = { + .index = vhost_vq_index, + }; + + status->last_avail_idx = + hdev->vhost_ops->vhost_get_vring_base(hdev, &state); + } + } else { + status->has_shadow_avail_idx = true; + status->has_last_avail_idx = true; + status->last_avail_idx = vdev->vq[queue].last_avail_idx; + status->shadow_avail_idx = vdev->vq[queue].shadow_avail_idx; + } + + return status; +} + static const TypeInfo virtio_device_info = { .name = TYPE_VIRTIO_DEVICE, .parent = TYPE_DEVICE, diff --git a/qapi/virtio.json b/qapi/virtio.json index 6b11d52..0f65044 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -811,3 +811,253 @@ { 'command': 'x-query-virtio-status', 'data': { 'path': 'str' }, 'returns': 'VirtioStatus', 'features': [ 'unstable' ] } + +## +# @VirtQueueStatus: +# +# Information of a VirtIODevice VirtQueue, including most members of +# VirtQueue data structure. +# +# @device-name: Name of the VirtIODevice which this VirtQueue belongs +# to +# +# @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 (descriptor area) +# +# @vring-avail: VirtQueue vring.avail (driver area) +# +# @vring-used: VirtQueue vring.used (device area) +# +# @last-avail-idx: VirtQueue last_avail_idx or return of vhost_dev +# vhost_get_vring_base (if vhost active) +# +# @shadow-avail-idx: VirtQueue shadow_avail_idx +# +# @used-idx: VirtQueue used_idx +# +# @signalled-used: VirtQueue signalled_used +# +# @signalled-used-valid: VirtQueue signalled_used_valid flag +# +# Since: 6.3 +# +## + +{ 'struct': 'VirtQueueStatus', + 'data': { 'device-name': 'str', + 'queue-index': 'uint16', + 'inuse': 'uint32', + 'vring-num': 'uint32', + 'vring-num-default': 'uint32', + 'vring-align': 'uint32', + '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': 'bool' } } + +## +# @x-query-virtio-queue-status: +# +# Return the status of a given VirtIODevice VirtQueue +# +# @path: VirtIO device canonical QOM path +# +# @queue: VirtQueue index to examine +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: VirtQueueStatus of the VirtQueue +# +# Notes: last_avail_idx will not be displayed in the case where +# the selected VirtIODevice has a running vhost device +# and the VirtIODevice VirtQueue index (queue) does not +# exist for the corresponding vhost device vhost_virtqueue. +# Also, shadow_avail_idx will not be displayed in the case +# where the selected VirtIODevice has a running vhost device. +# +# Since: 6.3 +# +# Examples: +# +# 1. Get VirtQueue status for virtio-vsock (vhost-vsock running) +# +# -> { "execute": "x-query-virtio-queue-status", +# "arguments": { "path": "/machine/peripheral/vsock0/virtio-backend", +# "queue": 1 } +# } +# <- { "return": { "signalled-used": 0, +# "inuse": 0, +# "vring-align": 4096, +# "vring-desc": 5217370112, +# "signalled-used-valid": false, +# "vring-num-default": 128, +# "vring-avail": 5217372160, +# "queue-index": 1, +# "last-avail-idx": 0, +# "vring-used": 5217372480, +# "used-idx": 0, +# "device-name": "vhost-vsock", +# "vring-num": 128 } +# } +# +# 2. Get VirtQueue status for virtio-serial (no vhost) +# +# -> { "execute": "x-query-virtio-queue-status", +# "arguments": { "path": "/machine/peripheral-anon/device[0]/virtio-backend", +# "queue": 20 } +# } +# <- { "return": { "signalled-used": 0, +# "inuse": 0, +# "vring-align": 4096, +# "vring-desc": 5182074880, +# "signalled-used-valid": false, +# "vring-num-default": 128, +# "vring-avail": 5182076928, +# "queue-index": 20, +# "last-avail-idx": 0, +# "vring-used": 5182077248, +# "used-idx": 0, +# "device-name": "virtio-serial", +# "shadow-avail-idx": 0, +# "vring-num": 128 } +# } +# +## + +{ 'command': 'x-query-virtio-queue-status', + 'data': { 'path': 'str', 'queue': 'uint16' }, + 'returns': 'VirtQueueStatus', 'features': [ 'unstable' ] } + +## +# @VirtVhostQueueStatus: +# +# Information of a vhost device vhost_virtqueue, including most members of +# the vhost_dev vhost_virtqueue data structure. +# +# @device-name: Name of the VirtIODevice which this vhost_virtqueue +# belongs to +# +# @kick: vhost_virtqueue kick +# +# @call: vhost_virtqueue call +# +# @desc: vhost_virtqueue desc +# +# @avail: vhost_virtqueue avail +# +# @used: vhost_virtqueue used +# +# @num: vhost_virtqueue num +# +# @desc-phys: vhost_virtqueue desc_phys (descriptor area physical +# address) +# +# @desc-size: vhost_virtqueue desc_size (descriptor size) +# +# @avail-phys: vhost_virtqueue avail_phys (driver area physical +# address) +# +# @avail-size: vhost_virtqueue avail_size +# +# @used-phys: vhost_virtqueue used_phys (device area physical address) +# +# @used-size: vhost_virtqueue used_size +# +# Since: 6.3 +# +## + +{ 'struct': 'VirtVhostQueueStatus', + 'data': { 'device-name': 'str', + 'kick': 'int', + 'call': 'int', + 'desc': 'uint64', + 'avail': 'uint64', + 'used': 'uint64', + 'num': 'int', + 'desc-phys': 'uint64', + 'desc-size': 'uint32', + 'avail-phys': 'uint64', + 'avail-size': 'uint32', + 'used-phys': 'uint64', + 'used-size': 'uint32' } } + +## +# @x-query-virtio-vhost-queue-status: +# +# Return information of a given vhost device vhost_virtqueue +# +# @path: VirtIODevice canonical QOM path +# +# @queue: vhost_virtqueue index to examine +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: VirtVhostQueueStatus of the vhost_virtqueue +# +# Since: 6.3 +# +# Examples: +# +# 1. Get vhost_virtqueue status for vhost-crypto +# +# -> { "execute": "x-query-virtio-vhost-queue-status", +# "arguments": { "path": "/machine/peripheral/crypto0/virtio-backend", +# "queue": 0 } +# } +# <- { "return": { "avail-phys": 5216124928, +# "used-phys": 5216127040, +# "avail-size": 2054, +# "desc-size": 16384, +# "used-size": 8198, +# "desc": 140141447430144, +# "num": 1024, +# "device-name": "virtio-crypto", +# "call": 0, +# "avail": 140141447446528, +# "desc-phys": 5216108544, +# "used": 140141447448640, +# "kick": 0 } +# } +# +# 2. Get vhost_virtqueue status for vhost-vsock +# +# -> { "execute": "x-query-virtio-vhost-queue-status", +# "arguments": { "path": "/machine/peripheral/vsock0/virtio-backend", +# "queue": 0 } +# } +# <- { "return": { "avail-phys": 5182261248, +# "used-phys": 5182261568, +# "avail-size": 262, +# "desc-size": 2048, +# "used-size": 1030, +# "desc": 140141413580800, +# "num": 128, +# "device-name": "vhost-vsock", +# "call": 0, +# "avail": 140141413582848, +# "desc-phys": 5182259200, +# "used": 140141413583168, +# "kick": 0 } +# } +# +## + +{ 'command': 'x-query-virtio-vhost-queue-status', + 'data': { 'path': 'str', 'queue': 'uint16' }, + 'returns': 'VirtVhostQueueStatus', 'features': [ 'unstable' ] } From patchwork Wed Nov 10 10:23:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 1553356 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2021-07-09 header.b=hgSwt8Fm; dkim=pass (1024-bit key; unprotected) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-oracle-onmicrosoft-com header.b=IiXu7QB7; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hq1Q42Bf4z9sCD for ; Wed, 10 Nov 2021 21:32:44 +1100 (AEDT) Received: from localhost ([::1]:53560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mkkuI-0006Qg-2L for incoming@patchwork.ozlabs.org; Wed, 10 Nov 2021 05:32:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkkmB-0002Tt-H1; Wed, 10 Nov 2021 05:24:21 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:31286) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkkm7-0005Cx-5X; Wed, 10 Nov 2021 05:24:17 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AA9SpV8032545; Wed, 10 Nov 2021 10:24:00 GMT 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-2021-07-09; bh=BfqZRVbaK5S/qhphPGr0frgjJ6jUxS3G9llv8/NdDI4=; b=hgSwt8FmPukWgRHWCRKawZFCahctsGm8BKk+yvT55BPiHlyPBoOTU2rGSzujZ4KJJ3kY aifwnySws3l/v5P8Pcc/jsfcfRYy8gGdpruv8OIcxk/DzbozHJdowGvfdLNXhuLSMlOi CCIp8c2rv2i3yV05mLKdxQxmoN70jt9R4wGSH9iod6PuSj36ONXM5CMyg5Axv0HXaghM jTFQCiMzU7Irva32nyPGx+bEsQxLUMIzbB5sP/rMRKEfmAE2Kmox6hk91RGoGg3Yfpza UBYt8fkMN3YFOtNn3djMW+xK89icOw+dI8BFBOQDpXMth1NFYWhkkDZne6QeMKUBQjy8 Nw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3c82vgap7v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Nov 2021 10:24:00 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AAAGOCZ034660; Wed, 10 Nov 2021 10:23:59 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by aserp3030.oracle.com with ESMTP id 3c5frfd2yq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Nov 2021 10:23:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YNnGQ7ilSLG+p8eh5ky/sWZTJULcHD+Szc7WLX5nWTzYMnpW8EejQxLeBXV5gNBoMB2rkGm2ideCAxevNkacYboT/gubf5155N97hBfbV0TOxD8ZVgLu2T0nF4TPYuxB2l380zlYjzieXqC5t3bB9ycbbQ0q7+HnjzzYNyXPf8gRk7p1RBqYq8ZhCLNWsHczwAMfQHdsQOwZP5DRAzfXcjumqSUTsFSRnwZF7C2mwpXkaretqUrhILVZhllZKsoiedP1W1+hJJlCRE0D2xfT3iSazacjYO9kuvVce8kMN3Y4jvBcgfnNrk/bCvVByHAyVjeKZwKMeWjXyzEyJJjCQw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BfqZRVbaK5S/qhphPGr0frgjJ6jUxS3G9llv8/NdDI4=; b=ReKMTkAUSGafUxUoOOMpdJ5FZ6kFMlzrvhoK7S6w59qiFObmNKvh+y2yQchxVa5nCQ8cTtsXOgOddMZ+XD1eWlDCN1SrGS+qgUvieWUfFA+kaLh+gkKbX/+1/MOnetcN6V0/MpL2pmyL+W+zhFNoR+5X1eXPRCxHPkipjHIFNUzgAuQdrjJJDvHTfuIwVv9ziakJtnw5AeIjm4bPJ97TF9xqi4O1q47rpXSHjvJcAUVD0i2oLIalBTq/xkrTP5KAtriRJtroLn8MRtZwRrx/pqnfkTIPuRvXmJ0OzTsi5YF2JlwdTSZsbt3mHjKP/63TmU99ZNVB5s9M6NhZMUflAg== 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=BfqZRVbaK5S/qhphPGr0frgjJ6jUxS3G9llv8/NdDI4=; b=IiXu7QB7BW3CNAYCrbnDY5dBtDmc8SjdRcMsuqPJtainvPTkXcXp0hnXkYa4ye/sO4BJVje5EgAXDuc2UcEf0vw1XXZF+ece9XRjA15wzmXxdseHlM5ixN8swCHIiBPnd2WnoHqqqXHQgDnvFsL5taxPgu3PQF+3mXpDhPW6rmQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB5895.namprd10.prod.outlook.com (2603:10b6:510:14c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.16; Wed, 10 Nov 2021 10:23:56 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%5]) with mapi id 15.20.4669.016; Wed, 10 Nov 2021 10:23:56 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v9 7/8] qmp: add QMP command x-query-virtio-queue-element Date: Wed, 10 Nov 2021 05:23:11 -0500 Message-Id: <1636539792-20967-8-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1636539792-20967-1-git-send-email-jonah.palmer@oracle.com> References: <1636539792-20967-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SN4PR0501CA0112.namprd05.prod.outlook.com (2603:10b6:803:42::29) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 Received: from jonpalme-lnx.us.oracle.com (209.17.40.43) by SN4PR0501CA0112.namprd05.prod.outlook.com (2603:10b6:803:42::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.5 via Frontend Transport; Wed, 10 Nov 2021 10:23:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e574944a-f882-45d4-7869-08d9a43433ee X-MS-TrafficTypeDiagnostic: PH0PR10MB5895: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3GfOOUz07mRDJMRHLk5NQxlj0vEOApE7yB7NJ59bDkGr8E9CWKdY8x4spvAtc/0zfoB+DFSVzMnP8n9LhZdMXgfP7i/zX8WdrRb/4TirSqHfOWSC3jai8evf6UnCACeeIBOx3zp7ue99OWN6egqNq6Oz2Np5Ip8493KwLaosxF83Pfok5T6e6PCPivBI8g2SuvxhEFmgojV4AVSqHvnUdUgm+89R+aJ5k1NZCjl9Q2iUTEQIxIrjjnOA8h3DCGpJr4cCINrJgnkMJS579CNuc4JaaIc8nEJLzyZzxOnkra1TzDJKWzud3R9XDxlNhFdDgJgG7dlU9mUyeWX/Fi0YsjGXy8+/2FlnNlTGb/QfthqjjhP5HT+qwer+v8oTCL6ZKCjo11O04L92pBlcU/44424CdDXAJq3f+HSSyLqXFs53S6n6HOFUJibye8LQ8dT/3i8Nh6JxYEGO5L1zDWx9siddZbH7b7ZTs+76+Bq0xlS/u9+1Rd20VuhUEhTQ2YJaoYcr9HIulPtt47P4MomWwz44I3hdQyk14DZwzZe+qqxNM2Ym0eGRmy3ja+dYVkshLNIn10MJIdlxloBwm7Do0usihZqBJXqvF2vBY3SHxCMofsuWI1dYyTKsXcOHykeiI9Ngls8BjeiFwPsA5s15S7eNLU0WTIvscA1hNeP7XUTIrabrNfTf5KWkAZrpf9qszG3Y/J37B7RZcaUXGKk8uA== 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:(366004)(316002)(7696005)(44832011)(83380400001)(956004)(2616005)(7416002)(5660300002)(6666004)(36756003)(2906002)(26005)(186003)(86362001)(4326008)(8676002)(38100700002)(8936002)(52116002)(6916009)(38350700002)(6486002)(66556008)(508600001)(66476007)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1hIkHAxx8Mkn1q71sBz+bDS4jeu3I3+XzGgKeAHXd+e8JeJM3I4fhZGTdg+nQVcDZcS+gdDoR3wc/jVT+2I+O6L4/G9OiCzJL8kgOgj748fqbGC56qhGYCS0YXeexIZD4gVw+E6V4Xuv1Fwlle88tHQQW4nPgm5+fOZeC0FHjPtkEdSy5WAdepeRIXo3Aw3PX7y8VLOnCtAU9uLANtI8378ObfFfgAszgAXTGrtDgenQXv1EbCY54bhgeelXDsSqBczS+0aOV/Ny3WGxOKm2TvpV+8VeTm5q8Qo91ghxCztI6+P8ziDRCQGWZOhhm+dywcFZI6seiDi2UPLdI1BWI0jG7d1/FOkyOiOPYkJZbT92MxBYIe4zJj042NqmhYuxADqfSB0BrtfnakfBwIp4rl4hlvaJMTa5dhyAdapQcorsd49ByYiHZ+5GoE0TLZYXizlcwRxxWY/5WHigflJj3P1XfSiPf3ht/Dtt8e+ALt/IBKFTtWji5dlp3vAmCGprfVNCpnBcdrcjzB3eQo4k2jMoP8aiE3oVwOA26JYvEZsFdyhrw7fdEVH67kT2WQET33QgKFwCPt4cm7KJiF2iwASlGIZApREiOBt1MXYYY24NvVpn/2/kPruc2y8zdFb+PqMMtuSKMBK2jx/tro9nJSHhqPXyFxGEqQ+LKhSmEBmaG35hCE48Ygz+SLerKt3+BekDusz/a/A92UxXjxFqyUR67L4YNjkV30ZfYVoM3Cyf7dWjD+1qSwzZPECxZx1kg1xNTP0RMyeUyyMWjaPvLzDieUg4edlBsQLiEskC3zPVLhnLOCHPUaKVssAIh8wxWNCx/iv31SDMZ3kTcexLm1G1S/s6lXsJVM4v3FKtCnetrUY8mkkz8hBhmzetjxYQgVqSUlEY8HkJEbTvvCaX1y//AGynIpzSJmGZlAirn+TqcaDd/N5fIUGbVuKMy+QMtkmw+2JZdQKXWsRfTFEpPuKfwEl0DMb8ZnLWVQUb/HN1nlv6U/unOtUzNygIFnCN4DBG7XYMONCTHX2ZbtlI/4QbQWuLOQlwKsYvRsm0ApePHHKOUdgBGe4MSNpXrViXRMwgjz8Vr7hfeu19Tdy+la60cGZ5ZVDUFw/vON3D8FzujoWREjupt1DmwbV1A+LAWnfhvq+ItyvhXJlCkwQo3+sdZmfkHoQdAhVQCsOYBcQG4KsXypz4qne3PDoqHzYkOiAJDeP7CeHhrf2BAtBGN5ucgu4oMHfJpCnN97IHfG7yY5BMqYaFT+FnUB7fSbgpJjYgj6yCeEfBYTEpMGWpDdqXIA68FT4l6KfDTrIZgB8l8QpzgyD80Kj4EdMQmb+6D7hpVLVN5CiS/t5k0IRuuMk6J0yj4IimKKqKhC4dJ0zNXrfC2L3udBIVjULu8XBdKr+yfwqKo5SU0VBcgE6keaVVkx4X1ZL2ClE0aLQltMZQjbd7JKwzScJgD222F5KS6pY8Q17+o/mTsiV7dU8kxFk95FKB435N/hxXnMNwGzQNk1hXSkvxvVK52e/ia5UTNq8N3gSY6MLiZM4KAh4V+6wI3vJ2fywGZbQz8Jz3ghVfcbAmkCPzyG2gC8GhagzW2+yyL62zr0DMEVFUDqYLLwkSWkQGy533JuzaYpPLZ3s= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e574944a-f882-45d4-7869-08d9a43433ee X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2021 10:23:56.7291 (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: QPH5GO+KmHzkoEiOHanAkFsX9njpJttXEm0OCr1D7be0gvHQByTGIp8VE3GszuZLsH4oesaw/6IJrtVz6irV3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5895 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10163 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 suspectscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111100056 X-Proofpoint-ORIG-GUID: qlCKodIlkYix4-4RbhJWCxjDV-O2XQck X-Proofpoint-GUID: qlCKodIlkYix4-4RbhJWCxjDV-O2XQck Received-SPF: pass client-ip=205.220.177.32; envelope-from=jonah.palmer@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier This new command shows the information of a VirtQueue element. Signed-off-by: Jonah Palmer --- hw/virtio/virtio-stub.c | 9 +++ hw/virtio/virtio.c | 154 +++++++++++++++++++++++++++++++++++++++++ qapi/virtio.json | 177 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 340 insertions(+) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index 3484b1f..810317c 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -31,3 +31,12 @@ VirtQueueStatus *qmp_x_query_virtio_queue_status(const char *path, { return qmp_virtio_unsupported(errp); } + +VirtioQueueElement *qmp_x_query_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 160cc90..6df6a85 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -480,6 +480,19 @@ static inline void vring_used_write(VirtQueue *vq, VRingUsedElem *uelem, address_space_cache_invalidate(&caches->used, pa, sizeof(VRingUsedElem)); } +/* Called within rcu_read_lock(). */ +static inline uint16_t vring_used_flags(VirtQueue *vq) +{ + VRingMemoryRegionCaches *caches = vring_get_region_caches(vq); + hwaddr pa = offsetof(VRingUsed, flags); + + if (!caches) { + return 0; + } + + return virtio_lduw_phys_cached(vq->vdev, &caches->used, pa); +} + /* Called within rcu_read_lock(). */ static uint16_t vring_used_idx(VirtQueue *vq) { @@ -4392,6 +4405,147 @@ VirtQueueStatus *qmp_x_query_virtio_queue_status(const char *path, return status; } +static VirtioRingDescFlagsList *qmp_decode_vring_desc_flags(uint16_t flags) +{ + VirtioRingDescFlagsList *list = NULL; + VirtioRingDescFlagsList *node; + int i; + + struct { + uint16_t flag; + VirtioRingDescFlags value; + } map[] = { + { 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 = 0; map[i].flag; i++) { + if ((map[i].flag & flags) == 0) { + continue; + } + node = g_malloc0(sizeof(VirtioRingDescFlagsList)); + node->value = map[i].value; + node->next = list; + list = node; + } + + return list; +} + +VirtioQueueElement *qmp_x_query_virtio_queue_element(const char *path, + uint16_t queue, + bool has_index, + uint16_t index, + Error **errp) +{ + VirtIODevice *vdev; + VirtQueue *vq; + VirtioQueueElement *element = NULL; + + vdev = virtio_device_find(path); + if (vdev == NULL) { + error_setg(errp, "Path %s is not a VirtIO device", path); + return NULL; + } + + if (queue >= VIRTIO_QUEUE_MAX || !virtio_queue_get_num(vdev, queue)) { + error_setg(errp, "Invalid virtqueue number %d", queue); + return NULL; + } + vq = &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 = MEMORY_REGION_CACHE_INVALID; + MemoryRegionCache *desc_cache; + VRingDesc desc; + VirtioRingDescList *list = NULL; + VirtioRingDescList *node; + int rc; + + RCU_READ_LOCK_GUARD(); + + max = vq->vring.num; + + if (!has_index) { + head = vring_avail_ring(vq, vq->last_avail_idx % vq->vring.num); + } else { + head = vring_avail_ring(vq, index % vq->vring.num); + } + i = head; + + caches = 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 = &caches->desc; + vring_split_desc_read(vdev, &desc, desc_cache, i); + if (desc.flags & VRING_DESC_F_INDIRECT) { + int64_t len; + len = address_space_cache_init(&indirect_desc_cache, vdev->dma_as, + desc.addr, desc.len, false); + desc_cache = &indirect_desc_cache; + if (len < desc.len) { + error_setg(errp, "Cannot map indirect buffer"); + goto done; + } + + max = desc.len / sizeof(VRingDesc); + i = 0; + vring_split_desc_read(vdev, &desc, desc_cache, i); + } + + element = g_new0(VirtioQueueElement, 1); + element->avail = g_new0(VirtioRingAvail, 1); + element->used = g_new0(VirtioRingUsed, 1); + element->device_name = g_strdup(vdev->name); + element->index = head; + element->ndescs = 0; + element->avail->flags = vring_avail_flags(vq); + element->avail->idx = vring_avail_idx(vq); + element->avail->ring = head; + element->used->flags = vring_used_flags(vq); + element->used->idx = vring_used_idx(vq); + + do { + /* A buggy driver may produce an infinite loop */ + if (element->ndescs >= max) { + break; + } + node = g_new0(VirtioRingDescList, 1); + node->value = g_new0(VirtioRingDesc, 1); + node->value->addr = desc.addr; + node->value->len = desc.len; + node->value->flags = qmp_decode_vring_desc_flags(desc.flags); + node->next = list; + list = node; + + element->ndescs++; + rc = virtqueue_split_read_next_desc(vdev, &desc, desc_cache, + max, &i); + } while (rc == VIRTQUEUE_READ_DESC_MORE); + element->descs = list; +done: + address_space_cache_destroy(&indirect_desc_cache); + } + + return element; +} + static const TypeInfo virtio_device_info = { .name = TYPE_VIRTIO_DEVICE, .parent = TYPE_DEVICE, diff --git a/qapi/virtio.json b/qapi/virtio.json index 0f65044..c57fbc5 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -1061,3 +1061,180 @@ { 'command': 'x-query-virtio-vhost-queue-status', 'data': { 'path': 'str', 'queue': 'uint16' }, 'returns': 'VirtVhostQueueStatus', 'features': [ 'unstable' ] } + +## +# @VirtioRingDescFlags: +# +# An enumeration of the virtio ring descriptor flags +# +# Since: 6.3 +# +## + +{ 'enum': 'VirtioRingDescFlags', + 'data': [ 'next', 'write', 'indirect', 'avail', 'used' ] +} + +## +# @VirtioRingDesc: +# +# Information regarding the VRing descriptor area +# +# @addr: guest physical address of the descriptor data +# +# @len: length of the descriptor data +# +# @flags: list of descriptor flags +# +# Since: 6.3 +# +## + +{ 'struct': 'VirtioRingDesc', + 'data': { 'addr': 'uint64', + 'len': 'uint32', + 'flags': [ 'VirtioRingDescFlags' ] } } + +## +# @VirtioRingAvail: +# +# Information regarding the avail VRing (also known as the driver +# area) +# +# @flags: VRingAvail flags +# +# @idx: VRingAvail index +# +# @ring: VRingAvail ring[] entry at provided index +# +# Since: 6.3 +# +## + +{ 'struct': 'VirtioRingAvail', + 'data': { 'flags': 'uint16', + 'idx': 'uint16', + 'ring': 'uint16' } } + +## +# @VirtioRingUsed: +# +# Information regarding the used VRing (also known as the device +# area) +# +# @flags: VRingUsed flags +# +# @idx: VRingUsed index +# +# Since: 6.3 +# +## + +{ 'struct': 'VirtioRingUsed', + 'data': { 'flags': 'uint16', + 'idx': 'uint16' } } + +## +# @VirtioQueueElement: +# +# Information regarding a VirtQueue VirtQueueElement including +# descriptor, driver, and device areas +# +# @device-name: name of the VirtIODevice which this VirtQueue belongs +# to (for reference) +# +# @index: index of the element in the queue +# +# @ndescs: number of descriptors +# +# @descs: list of the descriptors +# +# @avail: VRingAvail info +# +# @used: VRingUsed info +# +# Since: 6.3 +# +## + +{ 'struct': 'VirtioQueueElement', + 'data': { 'device-name': 'str', + 'index': 'uint32', + 'ndescs': 'uint32', + 'descs': [ 'VirtioRingDesc' ], + 'avail': 'VirtioRingAvail', + 'used': 'VirtioRingUsed' } } + +## +# @x-query-virtio-queue-element: +# +# Return the information about a VirtQueue VirtQueueElement (by +# default looks at the head of the queue) +# +# @path: VirtIODevice canonical QOM path +# +# @queue: VirtQueue index to examine +# +# @index: the index in the queue, by default head +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: VirtioQueueElement information +# +# Since: 6.3 +# +# Examples: +# +# 1. Introspect on virtio-net virtqueue 0 at index 5 +# +# -> { "execute": "x-query-virtio-queue-element", +# "arguments": { "path": "/machine/peripheral-anon/device[1]/virtio-backend", +# "queue": 0, +# "index": 5 } +# } +# <- { "return": { +# "index": 5, +# "ndescs": 1, +# "device-name": "virtio-net", +# "descs": [ { "flags": ["write"], "len": 1536, "addr": 5257305600 } ], +# "avail": { "idx": 256, "flags": 0, "ring": 5 }, +# "used": { "idx": 13, "flags": 0 } } +# } +# +# 2. Introspect on virtio-crypto virtqueue 1 at head +# +# -> { "execute": "x-query-virtio-queue-element", +# "arguments": { "path": "/machine/peripheral/crypto0/virtio-backend", +# "queue": 1 } +# } +# <- { "return": { +# "index": 0, +# "ndescs": 1, +# "device-name": "virtio-crypto", +# "descs": [ { "flags": [], "len": 0, "addr": 8080268923184214134 } ], +# "avail": { "idx": 280, "flags": 0, "ring": 0 }, +# "used": { "idx": 280, "flags": 0 } } +# } +# +# 3. Introspect on virtio-scsi virtqueue 2 at head +# +# -> { "execute": "x-query-virtio-queue-element", +# "arguments": { "path": "/machine/peripheral-anon/device[2]/virtio-backend", +# "queue": 2 } +# } +# <- { "return": { +# "index": 19, +# "ndescs": 1, +# "device-name": "virtio-scsi", +# "descs": [ { "flags": ["used", "indirect", "write"], "len": 4099327944, +# "addr": 12055409292258155293 } ], +# "avail": { "idx": 1147, "flags": 0, "ring": 19 }, +# "used": { "idx": 1147, "flags": 0 } } +# } +# +## + +{ 'command': 'x-query-virtio-queue-element', + 'data': { 'path': 'str', 'queue': 'uint16', '*index': 'uint16' }, + 'returns': 'VirtioQueueElement', 'features': [ 'unstable' ] } From patchwork Wed Nov 10 10:23:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 1553351 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2021-07-09 header.b=BVffv9qD; dkim=pass (1024-bit key; unprotected) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-oracle-onmicrosoft-com header.b=jCiHn0MB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hq1FM3VV3z9sCD for ; Wed, 10 Nov 2021 21:25:11 +1100 (AEDT) Received: from localhost ([::1]:36434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mkkmz-00031r-1i for incoming@patchwork.ozlabs.org; Wed, 10 Nov 2021 05:25:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkkmF-0002W6-8d; Wed, 10 Nov 2021 05:24:23 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:35594) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkkmA-0005EZ-06; Wed, 10 Nov 2021 05:24:21 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AA9SwW8002010; Wed, 10 Nov 2021 10:24:02 GMT 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-2021-07-09; bh=fNPkPN4B7NvFd0NIVZQrcjh/Vt8R8dlbUDX2yGPcKMY=; b=BVffv9qDK/Qm88Q84IcJIqrCAzSnFYS/NsUktxhOhBx39msj8eWuVXGuy3uutI9ZbgjV ez0St6wpkks28jWkJ0c5GcUr6zC7MDyXYcja80qnOsXbfc63+PM/6CFpiqhZjD62iQF8 cJhxFZtrZZRMIztv4b74KT6ngvanXRB4og62l/t7Xkr190iaTDaMcDzMkvNhNcpCz74o SUas/GYtDK7AfM0AxeOH2o6Eqb2g3WqrWRF6nGA5xj508iE61rhm5JdagY5hhztrNoqJ BFTp1hGNwIowFhJgZv7mLaFOpP6gRbjAz+j90jgl0t0hweNKOVcHCXo4GQcUoRRkmEO3 iA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3c880rsen5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Nov 2021 10:24:02 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AAAGbNd134555; Wed, 10 Nov 2021 10:24:01 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2047.outbound.protection.outlook.com [104.47.56.47]) by aserp3020.oracle.com with ESMTP id 3c5hh52tvh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Nov 2021 10:24:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nbxVujjxct0wSZoLiFPVpPtZw9fv7Y3NoRYzZZ/9UJy/a5V0kG2qi+2hTtlNjlbWAQ0AuOIoakUz62QYUqOaI4+hrlovpS1VX8eDRRyVkvxkz8iyMaMn0y5uDnE3fw9Qcb8/BYqtZeSi2kT2o+D44IohRmdcCHgV1oXAgS8nqx6txCsWoxiMDx7t9j958FVEqkxTYemQuk4R1Xc5l0NyxKE5G+wTbECKPoyY/IHvl1xks57CwZGFQ83a+6a/uwSaGmW1BG22hY5PCKN6gJOw8TTcdxrz6N1UvCq0W91+pK7je7NUHUsW7kKbqYg2pA6MgvwZmqyWTliAYG9MDm+1ig== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fNPkPN4B7NvFd0NIVZQrcjh/Vt8R8dlbUDX2yGPcKMY=; b=DKkUfxPsPRsO3JLPOES0kQwNpHHdWWHBx2nF9HAyKlxVPGMWYMXD+7SS7Dx7RXaOmLrv5+7WR7ThKuNuSGOOLQZu6jEZv/OivvwfAL4aBrpo6X3YXlGf84WuS2T4FsJrmjsr4EnxHh5uhh9mGhDqF9v7xomgMlH7bRXxKyijxcjNg1Hn6fUYo7HuvlOWSTjK0x6BMGqylNg6k9w75jwiM+cc7uB1VssLUvBbQyQPA2J0SqTPU1vFjkyLaf+lpM5IaPOjY4wI5Hcb9fD6/B/WOzwwTkzR+c/qKwxgZkIZxppjageunhIktLHUG6Vg34VIpCq2II/LIgGRIloAkuxTjg== 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=fNPkPN4B7NvFd0NIVZQrcjh/Vt8R8dlbUDX2yGPcKMY=; b=jCiHn0MBR/zRPMLaRd7GDfosoTv6wdimvthfMSeieqSy5lm/GYYpm0R5mr+sZJrM3Qud46kYnBOnbmkP+4unE0RURVz+5xvOom+NFEy8O7djPPo6kR6eInqDY+DcMziCnuP8QdLfhK/ZVOMCi49cglQHgnY55igjkGHUX5VG34M= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB5895.namprd10.prod.outlook.com (2603:10b6:510:14c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.16; Wed, 10 Nov 2021 10:23:59 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%5]) with mapi id 15.20.4669.016; Wed, 10 Nov 2021 10:23:59 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v9 8/8] hmp: add virtio commands Date: Wed, 10 Nov 2021 05:23:12 -0500 Message-Id: <1636539792-20967-9-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1636539792-20967-1-git-send-email-jonah.palmer@oracle.com> References: <1636539792-20967-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SN4PR0501CA0112.namprd05.prod.outlook.com (2603:10b6:803:42::29) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 Received: from jonpalme-lnx.us.oracle.com (209.17.40.43) by SN4PR0501CA0112.namprd05.prod.outlook.com (2603:10b6:803:42::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.5 via Frontend Transport; Wed, 10 Nov 2021 10:23:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 95097687-989d-424e-44cc-08d9a434355e X-MS-TrafficTypeDiagnostic: PH0PR10MB5895: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:173; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OuXRJR/25YnXlyqhD3AnJUHAMWslDfW/OBJyaJMRMfSKzAAedelpmN1MlrbiD++IVzWD3QuEmz3160iB3sAxP6aLbKRuAKRmV4aAfu+XilrHuBclyPTsbMAuNMh7NhSpfxEJPe7y6Yuv2sOFPn8hLsUdatZ9Vbv49kFVcBEOAlutKLA0R0CXP2DLT4rUEDVOLYUV5Ff9R5cIoeP16ncRxYSHWjgjX3lDLo1UGUZfByr1g/sSlc2HM7f+KUd5XHEVcLbh2Dxci8DFxtbAVI+eNdvbetf6UURMlyFAwhrR5q76ugQPuMK45ngt5pbFuwhJX/WuLQujghmWILl8ItJQ2f+/n4omWnf+bD1cW2r+2ryZFML0L/20xKFtqrRNPdzkN66yxMpPm+1AfIENoJDhv/jKSnLzGs8PTJuCitxKJaFI5koxAcvQddX8iqPwO9FQ62UUZSeszifG6UU5gdM2qPq3xe/FHGRLA26FLPpKencdMrqCxTOnEhZu6wJrGPw/3OBNn+zDeh0MkgX6/Bpmc+S7b3D9bBdMrcVWzBQEltpBYtzmPmJTRNUgp+qZl9TEH28Gjj9YcVZIr3LhP8WzKgBBGV35+KW38kVE35fyqx8ieCNLhIH27u5ymUkr3Kso5RLSq3mugBTF/B3mg7FP9EPZteJkBgaY9L/FAsEm4K4Xpx/M7XAdTj4ZOLozQpBfl7Ac0YtJqG6nkz1mH+X9yA== 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:(366004)(316002)(7696005)(44832011)(83380400001)(956004)(2616005)(7416002)(5660300002)(6666004)(36756003)(2906002)(26005)(186003)(30864003)(86362001)(4326008)(8676002)(38100700002)(8936002)(52116002)(6916009)(38350700002)(6486002)(66556008)(508600001)(66476007)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UeB0ea0MLzV0z65eftkDLumsfZ2AeWdWWsTXxORTnai7Mm/oxAVi67PyFDIGAmk7gjnMJjhbTYCZU0sx2SkQt35BluS6xs7notuNIsPYMzmOJFStXCae4gv9no8xTmyev551pzMv4go928OFwQqsuogxAlyq8PMb5cvxXrPSbIWcOLteTJBcG5dwzX65W3amG/2QixRboR+3ivmH1+TILebYClaM7cyBOPPZnrOi+G0EdoZyBHTWaPf/yr+JcaODhq37TSl0wJrR7mA5rtveBmW85u5jHBhDn6+JWeUKHT1EXv4g44/AIkmaQtDxL+befmxAoGfqeuOvI9pCQHM5doK/G2PwvlhQ6l+M8hOa5J23nWKy77dyDuGp+Yk7jwFvg6nzpaot1ux/of8d9sq1Wf0piVYIcVnrkNLOO3vx5r+zHHV5mfH0QDYvxugtiskR4RPM3e77oc3x1qcWZZAOlbAIH3WyDa1Z5pil/hLb7PMvjUP6UslGxZ1cwS09Eoi5g/RtvE7ooeCe4XrsL0XsjSAWgXRnESA7PZspNKjeXDQDW/lI1DqsUN9p1XiwqG6rcU3Kl60CMLQ2lzzB8Kd1N4AKc1ZHOOWVGGnR8LikrI7DHPVrI88Ik7A55sK9YpZfSniKey+Dq4gIpvtRbAY5dRIVZzJujv9bWFoE1co1HExRHVumXfBnhH9LiNRl4TKeHBroxeS3DgLG7q00mncxqV7Pf1BBuVzUaPe63zJ03wiV6F0z8mW8uK2+iU5cwaPsrdg+18X6WmLvLm1QKGzq4KBMSHAGcSKMPZDJt18u0cJT5hYVaw46nyMjmoe49OrHIrLr0wXD0rtQycDk5alJVKKy0G3FkqcctP9YEm/dUmUU79j3XJjVB+mKvoA8sjMNWAxq5H6VF2BTsJfVR4ak0uXaiHxhoVvTUy9vzIvNxBTCwog50DocV8Bdi+KkYZuDR3oXZXUavyyUvMJOEP2iqqvCRDxaqTOy+KGgVmCHJTBPG/0XPUaxxC7aeXxsrV3Cxrzr8KSDjpCmQEqor6+kziDVH07Jh9Zzl9906+RWqIgCCBxnwj5OuSdoB5ZaryJXcY3X39IrUlrFIsvWnlY9//5rBA/mNtW7A6jq67qJ2gs0YrHAPYHzyzJSYBy+zB/DPcGzDYhwJu+cTbkcmt9mgebYJYRAcqqi+Wkcbzg9392eS0SQuGRpAAwU+yg553NcPW0iHDCJUtfKfVupjr9YvAL2VPHOxjjQB3X7eeg1x+s1yFt8JXA3QBP/Fw/KLTXErnTpR1KqB4/vynVg/p5mNEwky+rt8SD+16Z8xN5X7EeoRgv1OAmWn2Bqj9z3FsmXGxqzSk3PdD5DCiRRVFFpDJ0xkEklkW6vqLZbQZie0jFAsUuH5Rc0iIu2D+hQgtN2o6ptZVe9D4mWEX/CXCacM2pelj2XLOVLAAzK1ATQQyq8i9WjWlmQ//jzduAESIaw93A0vLXyGUFMR061qY3labhmQ9/JFdmuD3SRJBEpmQmr43WNOVthQ6Rps8KLXCMI8zNDv5dMK3kpKo+yiI4LPwmtOQwzWLygZUJc8CtHx8JQ0/hChGOcTLDNvDugiF9K5xcZaFoteLF2z+AAmpwdEp3AY0AiohZXpqv4aLtC0Do= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95097687-989d-424e-44cc-08d9a434355e X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2021 10:23:59.1943 (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: a6/UooCKacDqtOglJUK7i1tJW2t1uR/EJYdHqriUCkDYFQ/YeIV3043jUdFRhWrp7nE/nU0fkH+XZx10iE6WaQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5895 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10163 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 mlxscore=0 malwarescore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111100056 X-Proofpoint-GUID: 3yprltFA9DFSEFQm5Nzg8FDNT9lzva63 X-Proofpoint-ORIG-GUID: 3yprltFA9DFSEFQm5Nzg8FDNT9lzva63 Received-SPF: pass client-ip=205.220.177.32; envelope-from=jonah.palmer@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier This patch implements the HMP versions of the virtio QMP commands. Signed-off-by: Jonah Palmer --- hmp-commands-info.hx | 218 ++++++++++++++++++++++++++++++ include/monitor/hmp.h | 5 + monitor/hmp-cmds.c | 358 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 581 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 407a1da..6bf7359 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -877,3 +877,221 @@ SRST ``info sgx`` Show intel SGX information. ERST + + { + .name = "virtio", + .args_type = "", + .params = "", + .help = "List all available virtio devices", + .cmd = hmp_virtio_query, + .flags = "p", + }, + +SRST + ``info virtio`` + List all available virtio devices + + Example: + + List all available virtio devices in the machine:: + + (qemu) info virtio + /machine/peripheral/vsock0/virtio-backend [vhost-vsock] + /machine/peripheral/crypto0/virtio-backend [virtio-crypto] + /machine/peripheral-anon/device[2]/virtio-backend [virtio-scsi] + /machine/peripheral-anon/device[1]/virtio-backend [virtio-net] + /machine/peripheral-anon/device[0]/virtio-backend [virtio-serial] + +ERST + + { + .name = "virtio-status", + .args_type = "path:s", + .params = "path", + .help = "Display status of a given virtio device", + .cmd = hmp_virtio_status, + .flags = "p", + }, + +SRST + ``info virtio-status`` *path* + Display status of a given virtio device + + Example: + + Dump the status of virtio-net (vhost on):: + + (qemu) info virtio-status /machine/peripheral-anon/device[1]/virtio-backend + /machine/peripheral-anon/device[1]/virtio-backend: + device_name: virtio-net (vhost) + device_id: 1 + vhost_started: true + bus_name: (null) + broken: false + disabled: false + disable_legacy_check: false + started: true + use_started: true + start_on_kick: false + use_guest_notifier_mask: true + vm_running: true + num_vqs: 3 + queue_sel: 2 + isr: 1 + endianness: little + status: acknowledge, driver, features-ok, driver-ok + Guest features: event-idx, indirect-desc, version-1 + ctrl-mac-addr, guest-announce, 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-guest-offloads, guest-csum, csum + Host features: protocol-features, event-idx, indirect-desc, version-1, any-layout, + notify-on-empty, gso, ctrl-mac-addr, guest-announce, ctrl-rx-extra, 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-guest-offloads, + guest-csum, csum + Backend features: protocol-features, event-idx, indirect-desc, version-1, any-layout, + notify-on-empty, gso, ctrl-mac-addr, guest-announce, ctrl-rx-extra, 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-guest-offloads, + guest-csum, csum + VHost: + nvqs: 2 + vq_index: 0 + max_queues: 1 + n_mem_sections: 4 + n_tmp_sections: 4 + backend_cap: 2 + log_enabled: false + log_size: 0 + Features: event-idx, indirect-desc, iommu-platform, version-1, any-layout, + notify-on-empty, log-all, mrg-rxbuf + Acked features: event-idx, indirect-desc, version-1, mrg-rxbuf + Backend features: + Protocol features: + +ERST + + { + .name = "virtio-queue-status", + .args_type = "path:s,queue:i", + .params = "path queue", + .help = "Display status of a given virtio queue", + .cmd = hmp_virtio_queue_status, + .flags = "p", + }, + +SRST + ``info virtio-queue-status`` *path* *queue* + Display status of a given virtio queue + + Example: + + Dump the status of the 6th queue of virtio-scsi:: + + (qemu) info virtio-queue-status /machine/peripheral-anon/device[2]/virtio-backend 5 + /machine/peripheral-anon/device[2]/virtio-backend: + device_name: virtio-scsi + queue_index: 5 + inuse: 0 + used_idx: 605 + signalled_used: 605 + signalled_used_valid: true + last_avail_idx: 605 + shadow_avail_idx: 605 + VRing: + num: 256 + num_default: 256 + align: 4096 + desc: 0x000000011f0bc000 + avail: 0x000000011f0bd000 + used: 0x000000011f0bd240 + +ERST + + { + .name = "virtio-vhost-queue-status", + .args_type = "path:s,queue:i", + .params = "path queue", + .help = "Display status of a given vhost queue", + .cmd = hmp_vhost_queue_status, + .flags = "p", + }, + +SRST + ``info virtio-vhost-queue-status`` *path* *queue* + Display status of a given vhost queue + + Example: + + (qemu) info virtio-vhost-queue-status /machine/peripheral/vsock0/virtio-backend 1 + /machine/peripheral/vsock0/virtio-backend: + device_name: vhost-vsock (vhost) + kick: 0 + call: 0 + VRing: + num: 128 + desc: 0x00007f44fe5b2000 + desc_phys: 0x000000011f3fb000 + desc_size: 2048 + avail: 0x00007f44fe5b2800 + avail_phys: 0x000000011f3fb800 + avail_size: 262 + used: 0x00007f44fe5b2940 + used_phys: 0x000000011f3fb940 + used_size: 1030 + +ERST + + { + .name = "virtio-queue-element", + .args_type = "path:s,queue:i,index:i?", + .params = "path queue [index]", + .help = "Display element of a given virtio queue", + .cmd = hmp_virtio_queue_element, + .flags = "p", + }, + +SRST + ``info 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 + virtio-net (vhost on):: + + (qemu) info virtio-queue-element /machine/peripheral-anon/device[1]/virtio-backend 0 + /machine/peripheral-anon/device[1]/virtio-backend: + device_name: virtio-net + index: 0 + desc: + ndescs: 1 + descs: addr 0x1312c8000 len 1536 (write) + avail: + flags: 0 + idx: 256 + ring: 0 + used: + flags: 0 + idx: 32 + + Since device[1] is a virtio-net device, we can see the MAC address + of the NIC in the element buffer:: + + (qemu) xp/128bx 0x1312c8000 + 00000001312c8000: 0x01 0x00 0x00 0x00 0x00 0x00 0x22 0x00 + 00000001312c8008: 0x06 0x00 0x01 0x00 0x52 0x54 0x00 0x12 + 00000001312c8010: 0x34 0x56 0xe6 0x94 0xf2 0xc1 0x51 0x2a + ... + + [root@guest: ~]# ip link show eth0 + 2: eth0: mtu 1500 qdisc pfifo_fast state UP mode + DEFAULT group default qlen 1000 + link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff + + And we can see the MAC address of the gateway immediately after:: + + [root@guest: ~]# arp -a + gateway (192.168.53.1) at e6:94:f2:c1:51:2a [ether] on eth0 + +ERST diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 96d0148..47446d8 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -95,6 +95,11 @@ 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_vhost_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/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 9c91bf9..343b266 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -42,6 +42,8 @@ #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-tpm.h" #include "qapi/qapi-commands-ui.h" +#include "qapi/qapi-commands-virtio.h" +#include "qapi/qapi-visit-virtio.h" #include "qapi/qapi-visit-net.h" #include "qapi/qapi-visit-migration.h" #include "qapi/qmp/qdict.h" @@ -2165,3 +2167,359 @@ void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict) } hmp_handle_error(mon, err); } + +#define DUMP_FEATURES(type, field) \ + do { \ + type##FeatureList *list = features->u.field.features; \ + if (list) { \ + monitor_printf(mon, " "); \ + while (list) { \ + monitor_printf(mon, "%s", type##Feature_str(list->value));\ + list = list->next; \ + if (list != NULL) { \ + monitor_printf(mon, ", "); \ + } \ + } \ + monitor_printf(mon, "\n"); \ + } \ + } while (0) + +static void hmp_virtio_dump_protocols(Monitor *mon, + VhostDeviceProtocols *pcol) +{ + VhostProtocolFeatureList *pcol_list = pcol->features; + while (pcol_list) { + monitor_printf(mon, "%s", + VhostProtocolFeature_str(pcol_list->value)); + pcol_list = pcol_list->next; + if (pcol_list != NULL) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, "\n"); + if (pcol->has_unknown_protocols) { + monitor_printf(mon, " unknown-protocols(0x%016"PRIx64")\n", + pcol->unknown_protocols); + } +} + +static void hmp_virtio_dump_status(Monitor *mon, + VirtioDeviceStatus *status) +{ + VirtioConfigStatusList *status_list = status->dev_status; + while (status_list) { + monitor_printf(mon, "%s", + VirtioConfigStatus_str(status_list->value)); + status_list = status_list->next; + if (status_list != NULL) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, "\n"); + if (status->has_unknown_statuses) { + monitor_printf(mon, " unknown-statuses(0x%016"PRIx32")\n", + status->unknown_statuses); + } +} + +static void hmp_virtio_dump_features(Monitor *mon, + VirtioDeviceFeatures *features) +{ + VirtioTransportFeatureList *transport_list = features->transport; + while (transport_list) { + monitor_printf(mon, "%s", + VirtioTransportFeature_str(transport_list->value)); + transport_list = transport_list->next; + if (transport_list != 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; + case VIRTIO_TYPE_VIRTIO_INPUT: + DUMP_FEATURES(VirtioInput, virtio_input); + break; + case VIRTIO_TYPE_VHOST_USER_FS: + DUMP_FEATURES(VhostUserFs, vhost_user_fs); + break; + case VIRTIO_TYPE_VHOST_VSOCK: + DUMP_FEATURES(VhostVsock, vhost_vsock); + break; + case VIRTIO_TYPE_VIRTIO_CRYPTO: + DUMP_FEATURES(VirtioCrypto, virtio_crypto); + break; + case VIRTIO_TYPE_VIRTIO_MEM: + DUMP_FEATURES(VirtioMem, virtio_mem); + 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_query(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + VirtioInfoList *list = qmp_x_query_virtio(&err); + VirtioInfoList *node; + + if (err != NULL) { + hmp_handle_error(mon, err); + return; + } + + if (list == NULL) { + monitor_printf(mon, "No VirtIO devices\n"); + return; + } + + node = list; + while (node) { + monitor_printf(mon, "%s [%s]\n", node->value->path, + node->value->type); + node = node->next; + } + qapi_free_VirtioInfoList(list); +} + +void hmp_virtio_status(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + const char *path = qdict_get_try_str(qdict, "path"); + VirtioStatus *s = qmp_x_query_virtio_status(path, &err); + + if (err != NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " device_name: %s %s\n", + s->name, s->has_vhost_dev ? "(vhost)" : ""); + monitor_printf(mon, " device_id: %d\n", s->device_id); + monitor_printf(mon, " vhost_started: %s\n", + s->vhost_started ? "true" : "false"); + monitor_printf(mon, " bus_name: %s\n", s->bus_name); + monitor_printf(mon, " broken: %s\n", + s->broken ? "true" : "false"); + monitor_printf(mon, " disabled: %s\n", + s->disabled ? "true" : "false"); + monitor_printf(mon, " disable_legacy_check: %s\n", + s->disable_legacy_check ? "true" : "false"); + monitor_printf(mon, " started: %s\n", + s->started ? "true" : "false"); + monitor_printf(mon, " use_started: %s\n", + s->use_started ? "true" : "false"); + monitor_printf(mon, " start_on_kick: %s\n", + s->start_on_kick ? "true" : "false"); + monitor_printf(mon, " use_guest_notifier_mask: %s\n", + s->use_guest_notifier_mask ? "true" : "false"); + monitor_printf(mon, " vm_running: %s\n", + s->vm_running ? "true" : "false"); + monitor_printf(mon, " num_vqs: %ld\n", s->num_vqs); + monitor_printf(mon, " queue_sel: %d\n", + s->queue_sel); + monitor_printf(mon, " isr: %d\n", s->isr); + monitor_printf(mon, " endianness: %s\n", + VirtioStatusEndianness_str(s->device_endian)); + monitor_printf(mon, " status: "); + hmp_virtio_dump_status(mon, s->status); + 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); + + if (s->has_vhost_dev) { + monitor_printf(mon, " VHost:\n"); + monitor_printf(mon, " nvqs: %d\n", + s->vhost_dev->nvqs); + monitor_printf(mon, " vq_index: %ld\n", + s->vhost_dev->vq_index); + monitor_printf(mon, " max_queues: %lu\n", + s->vhost_dev->max_queues); + monitor_printf(mon, " n_mem_sections: %ld\n", + s->vhost_dev->n_mem_sections); + monitor_printf(mon, " n_tmp_sections: %ld\n", + s->vhost_dev->n_tmp_sections); + monitor_printf(mon, " backend_cap: %lu\n", + s->vhost_dev->backend_cap); + monitor_printf(mon, " log_enabled: %s\n", + s->vhost_dev->log_enabled ? "true" : "false"); + monitor_printf(mon, " log_size: %lu\n", + s->vhost_dev->log_size); + monitor_printf(mon, " Features: "); + hmp_virtio_dump_features(mon, s->vhost_dev->features); + monitor_printf(mon, " Acked features: "); + hmp_virtio_dump_features(mon, s->vhost_dev->acked_features); + monitor_printf(mon, " Backend features: "); + hmp_virtio_dump_features(mon, s->vhost_dev->backend_features); + monitor_printf(mon, " Protocol features: "); + hmp_virtio_dump_protocols(mon, s->vhost_dev->protocol_features); + } + + qapi_free_VirtioStatus(s); +} + +void hmp_vhost_queue_status(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + const char *path = qdict_get_try_str(qdict, "path"); + int queue = qdict_get_int(qdict, "queue"); + VirtVhostQueueStatus *s = + qmp_x_query_virtio_vhost_queue_status(path, queue, &err); + + if (err != NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " device_name: %s (vhost)\n", + s->device_name); + monitor_printf(mon, " kick: %ld\n", s->kick); + monitor_printf(mon, " call: %ld\n", s->call); + monitor_printf(mon, " VRing:\n"); + monitor_printf(mon, " num: %ld\n", s->num); + monitor_printf(mon, " desc: 0x%016"PRIx64"\n", s->desc); + monitor_printf(mon, " desc_phys: 0x%016"PRIx64"\n", + s->desc_phys); + monitor_printf(mon, " desc_size: %"PRId32"\n", s->desc_size); + monitor_printf(mon, " avail: 0x%016"PRIx64"\n", s->avail); + monitor_printf(mon, " avail_phys: 0x%016"PRIx64"\n", + s->avail_phys); + monitor_printf(mon, " avail_size: %"PRId32"\n", s->avail_size); + monitor_printf(mon, " used: 0x%016"PRIx64"\n", s->used); + monitor_printf(mon, " used_phys: 0x%016"PRIx64"\n", + s->used_phys); + monitor_printf(mon, " used_size: %"PRId32"\n", s->used_size); + + qapi_free_VirtVhostQueueStatus(s); +} + +void hmp_virtio_queue_status(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + const char *path = qdict_get_try_str(qdict, "path"); + int queue = qdict_get_int(qdict, "queue"); + VirtQueueStatus *s = qmp_x_query_virtio_queue_status(path, queue, &err); + + if (err != NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " device_name: %s\n", s->device_name); + monitor_printf(mon, " queue_index: %d\n", s->queue_index); + monitor_printf(mon, " inuse: %d\n", s->inuse); + monitor_printf(mon, " used_idx: %d\n", s->used_idx); + monitor_printf(mon, " signalled_used: %d\n", + s->signalled_used); + monitor_printf(mon, " signalled_used_valid: %s\n", + s->signalled_used_valid ? "true" : "false"); + if (s->has_last_avail_idx) { + monitor_printf(mon, " last_avail_idx: %d\n", + s->last_avail_idx); + } + if (s->has_shadow_avail_idx) { + monitor_printf(mon, " shadow_avail_idx: %d\n", + s->shadow_avail_idx); + } + monitor_printf(mon, " VRing:\n"); + monitor_printf(mon, " num: %"PRId32"\n", s->vring_num); + monitor_printf(mon, " num_default: %"PRId32"\n", + s->vring_num_default); + monitor_printf(mon, " align: %"PRId32"\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_avail); + monitor_printf(mon, " used: 0x%016"PRIx64"\n", + s->vring_used); + + qapi_free_VirtQueueStatus(s); +} + +void hmp_virtio_queue_element(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + const char *path = qdict_get_try_str(qdict, "path"); + int queue = qdict_get_int(qdict, "queue"); + int index = qdict_get_try_int(qdict, "index", -1); + VirtioQueueElement *e; + VirtioRingDescList *list; + + e = qmp_x_query_virtio_queue_element(path, queue, index != -1, + index, &err); + if (err != NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " device_name: %s\n", e->device_name); + monitor_printf(mon, " index: %d\n", e->index); + monitor_printf(mon, " desc:\n"); + monitor_printf(mon, " ndescs: %d\n", e->ndescs); + monitor_printf(mon, " descs: "); + + list = e->descs; + while (list) { + monitor_printf(mon, "addr 0x%"PRIx64" len %d", list->value->addr, + list->value->len); + if (list->value->flags) { + VirtioRingDescFlagsList *flag = list->value->flags; + monitor_printf(mon, " ("); + while (flag) { + monitor_printf(mon, "%s", + VirtioRingDescFlags_str(flag->value)); + flag = flag->next; + if (flag) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, ")"); + } + list = list->next; + if (list) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, "\n"); + monitor_printf(mon, " avail:\n"); + monitor_printf(mon, " flags: %d\n", e->avail->flags); + monitor_printf(mon, " idx: %d\n", e->avail->idx); + monitor_printf(mon, " ring: %d\n", e->avail->ring); + monitor_printf(mon, " used:\n"); + monitor_printf(mon, " flags: %d\n", e->used->flags); + monitor_printf(mon, " idx: %d\n", e->used->idx); + + qapi_free_VirtioQueueElement(e); +}