From patchwork Wed Oct 27 11:41:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 12587073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF26AC433F5 for ; Wed, 27 Oct 2021 11:49:17 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2377560F56 for ; Wed, 27 Oct 2021 11:49:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2377560F56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:56252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfhQh-0004O1-O4 for qemu-devel@archiver.kernel.org; Wed, 27 Oct 2021 07:49:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhKd-0001Ee-TT; Wed, 27 Oct 2021 07:42:59 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:9164) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhKZ-00070F-CU; Wed, 27 Oct 2021 07:42:59 -0400 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 19RBgEVZ020462; Wed, 27 Oct 2021 11:42:34 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=80BCLn8ckqmKo5081wlWbJxwtMB7K7y7d2SZOQKoMm0=; b=CS0QOlsIsRHrO4AOfScc5NpXczhtEjCTzf4v8MbBRAsecw+Z5lrSCc72PJlSf9FWlf2o HrPJb4hWyqjzCTfvD4dVSKspRQ/o+dfuWneA1vvwTBwVdQ7c2k7eNl0x7J1s57UCmyRz AwQS5r0uvQ5LIQ/mH0YRp3OTjlhNRgTMGxDtpr28klKhmhqWcyNm1mfw/debPBOXjAZj /uFkvhDgKH3zjIwdw/82NomlbqVGjpXHHOZTDxS+bYZo/zcnJTP9R8FDzfAdVbrlZOnu VZN3xkfJmbkxFlMaG9oQ6m6KbYxBWAw1+CHOyfkJVszvUYf28y9VD5/Og1gWAhUbMgU9 Xw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3bx4fjjpua-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 11:42:34 +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 19RBfYNl006977; Wed, 27 Oct 2021 11:42:33 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2107.outbound.protection.outlook.com [104.47.58.107]) by aserp3020.oracle.com with ESMTP id 3bx4gcjgx6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 11:42:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZwI9eFYsjiYUxyi9A0Nv+rTVDU429cvOpcy5b287NrSTHXs9HL9XMMZkHXeg0NnRuBSJl17/LfIse5h8YntvsCZsdGnSX5E/k24GVSWCyozkffyBSC5IwQf3IURLea1nFRwhQjDGJurCfyD1Dn53mctVYmOJLGTZ1VKVfusix0gq0HdPXKXaRr+OUeXW8cVuXPRfLJ2v1RluFjwmQfl8pOQYcMf5PP96Ao3APeIhAvQoirDkrn1DuFZawQPP3cDDKwpbpP3NLPEfzwIeKDTznPlC4jZWPkEa9feztMFI8902uH3vRM4ZTKToo8HbtJOB0CQfuIdpDT7xxJWbNQoVfA== 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=80BCLn8ckqmKo5081wlWbJxwtMB7K7y7d2SZOQKoMm0=; b=eYCnrn+MBjUNfwgz3o3yJzBC2TGckL9lkTtx4LyVAAmCf7N7bvsbyOKT2r/4V5+Jm/oyIK+Y0F/Lgl1N2eundEui1+GRShGuNysiA0fPCXt21P23ozAX7spGjmmtRb7gJqhEIqZq9i3y/2d7CxBC9bAy2w7dr2B/nT84Q00dDpyjTn5ML1jvbgdzh3aodXi6Kn+FWjO44foxKFNjvE4CttEPSIiy0IzYhe0iSz3eOOYR7owvn1pNzP8UtIC5xZudqM6rY2S8oi2SqFzYUTfpL/+x/Gnm00ZSRqvILt0z1NCekEVEeOqOtdVsN2HgK4FOsY3s+Um8t86sEhLN9JHveg== 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=80BCLn8ckqmKo5081wlWbJxwtMB7K7y7d2SZOQKoMm0=; b=Udkd/T8QPj0kwDAWBJeDegREyVOiLRqmxwH/xy/OnT8+xc8q3TW85aemeFrrjLWVXFr5GfFULAQeRyX8YkNKvy9yiMJOFtqzCXYyzUt6BX4bJNfxhiFx81SKwfB0nD+CKecROX4T7jnkyXgxyp2hp6g/8YCQayFWYMcJAAz8yA8= 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 PH0PR10MB4744.namprd10.prod.outlook.com (2603:10b6:510:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Wed, 27 Oct 2021 11:42:30 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%6]) with mapi id 15.20.4649.014; Wed, 27 Oct 2021 11:42:30 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v8 1/8] virtio: drop name parameter for virtio_init() Date: Wed, 27 Oct 2021 07:41:42 -0400 Message-Id: <1635334909-31614-2-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1635334909-31614-1-git-send-email-jonah.palmer@oracle.com> References: <1635334909-31614-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SJ0PR13CA0088.namprd13.prod.outlook.com (2603:10b6:a03:2c4::33) 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.40) by SJ0PR13CA0088.namprd13.prod.outlook.com (2603:10b6:a03:2c4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.13 via Frontend Transport; Wed, 27 Oct 2021 11:42:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 865e24fe-53ec-4786-bc39-08d9993edbed X-MS-TrafficTypeDiagnostic: PH0PR10MB4744: 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: qGBpAfQjKj0qeWGyCnHxJ9djiTZgAEOqtgRK8Xw4nUProP5u59HUALCdORVrQk/+TgKz9oZv9JL9/JDQ5EJTQlIUG4TlbnqhdrwzexpcfSEL/lITxVlboAw+MNLU9HlpSU+8mKsn/67w33wRiS2ASNKZ8IOT/QzDUomppSQDKhmSR43Bq3wv/czgo22kst95NF5ADNOTmEWY13jYr/pwV81y/tRt0hRaKoKSMdvONnjcWNJu4lm+ITLHalLnmIUuxKmQhIOKV51fakeyQj7/vQHWe/KL4tBfSARm7DhAohbK6Ped1Pc65upnEORKKb9qrDiyEXFlL17cVDbN7i9v01pQjUQbe7mJK7HrmzChtDwUPIembEcJPMUKPdsZ3qNqyZjQllzHohbilrs/jEOwkHi0wSobWzi7Pu5OmgfMtJehVr0+k3m7J3dnqxnz9ZjePHO+vez2EbZ/dZpVy8bMYQq7aL5PxZnyLnCOgQ4R2CYURjJWczeXJL0uZlE0rkoh/uABFrhaSeEkMoBp9q7lLChKJnMDoFYaZ4ua3J++SNgtaEXFiE5Owo7FfF1iS3mOGTAFqqE+AKggYViIgDBZYc63TzdGEW+a2rs1KwVuGSB10TC/uIGqqYUN1uPoLmgtATOhyZC4aCgVHjxEjc4X4ju9ZIgEVfPsfQTbooeOQ07I5W9ZLJp1GhRX16tLBWgcZrKh1l0lKkdgqtcfzw3umQ== 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)(66476007)(44832011)(26005)(4326008)(316002)(38350700002)(38100700002)(8936002)(6916009)(956004)(36756003)(2616005)(2906002)(30864003)(86362001)(83380400001)(7416002)(5660300002)(52116002)(508600001)(6666004)(8676002)(186003)(66946007)(6486002)(7696005)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: L8WcI31LAuIzSaCerR587P3sjJS9lP/wMyCxWgP56KTK7MgKztk7Ky/DDIdYph0YWUcM4UJDdUr2DWlMllNZi0t5iZ24XSiNdrHwQ1i36vlOApSUKvVbnbgGEhZ82YzL6wM6eX2sxaQxY+wOITQH1FjJ/vHHj1iCCd8GjC0pElKR6ymKmyRiuK0YRS3oZtv1cDJeTLdKMWv4MAcuIN3C7VTFicvMhn/gSnMSMJrCJdmyNUn3L2V9cvwXIGrCZq4OK97+Ema6zpOyIrl46/Z/3YkF8aGwnFsf+8kJneHxQpnLH4YHZwL2GB7/IxfTjNmFj8UhwgMHMXwkGHgToXAmBP9sjbcttfYW5Cy+xJudizYQ2Lrh3znMZzj7yqYTuJL22g+gkcSmlYmwDfM2uFRLUe2hkjhWKVBMNWWik3KCR3qLe7piMnr3yqHcNdhpubHdN2JPFGn+MDyuvnzeP9ec3MCUg5A6ngEPtMQi2sK2bzRcH8FDZSdW8uF/XbNYOyZ4cZ68h0fBqOCdIS5KSmaszC2ACzD1IujB60zypmABv1ZYYEu1Pn6b9QCh/FxDB8s78148nBOXd1dUQgWcHcfvrK68RAa6JL4LgjnwQbO/BQ2X4isLgiqyrxaR0L+UUuBGahlLkVO767/YKVKa1GkEyn9S5IrIiz4xLIGMcyu+xoijHGKu9a5N2omI90rqXiezWZKXNpZ5fv/v/5AMOVUUbi/W1dOnHJZvtYxYJ4At/6eyJSE7CMrkdRY/fKPxciNnjZY8a4r3PC1JG8Wo4ZCug6dZReTsiWJ8/FdoDZns7aFfbC8VnJog1u7LODUiRcPWqL8R7zKg99LG+airGAv0M7GTvF+vpZ7m6DbydcG9lpHbpGNLxcBndSN141H1VLQQQijt/LOs6NKhTMkmVoi424lmDjj8ch8t9jr7LVsJWaH58Sr7GyDNkWJSo7cxE9zmTUeBRKKTcDQ98wiDftRYI1JnU0KYfbHtm6EcbfsmYVlhLjnJF26gtWrS/+vL98BKfNdMtZW/QdobmO9nM5gyaUEDFYrMdO+KmBdylJn72uVbjszuo4EejyVppMHyBzFKvbeLHtz4R71Gwk8CHIg1BcfDqq+FPgw7b9bldVe8UTTxc5MLmcK5Xf2Rie7CyJskNejkRMgXBZb6782yRd+H4OwrdZryvTE7AGbZ6s4f991ODDTejl4G2vzFwegbmLvBEZMP+7M6h2H9GyaleVgq3Im+Hp3tNLjCjYdENWC53pdm4CrJ8s5oFMFGh5a6jkb6bT7xb9LPq4lgOuT4LWgKE6cOuCM/G7fT7OxYJp4mc3xKKN3B5txVIbZFpNPdcaJ3rK8B3Hy/QBexCt24xpfDl0BMZClQiUm4Mn2tFyplRghtILk4Tt5nKL23974T+lfgQAna6F3yHOXeT0HkfvhqrCvAx57c6LUHnhdetKpVnlhRH2l+Hhc8eE9i3frSrTHVztJe3qxYti6CIeJ+m64VnVWDAAmLjXjXa2Z1qgPXsEIrM2QXaErcYEfYJxbyXBoJZWzWnFQEUVoib75fYJEZvDsleYFl9LBA0RR1fsfSy5VZjl+l7Tb2jIlOjCJgd7c/kctN20CRpfrRgi2Eja4aPFN/FTRzr9KEWGmIsgqkziY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 865e24fe-53ec-4786-bc39-08d9993edbed X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2021 11:42:30.7951 (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: qV7T2v43R1CMnppGKEQN+z8KKtinqUmaidwlqJzuDZrXLpnmnEVc4B8NbRjLlGv8D38EpWrmB0Yfdquk40M/yQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4744 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10149 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2110270071 X-Proofpoint-GUID: jhpbRjt2AKfpC6Z4EED0kaZgZVn1oN5s X-Proofpoint-ORIG-GUID: jhpbRjt2AKfpC6Z4EED0kaZgZVn1oN5s 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.23 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+qemu-devel=archiver.kernel.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 df91e45..dbef06c 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -737,8 +737,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 24c6628..96e7702 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 Oct 27 11:41:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 12587079 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E559C433EF for ; Wed, 27 Oct 2021 11:54:49 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 05DD760E8B for ; Wed, 27 Oct 2021 11:54:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 05DD760E8B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:34720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfhW4-0000tl-2D for qemu-devel@archiver.kernel.org; Wed, 27 Oct 2021 07:54:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhKd-0001Ed-Pb; Wed, 27 Oct 2021 07:42:59 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:10694) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhKZ-00070M-Iz; Wed, 27 Oct 2021 07:42:57 -0400 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 19RBgA0o012296; Wed, 27 Oct 2021 11:42:37 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=TVSud83aRoMcHdEllFTdm0gEq9u450YPpLIzGNXAP6JGC9YQrquMXXxHjQl2+lWiRCYz v+kOMRXFeMSCD0cyGo2xb4COAwCSchipgA47rcmeuuPhsOZ5/WIPBw/H3/1jGdkHYiuT xHihBR2Rp340Ibks6aqn33I7VHcZFFlK0zAweifY2yHisxcLWpT8xSdQyu+KCPEBP5gm nIOLbo9MHo10f1APtjryXWHSiLJyuQQVsx73KWwZfD7XeZ65ALrjHdrmoSfMAEwT0kQb mKU6bIfhy4Xp47XpYrdJkeNfEVIqyE/nSxNhprbP34romdOFfv5a+4mbYnRYDjW3NmLZ +g== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3bx4fg1uvg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 11:42:37 +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 19RBfYVs006996; Wed, 27 Oct 2021 11:42:36 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2105.outbound.protection.outlook.com [104.47.58.105]) by aserp3020.oracle.com with ESMTP id 3bx4gcjgyh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 11:42:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cg3rEzGrGkIsiZWl+We7FHSO51aMWBhDSuKmgz7aWYLBS336fyE66nqn9FVvVzcisKRQO3AnEvdN5wnYNj7y9ouyjkZ8hOvea+fPVT1swXq9/izmvEwPIFt3cyERqN+1kuD2vIvoALx2yARZ5ajors2551KiELN1BDc8P8+VBrnrFZ15ZTj69abgjgwGEx3Eavn0NIRfx53ZhYSjIcK59HLDT7ZalCzJJwf4N6hJxijrNmfy608XoXZg4HRUkj4EocxRsWvUiI3NrynfoWl2ndwW1+1HX049ayg0Oerd6MsLs/o9IxpsYEfj/fNiLhsvXNqKcg97giXG+4gKYgzF2g== 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=XakB75yoR0jUNJwvCc7g9qj26tytbcNIw7zWmbJ+fnjY1Q0IEY/H0xQBweGihltWFh53DoW6oi+Iwi/BVOeaxnQg+ksGhO44Py8SWDe2TlPf6HlW4aE0OqyVHFCGZ10w8NdjM7O6MZtTZcCN5G+3pOcaV8ImgBRy1LF1/30O1oFPwoUm7/lr8rGhfp2TbPHQno3bg86vtFYV82C1ypiSC5M9BjqNl3Vktrn8rzdYHm4dm6PZqfPN+fM35ou2a08eZHKQuKFfQiKMWkbtT7agCsDtBDlqF5CvDiIifTOp8PUW3XMc4CFqG+vbfiiBKX59HgtuE5UIg+zOyHspDiZ2Rg== 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=ircTNDSyexiAHd2QECBah411qazM2OgfjioMxb6VaufH577Kb/DH0jkEiateH9nhO4TssgZ6dvs7FVgf1PETaXc4un2fSai4gsc/nLmx+aL+Dl/QL4Qp/2FGwQ3GTgxeLcTR6i5fulL0EASBKGNuZiDEtOAJBCcS3NDeYiPl3wk= 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 PH0PR10MB4744.namprd10.prod.outlook.com (2603:10b6:510:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Wed, 27 Oct 2021 11:42:34 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%6]) with mapi id 15.20.4649.014; Wed, 27 Oct 2021 11:42:34 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v8 2/8] virtio: add vhost support for virtio devices Date: Wed, 27 Oct 2021 07:41:43 -0400 Message-Id: <1635334909-31614-3-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1635334909-31614-1-git-send-email-jonah.palmer@oracle.com> References: <1635334909-31614-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SJ0PR13CA0088.namprd13.prod.outlook.com (2603:10b6:a03:2c4::33) 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.40) by SJ0PR13CA0088.namprd13.prod.outlook.com (2603:10b6:a03:2c4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.13 via Frontend Transport; Wed, 27 Oct 2021 11:42:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dd00cdfb-f1b3-4800-0943-08d9993eddf8 X-MS-TrafficTypeDiagnostic: PH0PR10MB4744: 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: vXTeQMeTMAG9J4htTtg6z0xVGN1W5fTUb9c/h30L1bafz8KJMOU5D5at5F7zNfLIWp7oduE1PJaV/husvOhfLhjRk/PeEE18m+LeUemanHly4PRj5ICk2tHcq3rVtCnTg4aTBe47dxu0xDrW7t+vZMNh07+8e6cylO0nZ7TL/jfbwdgux/hPk1vqp9zHUpJDtQk1UvENmitNKNGg3VVvlM+0vh1equPR96VwvtV8VRE0YQsi2NUVUek/fN0KDtUw0kfLZHqLZs5EJKP5p2siOs5GG8CkKKjcjKrb3VWhvwzPGxaL55dcXtglw5eN2DMwrIOkL/MQcWTlGI0MgVNLiMBB+gdh2AZnJKf6/tfNdUdhb+o/vIaOZW6+0NuLmv9wve8i0a9OW3WJVHLmr3VQqyTlptWUxuYgzKSpwQ7uIVh8Vq9MWHctxcLZ15WNb4e6NXtW3Pv8TdqnNCbGiSv3kPA85XExlYHrNSkjYUhzLylrKVpLC5Sbg3ZIvQqVU8JmaStB6SrXZfGpzAssKabazSYzJ9M1A4PdN5hBQkVm5UDLz/KoNhlWq1l5LpqG69jzU2HVBuQBhjKSTgLlUkbff3jo3YiDGF7UC1/hcous0MpwfiWLcnsfj8Yve/xq/A7Y31a78zG5F0OSbY15x/WBMUZr8628st/9mk0M54DuAZArNq+y3PpcQFO9mCHJOSjl5O1un+i2ok9xF4vmQ5wikw== 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)(66476007)(44832011)(26005)(4326008)(316002)(38350700002)(38100700002)(8936002)(6916009)(956004)(36756003)(2616005)(2906002)(30864003)(86362001)(83380400001)(7416002)(5660300002)(52116002)(508600001)(6666004)(8676002)(186003)(66946007)(6486002)(7696005)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: N09EwU5L9F4hBH7BVEhPCt7aJglxpalONbaG+jJ1X/GgVkWOrJU5z97c42gr8sb3mOuBFcN0yfmm3YZ/nZvnJJn4BJv+uQflHW5q5PIqOOGjJkaLXtxMCyKT4ftf85zk97ilV+GZt0PDHDmte5OnlbWmtCWe0frDF6k0E/qPGxU2HZiFDl5kAbFMvTHcc0rsrJCByzPqEkvRPgmSfQ+Doi7e3hidQPxV5iXySfHtUyAPWjBx9vDjk+2mV3uytb4lYNR3GS90Z47yuh8yYslTM+lrgG2mFQBOYeab5sWiN+x3duvTP5l4mvLnfEyFEBGtqX2KCZ/ptOQaQCD7nFzvu4rVHOCh0llXEXcgHG4Oz/PDHdu1DwrAqLVRbCaZgK5nGeLHDx7GnWERJC5/iX3saZP8+SZkd3zzQQZkEvzXr3sC2wFXeXy/owPzQKf+l8LT2x87M9dPVHpfgZtkaBaKkKT+5p2fLD60JYh6Ht+JT/oiuIup0n5CV60TMxGQKVVdBe01HAT9lA1DIsxV+7ORTglZqo7MLFXpjUdaXSCVXdeYA97zFiCuEh7QRIfQJICi7HxGjOHZxxL/LdR+HqZHFb0ewZgngXtCHdEye1PZynjoODZHe7LisRf7LYdcJ4MFW6u7glasaMb8KtVMRhqKNlcbgrOcqS5hnjim9A2j/XhnyKgZCP6XQcyNLVCCmMcZs5y0WXKQFkQt7X6X8SGY5b8zBgBqw389aBhL36w+kIhZ2Kvzr9OJ7hRu+1T/Z235NQtxag0yCYB3IJhH9E6TGzESN6/b6trZFPuwghhmeg5C7EWAGzctKneVmBsj0sR2ot7q11n+BYN7XYoUz4wAhzZwpWsW82HNzSX5ERcS0/db+Uo9zuQxlhQaZ1PhbabG4ohTt/laMCXdpb0YDNOFfmP4AYHfEOagJvglcGtywwmO6zzn0RnUXRcZdbCLr50fSvrOQVbPA/WSzkh9cCCVb9bbVTBofaD/oNebJX6sIqJi14Z5huE7RPVS2X3Hkop3aFHY0Df0/8gH90/nIeLimCaLfacNGt/FgYkPWwViOWSy/OvG2E+VRbWIrhLIJhcX7i+LYF1rlHFuu/k2OS0KBYJCX3L/aGq7XhHKvULNkFJeZLic4RGkmvewsA06D1yEBClYO4heSw+II3ctKokmKBkc5l5ZqwD+rbgDWTOmhKWE3ZdxIQ+DfGTkzDf01RrnydvSxN75iQpDT+OZsWxXTFccaqXR8p+cjM7YLUA3iM2yGl9gJn+pqWGlcsCEbWtFgU+/UUgGn26onU6JIsR5hHm44GeRRu+eQGaY1v314Za2SsZ/O50UdLC4c0pjp+ZXdbsciRJZUc1xHJWyqAa0zupkmWgUkIZE0qb3TAtw5vO0f56Hh9Ru/RdSFC6JeDbQFkowtiC16XBTpNgMy3sKNRs9UZZJFavXnJ0F+B53OcC9jcT2+4vyUaz8YSwG6BFKR6Gfc+NaQWdWn+piPf5asaiIrbKLgFudLskG8BmLrLsu6b23VyWzVlj+zNeqacZBxGO9jh5dFtUcEwqEIqdF0CMMa8Wl8JcYI+Y/csr6Ifrmj6kMwc5MiG4iu8+e0BDGWd1YqLLH1HpKQSBpNHU1DCmZB4Pfn9hcC/4dzXqETkY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd00cdfb-f1b3-4800-0943-08d9993eddf8 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2021 11:42:34.2241 (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: 1P7z0wSEZfNLtfB4MYuDD2LVc5lz+k0oGCWdvQKADDD5kOu0HGRja8xEFxAztuMNi7sM3x3+Mjbaup27C+sr7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4744 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10149 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2110270071 X-Proofpoint-ORIG-GUID: bMKpR8NVABTyq3vQV3bgoEHvPBgkZkXO X-Proofpoint-GUID: bMKpR8NVABTyq3vQV3bgoEHvPBgkZkXO 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.23 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+qemu-devel=archiver.kernel.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 Oct 27 11:41:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 12587115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C4D5C433F5 for ; Wed, 27 Oct 2021 11:58:44 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id F18B260F70 for ; Wed, 27 Oct 2021 11:58:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F18B260F70 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:45396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfhZr-0008Eq-2Z for qemu-devel@archiver.kernel.org; Wed, 27 Oct 2021 07:58:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhKh-0001GB-7J; Wed, 27 Oct 2021 07:43:03 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:22634) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhKf-000716-0s; Wed, 27 Oct 2021 07:43:02 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19RBg8qs023575; Wed, 27 Oct 2021 11:42:41 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=koI0WZDYkplk+NMatgvRcZdkfDq0997CllV/CC2BrQ0=; b=vtyU1Hr3W6e7YqHSOkUoBxDLgci0LWufjV6U4+91Ytd1AMqBa4qkrzunhc8nC4hER5KC EWCZzfBvF2fFJfZwNZgm03gC57tveR3AXqTs7tNnbG4kMUpUrZ779drakkyPxMgcc2ry n7NSg2ywjYsa5HI8aeOCxGTI/9daScL9BcN/mo9t/227ui1R+hqWZqzF7TjmAFj9kvxN NXss6qn0bfI4q5GGJlNLkKTq2wPDdLXC5m9geoaelGRhNA4FQEB4gdhQxMR2PB6uZGrA 7ls0aENrKib7n9AJVTxrpR5UaA+RO9OuhzxLZRozRtgPXOdIFOQf6JRzm1SX0BENWuQ9 3g== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3bx4fj2mtc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 11:42:40 +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 19RBfGlf159506; Wed, 27 Oct 2021 11:42:40 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by aserp3030.oracle.com with ESMTP id 3bx4g9sr0f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 11:42:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CACCTsBbxIEfAhD1HdglGREaBIa1AUEZVCWsRkG1RigGSLdfg2gayvf1krvH9+GJ8IwNm3RfsUL1FkgpzVE05myFNLutbAPATbZcgPeiPhyAS+h1wPdcVrwXsOrEEoeM04e1JOYATQW/wVZEG80Q8XqU+YmQYOVS0JTU9HuB5+kHfdWcEzWyJwuNZKOlKLJdbSj058VtBjnT1qOh2NKvgmio2f6caTJLLX0N0Zv+mk9BH63zxj4A2mzW7ML/jaAUjqGMvBM37es61AkJW9Q0zRVJqAezI8glBAQPuh/cmTYZrFgdY4QM7TBC7GYqp1Rcido9Of/PiVPgOcmsyVLdoQ== 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=koI0WZDYkplk+NMatgvRcZdkfDq0997CllV/CC2BrQ0=; b=I//3FCnkP0cNMqrLKQaxcf/0gyUb6drMkhOzTwuxgm8Sk8W1R8vT/qIeg/EvcDyBNv385ECzO5MV8XYL7oWYrll1wGRtAIKawYqJboGvz1BD6bP6ndroVbJBkH2s92C81LJ3bk/zFPTs1sBkExRXtWpFer5C3a8pHWFirmarWAtR0MD+01hDfaann6jeFCX0ZqDzDx5Mys2W629fm16p5FPUS+bUIhDEmuxFvX4Hp68apwcwhMW2hON9BPZBRawqvQG7+2CXzuebCdAQdDFpz45JW6YxYQp2wEpDRLRH0xo7HK8s36uut9AYTbQjWw91rG1B5ZmMovYNIKwZX/WTqQ== 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=koI0WZDYkplk+NMatgvRcZdkfDq0997CllV/CC2BrQ0=; b=pR3+ftvFGl3BhZ9T6s0F9ULemsTMBeRuDk/DEA1maZQUmEBdh2MQ/8MTvU7CokpoTAzbOoTIXBteboSavFYNX7xIs58FopHgqqprTcl9oabe85mvMefLMDOpFajnYSv95DaV3HPPG39wPsMlNs5ZASdIDyPotYfAlB8SNwGALwE= 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 PH0PR10MB4744.namprd10.prod.outlook.com (2603:10b6:510:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Wed, 27 Oct 2021 11:42:37 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%6]) with mapi id 15.20.4649.014; Wed, 27 Oct 2021 11:42:37 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v8 3/8] qmp: add QMP command x-debug-query-virtio Date: Wed, 27 Oct 2021 07:41:44 -0400 Message-Id: <1635334909-31614-4-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1635334909-31614-1-git-send-email-jonah.palmer@oracle.com> References: <1635334909-31614-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SJ0PR13CA0088.namprd13.prod.outlook.com (2603:10b6:a03:2c4::33) 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.40) by SJ0PR13CA0088.namprd13.prod.outlook.com (2603:10b6:a03:2c4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.13 via Frontend Transport; Wed, 27 Oct 2021 11:42:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1cd27bb7-52fa-4442-1f9e-08d9993ee00d X-MS-TrafficTypeDiagnostic: PH0PR10MB4744: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:215; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xWv+YSDciCM5TqrmZ2cJWamT12H4ZWYwpM4QSTz0gZUaDseaX1XgM3L0WJKT+4rjpvmeZD8+6T4+TePrnKZLycXkSEgCQbwYSg+tBppdiI8MDCz906TS1SHYatQsYzxHVfDe6qdtHBzfA6/g/yLL9AY7jGVW34FuulbpHiSBVHnfXd/MkB2u2eNTvgcorNEPXKj81TH14R1YFahw6NBk+SYndUBkCNNC3O++9ytsdPjgd2+E2GyZCaqpL/HEVyd4qmkcolLhqafYYVL1lrVdbPh2kDfyVUO5kDAJgEn8298sAY5i5Z2tak2it7g6YBV6jZyNS6AnKy1mZQVj7thC+iSaeMJANFm9Ck7OeCZcSYrRUudqJhEWfPgNcUytes4ekHvrgZdrsxJEyEgzTGS6yvxFMQ4bxLSbbW1n6UeC2+N7MW1vDto+VdV2Ucy93XLteTvqvRhQLJWzo/b3U3gwE0aIGH87z/hXSK0f7rREDD7OeQODgtLlNQVsVv3wtoIb67Eglci0YjHtCIfZcBrC6eAOfSyhHLtEO+uRiNlXobuyEKntvqp4OeIi6IC2w2UJN0qY6o091nsx23cDHiM4Ize7Pc5FD57Mzd2U1smuJdmrX/ot5tre+6vJcjhxYus064K3cS/VTFO7ZxkYTGAS7c04gX+nf63IGfQ0p33iRi6KkZwPqtQy5QJ053mawn2N9XEoXai6sGcNqvgONHwGHw== 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)(66476007)(44832011)(26005)(4326008)(316002)(38350700002)(38100700002)(8936002)(6916009)(956004)(36756003)(2616005)(2906002)(86362001)(83380400001)(7416002)(5660300002)(52116002)(508600001)(6666004)(8676002)(186003)(66946007)(6486002)(7696005)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hoCT9Eni5o75KaLQPn0b9ujPzF4sAovFz1icK6fb4IBiaqwOmA86EVmQRWqJV7UICA+uJRpTRl583qr6jR4n8k5PNQ3QZSSNZMopWBIPt+dRiAft2NKL7KbYMCu1/kTPvY/UYEKfDQdEJZRX4ZqGpjtDYf9PAV2nqVzCQ0Bih+jnKk5rAbKZ+lf/Xanw1Wq/APdaTIUqytDwmbBgJmEYVyamAijXCVZyAZ7dLkZN2fZ8tuFokxOTiUwXJ8bCk7TpDnyzHZiRLzLhHB66A6nges+I9+J5/LObV/O1y4rW/SemSaxmxF3ZKmb8zgk+AMftVADWfvocrdRnHmWPK9F820i9bOoxMdcaaKxaP1otQxfcjaZ/L6F6goaW0SD0o1trSQFdBoQ6BLwfbbxu5+inY2UrDij6StVIxpfaIWJkIZuGdoHE067O9iztqZVjGTexVirGzdCd96CRY1YF5XK3cqbkJkLCeU9sWmvDSeV0GayGlLxNeZD71OBSE9Za8Wjr2AnY3oeDcoZ3BWhdYg+EYRr9cqeF3BX0AtQ46ywnJuhrAFBHulqkfqr/RU/mK8Ujy35xo8h59YOBqcwDqhFXOO8YS4Dwimn/Du5rontxEEu69zk31Ql8VLM9hXfc1Zvw3x3R9RK7OGsNlYrB1hsf0ij2h+8uTSHDwW1ZauW+R1pkmNWG3y12+7lyjEuf7541alGo6Sip5t8ebXXrGMHv5oLmprD3lTc8KBAQaRToSqJMcRK5wfE0AT2AOOYTJ1xAq4cALJ/GfjOqocFp3EzxHAsgUMHRODPjel2OgHj7g9SOEc7WfAUQqHMHrSR+kSA2uRYJFU/EjTPveneeN1QD60pdxDkWUDGCk14/vsI1S5uZ8xgpqT/swbHK4wQI3JsSCa3XDjv8NqFjS9wbYBqW+XCQuqyVWjZtVIQMKQNOIiBP5F/Ke4AHdZb4meWzMq6AeDq4euzfmbR4cu71FoOeGmmXa3u4AlGyvqAjnyqerB8uerpPt7NHSFvgIG4JRBP8yVtQcdg3xwepZzy7jFmbJwoIP8WdweXf5D6X6PxfQmIWmGTMRMBXX7rhzjoTgmV/aDbgTrNNhxOh/+laLeLxPO8JTgtABFZPmrymbOFP+9FDGWrtXzKJ0x6SWjFcDRF/iTkskKBhRgLUsS11BvqqYKievX4Q7V6HzSAb5VpJGDD4KMBjpjcbzV2EtIRYyQrtSV67VI37gGXhkv6/tVzC2lTWf9XhMeVflmE4acXkhmyoMFeVetwo9nD/UyUnTQFMk/G2/jt88/XdEoYvRu9d74sYPYltNliAFvFgEDNqipoP3Fgz3Trx0wpQXzlBlzVa+1+yyXjOENHX6NgsEVntbT+2oCTVYgJ6gCmb/919Gel6NYyqH+AKOpAOWchnx8dE4PW1SdomRmVx7/9zOOZ1A3XxS7VDhWoSXq99IcqzTy6CkFsEFK9H6ZAMxLMOLSe4IO5kenGEosafso6BVKRlPelGn3lZBLOOf+AZKo7uxgI+xVvmjGbcMoI6vMjhkN1GkmenKKNjHNFquXVftU8YhQoLUEf3dm9yCQhI+LYuhlZoLQu8UAyD2C5v7KNK9OkS0zCUB3k/DqCGojs2t6kfzsJU27TEXZOGdA1735f678U= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1cd27bb7-52fa-4442-1f9e-08d9993ee00d X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2021 11:42:37.6888 (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: bcoCqkeKtvtdTl/nx1NFhVmnCMTVqlLopahYZVLFjiemdG/dJhFSzHJQvWZOtFFhjK8TID2OzYasBKJXz2AxOA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4744 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10149 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2110270071 X-Proofpoint-GUID: IGbAQnIgTjxNvMD4eux7iwQiefl8r6Q8 X-Proofpoint-ORIG-GUID: IGbAQnIgTjxNvMD4eux7iwQiefl8r6Q8 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.23 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+qemu-devel=archiver.kernel.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 | 67 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qtest/qmp-cmd-test.c | 1 + 8 files changed, 114 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..d4a88f5 --- /dev/null +++ b/hw/virtio/virtio-stub.c @@ -0,0 +1,14 @@ +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-virtio.h" + +static void *qmp_virtio_unsupported(Error **errp) +{ + error_setg(errp, "Virtio is disabled"); + return NULL; +} + +VirtioInfoList *qmp_x_debug_query_virtio(Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 7050bd5..ad17be7 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_debug_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 c356a38..df5662e 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -45,6 +45,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..4490c2c --- /dev/null +++ b/qapi/virtio.json @@ -0,0 +1,67 @@ +# -*- Mode: Python -*- +# vim: filetype=python +# + +## +# = Virtio devices +## + +## +# @VirtioInfo: +# +# Basic information about a given VirtIODevice including the device +# canonical QOM path as well as the name of the device. +# +# @path: VirtIO device canonical QOM path +# +# @type: VirtIO device name +# +# Since: 6.2 +# +## +{ 'struct': 'VirtioInfo', + 'data': { + 'path': 'str', + 'type': 'str' + } +} + +## +# @x-debug-query-virtio: +# +# Returns a list of all initalized VirtIO devices +# +# Returns: list of gathered @VirtioInfo devices +# +# Since: 6.2 +# +# Example: +# +# -> { "execute": "x-debug-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-debug-query-virtio', 'returns': ['VirtioInfo'] } diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c index 1af2f74..62c6cc4 100644 --- a/tests/qtest/qmp-cmd-test.c +++ b/tests/qtest/qmp-cmd-test.c @@ -95,6 +95,7 @@ static bool query_is_ignored(const char *cmd) "query-gic-capabilities", /* arm */ /* Success depends on target-specific build configuration: */ "query-pci", /* CONFIG_PCI */ + "x-debug-query-virtio", /* CONFIG_VIRTIO */ /* Success depends on launching SEV guest */ "query-sev-launch-measure", /* Success depends on Host or Hypervisor SEV support */ From patchwork Wed Oct 27 11:41:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 12587151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24E4CC433F5 for ; Wed, 27 Oct 2021 12:04:27 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 941A260F70 for ; Wed, 27 Oct 2021 12:04:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 941A260F70 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:53648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfhfN-0005hG-La for qemu-devel@archiver.kernel.org; Wed, 27 Oct 2021 08:04:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhKk-0001JN-Bc; Wed, 27 Oct 2021 07:43:06 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:27162) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhKi-00071Y-2p; Wed, 27 Oct 2021 07:43:06 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19RBg7IN023568; Wed, 27 Oct 2021 11:42:44 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=DV14n7/S3wz2kgp24JFARftbQItwO4FTT3Cksm1E1Ro=; b=QrcItNyKt8eSEYt3cXarRc91fsU3yowNv5yKUgYPR8wxtsUkfu5sF1NOLFep3SbVwGRV zpKqbpzU+Zzj7uHw1XziL1kiAFHr8CeEQY/F6BlX3eaJlgVPqKjCZpA2Tc6uAGflZzIo FKHCip0rnROtSnvFTvuBAk0l1iwZJZyJjMB9Vr8a+yy9z38ss4s4gx8n7L5HnKAHDay1 2KCJQIW5eeC+zONZP/tFjMOtwscnJNKetdVQCRMtb5DY11vk+lgd+Vi/Ze8OQTFYXCgr ODGJZeNsaWRIMTR+0f29+cKTZFN2SStjmEDhq0XfaIR7AkIF42G5XBHB9h5pD9gHgVyZ VA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3bx4fj2mtj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 11:42:44 +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 19RBfHKh159674; Wed, 27 Oct 2021 11:42:43 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by aserp3030.oracle.com with ESMTP id 3bx4g9sr25-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 11:42:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i1TNQ3pvefwOWRANu6MDak/cc/ypBDjPegBA/rpvIinDYK4IWoGQ7+L4bdqub4t7rKHlPfF6ECQlV/ls6KprIGGPNM53KYyx0w1ED2KG/CwtrnCWS4vPkXAM/GHIIXgX2VJyGpbX37eJPR/+QGVhTGgikMIsbH4ujkbVQd4uVQidw6KY6P4KJoPFM2sXKSOip194P4ym7VTZdE/IZwHz71/e16RUudl0GUWWQn0E0lL+3fh1CX4V65OhgTiIg1iW9bJ+PLEQVrrnS91adrJ/9AXsHsoKUKrUT9+3rwi7EGfYR7AKlsVtpDxdDYazj2DjF4dxhi4p/mnSKvLMpyrYLQ== 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=DV14n7/S3wz2kgp24JFARftbQItwO4FTT3Cksm1E1Ro=; b=OMSsW1336egnehZox1bwCMvLWeGVutSD0q2vApGdpc3gTmaZ1OxNTXHN+t6CzDHZxAJMgeI42wSf5P5yiseV1hM7o+tZv0451TSxe2Dk9tvPaMVL3otSm7pDgA91tQkVWm20Rrw/cz6II59yVfzqBL7qXhZ3D3eprD2wXETJh6Mb9MmQi94bwy1r8dM2AKLuxZGxrEiDm9zx+fM4lKT/9WQi+ClQIpIudzz8RZPr3QyVk6avhi0m3Pg0UUZYNy01U5TutGuq2v7LElIUEiAl9qRD01h0WURNl9yRqKZ/qKOQmq3Qn2lJgLVKC+AWqr+lUND+97vcEdpqQddb4fdfHQ== 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=DV14n7/S3wz2kgp24JFARftbQItwO4FTT3Cksm1E1Ro=; b=ZxjY/imyFAr+4CDi+bJdOl+QTo6Qogza6zitcTJjjK969tYexBSaKRl+pc4Za6WW+qd/BB9OiisrLZadk4flMIMfGTbOXzIUlpho8D1BZoFszlUn36quwL91MO+R+riChfS7d3Dsr6ob+BGGFZsrQGtFh3OfyXbcRLad4Ftz04g= 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 PH0PR10MB4744.namprd10.prod.outlook.com (2603:10b6:510:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Wed, 27 Oct 2021 11:42: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%6]) with mapi id 15.20.4649.014; Wed, 27 Oct 2021 11:42:41 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v8 4/8] qmp: add QMP command x-debug-virtio-status Date: Wed, 27 Oct 2021 07:41:45 -0400 Message-Id: <1635334909-31614-5-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1635334909-31614-1-git-send-email-jonah.palmer@oracle.com> References: <1635334909-31614-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SJ0PR13CA0088.namprd13.prod.outlook.com (2603:10b6:a03:2c4::33) 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.40) by SJ0PR13CA0088.namprd13.prod.outlook.com (2603:10b6:a03:2c4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.13 via Frontend Transport; Wed, 27 Oct 2021 11:42:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e69e642d-963d-4931-8af7-08d9993ee238 X-MS-TrafficTypeDiagnostic: PH0PR10MB4744: 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: 0Rgl9LaGnnbeitq3inN2xQaefcrBizBZP3LgMKZiClmvXiXamV4vVGb5RxXIhaix+U2JFny1exuiX+W5zZNs0fNbSVPrpODM4DTQCS8jpKQjoTGI0wopmNe02MPE0lOcLuOV3nY/Fl50VSIJs4ojnhLAYPGWX+h1KLaZhk+irmWUSZSDHkZVydcCLM5NC1pTUWNg+rTW6pbyhjk+3u6HoSRhU6XiF6yr3H4A1cDUT0Tjb5ZHbmmGrf+NHZqQj4gJM3w75l0zwTMB7s+WroIMWpPCcvttDQQSd1zQHUek6MTPZU0gkYEJVKbLlu6fmpRrgSC6XOa3dfTHF5I8H00+Y9hihC6HMqzR6dBqpDzj5J4NBxT8BdfvfhugmLZCuhVUYSCYHepS6r4rTjqTSAzL/AoTrnsPWwJbdL8RzErdcsn5rYNSOn7UzhE2yLvSGu7ExEeNzgb94f2IsmQozgpuDB8wQdfS7PyLGQ36YBivKIpLgxdTSTcgihR4OoFjq3/JRXoNrRYsesKFYehSpOqebO2YTEEkSmKcNU8pOuSfW1ponKiUecmEPOOEx5QBXPe7kCoMKuU2ONKvHoNeBDc5lkEmwTCIj7fa4fKpsF15NKk45hZ9IpG0cljP2zVXqVPxaFjClqNro5bJ3QxrNCReg+hbkXfkw33FJpSLaKaRa7thy1btmsn+/uQ2XUhk7SSK5qRh1SWACtB9y7PgQ+QivA== 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)(66476007)(44832011)(26005)(4326008)(316002)(38350700002)(38100700002)(8936002)(6916009)(956004)(36756003)(2616005)(2906002)(30864003)(86362001)(83380400001)(7416002)(5660300002)(52116002)(508600001)(6666004)(8676002)(186003)(66946007)(6486002)(7696005)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Uxc4VmR7uu++QRBQWbWPbE5xE3/nav+LufE5/Qa5iWYGtxKIskuCzUyk4QysgxJoA3kAsqabsxJw/OiIHWFznUt/b3ZN6bY+JmE6ByAqgRqpsSjG+6cK1eOuBD15SCWT1MrcaS5jQTJHE7sp8tX25QwXxcJ8F3ZP8JqsPsnkCImT54uxsPpDop9O9OqbqGh1K6r7TL7m/GULzloS8GP/t54BztyXyHm08SkqlNyhFHYdjOKHeRFoEoHZyAhuhRtLwVx4v+W2IwjThlAoO4pPfS49ZrhtCTyJHwQybuTj/GgqNX1zakNfTx2jNV6yYvnfxFiythGC9e2xbqnmsT/HqvCuQGHoXcAW1iP00rB6PoFUoTHcXrSwHTPWpD0H1EMRZTKFX3RBObgDyTl9npO9kcldhBOyA2G8ocQ5z3Xh1Gt1/cHwqmzHnWrrKWzRirqQVpFscfTb0AgnjaxAjf/Stw17wFg4vCV1csj7J9/Upb9l5B8NKUh8HP6OSexOwhG0eIu+5c1uS7aB8ybwQr98ezerEMfMtPVrosGRO1sgbQ+In7NrBYgpLhgmCAZxlBr5Bts51YMS0q0p/zdbI5FeknJlUTQuDYfKWMtUmmV01wanNe4Ni57w8MJix67eiPo3JRMjmuEWTVTLQVIwYwqchQ+tH771ygMG01Ma8VT13L0+DoV/HBLzgS8lrbXFmW7Na1S326Rfkb050/LDxJEK99Iuko5pnDKJTCDN8jtNY3SM6BD6c8QckLXwSaptr7wM9vup17KT36cp6qzUlaTgT7SP93PsJoAHmik/g2gxHD4eXFEIQfBXmFaVLqWJJisWi1df5r2/NSiA4qXiwtTMhMLxQjZWN/q0FahcBtZUoA/R7ZqnicKAXNuH5d21jXScIamiI++pU0IJ9CPMsH/8YT6R6jSbwYVD1W8MHY6VcgT1A11r23Z84750v6IcC55dbi8gX0y2J3rf2NOKMIj1vV+11p4wZ4PcpRhGcphPrjSpsjCJTrbP/bE8oUmfWcE+kdf+uE70vD2CoQi4SV/oSr9mA0I8ZQquwnVf71eXxygZKnkTmp6myvf6n/6c+2eU2AHmI4P2m8V8zbbuVFen+/u9mp6RMWbv+qABgicr7dI+Ae3Pwji8lpslpZNuy86MpLNjzAwCgHm3X6gOZOggzTz5DbjsF+AppZDSMKF7WnrhtMEa31FDkFksDMpb6WnPc2pA3iOa4KoeeE4lkaM9QeFwXA0/UMg1qNavCbYSpJzgPLTR+FFWpINo8Ryo9GsE9PGnvFH0Qc3UCWd8qd3wacFyjLKoqflAdl1UrntnoOrNGMACt98DiLPm0qwd0JJm0TDdRRxsqf96Q0/U5zUQ/EwhQqlBNCBg9moOM+ciAZpzjHbPiU8iNXhb3vTwDZ67gFl0JHmcW2s6u3+l/a8B6tDynRmGngpqjiOJH0nUbx2x2xUPxpP0ExEH/gPobM+e4ZPiL93P9c5j9cChGUkvuT5BbKvZpBt3FXOCakPCujg7LCIOU/EettZznVWar2mhsXzlWAIE3SYfHtcHixDYv1yrZ6epGwMRU3+4i9Vy+WIUDfj9owdsAPc9ydk21yJZvdiSSAgfcP9JL8/Gy0sHTpxzoQfPTOPCTiPNu2yoUXE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e69e642d-963d-4931-8af7-08d9993ee238 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2021 11:42:41.3219 (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: XzbMmZwMelbeDcHGYCxn5NoXWNpYIFa7k6U4G6cilxJx5/wkaE0kE6focHCnqd58gm5cb0bmTOQ1xS6tnO7PFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4744 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10149 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2110270071 X-Proofpoint-GUID: 99-hRZFed_Nis5fzkTlplwX_zEuoPp5R X-Proofpoint-ORIG-GUID: 99-hRZFed_Nis5fzkTlplwX_zEuoPp5R 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.23 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+qemu-devel=archiver.kernel.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 | 255 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 356 insertions(+) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index d4a88f5..ddb592f 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -12,3 +12,8 @@ VirtioInfoList *qmp_x_debug_query_virtio(Error **errp) { return qmp_virtio_unsupported(errp); } + +VirtioStatus *qmp_x_debug_virtio_status(const char* path, Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index ad17be7..8d13d27 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3933,6 +3933,102 @@ VirtioInfoList *qmp_x_debug_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_debug_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 4490c2c..656a26f 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -65,3 +65,258 @@ ## { 'command': 'x-debug-query-virtio', 'returns': ['VirtioInfo'] } + +## +# @VirtioStatusEndianness: +# +# Enumeration of endianness for VirtioDevice +# +# Since: 6.2 +## + +{ '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.2 +# +## + +{ '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.2 +# +## + +{ '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-debug-virtio-status: +# +# Poll for a comprehensive status of a given virtio device +# +# @path: Canonical QOM path of the VirtIODevice +# +# Returns: VirtioStatus of the virtio device +# +# Since: 6.2 +# +# Examples: +# +# 1. Poll for the status of virtio-crypto (no vhost-crypto active) +# +# -> { "execute": "x-debug-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-debug-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-debug-virtio-status', + 'data': { 'path': 'str' }, + 'returns': 'VirtioStatus' +} From patchwork Wed Oct 27 11:41:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 12587153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 277C9C433F5 for ; Wed, 27 Oct 2021 12:11:00 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 50E9E6103B for ; Wed, 27 Oct 2021 12:10:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 50E9E6103B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:33356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfhli-0002xH-E0 for qemu-devel@archiver.kernel.org; Wed, 27 Oct 2021 08:10:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhKs-0001RH-6H; Wed, 27 Oct 2021 07:43:15 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:8022) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhKl-000724-MK; Wed, 27 Oct 2021 07:43:11 -0400 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 19RBgKbP010645; Wed, 27 Oct 2021 11:42:50 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=H0xgOvoUNS1S1cK/suA8UoJ1TtoWjrxWBi7YcjoisJQ=; b=m6Lng2uymjOnL3AVEMP+j+5Qu/y+MHyqbD3HkDM1Lt6dGR4l6NSuhiMhLzFnZPxklNMs E+4BwE8Q0faRQ2MOOw30sddlHJEtwTP48+BqcPJhOG+jEbVkheVrGhGEIxfrc4gIxYSV vo0GUoXt+7gj++rZkz19vdBjBVsAeuDMtH6x6THYI/TPoab/m7i/edG2pP98pd77SKZN uVWj8YZIyS20TIpes/A0Fw+qd5l8TY8QB5EAps36zI8Z2zFVdUC1nVevC6IgLN8QRXtC fmUNGhLV6JrIehRxHwEMvfkIUP140BJDC0lYazt/jdA2+lBGOSUGcIeyKxAnFAXyu/te dQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3bx4fj324t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 11:42:49 +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 19RBg0m1097311; Wed, 27 Oct 2021 11:42:48 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by userp3030.oracle.com with ESMTP id 3bx4h27wps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 11:42:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eKKZBqzq1CkIo1VbVxXuj1d6m5alI/s2tp1Ni5yf4lQaPn9n4RgAUsd0lsPAXRQg9Qqkmk90BCbN5j4EegoVUzP8YKbq6bMmjah5ZI94Jp8p2mCIVBuxpE4cwpvJpEMjZsloo0Jje3og9VCJtGycuExyOnkTntTF4Ax0Ko4vbj2jgyKCcMHq2cNB2FAFB8Jt+oABQD7JajZMfHI7r07StSwkhOk40pqm/07yTMrzzD5IUZqCmEwiJxWLgGNnxn2ic9fef2wmy7z2AA4PPXQURCXSEsWmx/NqsJhJWXR5T+opntvCBXPy4ueE5dbLzDnSrVNhbPuVfQzMLYVjWwO9Kw== 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=H0xgOvoUNS1S1cK/suA8UoJ1TtoWjrxWBi7YcjoisJQ=; b=JvdjhDTZ3bGLU1CQC/GcR4LrE8ODKWbn3Sg+v+9oHoTBRe4/BYfskisRCFY2Kbck2qmf+LnNmocjQ34AQy+XD0NmW8pOHdVAZJtE8YNAVpO3bkwlUFhp9bDDYNp1dscJ2q7nXtUQo+QYYbPDjoK0OmZB9luznEEIy5+YhDq03TJGUXGncsTUwNcvVlY9SzWhR5HwNATz7nTRuDzZ6dZvd4dm4GYQVIncXAIEYFmFhJnn2mDip1JwvAjZah1NZxv3GycUl5vm8E37pSlip6yAxwKZzejl+fq+M+o4WWjpGPKX+cS7bFQIC8SXJgcKK9c9X6z3ipsEfHCPczyY+8Vy6A== 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=H0xgOvoUNS1S1cK/suA8UoJ1TtoWjrxWBi7YcjoisJQ=; b=wgOr8hzOynEHuDMhylj81r81nnziZjhHHeZey9Z/Vewl/VZIU7JnmevBINyPKir/X9m1q0TPGHkV7sTfCqob9m/LvqDj+4PAgAESWm/iqtUWoxgap9mnUTvEq6EGYNOHglcd/jY71b6BC28J3+L7Ueg2ypWRlwJzD4rBUKzi2/Y= 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 PH0PR10MB4744.namprd10.prod.outlook.com (2603:10b6:510:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Wed, 27 Oct 2021 11:42: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%6]) with mapi id 15.20.4649.014; Wed, 27 Oct 2021 11:42:44 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v8 5/8] qmp: decode feature & status bits in virtio-status Date: Wed, 27 Oct 2021 07:41:46 -0400 Message-Id: <1635334909-31614-6-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1635334909-31614-1-git-send-email-jonah.palmer@oracle.com> References: <1635334909-31614-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SJ0PR13CA0088.namprd13.prod.outlook.com (2603:10b6:a03:2c4::33) 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.40) by SJ0PR13CA0088.namprd13.prod.outlook.com (2603:10b6:a03:2c4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.13 via Frontend Transport; Wed, 27 Oct 2021 11:42:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 393b1adf-e3f9-4b6e-3c05-08d9993ee436 X-MS-TrafficTypeDiagnostic: PH0PR10MB4744: 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: BecNAFcCQSNpZobEAn93MaBvwREaMM2cpoDcrBSSdOLMhhrQmZNm/1S7ik86p2wZaCkMRbywr5ty5ifxl80a0CXWP9H6IpNa7S7WY21e/nArdbgut085/gvFNT9FPZQYBPbN9gRNkxgbpRxHQe2GdOzl9oPxPPgtQPxR495TQKAtQq9hk/PqiyRoHHHNYTYXJUPGfHSSOLDp7MyDTjmfTdci46T0Dk5fqnTxezTOOmwq4zXJixNnvGLfs/qy6BbiwGkyINw/VHs8oWxMDPW4pL2nW9XUL4q5cOQwDBJW1NPt0fs3CSdb+z1czXHIeVTmC8oIeysu+0CK38U1fRUGo/drqFSeCEClOO/A3svqYob/eyJYgcCjpONiFCob1MTL+Wc2xNvnvljixAyyoAme5EX8Qsy8S4K0tWTdW6QpLghgCVA9aH3m5psw0KhfDkMijikChJQU2e/a2az2Szp5av/iyXl8vqooLXODqPPWalS1MNzCmGITDrr58AYv/U5s6PZcSKlCRx+S9aulrI3QSe7RkVWryow9qq8FI+D/pumALL6DCxga0AVeluah23KF3xU/9wMg2A2g91oB5iKjvRis8bQP89HmKrrEDHgfuP/eATIyMQGhfnfwkQ2xeZR8nEx45F+GihJMHmea86ihFxRkrEbShzaylt2mZWjcRHKf1gQwLoqK7bxK/2sUVEfWgAwD9ZhlCP94RO49Zih5Bw== 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)(66476007)(44832011)(26005)(4326008)(316002)(38350700002)(38100700002)(8936002)(6916009)(956004)(36756003)(2616005)(2906002)(30864003)(86362001)(83380400001)(7416002)(5660300002)(52116002)(508600001)(8676002)(186003)(66946007)(6486002)(7696005)(66556008)(579004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7vn0jT9bTikCIc/RliNyq6vVJnA7iW9R5wL3LlJiOvgk5ZH8qDuUXF+aW1yIjAC0SRKt4+FDtxgfPLe1HamVYjmlceobV1h70HP675skNw4blV5Gkw6CeNo1ElhsWM3Qh8INZle6p4GXxGY7Te2pNq55m1rieaf6vAlTuZR4mv06DlMnFrKVPcHnJ+pYPgpd8e9fl1OEtT69HM2hqoxAmmnHdQ1DoSYWdzgjBG3ruQti91AmQJbbU1W1QUmhn0ZRB4hA8wtSs8+23SCTc1oNxz9dJj8AFnHSXRj/t+k81993glhMt+O9ISLXIuO5mZQdbsg013NJawYiWBXovzZA0cVKvS06oDpNWWwbUbmofmed1EvPR0hgeFo0v7KXwgleYaIvxZ+nSIZqFqUbPJyneJaR8kayNpHDDMiCFmN5EU1qwwjVp+5cSsgjsPmPQ+1EUKb9zxjo7S/Bh909SQdrkyyMPiJS25PqAcKlxACGb0TaM7nOvWYw1XvyBf6Q2pBcMhoumdvsLNt4V8+hUj126EWMpdPzlDsp0gmxW039e1nKJ7kRAhTeXp9dK33QXLMR0ekS4He9HJWfv02BWeU0RkCztPfiAnSCe5Bn1gA4fzfnWACE8QQvZ8txbjZX1P21+zER7qwpyfdnkdm+lDaQ4lnyVB//yPLDytt2TY7/V/tD57rumcF2OV5bryoptVNAxpTDudNxgebLrVXj+gNNruRf8HDQgQPTlW8xQbYyg9a9B6RqMwWK3GoNDqmZikaS0X5oTQPooWLFhY8eWwLY5QhAl8zBqhBU1HN6VEmf2b3tQF/YifOOtGlkVO9P+c3VDsMppJzm+WPcnZI+WOcEXX6I+I27/eE4gunbBn1yaseOJ3LDXUmbe2odkdCfQa9EEaJkPbhdMyVVkQWU4anj8xSdkoAzuyTws9nKWMAqFbiKlAqOyKUMQ8qBmo6t6BC/nU6ojzgO8cutVjaVllSy0c+EyzVGNqtiqKt7mDywmkA+P1a+EV7Q4LI8dJim61LZN8JP0kOKBTxHyen3UIKsrdaUpVPTQnGTpcLDSJNkvW39QjnktTgHHG71fOfu9XPCQfOLefABO4HmAqD5FzyMl9BxCdOl0aMFJCEZswXqf+jIZmV+qclxtr1G+cTKRpTsDfu3VKXH9aqJGZWoxqrdMzNWaeREe3a6/KIHp0lweJhYC+rcyJ0R5rzBdq/mg0/Ds87lLLaLBCE6hqzplVkXH4Wwzapc8BRUq83ZRMaEOqli4z4FoajngacWqaY1Wh50N0KZlJFDgmfILW3o7qiwvT+knxYQHt9SaM2aaRmuML5sHMIDV6+k6BRQ2zSg5h6suP4AZGQ+Jh3TELUIe41c0NRLEh1vPW4ad/Crnv/lR3CyrvlLP8TzWu5/Itds9uuWvBDK5LMIwsfXr9ynQYQ/O1ixYZjDn0nBSC8UgG9ypfImAbjbfUh3Lt93w08B4rocrxKVy/Zu1Z2QSjh1IQ9S8sPC1fN0qtM0rOv9qk2AdohhJi4vIyH4d+rdxd0IkrAlZQsbN0i1VvlbMl5rul5LIj0rbV7g2doZlnBacHxXjcD2AU/v1xgYC/Qfp63zGM8sdaenHw4C2sgqiwABqx+v/zh50cbeIE4QTNWo3/UKTfo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 393b1adf-e3f9-4b6e-3c05-08d9993ee436 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2021 11:42:44.7448 (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: SfHisGd5VjqaqqRN6bOvFz5S31pMpb8dUEQj7Z0pOToOgtRa405sNjPKTwDPaMn7O8kQiVwlKKNQi4LNQgBpPQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4744 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10149 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 suspectscore=0 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2110270071 X-Proofpoint-ORIG-GUID: zGfky2b6AoTrgMkTzs8bqyd7StUpkW2W X-Proofpoint-GUID: zGfky2b6AoTrgMkTzs8bqyd7StUpkW2W 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.23 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+qemu-devel=archiver.kernel.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.c | 273 ++++++++++++++++++- include/hw/virtio/vhost.h | 3 + include/hw/virtio/virtio.h | 17 ++ qapi/virtio.json | 577 ++++++++++++++++++++++++++++++++++++++--- 15 files changed, 1015 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.c b/hw/virtio/virtio.c index 8d13d27..5bac549 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,164 @@ 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 + /* No features */ + case VIRTIO_TYPE_VIRTIO_9P: + case VIRTIO_TYPE_VIRTIO_PMEM: + case VIRTIO_TYPE_VIRTIO_RNG: + case VIRTIO_TYPE_VIRTIO_MEM: + 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_debug_virtio_status(const char *path, Error **errp) { VirtIODevice *vdev; @@ -3965,9 +4212,12 @@ VirtioStatus *qmp_x_debug_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 +4232,7 @@ VirtioStatus *qmp_x_debug_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 +4245,8 @@ VirtioStatus *qmp_x_debug_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 +4254,14 @@ VirtioStatus *qmp_x_debug_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..fc703bc 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -71,6 +71,23 @@ 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[]; + enum virtio_device_endian { VIRTIO_DEVICE_ENDIAN_UNKNOWN, VIRTIO_DEVICE_ENDIAN_LITTLE, diff --git a/qapi/virtio.json b/qapi/virtio.json index 656a26f..c820001 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -79,6 +79,463 @@ } ## +# @VirtioType: +# +# An enumeration of Virtio device types (or names) +# +# Since: 6.2 +## + +{ '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.2 +## + +{ '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.2 +## + +{ 'struct': 'VirtioDeviceStatus', + 'data': { + 'dev-status': [ 'VirtioConfigStatus' ], + '*unknown-statuses': 'uint8' + } +} + +## +# @VhostProtocolFeature: +# +# An enumeration of Vhost User protocol features +# +# Since: 6.2 +## + +{ '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.2 +## + +{ 'struct': 'VhostDeviceProtocols', + 'data': { + 'features': [ 'VhostProtocolFeature' ], + '*unknown-protocols': 'uint64' + } +} + +## +# @VirtioTransportFeature: +# +# An enumeration of Virtio device transport features, including virtio-ring +# +# Since: 6.2 +## + +{ 'enum': 'VirtioTransportFeature', + 'data': [ 'notify-on-empty', 'any-layout', 'protocol-features', + 'version-1', 'iommu-platform', 'ring-packed', 'order-platform', + 'sr-iov', 'indirect-desc', 'event-idx' ] +} + +## +# @VirtioSerialFeature: +# +# An enumeration of Virtio serial/console features +# +# Since: 6.2 +## + +{ 'enum': 'VirtioSerialFeature', + 'data': [ 'size', 'multiport', 'emerg-write' ] +} + +## +# @VirtioBlkFeature: +# +# An enumeration of Virtio block features +# +# Since: 6.2 +## + +{ '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.2 +## + +{ 'enum': 'VirtioGpuFeature', + 'data': [ 'virgl', 'edid', 'resource-uuid', 'resource-blob', + 'log-all' ] +} + +## +# @VirtioNetFeature: +# +# An enumeration of Virtio net features +# +# Since: 6.2 +## + +{ '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.2 +## + +{ 'enum': 'VirtioScsiFeature', + 'data': [ 'inout', 'hotplug', 'change', 't10-pi', 'log-all' ] +} + +## +# @VirtioBalloonFeature: +# +# An enumeration of Virtio balloon features +# +# Since: 6.2 +## + +{ '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.2 +## + +{ '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.2 +## + +{ '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.2 +## + +{ '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.2 +## + +{ '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.2 +## + +{ '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.2 +## + +{ 'struct': 'VirtioDeviceFeaturesBase', + 'data': { + 'type': 'VirtioType', + 'transport': [ 'VirtioTransportFeature' ], + '*unknown-features': 'uint64' + } +} + +## +# @VirtioDeviceFeaturesOptionsSerial: +# +# The options that apply to Virtio serial devices +# +# @features: List of device features +# +# Since: 6.2 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsSerial', + 'data': { 'features': [ 'VirtioSerialFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsBlk: +# +# The options that apply to Virtio block devices +# +# @features: List of device features +# +# Since: 6.2 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsBlk', + 'data': { 'features': [ 'VirtioBlkFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsGpu: +# +# The options that apply to Virtio GPU devices +# +# @features: List of device features +# +# Since: 6.2 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsGpu', + 'data': { 'features': [ 'VirtioGpuFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsNet: +# +# The options that apply to Virtio net devices +# +# @features: List of device features +# +# Since: 6.2 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsNet', + 'data': { 'features': [ 'VirtioNetFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsScsi: +# +# The options that apply to Virtio SCSI devices +# +# @features: List of device features +# +# Since: 6.2 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsScsi', + 'data': { 'features': [ 'VirtioScsiFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsBalloon: +# +# The options that apply to Virtio balloon devices +# +# @features: List of device features +# +# Since: 6.2 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsBalloon', + 'data': { 'features': [ 'VirtioBalloonFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsIommu: +# +# The options that apply to Virtio IOMMU devices +# +# @features: List of device features +# +# Since: 6.2 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsIommu', + 'data': { 'features': [ 'VirtioIommuFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsInput: +# +# The options that apply to Virtio input devices +# +# @features: List of device features +# +# Since: 6.2 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsInput', + 'data': { 'features': [ 'VirtioInputFeature' ] } +} + +## +# @VhostDeviceFeaturesOptionsFs: +# +# The options that apply to vhost-user-fs devices +# +# @features: List of device features +# +# Since: 6.2 +## + +{ 'struct': 'VhostDeviceFeaturesOptionsFs', + 'data': { 'features': [ 'VhostUserFsFeature' ] } +} + +## +# @VhostDeviceFeaturesOptionsVsock: +# +# The options that apply to vhost-vsock devices +# +# @features: List of device features +# +# Since: 6.2 +## + +{ 'struct': 'VhostDeviceFeaturesOptionsVsock', + 'data': { 'features': [ 'VhostVsockFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsCrypto: +# +# The options that apply to virtio-crypto devices +# +# @features: List of device features +# +# Since: 6.2 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsCrypto', + 'data': { 'features': [ 'VirtioCryptoFeature' ] } +} + +## +# @VirtioDeviceFeatures: +# +# A union to define the list of features for a virtio device +# +# Since: 6.2 +## + +{ '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' + } +} + +## # @VhostStatus: # # Information about a vhost device. This information will only be @@ -119,10 +576,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', @@ -190,12 +647,12 @@ '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', @@ -207,7 +664,7 @@ 'disable-legacy-check': 'bool', 'bus-name': 'str', 'use-guest-notifier-mask': 'bool', - 'vhost-dev': 'VhostStatus' + '*vhost-dev': 'VhostStatus' } } @@ -238,28 +695,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, @@ -289,22 +749,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 Oct 27 11:41:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 12587081 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44081C433EF for ; Wed, 27 Oct 2021 11:55:57 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C96856109E for ; Wed, 27 Oct 2021 11:55:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C96856109E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:37476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfhX9-0002m8-UK for qemu-devel@archiver.kernel.org; Wed, 27 Oct 2021 07:55:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhKs-0001RI-6N; Wed, 27 Oct 2021 07:43:15 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:11920) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhKo-00072a-Dr; Wed, 27 Oct 2021 07:43:13 -0400 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 19RBgGBn013553; Wed, 27 Oct 2021 11:42: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=kfwqhX9OWBYs3eENysnrf2nl3OWZ3DYXgUqbge+DHE4=; b=hUvEXpdtQYp96T1DC3x/brR3uRjaZ4NTzpLy2qLQZYzMdWcywuWveOpzCgwEG9fBpldI xzPUbEoiXAYPjGllEpdWb14myzSeXtJlb24F6EpDD56MVjOJ0StJI52xDf72VZcZpXe0 pwzVqJPB70QP2OyjSpDmaY5RkK4fhs5pwhRvYSjjGTYMHao+MUJsoFRTTyzTRgwkKzuv KfI1nFWc0lQJuXGT+H+5btu/bpfaaVLuf0Dy3Rehxvs7dtJtcQNTV5mo9LuhGZw/k5sE 6Sa70j6XQlzAC6yYjlKxXUJn6TZJ17HVxsIgE8fxLi5zhBGA0JVRmuMg68sa0iLCut6Y aA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3bx4fyj9sk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 11:42:52 +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 19RBfw2o067645; Wed, 27 Oct 2021 11:42:51 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by userp3020.oracle.com with ESMTP id 3bx4gqx3rw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 11:42:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b1xlkpk21YR1ZdwDrRdAlIPX/fSefEozCsbZVWS5SWoOlTvWmgbNDl80IML/BvPNxkekHyvvJhlzH0LdeWd75VGcVHa0AH/aTdlve6qMlW+Nc/CDVyn8RqhySVGzS4VqXS5Y8Cjus0BZNcns+cbtaLEhQOtHuFAV2ZU9kJ7tvSAos1922eDPdleg0xzGJkg1qdmr86an6DetnkeVniw7+XnbEAWhLPAgj6VYOWlQPDpOz1E/EIXDC/QMPiJ/75pFserCGnDLrB5EhmcSzvsgXCyPoRhuwqQ4I7VND6iCk/P3uT0II+j0IMIAlgs/mlm6jkvzp/Ilr9nmrBr2ufH4zw== 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=kfwqhX9OWBYs3eENysnrf2nl3OWZ3DYXgUqbge+DHE4=; b=hzYsYy2NtItrsfC/dMoJs1v+VjpQ1ifVtkUiZbnIXQrng1/R5klIsRVfmv7SBNpNJ2AlyHPSpK60R/bbb+lLqwDJoispb4TUw+HojqYFQMBVqZSi8PgZGPVkVpsjDpCGagPey82xeRhL8u48t69Im5fE5GEh68OToUGNNtSohFhgQBLseijQmPuaoLa1Fn0clq4L2Rsp9sQeF4aGG9s/1Ot8wYnW6M1Tdl3VmLfhzoqfKkA4byl8V7ADijNPxgg5EpzLxlLCywY7GAqaRFdfRiXiLx/imQ6q9rvA0Kn8DEBRs+eiLqpBe+/SylHBL/sN4jID4i/a1ctQIOD3gIJInA== 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=kfwqhX9OWBYs3eENysnrf2nl3OWZ3DYXgUqbge+DHE4=; b=qSvods8iiQ7xZE1jK567okq0hzZQVPap8qnwOG+NklER+FoXRCgDfmIv49xBJPJS7jRnM3sY249rfbt0Pbv7hvSJ6H223x36TXoh9Uz/AUSf2v868Bc9EJYFHhjVkhssvUl/fZKwdCAVJT4o4K32bab+iEsGvDk2O/rKOucdW7k= 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 PH0PR10MB4744.namprd10.prod.outlook.com (2603:10b6:510:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Wed, 27 Oct 2021 11:42:48 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%6]) with mapi id 15.20.4649.014; Wed, 27 Oct 2021 11:42:48 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v8 6/8] qmp: add QMP commands for virtio/vhost queue-status Date: Wed, 27 Oct 2021 07:41:47 -0400 Message-Id: <1635334909-31614-7-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1635334909-31614-1-git-send-email-jonah.palmer@oracle.com> References: <1635334909-31614-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SJ0PR13CA0088.namprd13.prod.outlook.com (2603:10b6:a03:2c4::33) 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.40) by SJ0PR13CA0088.namprd13.prod.outlook.com (2603:10b6:a03:2c4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.13 via Frontend Transport; Wed, 27 Oct 2021 11:42:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 041c12f4-c97c-4519-8537-08d9993ee68a X-MS-TrafficTypeDiagnostic: PH0PR10MB4744: 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: rQkRz1NWnY9u6GyTy1zUZmwAahMAb7yucnsgNH78rhiad3CcFd6BWfVhA/ORXUzRWpRomo5Ng1KkAhzFxeEw9iUWmQtJ1gNeez17++KAAXlD96CqbQC3GfCeK3sS5NnDDcRDydu9+fICDOoVJSBRqZj5AnxGtDuCX7fKNE+NKY+Pk0QYIkEgprt5v9GMe7/NCpSW5LvD64R3SgOvN3SB2NkTxaDVGMFP1YxshxfzSCqJjDXADJJKHkPu3siZwsaSh080ENXaP/OBq1DTAV72xt53jO0YkaIxrtInNlzsoB7s2KyanNKHUvuILDn/pCDjFchq6QRVB7aOnI4li+Pgf8hS57qRO6ITZteFU2h3ty6DTQ10d957EbuWgon1+Nmk+hmufvvNeX9BcZvOTl9LgGZSMjezZRfevgEiOJBZ3xbknUzLwEeyfWQRi0SraZAbwPvLBqomrjfJyTiGEV8xywRU9vI5EaZYyW32bx08aUaqurY7yXjhh82IOmxAPPqQ8LU7HrErqu//Wjn95+uatfIjWp1ujkLYaVOh6jNXWPoxlLh+Clo1t4CnaVSZljyP7Jj2ea5SI3eqPzIxlpRMvK+YrDJaQXPl1cI8p4umJiu+zGYnlmSB8PZTAW9QFaXeWAaqUC+PqnNCXDLgpoqVb0frtiDMCApr0jU1JIp8qf40WAA07JnTuwidfOrtn8DM 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)(66476007)(44832011)(26005)(4326008)(316002)(38350700002)(38100700002)(8936002)(6916009)(956004)(36756003)(2616005)(2906002)(30864003)(86362001)(7416002)(5660300002)(52116002)(508600001)(8676002)(186003)(66946007)(6486002)(7696005)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: atD2GMKVAL39VuEXvmCIYKxke9z1PtBgnenYrsKtVrTmUZoZmDrKx3748cQxFXtIiMHTMLtnYwhwxqzEDYQ7l4MaQrPd/8h3b8q7OV9bt8WGBEL/RnuzUV9a3YvuW9MSH205dBNfgBF+gMG5XsH22wTTH/fOLzoo7OSyVw72aUvtErRlH+7KYSdX+/7Ow3C4WC/LK1ZaciY8vw76NoFWgqlPqBW05EZBnMZCslnmUOHa37Uj7VAwgYAylFCfBnOK7wbMshKnZtWWTb0EV+6nwO22Gi/ZbeEgX6YV8C+TnuYtZ9lYAD1aOLdLWqw+2zfZWN3V5aC/Vk22/tZ/zM9RUlM/AHj21CMzFHAQCCvjAAnNMhTNajPUajOtC9jZYZx61Ku/NOEG4xwi/thhSqkeWeR+tpQpNMZlr9qbUy04Zta68GnFjF59wQtoSaIIAe/JNDsOwSYmiFLjHsnpRemMYlu9ErAS88UbNIKh8pm2Juusy8DZWwraXR1lfDL/o3yHU+m1/ekQ6FeRzwcsNtOUIhK1AKEKSmzkPQKl10wxoGvDEBUUZTA9JnoTUyaVwDR7DEk7E+f9nrSfp4Y8hxApxrSP6KI1OA48sIac/ntZNMXaP9MeE4pJe/7fJ0uGNgFG+9QvRQPh2tM5/pkZFUNAuUl2h81R0SuKVh2elzhwv0QFnK8keFc2B/pLaktjEvvGM4GvX/gucEJ7aU/IhRuarobSio/cJhcgEH0HHLUd2M9LFn9fVUSueJOCbK37g/elWOgRxEuCOTUV3qXVfWIDu6aLihvddpaa6eWQfdD761krD+o5fQH9EffE7RAFwvKxuC6+K1/NDYaYn2OQJxSdcpnwB4FGRJbGzu8mU+qirIPtXR9ZGh8OwDxje3YOMIVMmuhT7oL5tOGjUFqXAP2Z/MvgloWmoQ6FDiTkrRUeZqT4NGpSZFyen/kJvRIIrIEkiUeCVzVYdH9PgVqsUJ4VvmXBGCWgUsZMk4nP9CVaCZCr/ZlBUY2h1LwJqWxxxr0T0KnzBesV2d0YPnLi/09WY8gnGrcbOmrmOroTOeKqOs3FJnFntN3tRyz5TxI3IewhUqpK0jwzYnXuxrxsZsNfulQm8XwWYDDHVot701xi8gf1DKq0NTzktWnxTx8Kc9E4Cj8oOTITqTpS5Om0XiVFPP8xj90sP45A1DblxNvwTysa0WFhfRq2LVjX7pcwATIS2HxlAPLFnkomaTH7P1PDLQSD8TPZTc0OHrFmquklrxHRH0ySpRGGZY8g1r6qYvk7lkWAMzSRZdlUI0jnwwJXaUjJi0jLRa1JCR6YYmzNIo7ftoctRhbaPtjrWSlvRRNbAjdkeWKmyx3Ct8aAAVKXk/uLqZwBVxrbxC3pVZY0toMyN1JuWj1nemXqN9mFRyhHAOaI8UKM4VzMsVLC6UxDvLswdk7BiqUYAedWM0WVMf3dmErw15AiS0J+wveh7oyEV1+M4S2IJQ5TyBOZU5o0mxvm2cHNe50d+vY+ZmCAMHl2TQA4GfzCiSRLE4Bq6viefzGSqypGIb24l5BbsnsfjywKpAAkiNXS10X+91xteNPodRofIeyBW5ncKMkG7bmTGRFY5/lfvzQMl9KVdt0gzEQV6uyLT24tpFk9OT9sVWs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 041c12f4-c97c-4519-8537-08d9993ee68a X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2021 11:42:48.5879 (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: 9dh4kja23V3Euxpu4TWFjKq2SvO7ITSNXrD83C1mzBe9ROPG1YDI+JCY3BlkQ7eAtpYshzmcmv2zepLA2V1f5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4744 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10149 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 adultscore=0 suspectscore=0 bulkscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2110270071 X-Proofpoint-GUID: voLZRcYvdpUKG3ReVLu96hZulFK8C4io X-Proofpoint-ORIG-GUID: voLZRcYvdpUKG3ReVLu96hZulFK8C4io 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.23 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+qemu-devel=archiver.kernel.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 | 268 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 385 insertions(+) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index ddb592f..387803d 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -17,3 +17,17 @@ VirtioStatus *qmp_x_debug_virtio_status(const char* path, Error **errp) { return qmp_virtio_unsupported(errp); } + +VirtVhostQueueStatus *qmp_x_debug_virtio_vhost_queue_status(const char *path, + uint16_t queue, + Error **errp) +{ + return qmp_virtio_unsupported(errp); +} + +VirtQueueStatus *qmp_x_debug_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 5bac549..7fd98c5 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -4284,6 +4284,109 @@ VirtioStatus *qmp_x_debug_virtio_status(const char *path, Error **errp) return status; } +VirtVhostQueueStatus *qmp_x_debug_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_debug_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 c820001..7b67235 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -829,3 +829,271 @@ 'data': { 'path': 'str' }, 'returns': 'VirtioStatus' } + +## +# @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.2 +# +## + +{ '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-debug-virtio-queue-status: +# +# Return the status of a given VirtIODevice VirtQueue +# +# @path: VirtIO device canonical QOM path +# +# @queue: VirtQueue index to examine +# +# 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.2 +# +# Examples: +# +# 1. Get VirtQueue status for virtio-vsock (vhost-vsock running) +# +# -> { "execute": "x-debug-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-debug-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-debug-virtio-queue-status', + 'data': { 'path': 'str', 'queue': 'uint16' }, + 'returns': 'VirtQueueStatus' +} + +## +# @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.2 +# +## + +{ '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-debug-virtio-vhost-queue-status: +# +# Return information of a given vhost device vhost_virtqueue +# +# @path: VirtIODevice canonical QOM path +# +# @queue: vhost_virtqueue index to examine +# +# Returns: VirtVhostQueueStatus of the vhost_virtqueue +# +# Since: 6.2 +# +# Examples: +# +# 1. Get vhost_virtqueue status for vhost-crypto +# +# -> { "execute": "x-debug-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-debug-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-debug-virtio-vhost-queue-status', + 'data': { 'path': 'str', 'queue': 'uint16' }, + 'returns': 'VirtVhostQueueStatus' +} From patchwork Wed Oct 27 11:41:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 12587075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C1C4C433EF for ; Wed, 27 Oct 2021 11:49:31 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 12B3560E8B for ; Wed, 27 Oct 2021 11:49:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 12B3560E8B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:56540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfhQv-0004a9-RO for qemu-devel@archiver.kernel.org; Wed, 27 Oct 2021 07:49:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhKm-0001MN-Bf; Wed, 27 Oct 2021 07:43:08 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:28606) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhKj-00071l-B1; Wed, 27 Oct 2021 07:43:07 -0400 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 19RBgA0w012296; Wed, 27 Oct 2021 11:42: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=tUWUamb44OzGr1g1pX5OXwZI1gpljzlXFwLo8k1Kgek=; b=YFEqnsTmVuqXCmnCNqBF+7gcq+T8npX/zVgq5qdseD8uYD627LJSVap/eTiNGI3tV2Y9 mvbhXXXHZ0eKRa3Js60a/NUqLXsqLVeO9AIXNBQJlFgsCQOQcb+l16TP6FP0TNMYkSDs ryJsEacHAqXg7hpVhfqtxIp18LahB49kqEGGfCu+hORRFiBhVk30nXVndbKT22hcSoSn e/+fL7Voy09nAcGz6YrLUbPkOszdyF/77b90krWXIOfJqgE+2GGG25kE4HQvojfOvjua eC7piAyjI3qhyXwZnMHiooEWM194JS76nVbWS+uklyADoJZlSiDWo8Uo5qGNc6WSDzi7 NQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3bx4fg1uwg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 11:42: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 19RBfHRW159597; Wed, 27 Oct 2021 11:42:54 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2105.outbound.protection.outlook.com [104.47.58.105]) by aserp3030.oracle.com with ESMTP id 3bx4g9sr81-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 11:42:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F9LkCj/bEibKSY0nLMbrhrbOLQKgQ6UwclvzmnEdRjjdZ7jsa+Pnk+AtXYZf/vMUEnTkToBJ1PYWh4bK3Ed3cL2oAwtV6O5FhCGaB03ccyopbEpTAuAveTYIzznbddMVZlKN4Zt25wvSy64HX9Z1SpHR/ruciwT+JM8jsKk+LsUfblxU9KhMVOmYPqP606AlkANIEtH/g2E5/s8D4IaI7L+xghlyXCve5OalDCUA/Vvf/lqmF/E6Ns4geV4xvlMv6HbwhZpNG0AODfuhvjhsACtIQc0WDbSMElhiIw56qbcNvyYyuEDEA2iL2JvMJSEe+ev7yE+1kjMKV5fKwpszlw== 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=tUWUamb44OzGr1g1pX5OXwZI1gpljzlXFwLo8k1Kgek=; b=ieDk8BIPQocywKUuznoEf2cKgI8imIqqSfXJzn/ikUSQrRtFA4FdzQPUlWHHcw/h5DoG7wA134//rlynMQmw6GwdEFaDUu+UD4AVSNzwQc4I06tEd44NWk+TXDowTb1Kx2IbHdkqP8GYQRDB0lktg08u046DbR103SiWsC3YOZlWMeLpgFDKmJZaI15iJKyaE3A8Gv893ud5hKBy3atR1eDZqSF19Xzc3MJIZs4ZpXYq0+5jhvkEeljv6i+NVAEefXqxP4dQ0HDCxEsHw4bK1pzzqRS9748cWhr1ALTMWD84Zq1O/NkUZ2Fc0CVe8RmCsAExly7/3jNqeRQk0HBD2A== 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=tUWUamb44OzGr1g1pX5OXwZI1gpljzlXFwLo8k1Kgek=; b=QhXgIP1is1q+0vPhS6T0Nkf4bcGCfv4PEpg8o8//o1iuyKHI/nO+NulCIdEcInRmz08bisMRnESEHKgwQAKUnYHIrhV4qljuvRWyBBgrhK+e89bYPV7d/4VEgbMNl1xS7Pu2oNsisPQ9yvTN7uxp5j0E3QruUcOHV6YRU4BPWgQ= 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 PH0PR10MB4744.namprd10.prod.outlook.com (2603:10b6:510:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Wed, 27 Oct 2021 11:42:52 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%6]) with mapi id 15.20.4649.014; Wed, 27 Oct 2021 11:42:52 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v8 7/8] qmp: add QMP command x-debug-virtio-queue-element Date: Wed, 27 Oct 2021 07:41:48 -0400 Message-Id: <1635334909-31614-8-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1635334909-31614-1-git-send-email-jonah.palmer@oracle.com> References: <1635334909-31614-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SJ0PR13CA0088.namprd13.prod.outlook.com (2603:10b6:a03:2c4::33) 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.40) by SJ0PR13CA0088.namprd13.prod.outlook.com (2603:10b6:a03:2c4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.13 via Frontend Transport; Wed, 27 Oct 2021 11:42:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3b2c8df2-254f-4c82-20da-08d9993ee8ad X-MS-TrafficTypeDiagnostic: PH0PR10MB4744: 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: vOHRi7fW0ZSB+FJl96Ee0lzkjhqDC98cr5BxIPHZyRFdyGkXeXo6BVim8uubEhdqMBZFhJhvXG9Dx1turGsvEwFwluec3cT67OxC84MfLe6GK5zybiJ61FtRK3n1neXei+B8vfoMhBN4CX/SaS74D3gWR7jYKAEWMtf4F5OcuEx1/fx8lnVlZC6JWJFLM80YSWV5GNiTm/xCn3d/YPGvNq8UswQZw+NVRMeLOrCOYHNb6U6oms2fbvcbfHFTgP54ditbwdwbS7EIDF/lk3yMaejHmkndBRFhX8P5HsXNkSYgYsNgvKXLzkB/VpWhr/wWzTVhl68dNaXPOq/5W780wSlu7VFzv5myMdhJ8eJX5JtOzEQpOpvqO503MC40diKNknfpS9PZlShSvcJA+iHGjOlkm1a5LoK+HoPM0HtjhbQyN7RrmWs06EyPc4kcmjm13AFN61y2R+cessoaaXZaEYw6B+a6k9DDBFJL2N+Uiux4HcZLQscs0L5TvyoCsFMDXZhQFJgyk/+8CgFpmSyyPdJiELurPhs3ALkWfpZ8fkXkynawNiWZoiNPZYf+ArA1XzRZNFjocQsKhMUF8BOt02hm6y17LiTyZzYJUT1xkzokB1rpnZtOzGsCGPqv27zn7Ht4YYuoKj21CsZ+uwC5+BVZTwkD992ge/QxMN7Wq3EphU2vn8IUUOHizb3+neVaVyKR4JkFk89dHiZn/379ug== 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)(66476007)(44832011)(26005)(4326008)(316002)(38350700002)(38100700002)(8936002)(6916009)(956004)(36756003)(2616005)(2906002)(86362001)(83380400001)(7416002)(5660300002)(52116002)(508600001)(8676002)(186003)(66946007)(6486002)(7696005)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Qf77acQUJTCY7sUTpruhJ7MPnOymJxTz3gnYmwxS1CRpQlc7uF8AukHtuIh//XwiAxk1yBSO3g9C89Y33EMnSblkmn3UX4vQGqbsnLfkmeb3OCyTB2Ez07G8ZAqs+zr/LPYWFCVSlmR3yN9w5SWj8jm/mA8VvGnR44cQJLzWJzMd/rdYa9ht06pc8itL3W57P3Y2kN2E9yFURIEG3c4QlMeFnZI7td3ag3nmAfetUGXaA3PLq6Dfy/zLpPVKnVciJuI9UHBVDlRnRjqkwzz9Oey926q239AZ4Xvf2bSxPaQSe7hLW+/i2lYgEQBz6aAbYIxu4C0/RadEFUpSvE0dotW5YmZHNbLCcWMrxvN918LfWo/dqE2IwuY4JuDWOKSpm9sxNQZOz93bB/qp9lFxGYf1XPuEcx8xd6TBg5AVJ1ImqAbekLQVVWqSUu18wUVOu0el1GfDA8flKE+E5EIH4RfrtnHftSWEQRAmElG3Y+W9pxqVtFqvaBZv7BQ4ZdvRJULYpC4MC1tvlFg40Zugdlgelq6RewZY9X3ji1KZGURrLfP79n57p1BcgsBjN5x7cYy/tPhLf1s1OjUW63ujz7cC0gAexaHwafNKxpUOiqwSYqyEmmpIxC36+8/rWqT5wOTVAYN8Z+m1JYl+zZoHbgV7sa6q+dEjVCMeMfW5NV9hPUi7oo2q8aKjOCdWaRWjzPXMaT1ulJErPG2erx++hPcvORpOiiJVbWAb8p1oD8sZu0mNw+ugYJxIm/DVE1j8u/STbweLWHpxt2JNZGHXoBIUAG7aBAXaBnKTwx0BmOXYEUeHvCVimMbeHQwsQepa13C93sJx5Tqhf9kvIfUftc3+Pr/VEcJcctjuhR9tzeFHBPYCkgXoPivUvmtAmJ9lmLkCVZpHYnF2vpms8o7Cq0Kn24MVaWMtEt/YVHmDV64SYpwgzQO3Tq3jAG1S2W+NfRotnU+pJ8Kfgf5le4KFcqWOKLw0H0zgIpl/sxnzsOwJfJG4PdvUAyYMLPgTy01GZLZOdy0zgJfNhStnUOcYc9nNgqspkPrVfkVTgrd+P3dg1PhXp1rdMW+Hk8HhaPqnDOl9DAt1ePnNGYVgODjy9QfIP7ielV1GUbBj2mEc6J0Fi6ogVgXjbbm9pZL/iZkesTgqdmTWUAsQqnHsCEyQENqp/pB3WDHWaUiFuzkIhm4JhO+zGaGvih42Y/ydY+pU7ipEbWAJhgqDTc5cvpIiCYvL8f7rEuL++KWNPFQMz/dt3enKzcraUrCUjZ5Xio7PV4DZkScfshQnUm9GQ0V+W1AE8JQ6LKD44oiFjRcCNClhLSxtRfnTYUiRoRJ1x5BmrCn7RgOoMj2RCjURIruFQYDHKX6B6pcEhemlxy9NIJnAvAz+G1xJuBJCTi4DBRpLowfsYV62VjdmFy+RTXGT8vvi67cdkEo+HoLEpYLz5bMozCYhFjtpD7mD0uzZ9SFzkzv9YA+3V3nOXtwruXKrt3WpeOocPWx00lv3TSjE4JlhYYPN31o9KVlA+NVMQbEFg+443mZx9sbR0/TnS+SUVbP1teg5OcsbM3A8mOPtDGLyY+SWx0Tu6+34fa29fbk69Oy9k89EXqqfkMV3SHwmrR/xfm7Yuj/kKO+jF/Brz18= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b2c8df2-254f-4c82-20da-08d9993ee8ad X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2021 11:42:52.1950 (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: WRYi2NZ2EzbCLGgkFX0qm8RFnhi0mk3W9W6BmTW6t0HysUdzft75RA+BBP+C4H3RhcWMDdDxklWchYmZmP0jSg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4744 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10149 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2110270071 X-Proofpoint-ORIG-GUID: nN1Xc_pHzhiGucTWuVHLBRmTc58reH1B X-Proofpoint-GUID: nN1Xc_pHzhiGucTWuVHLBRmTc58reH1B 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.23 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+qemu-devel=archiver.kernel.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 | 204 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 367 insertions(+) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index 387803d..6c282b3 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -31,3 +31,12 @@ VirtQueueStatus *qmp_x_debug_virtio_queue_status(const char *path, { return qmp_virtio_unsupported(errp); } + +VirtioQueueElement *qmp_x_debug_virtio_queue_element(const char *path, + uint16_t queue, + bool has_index, + uint16_t index, + Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 7fd98c5..8c8a987 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) { @@ -4387,6 +4400,147 @@ VirtQueueStatus *qmp_x_debug_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_debug_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 7b67235..232f0cc 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -1097,3 +1097,207 @@ 'data': { 'path': 'str', 'queue': 'uint16' }, 'returns': 'VirtVhostQueueStatus' } + +## +# @VirtioRingDescFlags: +# +# An enumeration of the virtio ring descriptor flags +# +# Since: 6.2 +# +## + +{ '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.2 +# +## + +{ '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.2 +# +## + +{ '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.2 +# +## + +{ '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.2 +# +## + +{ 'struct': 'VirtioQueueElement', + 'data': { + 'device-name': 'str', + 'index': 'uint32', + 'ndescs': 'uint32', + 'descs': [ 'VirtioRingDesc' ], + 'avail': 'VirtioRingAvail', + 'used': 'VirtioRingUsed' + } +} + +## +# @x-debug-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 +# +# Returns: VirtioQueueElement information +# +# Since: 6.2 +# +# Examples: +# +# 1. Introspect on virtio-net virtqueue 0 at index 5 +# +# -> { "execute": "x-debug-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-debug-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-debug-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-debug-virtio-queue-element', + 'data': { 'path': 'str', 'queue': 'uint16', '*index': 'uint16' }, + 'returns': 'VirtioQueueElement' +} From patchwork Wed Oct 27 11:41:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 12587181 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F396C433EF for ; Wed, 27 Oct 2021 12:17:28 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C2AD460F5A for ; Wed, 27 Oct 2021 12:17:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C2AD460F5A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:40832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfhry-0008LE-GF for qemu-devel@archiver.kernel.org; Wed, 27 Oct 2021 08:17:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhKy-0001UY-Nj; Wed, 27 Oct 2021 07:43:21 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:45198) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhKu-00073q-Bt; Wed, 27 Oct 2021 07:43:19 -0400 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 19RBg9La012290; Wed, 27 Oct 2021 11:42:59 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=sxz008/SYJp7Du6pULrcUMZoiovVSa99pSm+A5xKus8=; b=DPbhZiU3UNaj0HR5Ni4brr+2ULU2SdsHNSPbjp6A67znXclHWpJ2qwwl/r4XY4WeMB+g bgFtqCGvuwQzb/g4tYFWaA/oDZHHJaMrwxbapVDOgR2Dkw3l+In8ck3bdZ30WJ6OhfbH W3STqtTfhz3svkuV3THpCDQZKvhltfCSGP65e2UkdDU/oW0fHzFii+W9m2dWzG28ZHJi mK/wZ6jRabWEFqaAFl02bGouqC5mbMANlvND7eV308AT9mYX0g/ZbjeGBw4DvR24WlLw GzbnB2QIEe0iY+jm0wFmHmZPsOxsZwT+LmxeWRfeGrh9Lwc0Ak1UalgE5Yn/si2m70Br lA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3bx4fg1uwp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 11:42:59 +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 19RBfHRs159521; Wed, 27 Oct 2021 11:42:58 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by aserp3030.oracle.com with ESMTP id 3bx4g9sra2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 11:42:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uy7ezxJvcWakG0TjlT6lRBHGkevuRwRfS+1Kc3XtG4Dg04/VygEeyu2gTsT0hVaPsxwzR0JDsyr6lZxKCgn0yHYCkOY0237Zp93dJ11BPpVhbCMEJawGdZa7/SWNpXhwflyNFyWZFy0Q9lRu6tcCdaMwpfTuw5RlSTx6Ivgt2ohcutMimL/6yO7Tfd+qNksrJK0QH/qnzVXCHKK36V4Mz66lJyA+GO0HzrxJCvk4qyZgEEAT36KvXQCXa9VkY2n6HfaiGAIMioWnRCkWUnZdg15DPEW9VNH7YrRR5ZIab+h6OTywqQBpek6CAxUaWnp7+4NqcElrN8t4V7d5QOL/tw== 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=sxz008/SYJp7Du6pULrcUMZoiovVSa99pSm+A5xKus8=; b=KOVAcbbAGXNfX+heou02h7NfgnLEpWbm4mrjaPX2S3xmiBZB7K+5C1NQDgF3Qfc8ANPS/qHjqUGh3UxTKCPP6ueTd+hzotSt+S9ntscyzz149Po42Pi650qWfUxtqaO4fFWQbtjgUXZunhRwfS6qFzOkeQ7bmYPpFjptixVtg/EbNEdeuF74z4laEePw8QjwLWTslUnL5AWzYnMfVVFUci2kF55QVo5dgwHVX/Ik85fOpaQUDNer+gEITXoKnRaUzMmMytVmfHw5qi+h6ipVurrUnX7oK1RkN6MPwJhVjRkMfUMgVvR9wVd1ligXnovhF6SDBeyWajLhQsc0xAlSjA== 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=sxz008/SYJp7Du6pULrcUMZoiovVSa99pSm+A5xKus8=; b=rRqw2JLJWNxhuEOS+NwnjdE1Ut/eWbjjA2gzfzcrFSQNdlkLk8D1WHwnUi/jO+6pU3aC+9xR8pBJGdAF59/U/IHFG/T79i211YpfdE28io8v2+ia6c6E8j5SRVNFt99aPjV+ryoKRbwoAY1Haj8b3WpUjPq2uMf9QYvlZvLc/HI= 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 PH0PR10MB4744.namprd10.prod.outlook.com (2603:10b6:510:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Wed, 27 Oct 2021 11:42:55 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%6]) with mapi id 15.20.4649.014; Wed, 27 Oct 2021 11:42:55 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v8 8/8] hmp: add virtio commands Date: Wed, 27 Oct 2021 07:41:49 -0400 Message-Id: <1635334909-31614-9-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1635334909-31614-1-git-send-email-jonah.palmer@oracle.com> References: <1635334909-31614-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SJ0PR13CA0088.namprd13.prod.outlook.com (2603:10b6:a03:2c4::33) 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.40) by SJ0PR13CA0088.namprd13.prod.outlook.com (2603:10b6:a03:2c4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.13 via Frontend Transport; Wed, 27 Oct 2021 11:42:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1ebce783-4d6d-4715-06ec-08d9993eeacb X-MS-TrafficTypeDiagnostic: PH0PR10MB4744: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:312; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m/Z1J6QgNN8cnqo7jGc1sBTsUv45eptlkZuHJdi+kqCAspcF+7ro7D6t+kH2knFUshcGR7Q0eGfwGJ1s66ONeYZIvqa4VgPbgv3QfxIlLk+pXO/LQi5iW62XKAmTg7D8VI+FCkq2nm8QrDd763rl6W/H5S7QtJ4KKpT6f0ESsYRZjz1iy3LZdKLpqoSICRzXEV7HLtSJKNi5Y3CxHbYJOoMPTN+LRAe1f/yadffTPJRfKaOy4nNLqKe7LfKZ+UAS8V0W/njVO72zbXCvUN2fm7mT/W5KW1rFEMyQYW6h/2pfYBU8ljOPO7X9BhfeMtDyJd1X+/v2ELSq0L1VHLb6sU7zp2p7p7FkPhniuwxINzRduPj5TCgAlCKN1pjzKurkej8SJECB2+q6XMmvAS+UHniNGmEIPRlvWLXAfxAhKFv/Efbx0fAMereX1+y+gRt6yy2VbyDSQCSAfvtgTv3HEhPtG4P5z2dHigkYTV7XmzYD8O+Jdpn0b5t9fNN7W0PV09O9QfGvR3mHfgmwbD2HNgQlRBP9aRXnbF77CPU/C3Sh+208kEOm0D6rNTqZfxhVV/KbW+UA1xGm2R6QE3Dpo0dJ7JwJ3R9hWtvdixC9xNcCNxu4iT2y7R9Hz7WDG3zkFIh/TqwZcSlVfzxFvBRhY4X07weUqQcdB6yt51RtOTeFbmqSVPluFr+Ba85IQ3Bkq8nEtYaITRgjkqk7qwiMNw== 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)(66476007)(44832011)(26005)(4326008)(316002)(38350700002)(38100700002)(8936002)(6916009)(956004)(36756003)(2616005)(2906002)(30864003)(86362001)(83380400001)(7416002)(5660300002)(52116002)(508600001)(6666004)(8676002)(186003)(66946007)(6486002)(7696005)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +qQivth5UZqL6oKPi6/crLBy16senha/YwFQ90FkU41TzvAZV3XLiONBK92LNH/AxxMY7ghGjRTO6LcHjss5/hFq7q7oqY6Sr2j8KokfXv3AYPDd8Q0QmEoZvyI62JJdLpLR7+VODGUsaOWKrfUuTGb+ZAg7WftZ/eK752C1jr5St+7wvrHM+x+6OERoBz4kLH3OqEFm8pF+IMnTJ/GaxXcHH+3LbIR/x6J2LHj5lQD3UFKBhj4WyvMVOBBSoCZJlMssfcpychdkMn5Bjf5sQ7LJmN2dvCDuajnpHvdmLTxhLvreZ9cSqUR545YHD5g72d/uwLVZgt/6mnS19pLlJ79PMPhAvFzGEdzqINCUz1+UoJV5UoY8hHr3OnnOuol+TB95sYg/101fCGNE3okGHaHxm22pMxMwLOi42iDzKkdp4j/fsUlbJKydVnXvhK84v05QyTBA6L3kQrI0/ZB5BjhggsKoRt6UmzwKiEIoAlmKpydcAFvyASPxtjfvLfe7yrmIpEa6Dz131yGjhrNSb7XCkn5c6FGs6zlekaMteh6SwqZMSTX2OWzNb1/Pk2icSPSy4nBfN5EuTtKvs6Eg7K1Rw19tBS5rjbuigzsEgI4OghebLdX0+bztjKHZnQh0ZN0UvpWi1bnfX91D8F0e5Ri7zgzS/gyt9lN3V+4ERq6/5/UmzfToELRRxeh6yy/x1haxi2OvpLRl569qG5WzyFB4lVkb9i3yydZCijEMTTZ0i7cQfcyVm+HciCtXPePC4B3noqDbWYxjow8dCTRvAFkX3A1mIBoVXwDODUgDa3L5N32spNrNbz4RHVNCozg414EXeYs3X/X1HtxqXPc4Rah5OQEn/iiQSaNnex9kYDHw0m0oJY8AJZmtWI3jzU87kVosB7ZneWzN2exlWZgbVmVGGIUErO4M1Sj5RBcj05w3T3AS1gKZzpv8Es2FyobbU5/Hqq8lA0dFTqUM7liC65RwCu4Bo5csHnqn9Y44Cu78VXQuXxhpNnaxTSndwfId0okYJBaBareoF7HM8alNfVuQl+w4BAnw5GlvE50qwumJd7bcViMePNos7njrcHT+yGJrCk0qSuGuUFA1SnbSl2wyBl3D4ZtcDAomUhXSrZfEZ0SxCBwpGZ8pZszyoi3zIC01KaSw7AYvoFFUnNJFazEZDQBw9LJMGEz/hjJO0TVw7p5MK0i6gIfvJlTBccocInRFUP+VBCMtpnOjGwjEiAjvduXC2qUWvI5RyeElb9FddbhfIVwyAWCBtEYkBSm7pl8owTVqFdifpmWRv+pxMFuaZF0xYwPKDmB06l23d5YVxofxj/q2m9OTtbz0jL+9ClG/O33iNzRxDf+8p6SdrHIATne3mKhgyhhCHzMLBV2GFn7OcRK0y6OG5nm29OX4kf1QtpjIgqQvld+1NAqffa3hvvKLQcy3tSZ3E1hDUH3lwfyF9g8E4lmRf4fcLrGfTWV3Ey2MmXJ7uyzwWjSfmeiV6e7OZmH8E4S4sPDaCZ1F54RYe/osyyL1NCiO3CocqDcDKAGzrN35pH4BObCZEp52Z9Tbspi4/o4qxjIxS8H7I9P/oqLShm0JaItRRztDHAuL0apaV4M7A+lrH+9yi3yL1NTgmms4I5II5CVHG6w= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ebce783-4d6d-4715-06ec-08d9993eeacb X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2021 11:42:55.7295 (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: UN3BGmTnSjr+7enGJrJzvbeYg2cRfWE4zFU5Es2W2ms+FqywSzNUpmVcYJxAJwxM3Iv5aj5MLHPFqjtrMSymoQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4744 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10149 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2110270071 X-Proofpoint-ORIG-GUID: Oe39SHbIS0R51TNSDXCSYSHBzP04UqRz X-Proofpoint-GUID: Oe39SHbIS0R51TNSDXCSYSHBzP04UqRz 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.23 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+qemu-devel=archiver.kernel.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 --- docs/system/monitor.rst | 2 + hmp-commands-virtio.hx | 250 ++++++++++++++++++++++++++++++++++ hmp-commands.hx | 10 ++ hw/virtio/virtio.c | 355 ++++++++++++++++++++++++++++++++++++++++++++++++ include/monitor/hmp.h | 5 + meson.build | 1 + monitor/misc.c | 17 +++ 7 files changed, 640 insertions(+) create mode 100644 hmp-commands-virtio.hx diff --git a/docs/system/monitor.rst b/docs/system/monitor.rst index ff5c434..10418fc 100644 --- a/docs/system/monitor.rst +++ b/docs/system/monitor.rst @@ -21,6 +21,8 @@ The following commands are available: .. hxtool-doc:: hmp-commands.hx +.. hxtool-doc:: hmp-commands-virtio.hx + .. hxtool-doc:: hmp-commands-info.hx Integer expressions diff --git a/hmp-commands-virtio.hx b/hmp-commands-virtio.hx new file mode 100644 index 0000000..36aab94 --- /dev/null +++ b/hmp-commands-virtio.hx @@ -0,0 +1,250 @@ +HXCOMM Use DEFHEADING() to define headings in both help text and rST. +HXCOMM Text between SRST and ERST is copied to the rST version and +HXCOMM discarded from C version. +HXCOMM +HXCOMM DEF(command, args, callback, arg_string, help) is used to construct +HXCOMM monitor info commands. +HXCOMM +HXCOMM HXCOMM can be used for comments, discarded from both rST and C. +HXCOMM +HXCOMM In this file, generally SRST fragments should have two extra +HXCOMM spaces of indent, so that the documentation list item for "virtio cmd" +HXCOMM appears inside the documentation list item for the top level +HXCOMM "virtio" documentation entry. The exception is the first SRST +HXCOMM fragment that defines that top level entry. + +SRST + ``virtio`` *subcommand* + Show various information about virtio + + Example: + + List all sub-commands:: + + (qemu) virtio + virtio query -- List all available virtio devices + virtio status path -- Display status of a given virtio device + virtio queue-status path queue -- Display status of a given virtio queue + virtio vhost-queue-status path queue -- Display status of a given vhost queue + virtio queue-element path queue [index] -- Display element of a given virtio queue + +ERST + + { + .name = "query", + .args_type = "", + .params = "", + .help = "List all available virtio devices", + .cmd = hmp_virtio_query, + .flags = "p", + }, + +SRST + ``virtio query`` + List all available virtio devices + + Example: + + List all available virtio devices in the machine:: + + (qemu) virtio query + /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 = "status", + .args_type = "path:s", + .params = "path", + .help = "Display status of a given virtio device", + .cmd = hmp_virtio_status, + .flags = "p", + }, + +SRST + ``virtio status`` *path* + Display status of a given virtio device + + Example: + + Dump the status of virtio-net (vhost on):: + + (qemu) 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 = "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 + ``virtio queue-status`` *path* *queue* + Display status of a given virtio queue + + Example: + + Dump the status of the 6th queue of virtio-scsi:: + + (qemu) 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 = "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 + ``virtio vhost-queue-status`` *path* *queue* + Display status of a given vhost queue + + Example: + + Dump the status of the 2nd queue of vhost-vsock:: + + (qemu) 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 = "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 + ``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) 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/hmp-commands.hx b/hmp-commands.hx index cf723c6..315e629 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1719,6 +1719,16 @@ SRST ERST { + .name = "virtio", + .args_type = "name:S?", + .params = "[cmd]", + .help = "show various information about virtio", + .cmd = hmp_virtio_help, + .sub_table = hmp_virtio_cmds, + .flags = "p", + }, + + { .name = "info", .args_type = "item:s?", .params = "[subcommand]", diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 8c8a987..20e1dcb 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -15,6 +15,7 @@ #include "qapi/error.h" #include "qapi/qapi-commands-virtio.h" #include "qapi/qapi-visit-virtio.h" +#include "qapi/qmp/qdict.h" #include "cpu.h" #include "trace.h" #include "qemu/error-report.h" @@ -31,6 +32,8 @@ #include "sysemu/runstate.h" #include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/vhost_types.h" +#include "monitor/hmp.h" +#include "monitor/monitor.h" #include CONFIG_DEVICES /* QAPI list of VirtIODevices */ @@ -4035,6 +4038,31 @@ VirtioInfoList *qmp_x_debug_query_virtio(Error **errp) return list; } +void hmp_virtio_query(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + VirtioInfoList *list = qmp_x_debug_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); +} + static VirtIODevice *virtio_device_find(const char *path) { VirtIODevice *vdev; @@ -4074,6 +4102,116 @@ static VirtIODevice *virtio_device_find(const char *path) list; \ }) +#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; + default: + g_assert_not_reached(); + } + if (features->has_unknown_features) { + monitor_printf(mon, " unknown-features(0x%016"PRIx64")\n", + features->unknown_features); + } +} + static VirtioDeviceStatus *qmp_decode_status(uint8_t bitmap) { VirtioDeviceStatus *status; @@ -4297,6 +4435,86 @@ VirtioStatus *qmp_x_debug_virtio_status(const char *path, Error **errp) return status; } +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_debug_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); +} + VirtVhostQueueStatus *qmp_x_debug_virtio_vhost_queue_status(const char *path, uint16_t queue, Error **errp) @@ -4341,6 +4559,41 @@ VirtVhostQueueStatus *qmp_x_debug_virtio_vhost_queue_status(const char *path, return status; } +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_debug_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); +} VirtQueueStatus *qmp_x_debug_virtio_queue_status(const char *path, uint16_t queue, Error **errp) @@ -4400,6 +4653,51 @@ VirtQueueStatus *qmp_x_debug_virtio_queue_status(const char *path, return status; } +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_debug_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); +} + static VirtioRingDescFlagsList *qmp_decode_vring_desc_flags(uint16_t flags) { VirtioRingDescFlagsList *list = NULL; @@ -4541,6 +4839,63 @@ done: return element; } +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_debug_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); +} + static const TypeInfo virtio_device_info = { .name = TYPE_VIRTIO_DEVICE, .parent = TYPE_DEVICE, diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 6bc2763..cc80686 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -94,6 +94,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/meson.build b/meson.build index 2c5b53c..179f64a 100644 --- a/meson.build +++ b/meson.build @@ -2342,6 +2342,7 @@ if have_system hx_headers += [ ['hmp-commands.hx', 'hmp-commands.h'], ['hmp-commands-info.hx', 'hmp-commands-info.h'], + ['hmp-commands-virtio.hx', 'hmp-commands-virtio.h'], ] endif foreach d : hx_headers diff --git a/monitor/misc.c b/monitor/misc.c index ffe7966..5e4cd88 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -23,6 +23,7 @@ */ #include "qemu/osdep.h" +#include CONFIG_DEVICES #include "monitor-internal.h" #include "monitor/qdev.h" #include "hw/usb.h" @@ -219,6 +220,15 @@ static void hmp_info_help(Monitor *mon, const QDict *qdict) help_cmd(mon, "info"); } +static void hmp_virtio_help(Monitor *mon, const QDict *qdict) +{ +#if defined(CONFIG_VIRTIO) + help_cmd(mon, "virtio"); +#else + monitor_printf(mon, "Virtio is disabled\n"); +#endif +} + static void monitor_init_qmp_commands(void) { /* @@ -1433,6 +1443,13 @@ static HMPCommand hmp_info_cmds[] = { { NULL, NULL, }, }; +static HMPCommand hmp_virtio_cmds[] = { +#if defined(CONFIG_VIRTIO) +#include "hmp-commands-virtio.h" +#endif + { NULL, NULL, }, +}; + /* hmp_cmds and hmp_info_cmds would be sorted at runtime */ HMPCommand hmp_cmds[] = { #include "hmp-commands.h"