From nobody Sat May 4 07:55:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1642690659; cv=pass; d=zohomail.com; s=zohoarc; b=WqQ72ge1tfb8mm+cB++s+MohatOc9UNi7JljC5U6aIiuVSaW8s3CEdedmFk/8hTYKbXWRfohayix+/1g5JmcUzR+kvjP7jcEZ3QKsl8aPBrfI5VrbfOQNMRhstXrbKw024N0BOseGd3grXx7Yqfx6IRKKwi/G5GWZSLrXuO+Je0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642690659; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BUXFREAqAKuRVB7lMR6s0ykbf0NT9PN0zv4rMofMPU0=; b=AvYMvRx0qSRXlRBeB56uX3l8Gs0EmEX4RGttjB4jiKZ4m58uO918iQ4VVF/Q+GtoP4CuTf4IaGRVhdaFCZfuoTh6kUvaCIdEccFfJnKjtoRZyClqsLnSNX6p11MKqJ6oC0oafVjUupTw9Teqi7I1OVUqpYTiky26Mvs1CrPYUe0= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642690659754555.125252208876; Thu, 20 Jan 2022 06:57:39 -0800 (PST) Received: from localhost ([::1]:36778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAYsa-0005VM-IK for importer@patchew.org; Thu, 20 Jan 2022 09:57:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAVey-0005c8-Qe; Thu, 20 Jan 2022 06:31:23 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:60910) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAVen-0006Vu-MI; Thu, 20 Jan 2022 06:31:18 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20K8MnLB032601; Thu, 20 Jan 2022 11:30:15 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3dnc4q84f5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jan 2022 11:30:15 +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 20KBGfYk031345; Thu, 20 Jan 2022 11:30:14 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by userp3030.oracle.com with ESMTP id 3dkkd24hb7-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jan 2022 11:30:13 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by BYAPR10MB2648.namprd10.prod.outlook.com (2603:10b6:a02:b3::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Thu, 20 Jan 2022 11:30:09 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::95b1:2ba7:964c:d3cb]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::95b1:2ba7:964c:d3cb%9]) with mapi id 15.20.4909.010; Thu, 20 Jan 2022 11:30:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=BUXFREAqAKuRVB7lMR6s0ykbf0NT9PN0zv4rMofMPU0=; b=dbwlkUpFGTfxQ6XIgU38QTLJfB+ycgx9v9Uzg0ConG5o4hdjXvLEvSDaHcM05qsRTOmx cXrEis5vIOctSUPUNGJB6GvXC2EEeJi+LCtM+imzLM+0gdn0KE46wI+6SfXUlGZQOyNh NsGPQehkkSfiTEe8II89uIUIexvERa0eAUFQlPN7HYj/8mgvcdmC57W18WyUYJR1luS+ wMbZkgBdZ6M9WMBFE24nPtagk8efgIO+RTrlgK+DFXYcLzw2xNC4A9lorhQ1CcdYGNcx g00ELhGO9PXhO15yH+ISk/ZBh7KiwdpFP0F7S/AO909HI4acmEGw6Ztk8UvUdnTNCc1g PA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LYCjGfzD1wCfXVJQ1h3wZKLmXisW+TUwCMVb+56SQAYwdj6oIQuOodYmqVLAzLhaco0caQJNav7v1Z0nIZixdJAKhBK186K5w+akGBawk/Z8RLfmsd6/6NESgJ0s14rEqxpWlE8T+d82bSaCGuXTVmF1FTUwaDUe0/9wFX8hqeNOFjoV2OIPey7tttQEVWbNG06BuEi9Kci6YCkTe5vPZAfalwPnahhdoj85DVz0FpCJ/oVpD8GhU74ZbC47AiOs4N2hoApeBRUuBnUc6DcYzg0E9v2E8lmABQqQH/LVwdGAid2EX5hbFpdLV8qTKugn6lRjpdBKB62n1OCkcLZK7Q== 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=BUXFREAqAKuRVB7lMR6s0ykbf0NT9PN0zv4rMofMPU0=; b=UvzUbF1ZCqSJEF2m4HqTRpEy8lsR3eQ7wtjczJmUTVyZpk98OVHuJCEsxCwkqdT9A+KDTAbN83cMHq6437iQ/C2hxyw/9oQuvcIVkZEG/HnMgPy/rrDQGSkP+645V9Jke8QbsJcDMxdUpMMpA70kyly0CHyBkVxFxl8H2FI61wJG7oflO7TuMtHfi1mXcBGs62PBlPU+nzeQQWDZYsRw4AUkW22TtnsvrJBs1DAP/ULEBVLP4JPulaUPv5Qdk224YI151o1UKyouGJYiUDcZ9bBqTDYc8PjLhMmddBvaeM6wUFbJcLZtzjIxsJ2X2Juo7R0c29HGJLxshYjXkVxNeA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=BUXFREAqAKuRVB7lMR6s0ykbf0NT9PN0zv4rMofMPU0=; b=gHXEjNX2kCffLoofWF468EOi8U0vSFcZYZSZC0MUMaCQhN0NkqsruDs4VSHm+ZmD1SjAiSmq8tezk7K5/oHidNzrONv1KnRPdSWcGsR/lekO3CYtFZ5wukFIg+hqHOVLLswfwYZBd+bB3D4/BUxUXvWXi+fbUFJ0FE+H1bow3eU= From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v11 1/8] virtio: drop name parameter for virtio_init() Date: Thu, 20 Jan 2022 06:29:21 -0500 Message-Id: <1642678168-20447-2-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1642678168-20447-1-git-send-email-jonah.palmer@oracle.com> References: <1642678168-20447-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SA9PR11CA0025.namprd11.prod.outlook.com (2603:10b6:806:6e::30) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 447c133b-b86e-48cb-5476-08d9dc0835c9 X-MS-TrafficTypeDiagnostic: BYAPR10MB2648:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2399; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TVH3tvFS2SYY8PkPH3yC3JKiFMKAT6SEqOXkiDmEaa6aPJYsaL+1Cmw1dgRrp2os2frff0gZdi99VSqyGpHbF+J3U8UVstA7Kvd6jwEmnutfHiF9mS96TA4tZzPnBO5XnCgx+CejsRSVXftIoFfWO7A7Sv3gcfVmQrU0OLaYFyHYqYKl+vL8ZW7EEc/21CxDdMtd3/qHXV3HeBxQtYXcHKC2KI4WGNhUwc39tNQnQhdaWrX1EOguFgVi44DNAh2ThFfQ4+nyrkGX2G3qxcw8OyqY3+YLOnRGbV1/JeiNojLNMskQXdaUVVIKyhZBl01a4mrMIzknsoa5eEBiBV8+CfIEhTIQVfjXS5xaqbdheunRtxV+Nrk0UTkJ6MduVGa5B8/a0Mfhf+HO4Ezth3GOS61kqN3t0HAEHXjdysTbNi7lMvjez9xRtPVeUDCZUvVy/Cab1H9SX96EpFb139IMO/uk3bgxctoYzIFA7iPr/8JyjrEF2O5sWcF7c9OR33E4HR8MAQJqHT/FP0cPGdswY7w2WoKcM189iuI3dipMMtkyfEHPWmyhqArMReyS64t2RSGkljTO+RzMdZn93ufKozTM/fHyFmXn0VesEFUDnmbvT5ZHwgr4BlEEK56APl2nlbTZFTiR9zItLxky8XVb3OzZEFKLHIvM0vlDpm6x9dFTG0yQiQWEO4/xZfUsQrfQaV3UkpPXj/zU6bYAzJzasA== 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)(8676002)(66556008)(6512007)(6486002)(8936002)(66476007)(6666004)(2616005)(66946007)(44832011)(186003)(316002)(36756003)(7416002)(86362001)(508600001)(38100700002)(26005)(6506007)(6916009)(38350700002)(52116002)(5660300002)(4326008)(83380400001)(30864003)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?nfKztFs3RSYmb4+itOhLdb5WWZmDPy9FMcOYRhcCvxR5Hpqnqz2KgBKYR38w?= =?us-ascii?Q?m7ZMHWcjPCVEnjx+m338PwWQezHrvoPQkgva5qdsakIfCX/uiWpPyAbmo6k8?= =?us-ascii?Q?O1RqLfzBm6whHVzoqQsC9BeSOjpWuPaYsdvSHPvT/yLF2Go1Fdq+qYlCBmCU?= =?us-ascii?Q?uda3qatyledTmkU8KlVTwFkyCx+asj63DowFbHATji6Aq0SiWDgV42KUU6N5?= =?us-ascii?Q?D9Kgbo3NLqQaZhFezCeU7al49i17u1tb0mzxD/R/A9YP0EFp2b2Sxk/XD0yy?= =?us-ascii?Q?b2f9R3wRY9mCXbX2lzEMq9ewfftt3fFoqSFNo0oedcWu2PBDbOeITIAlFxO8?= =?us-ascii?Q?Uz6W2ts1wYy/fZsDYAhwxe9fJy0Tjvsy7rXzojUS+s7lyp11/t2RYQ7osKGd?= =?us-ascii?Q?2DdNZf/9x2B5lLwViNOSQTtFB0+nz7mhWhuR6Bo6LU1A7LGB6OKbSmknM76v?= =?us-ascii?Q?3MXuDFsfMx4MZt/cqNMGxCBL1sNtkGKdnhbO+lk/aPPo35hb5LsoqDnHMLz1?= =?us-ascii?Q?pRyvjiFjHpl/RM2hTZyopWx271yHQyYksKj6Vn6K+7HtR6ORIzTBYqXv6Pj4?= =?us-ascii?Q?nnrsKjejeemIDSKJRraxYftj6HrFCPtX+cddY0xZ8SbhyQRqd4l6kqEkKqlH?= =?us-ascii?Q?hKGVEvYeeBL27rpjfWnMoAIlJhXUBz46CmOLONajh29yC+5X7cwDXdiXpjaj?= =?us-ascii?Q?/KU0qFmbuf9mkLRaDZ1szXxRBfVus5pKv1X5UD5sggaHfaf/gVW46fL1clRk?= =?us-ascii?Q?5SOlFQ8SzFHszGa0z4mNy+dQOhRhxjpb5Yb9LfMFMXhf9/ICpRSISlvN0Y+W?= =?us-ascii?Q?+s4nn4ShCLizn5h2xMWAC74BD+Ni+iAm+bM+3dYMijYzA8oO9H616Af3fABu?= =?us-ascii?Q?lrDjW0+9oTAFqU9FU+2UrzZ6J8W4URCQYD/UCER71GsNP3JGJAvukXlofHcb?= =?us-ascii?Q?lbRIzAZ8wgadBZGvJm+abFeFtxxRLFn4QKkL+lZC7w8EncUKawT7gy26Wp70?= =?us-ascii?Q?fSsrlETDMR92WQa60j37N9z1gvBHo/9dQGDFAoizfGoRUYzqmSuAGx1g4exm?= =?us-ascii?Q?vbys69vrtfopAhxgpODWp8h0KaI+dUpk0yh25ERn6TBISyElqTr4jgiQdfVi?= =?us-ascii?Q?OwNAcvZmvpMjxr9jP+8/yvPGSD+v6TRSsddJ4Mopjv4RUE8V5823HLrt3EFD?= =?us-ascii?Q?1QARNBzkK6T8ne/r6ZG9Sfj/qIxYsAHH2L3+ka9Z4cmc103RSORiDTDXFfDn?= =?us-ascii?Q?0CBFr281A8DAxP/uD8R2K6e1/IAGy6bgFxgQZzUnnDIF/Uy0t/s9nYNOpjE2?= =?us-ascii?Q?QUB1OJcTab1fKpLbwQRaDk1T71QgCZbJIrWpddNPLGPZpFmY9nV7RP2M6wIC?= =?us-ascii?Q?hgOjY9XFs+rYjPyT62f7kPpJx4nljmxscdoM5XDnmmY9hMWRAjW4/hNqO+Bt?= =?us-ascii?Q?Vp0KcAhcF5+lYvYmnx+8v7sx5lLvu8SSlPpBqhHlj1tSgZ9U5malDz0OxT7w?= =?us-ascii?Q?uA5ZEIr4uVERHRDxcO+sEI4LTmfv7oHbBBd4gNXpo+LCN58pVJP15Sn2BMso?= =?us-ascii?Q?cAWoEoX2IdBUjEGQjDwg793CaOv2zhJ51gNUkkO+a5urBuhTr0fAzex1t/gg?= =?us-ascii?Q?y34cEHaRSPmERKLAMyS91/I=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 447c133b-b86e-48cb-5476-08d9dc0835c9 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2022 11:30:07.1277 (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: eUdrWmb32lP3n41OdnjRrl3IAyOdofmqt/y4YFbP59K8WQUV2uh4EgorOogVoObbn20opO/7OD3HdFMgv03U4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2648 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10232 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 adultscore=0 phishscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201200058 X-Proofpoint-GUID: bfCjTeWchH2ECmCyW9jgBmJhW9_25VJt X-Proofpoint-ORIG-GUID: bfCjTeWchH2ECmCyW9jgBmJhW9_25VJt Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1642690661357100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 lets us do this and removes the need for the name parameter in the virtio_init function. [Jonah: added new virtio IDs to virtio device list from rebase]. 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 | 3 +- 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 | 7 +---- hw/virtio/vhost-user-rng.c | 2 +- hw/virtio/vhost-user-vsock.c | 2 +- hw/virtio/vhost-vsock-common.c | 5 ++-- 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 | 55 ++++++++++++++++++++++++++++++= ++-- include/hw/virtio/vhost-vsock-common.h | 2 +- include/hw/virtio/virtio-gpu.h | 3 +- include/hw/virtio/virtio.h | 4 +-- 24 files changed, 77 insertions(+), 43 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) } =20 v->config_size =3D 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 =3D virtio_add_queue(vdev, MAX_REQ, handle_9p_output); } =20 diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 1a42ae9..e8cb170 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -491,7 +491,7 @@ static void vhost_user_blk_device_realize(DeviceState *= dev, Error **errp) return; } =20 - virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, + virtio_init(vdev, VIRTIO_ID_BLOCK, sizeof(struct virtio_blk_config)); =20 s->virtqs =3D g_new(VirtQueue *, s->num_queues); diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 82676cd..2e3809d 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1205,7 +1205,7 @@ static void virtio_blk_device_realize(DeviceState *de= v, Error **errp) =20 virtio_blk_set_config_size(s, s->host_features); =20 - virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, s->config_size); + virtio_init(vdev, VIRTIO_ID_BLOCK, s->config_size); =20 s->blk =3D conf->conf.blk; s->rq =3D NULL; diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index f01ec21..9f19fd0 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -1044,8 +1044,7 @@ static void virtio_serial_device_realize(DeviceState = *dev, Error **errp) VIRTIO_CONSOLE_F_EMERG_WRITE)) { config_size =3D 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); =20 /* Spawn a new virtio-serial bus on which the ports will ride as devic= es */ 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 fff0fb4..8ba5da4 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -173,7 +173,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev, } =20 g->virtio_config.num_scanouts =3D 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)); =20 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 *de= v, Error **errp) vinput->cfg_size +=3D 8; assert(vinput->cfg_size <=3D sizeof(virtio_input_config)); =20 - virtio_init(vdev, "virtio-input", VIRTIO_ID_INPUT, - vinput->cfg_size); + virtio_init(vdev, VIRTIO_ID_INPUT, vinput->cfg_size); vinput->evt =3D virtio_add_queue(vdev, 64, virtio_input_handle_evt); vinput->sts =3D virtio_add_queue(vdev, 64, virtio_input_handle_sts); } diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index cf8ab0f..25f494c 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3388,7 +3388,7 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) } =20 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); =20 /* * 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 34a968e..2a6141d 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 =3D VIRTIO_SCSI_COMMON(dev); int i; =20 - virtio_init(vdev, "virtio-scsi", VIRTIO_ID_SCSI, - sizeof(VirtIOSCSIConfig)); + virtio_init(vdev, VIRTIO_ID_SCSI, sizeof(VirtIOSCSIConfig)); =20 if (s->conf.num_queues =3D=3D VIRTIO_SCSI_AUTO_NUM_QUEUES) { s->conf.num_queues =3D 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; } =20 - 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)); =20 /* Hiprio queue */ fs->hiprio_vq =3D virtio_add_queue(vdev, fs->conf.queue_size, vuf_hand= le_output); diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c index d172632..58fd729 100644 --- a/hw/virtio/vhost-user-i2c.c +++ b/hw/virtio/vhost-user-i2c.c @@ -14,11 +14,6 @@ #include "qemu/error-report.h" #include "standard-headers/linux/virtio_ids.h" =20 -/* 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) { BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); @@ -220,7 +215,7 @@ static void vu_i2c_device_realize(DeviceState *dev, Err= or **errp) return; } =20 - virtio_init(vdev, "vhost-user-i2c", VIRTIO_ID_I2C_ADAPTER, 0); + virtio_init(vdev, VIRTIO_ID_I2C_ADAPTER, 0); =20 i2c->vhost_dev.nvqs =3D 1; i2c->vq =3D 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, Err= or **errp) return; } =20 - virtio_init(vdev, "vhost-user-rng", VIRTIO_ID_RNG, 0); + virtio_init(vdev, VIRTIO_ID_RNG, 0); =20 rng->req_vq =3D 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; } =20 - vhost_vsock_common_realize(vdev, "vhost-user-vsock"); + vhost_vsock_common_realize(vdev); =20 vhost_dev_set_config_notifier(&vvc->vhost_dev, &vsock_ops); =20 diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 3f37712..6146d25 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -220,12 +220,11 @@ int vhost_vsock_common_post_load(void *opaque, int ve= rsion_id) return 0; } =20 -void vhost_vsock_common_realize(VirtIODevice *vdev, const char *name) +void vhost_vsock_common_realize(VirtIODevice *vdev) { VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); =20 - virtio_init(vdev, name, VIRTIO_ID_VSOCK, - sizeof(struct virtio_vsock_config)); + virtio_init(vdev, VIRTIO_ID_VSOCK, sizeof(struct virtio_vsock_config)); =20 /* Receive and transmit queues belong to vhost */ vvc->recv_vq =3D virtio_add_queue(vdev, VHOST_VSOCK_QUEUE_SIZE, diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 433d42d..696635b 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); } =20 - vhost_vsock_common_realize(vdev, "vhost-vsock"); + vhost_vsock_common_realize(vdev); =20 ret =3D 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 9a4f491..236542f 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -888,8 +888,7 @@ static void virtio_balloon_device_realize(DeviceState *= dev, Error **errp) VirtIOBalloon *s =3D VIRTIO_BALLOON(dev); int ret; =20 - virtio_init(vdev, "virtio-balloon", VIRTIO_ID_BALLOON, - virtio_balloon_config_size(s)); + virtio_init(vdev, VIRTIO_ID_BALLOON, virtio_balloon_config_size(s)); =20 ret =3D 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 *d= ev, Error **errp) return; } =20 - virtio_init(vdev, "virtio-crypto", VIRTIO_ID_CRYPTO, vcrypto->config_s= ize); + virtio_init(vdev, VIRTIO_ID_CRYPTO, vcrypto->config_size); vcrypto->curr_queues =3D 1; vcrypto->vqs =3D g_malloc0(sizeof(VirtIOCryptoQueue) * vcrypto->max_qu= eues); for (i =3D 0; i < vcrypto->max_queues; i++) { diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index aa9c16a..15b3fa0 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -968,8 +968,7 @@ static void virtio_iommu_device_realize(DeviceState *de= v, Error **errp) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIOIOMMU *s =3D VIRTIO_IOMMU(dev); =20 - virtio_init(vdev, "virtio-iommu", VIRTIO_ID_IOMMU, - sizeof(struct virtio_iommu_config)); + virtio_init(vdev, VIRTIO_ID_IOMMU, sizeof(struct virtio_iommu_config)); =20 memset(s->iommu_pcibus_by_bus_num, 0, sizeof(s->iommu_pcibus_by_bus_nu= m)); =20 diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index 04c223b..e886e5b 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -858,8 +858,7 @@ static void virtio_mem_device_realize(DeviceState *dev,= Error **errp) vmem->block_size; vmem->bitmap =3D bitmap_new(vmem->bitmap_size); =20 - 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 =3D virtio_add_queue(vdev, 128, virtio_mem_handle_request); =20 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) } =20 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 =3D virtio_add_queue(vdev, 128, virtio_pmem_flush); } =20 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; } =20 - virtio_init(vdev, "virtio-rng", VIRTIO_ID_RNG, 0); + virtio_init(vdev, VIRTIO_ID_RNG, 0); =20 vrng->vq =3D virtio_add_queue(vdev, 8, handle_input); vrng->quota_remaining =3D vrng->conf.max_bytes; diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index aae72fb..734b7fb 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -132,6 +132,56 @@ struct VirtQueue QLIST_ENTRY(VirtQueue) node; }; =20 +const char *virtio_device_names[] =3D { + [VIRTIO_ID_NET] =3D "virtio-net", + [VIRTIO_ID_BLOCK] =3D "virtio-blk", + [VIRTIO_ID_CONSOLE] =3D "virtio-serial", + [VIRTIO_ID_RNG] =3D "virtio-rng", + [VIRTIO_ID_BALLOON] =3D "virtio-balloon", + [VIRTIO_ID_IOMEM] =3D "virtio-iomem", + [VIRTIO_ID_RPMSG] =3D "virtio-rpmsg", + [VIRTIO_ID_SCSI] =3D "virtio-scsi", + [VIRTIO_ID_9P] =3D "virtio-9p", + [VIRTIO_ID_MAC80211_WLAN] =3D "virtio-mac-wlan", + [VIRTIO_ID_RPROC_SERIAL] =3D "virtio-rproc-serial", + [VIRTIO_ID_CAIF] =3D "virtio-caif", + [VIRTIO_ID_MEMORY_BALLOON] =3D "virtio-mem-balloon", + [VIRTIO_ID_GPU] =3D "virtio-gpu", + [VIRTIO_ID_CLOCK] =3D "virtio-clk", + [VIRTIO_ID_INPUT] =3D "virtio-input", + [VIRTIO_ID_VSOCK] =3D "vhost-vsock", + [VIRTIO_ID_CRYPTO] =3D "virtio-crypto", + [VIRTIO_ID_SIGNAL_DIST] =3D "virtio-signal", + [VIRTIO_ID_PSTORE] =3D "virtio-pstore", + [VIRTIO_ID_IOMMU] =3D "virtio-iommu", + [VIRTIO_ID_MEM] =3D "virtio-mem", + [VIRTIO_ID_SOUND] =3D "virtio-sound", + [VIRTIO_ID_FS] =3D "virtio-user-fs", + [VIRTIO_ID_PMEM] =3D "virtio-pmem", + [VIRTIO_ID_RPMB] =3D "virtio-rpmb", + [VIRTIO_ID_MAC80211_HWSIM] =3D "virtio-mac-hwsim", + [VIRTIO_ID_VIDEO_ENCODER] =3D "virtio-vid-encoder", + [VIRTIO_ID_VIDEO_DECODER] =3D "virtio-vid-decoder", + [VIRTIO_ID_SCMI] =3D "virtio-scmi", + [VIRTIO_ID_NITRO_SEC_MOD] =3D "virtio-nitro-sec-mod", + [VIRTIO_ID_I2C_ADAPTER] =3D "vhost-user-i2c", + [VIRTIO_ID_WATCHDOG] =3D "virtio-watchdog", + [VIRTIO_ID_CAN] =3D "virtio-can", + [VIRTIO_ID_DMABUF] =3D "virtio-dmabuf", + [VIRTIO_ID_PARAM_SERV] =3D "virtio-param-serv", + [VIRTIO_ID_AUDIO_POLICY] =3D "virtio-audio-pol", + [VIRTIO_ID_BT] =3D "virtio-bluetooth", + [VIRTIO_ID_GPIO] =3D "virtio-gpio" +}; + +static const char *virtio_id_to_name(uint16_t device_id) +{ + assert(device_id < G_N_ELEMENTS(virtio_device_names)); + const char *name =3D virtio_device_names[device_id]; + assert(name !=3D NULL); + return name; +} + /* Called within call_rcu(). */ static void virtio_free_region_cache(VRingMemoryRegionCaches *caches) { @@ -3209,8 +3259,7 @@ void virtio_instance_init_common(Object *proxy_obj, v= oid *data, qdev_alias_all_properties(vdev, proxy_obj); } =20 -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_siz= e) { BusState *qbus =3D qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); @@ -3239,7 +3288,7 @@ void virtio_init(VirtIODevice *vdev, const char *name, vdev->vq[i].host_notifier_enabled =3D false; } =20 - vdev->name =3D name; + vdev->name =3D virtio_id_to_name(device_id); vdev->config_len =3D config_size; if (vdev->config_len) { vdev->config =3D g_malloc0(config_size); diff --git a/include/hw/virtio/vhost-vsock-common.h b/include/hw/virtio/vho= st-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 feat= ures, Error **errp); diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 2179b75..afff9e1 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" =20 #include "standard-headers/linux/virtio_gpu.h" +#include "standard-headers/linux/virtio_ids.h" #include "qom/object.h" =20 #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) =20 -#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 f095637..2a0be70 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -165,8 +165,8 @@ struct VirtioDeviceClass { void virtio_instance_init_common(Object *proxy_obj, void *data, size_t vdev_size, const char *vdev_name); =20 -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_siz= e); + void virtio_cleanup(VirtIODevice *vdev); =20 void virtio_error(VirtIODevice *vdev, const char *fmt, ...) GCC_FMT_ATTR(2= , 3); --=20 1.8.3.1 From nobody Sat May 4 07:55:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1642685022; cv=pass; d=zohomail.com; s=zohoarc; b=FT/34RVscVQB5Jr1jPADBmw08iJ9GJnxCfh2IoDlmsSuhQOtrKMnIoyxYHCizvdNU6R5BRGfym+JrwwHYesYhpvT7JNQAof+DXZl4ES6eTXoUFa9DbN+0OlaWA0+uVjOxCrTbdH3CQCLSUOD/EiH51CxXYZkv2oWVt33h2gpe30= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642685022; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wDVVUxehxJjhlBu/bBfauPq7qw3L2r2FYTBkTJ1fk40=; b=FeI5wnLLqr+QbV6yN/ewBkJbwGTFq8xkjxVW1xPfPnjiymDKpbL04jX6KCq2LtqVl/7MOTiPQT5qF2WI58r8Gb2PEDgau7LyfMKkHP/IPhg8wOdtnDGuy6posJMKDrRta6GSVsiC1UMEcUMITKD5GXX22JIjIbyQ8wm9tk2lc/M= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642685022770242.48953746514792; Thu, 20 Jan 2022 05:23:42 -0800 (PST) Received: from localhost ([::1]:52842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAXPg-0001ry-JU for importer@patchew.org; Thu, 20 Jan 2022 08:23:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAVeq-0005an-Ft; Thu, 20 Jan 2022 06:31:13 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:61398) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAVem-0006WE-Pl; Thu, 20 Jan 2022 06:31:11 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20K9r3iZ031238; Thu, 20 Jan 2022 11:30:16 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3dnbrnyu2u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jan 2022 11:30:16 +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 20KBGfYl031345; Thu, 20 Jan 2022 11:30:15 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by userp3030.oracle.com with ESMTP id 3dkkd24hb7-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jan 2022 11:30:14 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by BYAPR10MB2648.namprd10.prod.outlook.com (2603:10b6:a02:b3::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Thu, 20 Jan 2022 11:30:10 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::95b1:2ba7:964c:d3cb]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::95b1:2ba7:964c:d3cb%9]) with mapi id 15.20.4909.010; Thu, 20 Jan 2022 11:30:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=wDVVUxehxJjhlBu/bBfauPq7qw3L2r2FYTBkTJ1fk40=; b=0GrBOgV1a8IjG4x1n+ByLULiR9vyboDqsW+zhiJKRYJQKs735XNngV2mkSBBeTTPJNfP 5cVskdb3lcxcmwGqTc90IQjfNgQMLFmSK66yj8fTmWaMH0HlPkEQDtF3UafC0l39pN6z +orQUxkPVRncoHe3CBvgtytTvPF5+D/+l+81cvXcyGo74ZSzXHlqSz2vhkHHeTcf1muR Caxa+kwlNe4CgYJfAYQpWHXqa/vz74EfLu6/zyU5oJodfWPDHdOtd+O7JFY9QNu5+B5h tVcQz7oUTO7KsMq5536Tsy3DAzHTu7s0He09CO/VZlITMuESlHnO8OwPmGQ/vmj24Ebi KA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TktLttgc2qmB9/sgvonTGLTJXV6WVtKl/BSCYGYxMeNMSwtBw/T8rpW8tT+8iKrDzgWHd18Oi9SRmlC6IC1bh0Qo8D6IOZmgjUZin4aROClS/no/NI6qvoC1eEcyHvyG5sxLCov50cPdMv2cIK1/9fzBoHViDPB9nlMG0fENuVde05xfS33SlKrhkeQxuq5hjJ60vIe9sWp8jR7EZV1d+Ieley1x9w4WljV+QNL80wzeMb3B/Es3ZkQNp6nH4Yw6XweFXtj0udEPv1YaPZ6Vf32kvmIQg8wqVXQQMzYaXbsVOV6eLkyqEXrxORs2dtSqShGgmCgarzjJqP84gvNsHg== 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=wDVVUxehxJjhlBu/bBfauPq7qw3L2r2FYTBkTJ1fk40=; b=Pazw0iLa0+JvbPGu9r8ApFoO3ubX+kW39B9tceZxG4Jg1cld8iy12yagJC/fZz7EM6pGFh9cza7s2LvE3JVvR2ql+LKZgkszOnmtCiB4PGwcH4JGOce109smyKcu5vcZdDK/6m8wwiQgYbKoTJcnY6dW8A/z4RJCkk7CUdV26Vk9utt1BTyx1wshmcBtu4wuxX8W8X5LOcCBNUqX1sYn+B/1J2BzWjwzp8ja0/9VkQaMLeC3IoY0ItIo8QmQa/umfZ/8rKh4eztp307uABVpWAJbh1lTouFD+XkAuvFyk1c82fmaOVGPjm8RDwtoJ/p+1H+cBPHiCGIcp6amFxXMTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=wDVVUxehxJjhlBu/bBfauPq7qw3L2r2FYTBkTJ1fk40=; b=Dug1CqxHHpBNh5ncw5yPZUXd4mUfiTFj/flMKUDVOBaAt6XVQp1cFOqPA/0yYs0Tbu/0wCxfEYKKciioYuizm1VjDAvKy0pWrbLco/Zo3+XobocxDuK3SAWFz1m62ZOT31PP+wOD9Lok6xvoP9xswMPmVbvJoV18u92V60gmi2U= From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v11 2/8] virtio: add vhost support for virtio devices Date: Thu, 20 Jan 2022 06:29:22 -0500 Message-Id: <1642678168-20447-3-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1642678168-20447-1-git-send-email-jonah.palmer@oracle.com> References: <1642678168-20447-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SA9PR11CA0025.namprd11.prod.outlook.com (2603:10b6:806:6e::30) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 968e3f29-7a2b-4011-eed1-08d9dc083746 X-MS-TrafficTypeDiagnostic: BYAPR10MB2648:EE_ 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: ll1ROVqYJYBUutLjWGQ/Qe9nmXLfYbfKGk6v8Tks1Ux7BKzy6N6M7kXKkb8AVhZETD+ePxb3dCTvtyYayI6aEOJrUqc5V8AcAwPw4k4Z19s8I3MzTzsCfFW4V+/wOVk1ROACnD4UGRCodMLc95FdLsTV/vwCbue9b7n8NE6Q1RciEM1FG0d66uIORdXE/MzGF4P72VuuNuVsww5+qGzYHJeBS3X6rSoreXLhGL6waJmRg7IaL7Lv3EIcxquZhzSzuwsadxTe68lvn13U61dBKL3dghTRqODfHi/Gv18WwlhqJmxjIXrmGxGfxxh5atLEXJKveYVYo16f10tfrszMLSb+QdC/2Cn93vP1sRx8fzlhgjoXnGSRhYw4KhCdEC6PpqoXpLakfcRXIMy2XCVq6a2beSjtduR3kRVne6w4m8FQzXyT6Ze7iFChya5+mhPZOXGzO2PosfmeaRkgd50YHzDM/K9qAqXxKYBY9Wfk6RczXsV9PFfaOyDr8+mt17fFwMu+apLfrApqYX4hIp8XHd4E6Vkm9ZK3D3VYEEtxdM+gD/xMJcf8X/azTPBlpaeXWRzf342Rej3WytfEYuRcEWk3QWKnPbybEVbOpCWoh+bEDaFr74FYxLdaef0XG4dHfsX3TscHedaSgkhMzUjLugAvVDlInrfsJUkkhAipRTxeul9iMkPE0R8kP3oNrVc5TYJheirKz1CzqZjBOarfmA== 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)(8676002)(66556008)(6512007)(6486002)(8936002)(66476007)(6666004)(2616005)(66946007)(44832011)(186003)(316002)(36756003)(7416002)(86362001)(508600001)(38100700002)(26005)(6506007)(6916009)(38350700002)(52116002)(5660300002)(4326008)(83380400001)(30864003)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?8u5ze4A24yQH5Cb3QyeaKlV0vu8RLrgi/4aLgbvphM0P+65kP7hSMKmjtkpe?= =?us-ascii?Q?FtthNPAjlxobDsp0yFv1qN8GXXt8hjG2Rqh9JNd9aB4eElkSVI9nksnZBeRa?= =?us-ascii?Q?WdE7y3SosY5O7Y6mzbUsn5KGNor4X/tBh9oi2HX5QcEbARNLYV49Jbx0uEVb?= =?us-ascii?Q?UuZqRcSsG3WWP+kCD8P1Wwz7t1JSTLkbVJY5F+EZVEkx90Wq6blknymUaI2u?= =?us-ascii?Q?2e8EuCGu3xFNBMt5J/saUzbaERv2trd9eLJC1bArM8eb40iQPrZiMpjZP30E?= =?us-ascii?Q?GxV4gf6P7SjGLTGNwS88AaDm9HQYa2gRqA4jYrX4tkt96T1YCh+J+rDlokri?= =?us-ascii?Q?49HFF00U7gtW2tKu0zXgN8EBQy6zvFPtIOJL67qlcxD/4vUQte5kLhqEcnLI?= =?us-ascii?Q?0JBV+4p4FN4NiCmmEt3mXc4dmEuAptaQe3VQbm36cpMUNZ/itaMHWWg1iR0F?= =?us-ascii?Q?J+bD6ZOkKj1lb5YIB3wSHMqaCZLS6RK8+O8MVxLoQEHiqE4iPMxveFTu3jr+?= =?us-ascii?Q?TujkfN+30UHU3qLz7rNLbxZ8EG8kKKXg1AQy2OtQAqQaghrI67Z86jeSDJCo?= =?us-ascii?Q?TByG019TwucXbwjDRFoiNiLZC5+5Q1iFC4p/piIg92Blhiuyc0E3x1Ua5LX6?= =?us-ascii?Q?wfmvaIL8QaS8yThE0fDX9UCdKff4EFRMFLg28iuTo2pDBA7NlS3h8MlKu7Ki?= =?us-ascii?Q?HCNrtg74zRa8t+ZrVR137eh0W+byAIoOkrvLt9wPdmKhUz2QP1Flenh71a1D?= =?us-ascii?Q?U/7W9tqF66Ftj0slLlIOaaKlbJz1rJ2o2yI7yrkLSbpvyMw/3k5HmoY780tR?= =?us-ascii?Q?VzKYLrq4L+Df2yu7wI/za0ioMFVp8SA57PPzw3FHkzyYrJNG4M/j/eK9UImA?= =?us-ascii?Q?I2z3ryD9g++HvB0d3txioqxxUdZUFgfu/yXNfqK9SSfZzVYaAf7fOx1EL1lu?= =?us-ascii?Q?eo7qp9nrtpKQTdkDTDSypphla8gnxf9EfQ9OwtVkP9aA1bjKQrRVe/egirBr?= =?us-ascii?Q?ehbs3Y52zgxtR/eBfSFC4yxfcQa0tDEKRZvSyunN5T4R2iIRjAJRgGsxVdVT?= =?us-ascii?Q?XHEoO3QjG5YNJ6ato8CKCEmKxrO5LnZ5Vb68/Zt9o29NOj4uwTgiz39mlkhT?= =?us-ascii?Q?RB91dehbySIyMuUdHgo/S4vec9yENP/9QUoyX2u12aqH0wFjIl7tdBlv9dQS?= =?us-ascii?Q?IArTWDDSrFwngIRzaAmd+2aAHoIgVSZLORFtypwAcaGVGFRTf+JMi0WmoSM0?= =?us-ascii?Q?quEc36bMgFjMENXWt6amohEraDi8VRyCJMLcG0HHM7LO3Ej7UzSP8QfSqIS2?= =?us-ascii?Q?/wDWoL/lidCficnkh34sb8ODC7iSco/d0aKqnZKstx4FxmKemUXU/9GnknAF?= =?us-ascii?Q?iGLI/wqItArdmNpgYc5yzaQmea45xbz8q6PoHO303Y51hPK/xPnmdNM50S39?= =?us-ascii?Q?mQn0oSarwPPOGmok95o14XzZtFMYloQjslGL4TfxIcgKRjMTZZSo6ZebM23T?= =?us-ascii?Q?kzpt0hQ8OoLDl34Qj7rkkOdVGP9Vhaj/dEi3j/s5aScL1bNGkj1OPLSZT8Au?= =?us-ascii?Q?ZEQzxnlrKB0OJzmsaYIsnWRE4WsO+yXaecDAzVrdSnxC+x2kxa6cCo+TDcd6?= =?us-ascii?Q?0h9J1yNPRaU6aSs+CIOzfXQ=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 968e3f29-7a2b-4011-eed1-08d9dc083746 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2022 11:30:09.6286 (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: bKFraWjQU0X+HBlGY4HAV5YTqH0bprMIyxVeVq8xE8QCRhhp8uBe0rJp5DDiLyD19jPRX32pkzmiHRDmkLRCuA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2648 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10232 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 adultscore=0 phishscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201200058 X-Proofpoint-GUID: 00jGvvbs17CosqtXEIwfK_7LpJM7Kh9c X-Proofpoint-ORIG-GUID: 00jGvvbs17CosqtXEIwfK_7LpJM7Kh9c Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1642685025134100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 | 4 +++- hw/virtio/virtio-crypto.c | 10 ++++++++++ hw/virtio/virtio.c | 1 + include/hw/virtio/virtio.h | 3 +++ 12 files changed, 76 insertions(+), 1 deletion(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index e8cb170..5dca4ea 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -569,6 +569,12 @@ static void vhost_user_blk_instance_init(Object *obj) "/disk@0,0", DEVICE(obj)); } =20 +static struct vhost_dev *vhost_user_blk_get_vhost(VirtIODevice *vdev) +{ + VHostUserBlk *s =3D VHOST_USER_BLK(vdev); + return &s->dev; +} + static const VMStateDescription vmstate_vhost_user_blk =3D { .name =3D "vhost-user-blk", .minimum_version_id =3D 1, @@ -603,6 +609,7 @@ static void vhost_user_blk_class_init(ObjectClass *klas= s, void *data) vdc->get_features =3D vhost_user_blk_get_features; vdc->set_status =3D vhost_user_blk_set_status; vdc->reset =3D vhost_user_blk_reset; + vdc->get_vhost =3D vhost_user_blk_get_vhost; } =20 static const TypeInfo vhost_user_blk_info =3D { diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 0981823..96e56c4 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 =3D -1; } =20 +static struct vhost_dev *vhost_user_gpu_get_vhost(VirtIODevice *vdev) +{ + VhostUserGPU *g =3D VHOST_USER_GPU(vdev); + return &g->vhost->dev; +} + static Property vhost_user_gpu_properties[] =3D { 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 *dat= a) vdc->guest_notifier_pending =3D vhost_user_gpu_guest_notifier_pending; vdc->get_config =3D vhost_user_gpu_get_config; vdc->set_config =3D vhost_user_gpu_set_config; + vdc->get_vhost =3D vhost_user_gpu_get_vhost; =20 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); } =20 +static struct vhost_dev *vhost_input_get_vhost(VirtIODevice *vdev) +{ + VHostUserInput *vhi =3D VHOST_USER_INPUT(vdev); + return &vhi->vhost->dev; +} + static const VMStateDescription vmstate_vhost_input =3D { .name =3D "vhost-user-input", .unmigratable =3D 1, @@ -93,6 +99,7 @@ static void vhost_input_class_init(ObjectClass *klass, vo= id *data) dc->vmsd =3D &vmstate_vhost_input; vdc->get_config =3D vhost_input_get_config; vdc->set_config =3D vhost_input_set_config; + vdc->get_vhost =3D vhost_input_get_vhost; vic->realize =3D vhost_input_realize; vic->change_active =3D vhost_input_change_active; } diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 25f494c..21328dc 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3615,6 +3615,14 @@ static bool dev_unplug_pending(void *opaque) return vdc->primary_unplug_pending(dev); } =20 +static struct vhost_dev *virtio_net_get_vhost(VirtIODevice *vdev) +{ + VirtIONet *n =3D VIRTIO_NET(vdev); + NetClientState *nc =3D qemu_get_queue(n->nic); + struct vhost_net *net =3D get_vhost_net(nc->peer); + return &net->dev; +} + static const VMStateDescription vmstate_virtio_net =3D { .name =3D "virtio-net", .minimum_version_id =3D VIRTIO_NET_VM_VERSION, @@ -3717,6 +3725,7 @@ static void virtio_net_class_init(ObjectClass *klass,= void *data) vdc->post_load =3D virtio_net_post_load_virtio; vdc->vmsd =3D &vmstate_virtio_net_device; vdc->primary_unplug_pending =3D primary_unplug_pending; + vdc->get_vhost =3D virtio_net_get_vhost; } =20 static const TypeInfo virtio_net_info =3D { diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 778f43e..3059068 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -273,6 +273,13 @@ static void vhost_scsi_unrealize(DeviceState *dev) virtio_scsi_common_unrealize(dev); } =20 +static struct vhost_dev *vhost_scsi_get_vhost(VirtIODevice *vdev) +{ + VHostSCSI *s =3D VHOST_SCSI(vdev); + VHostSCSICommon *vsc =3D VHOST_SCSI_COMMON(s); + return &vsc->dev; +} + static Property vhost_scsi_properties[] =3D { DEFINE_PROP_STRING("vhostfd", VirtIOSCSICommon, conf.vhostfd), DEFINE_PROP_STRING("wwpn", VirtIOSCSICommon, conf.wwpn), @@ -307,6 +314,7 @@ static void vhost_scsi_class_init(ObjectClass *klass, v= oid *data) vdc->get_features =3D vhost_scsi_common_get_features; vdc->set_config =3D vhost_scsi_common_set_config; vdc->set_status =3D vhost_scsi_set_status; + vdc->get_vhost =3D vhost_scsi_get_vhost; fwc->get_dev_path =3D vhost_scsi_common_get_fw_dev_path; } =20 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 =3D NULL; } =20 +static struct vhost_dev *vuf_get_vhost(VirtIODevice *vdev) +{ + VHostUserFS *fs =3D VHOST_USER_FS(vdev); + return &fs->vhost_dev; +} + static const VMStateDescription vuf_vmstate =3D { .name =3D "vhost-user-fs", .unmigratable =3D 1, @@ -313,6 +319,7 @@ static void vuf_class_init(ObjectClass *klass, void *da= ta) vdc->set_status =3D vuf_set_status; vdc->guest_notifier_mask =3D vuf_guest_notifier_mask; vdc->guest_notifier_pending =3D vuf_guest_notifier_pending; + vdc->get_vhost =3D vuf_get_vhost; } =20 static const TypeInfo vuf_info =3D { 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); } =20 +static struct vhost_dev *vu_rng_get_vhost(VirtIODevice *vdev) +{ + VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); + return &rng->vhost_dev; +} + static const VMStateDescription vu_rng_vmstate =3D { .name =3D "vhost-user-rng", .unmigratable =3D 1, @@ -272,6 +278,7 @@ static void vu_rng_class_init(ObjectClass *klass, void = *data) vdc->set_status =3D vu_rng_set_status; vdc->guest_notifier_mask =3D vu_rng_guest_notifier_mask; vdc->guest_notifier_pending =3D vu_rng_guest_notifier_pending; + vdc->get_vhost =3D vu_rng_get_vhost; } =20 static const TypeInfo vu_rng_info =3D { diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 6146d25..416daf8 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -254,6 +254,12 @@ void vhost_vsock_common_unrealize(VirtIODevice *vdev) virtio_cleanup(vdev); } =20 +static struct vhost_dev *vhost_vsock_common_get_vhost(VirtIODevice *vdev) +{ + VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); + return &vvc->vhost_dev; +} + static Property vhost_vsock_common_properties[] =3D { DEFINE_PROP_ON_OFF_AUTO("seqpacket", VHostVSockCommon, seqpacket, ON_OFF_AUTO_AUTO), @@ -269,6 +275,7 @@ static void vhost_vsock_common_class_init(ObjectClass *= klass, void *data) set_bit(DEVICE_CATEGORY_MISC, dc->categories); vdc->guest_notifier_mask =3D vhost_vsock_common_guest_notifier_mask; vdc->guest_notifier_pending =3D vhost_vsock_common_guest_notifier_pend= ing; + vdc->get_vhost =3D vhost_vsock_common_get_vhost; } =20 static const TypeInfo vhost_vsock_common_info =3D { diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 7b03efc..34f8c12 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1739,6 +1739,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODev= ice *vdev) /* should only be called after backend is connected */ assert(hdev->vhost_ops); =20 + vdev->vhost_started =3D true; hdev->started =3D true; hdev->vdev =3D vdev; =20 @@ -1811,7 +1812,7 @@ fail_vq: =20 fail_mem: fail_features: - + vdev->vhost_started =3D false; hdev->started =3D false; return r; } @@ -1842,6 +1843,7 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODev= ice *vdev) } vhost_log_put(hdev, true); hdev->started =3D false; + vdev->vhost_started =3D false; hdev->vdev =3D NULL; } =20 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(VirtI= ODevice *vdev, int idx) return cryptodev_vhost_virtqueue_pending(vdev, queue, idx); } =20 +static struct vhost_dev *virtio_crypto_get_vhost(VirtIODevice *vdev) +{ + VirtIOCrypto *vcrypto =3D VIRTIO_CRYPTO(vdev); + CryptoDevBackend *b =3D vcrypto->cryptodev; + CryptoDevBackendClient *cc =3D b->conf.peers.ccs[0]; + CryptoDevBackendVhost *vhost_crypto =3D cryptodev_get_vhost(cc, b, 0); + return &vhost_crypto->dev; +} + static void virtio_crypto_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -977,6 +986,7 @@ static void virtio_crypto_class_init(ObjectClass *klass= , void *data) vdc->set_status =3D virtio_crypto_set_status; vdc->guest_notifier_mask =3D virtio_crypto_guest_notifier_mask; vdc->guest_notifier_pending =3D virtio_crypto_guest_notifier_pending; + vdc->get_vhost =3D virtio_crypto_get_vhost; } =20 static void virtio_crypto_instance_init(Object *obj) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 734b7fb..7c1b1dd 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3273,6 +3273,7 @@ void virtio_init(VirtIODevice *vdev, uint16_t device_= id, size_t config_size) =20 vdev->start_on_kick =3D false; vdev->started =3D false; + vdev->vhost_started =3D false; vdev->device_id =3D device_id; vdev->status =3D 0; qatomic_set(&vdev->isr, 0); diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 2a0be70..90e6080 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" =20 /* 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); }; =20 void virtio_instance_init_common(Object *proxy_obj, void *data, --=20 1.8.3.1 From nobody Sat May 4 07:55:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1642691827; cv=pass; d=zohomail.com; s=zohoarc; b=A3a6XrNvSScRT2gBIP3VnTRB43ql0c7+xxjYVnfQij9NeNeQAErcKARmIp6FrgcAvW0V+30bwuKdfJnLu2j7i31T6bsWKKHygBoteIAzObTRhccshtWu5+n+VrAUHusPsOxrk365TIoSmuKpO01Kc80kcckEpxm/Pw7yD4mvsWc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642691827; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DSS0yWCFM+yy0zNaf1wF/V5nILO7Ph0jnGOfn6+1v1s=; b=CEVReFwk8p+4ddFHrJdd7ER6zZt6lz/lHBaw+rTZL8E9hO+Z6+CWQa3esoATdf3fwWpR4jJ8dY5mkLbyQsZ1tOZDCaZhMOzJ7/s4/eeaj6Uvqn3l3ZzYc7bslYo6atbDFh+6Vc84YFvw6Th3r4HrwVwhQ+TS8EqMgQe4fXeLXT8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642691827415794.2775793464443; Thu, 20 Jan 2022 07:17:07 -0800 (PST) Received: from localhost ([::1]:49134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAZBR-0006Rj-P0 for importer@patchew.org; Thu, 20 Jan 2022 10:17:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAVey-0005c3-Ps; Thu, 20 Jan 2022 06:31:23 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:33636) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAVen-0006ab-NB; Thu, 20 Jan 2022 06:31:15 -0500 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20K9c0Am001411; Thu, 20 Jan 2022 11:30:18 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3dnc5f7wfg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jan 2022 11:30:17 +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 20KBGfYn031345; Thu, 20 Jan 2022 11:30:16 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by userp3030.oracle.com with ESMTP id 3dkkd24hb7-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jan 2022 11:30:16 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by BYAPR10MB2648.namprd10.prod.outlook.com (2603:10b6:a02:b3::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Thu, 20 Jan 2022 11:30:12 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::95b1:2ba7:964c:d3cb]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::95b1:2ba7:964c:d3cb%9]) with mapi id 15.20.4909.010; Thu, 20 Jan 2022 11:30:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=DSS0yWCFM+yy0zNaf1wF/V5nILO7Ph0jnGOfn6+1v1s=; b=NZ2IrV+Ihhd1GW5YgMu8lRftqrN20sjrWn9EfhAj/rdiWZiQ9/Y2VttGcMolnwLIZg4t Jq5AydjHvaY1q8IbzCPvt5MGo//83FTHci28aHqtdf/Tlcw3p3JBoFPijNhLk71gl+dW K8cKMMXFB0NZcNVCTGjfHrzN3GU6mgjvf+DqLhxmuIm2R1IeXEkPmcWxF7q18QwdO9Fs 643Ccmhjvw4EWcmeOFZ0Y56UqigZQz/TkArOcUfmetQcoH37Hl/6YI38UehC/JHh0rUp 1wTDbMQB1q3tlHbc3pUIl1x7i7Q9qAksjBn5hMFWucO/nFbZQO2ThtWZDOaSXoaNnVw8 2Q== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FvtmVUw5wBuUhZjHE69Q0Z6sEb0fdRHKbKZL3Xne4nEcQ9Uc9mH8nn/2nS+gaB77MchIJeeOMeAkhkS+Xl9BbV0bgcKBxb0gDrx7rcMr1uPa/hJIZM7uUx4DMljPSHQ16BuYS9D2bRguH+bltkDosvThe685R2kFW8W6MC+BOoafHVZtrJR4NnMFUDYpCSGw2PNKDJOcDoW8ACTUFuqTxY2Cs7cjVcyW8x/JlPgtir8rDoJYWQaUSeAG57SMkwn9bBPzmp90tNkt4D8g/elOum+ww25k8wPeBMxoUZe+4V0Ood51ZNx7vdAjBEf+97Toqal7uqoApXJefv6kUNcaqQ== 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=DSS0yWCFM+yy0zNaf1wF/V5nILO7Ph0jnGOfn6+1v1s=; b=ic3r1BJDLuBupES53bk8RqhDnxKSvOIi2S/z93bHHLpIpx9Zj8TVa3n96ovbRM76EOYJFTwHuBZw4FVPCgykMo99C9zM2BwIkQjGzfbhvEVfs8ppo8MLb6l4J8mioFljQ4KZCbW0I2xPnTZ9M2vOQftjoAPsj9JtilXtAE6ThZTJS4cltQEfj0khnVpJON30ntRLpGHTCodf0n06IevaCmVNOsy5Aqb4MOADfDxomUIw/PWxC62mxOKNsuQlZHUMsPegksz3veKg77zDiWLr9RH2z7qdFOXkE1xFbUUj5dmItd5K7+ud5HahjPCUex998APvkhRWf/7YlEa9QNkfIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=DSS0yWCFM+yy0zNaf1wF/V5nILO7Ph0jnGOfn6+1v1s=; b=tsXd7Fj6uL/c8bas19H+RA6ohmPXoIs9N70cBE7QoAkagNNqfZ3OxCY6TB4/9+JdhB6WSReloj/E+Pu9RqOSgtXKCb9NeMycWxzBQY7iZVkddbXRLEC4IBjnC4fcrBzmobPmo2nHtnQuCcmu0vbUgbFncVNXIEx4ToHUJE8N5IM= From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v11 3/8] qmp: add QMP command x-query-virtio Date: Thu, 20 Jan 2022 06:29:23 -0500 Message-Id: <1642678168-20447-4-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1642678168-20447-1-git-send-email-jonah.palmer@oracle.com> References: <1642678168-20447-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SA9PR11CA0025.namprd11.prod.outlook.com (2603:10b6:806:6e::30) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6ddb4787-9b91-4b47-5d1b-08d9dc0838bd X-MS-TrafficTypeDiagnostic: BYAPR10MB2648:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2L2k/I1EI6YiV7P9FU1IqUBVx8vJIQOQrERiIkV/Ys0dNYtDXgOM1FwmQZe8JBeA1bLiG5MSy4Dq5UOrLG1zmH1F8+NWxORIhbXtL7sCisk854lZfsPj1zZMhpgb4DOVTXnxLeRkeiDuuSLkJna/H0bom+3+I+mxCL0D5LePxF97tBTBYUg9/7zo68jNGikmrMRIpiNsPqeRnSQXbsLAAofSGhMuvlwcYgee79ufCDUyC0vt5h45gKgvQzEaty9L0pDeCs0quUM1kXx92EddyXqfAPtPzobm38LUvjQ6eBLvIDHv6xwnGrgVIJZZIMMQ/gZAyJgs0Af+b5c2U/obD32NJdqxuCMOPRynAW3nZQBexgaGD4YU9g970y7JrQDEnbBZQUekpKjci2xU14DX4RX8gCTecgYyaa4kUC8ALRAzO9vRkeASN9+73VmOi7BoPjFEmIRnweqVLPYkeIAYjJlAiwAR16X2Cbd8TM8Xm65k4tKRGQyQZbxBx9oJD8bRRrf5R98b2NfptWQMV8Ck4Rk9/0M7le0emOQmQOMI80zf+ZEvVRu+jfTqrl6xB3NOyf+RKrR1xFRYnDXaygIt1kMd8DFO/6l5f6wxC3hRZFZjUI4xpksWQ9KJVF6ZIfyvCO1S3EwotvHLU++Dg090tCJNEAjXSx78+wMtmeZXEENEibvIu4LDdtH3NxyRevwam9at4aUOlx+GlJexiDNZsA== 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)(8676002)(66556008)(6512007)(6486002)(8936002)(66476007)(6666004)(2616005)(66946007)(44832011)(186003)(316002)(36756003)(7416002)(86362001)(508600001)(38100700002)(26005)(6506007)(6916009)(38350700002)(52116002)(5660300002)(4326008)(83380400001)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?COYs9q3Y1uahelVbvDntv6UwnxwvSDK8C5HHauj9KRn50GPLkG/HD/Td8lRn?= =?us-ascii?Q?ZI/AhJF/8mKjYO1B8wwFuqlcYWTV5Y+Hdk4yYkJWL6EivTV6f11zOdlC7Spp?= =?us-ascii?Q?fzKhqfEacAt6zjKvL8wgTMiYMUlD9fUIBBfYvT+IPgIRrribCnbYbKl1FV37?= =?us-ascii?Q?zXRoR9gKhign5fOpst/2CIshDLS2W/MHS68/7facwRZMPwR/wy+/mJJc8pi4?= =?us-ascii?Q?fCcrc0iKySpgop9gmjKq/jVRg5Ol3ICGlnkClAsKudrQy0gZ2WdqmKxG29ld?= =?us-ascii?Q?FrYbJ0b1Av6H13nQ0dHCRdao856hpZhJawVART9lNiaXCRXvAhgSRc8hvjT4?= =?us-ascii?Q?E029x9IBpFgGHadYeVqjCLu4l4nFqAZrpEOk477fIkdQHjTeUEEsC8aKwJFE?= =?us-ascii?Q?mxl5pW7XWluLB/A0f63FDU2Ti14YJhTsjsQ2OP2v62Hd9uU96HkSawSH6U0P?= =?us-ascii?Q?AD+QcQRpY8auevXMRxN2GpXHQ5dMhnIDV1BCualStz+uJ9W+P2AFzhPHSfxg?= =?us-ascii?Q?Wp88Pi9ptZx3wj1X/aPqzu8EQqbcWvKQX4OaUVsMHoCJgAQgAUnVE8eDmfWc?= =?us-ascii?Q?WEYS9gtsfhoj7hEVR0wpznwYvNPXA7UW2tmWzx1gMWiKWZAy82WQCfcUDSrj?= =?us-ascii?Q?JxiSjaFolLaPTO16MdJ5FFSH6GMPrwZqVzltQmdhiy9gA26nSEU9mTFKANqF?= =?us-ascii?Q?TMioHoHYPu4PuWL0tq7dazVczF1Bb/3yr/SBEaquO2rm9X9hOoycFmWH7GQ8?= =?us-ascii?Q?LxUfVTz5F8oMyZIBFWCo3V10Cntz5m089UCCkw7m4cEMykrN6rzV6Ou7S/oO?= =?us-ascii?Q?Xd8Oa+ziGpKBDzpGC+aVTbM4STNDXZZuqnSfTsUk/l9t3nLdDm6JX25CFkia?= =?us-ascii?Q?dW8zHEGJVTB3l//ByQUTx+LG2Gg3Ca3dvPC8sJQFAUE0dU//t5F5//v+gwMv?= =?us-ascii?Q?o1D4PN36uNnxlqPiAM0zTe6XP9S+Vzv4/xbIZuxifRb3IEtB0UydWziIqD1A?= =?us-ascii?Q?vVmnAU6ZdmdF94K87KrFIncamaJSJ4Ef9qncNZfM8CkrlkIETXRGU3x6wZK6?= =?us-ascii?Q?ZYmmVsJvwQXNXhO1daHYLygd+jndaWkZkm6vGArDLQqNzrVqnZhJeP/GVrwE?= =?us-ascii?Q?PRZqJ7oqetthef6a46I3q3XIqzk7okLQze6sbURCnqzomwINVOxWBZDwygW4?= =?us-ascii?Q?q/BIPS4sr1SdnkwqV/0xXIuFwJ1DXtbZeXlsQslQ5iZYqeFPVYWMYDlwFRyt?= =?us-ascii?Q?8tTB2o7y0xcAeK3x/Sw3wjJdmJEPNnVcHBCi+SjRk3n004QT6t3Ti0ji8mHg?= =?us-ascii?Q?nEVi4q/U1YhB6mzYXLxdNmohUFIQRLnFQU0ig2/2jw16AYJEo1YcNO4M5DnG?= =?us-ascii?Q?RkQqzKAMkinfje5v74TJWPC7N8HC9zyZZWH4IYgO5WuI2p0PXL2Xj4zKIwp6?= =?us-ascii?Q?1LhT+1n8tprwQrkx2EPOHuBIwgNShEZmSfJNxE6lCEtgF60i7u0UlToi3/HW?= =?us-ascii?Q?refdr/EZH+HtE0nI3Qgbs3q1k7bvsX7iRcjspVbLB/boUXUme7MHWziFLlEo?= =?us-ascii?Q?0dMTIQhsltG/mwuCYZtk5/iDLOUyExrOdRFzgxz0WAJrz0Ap+ITuOv6cieCy?= =?us-ascii?Q?hG2X9QjyyFmoI+sF/SLiRZE=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ddb4787-9b91-4b47-5d1b-08d9dc0838bd X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2022 11:30:12.0668 (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: TI8D/xZ8pZnrr0c37N4pt/l+VclFwgvNL8Xv9ZzLJXv97PNhwJqe3HzLgkoyq3O0qPRZW5A3u2dmzCRvsbopvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2648 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10232 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 adultscore=0 phishscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201200058 X-Proofpoint-GUID: FDqywvB9S6roZ3NG2wJFx5AHB5z_qZzN X-Proofpoint-ORIG-GUID: FDqywvB9S6roZ3NG2wJFx5AHB5z_qZzN Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1642691828982100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This new command lists all the instances of VirtIODevices with their canonical QOM path and name. [Jonah: @virtio_list duplicates information that already exists in the QOM composition tree. However, extracting necessary information from this tree seems to be a bit convoluted. Instead, we still create our own list of realized virtio devices but use @qmp_qom_get with the device's canonical QOM path to confirm that the device exists and is realized. If the device exists but is actually not realized, then we remove it from our list (for synchronicity to the QOM composition tree). Also, the QMP command @x-query-virtio is redundant as @qom-list and @qom-get are sufficient to search '/machine/' for realized virtio devices. However, @x-query-virtio is much more convenient in listing realized virtio devices.] Signed-off-by: Jonah Palmer Acked-by: Markus Armbruster --- hw/virtio/meson.build | 2 ++ hw/virtio/virtio-stub.c | 14 ++++++++++ hw/virtio/virtio.c | 44 ++++++++++++++++++++++++++++++ include/hw/virtio/virtio.h | 1 + qapi/meson.build | 1 + qapi/qapi-schema.json | 1 + qapi/virtio.json | 68 ++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qtest/qmp-cmd-test.c | 1 + 8 files changed, 132 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: file= s('vhost-stub.c')) =20 softmmu_ss.add_all(when: 'CONFIG_VIRTIO', if_true: softmmu_virtio_ss) softmmu_ss.add(when: 'CONFIG_VIRTIO', if_false: files('vhost-stub.c')) +softmmu_ss.add(when: 'CONFIG_VIRTIO', if_false: files('virtio-stub.c')) =20 softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-stub.c')) +softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('virtio-stub.c')) =20 virtio_ss =3D ss.source_set() virtio_ss.add(files('virtio.c')) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c new file mode 100644 index 0000000..05a81ed --- /dev/null +++ b/hw/virtio/virtio-stub.c @@ -0,0 +1,14 @@ +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-virtio.h" + +static void *qmp_virtio_unsupported(Error **errp) +{ + error_setg(errp, "Virtio is disabled"); + return NULL; +} + +VirtioInfoList *qmp_x_query_virtio(Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 7c1b1dd..e59f0d7 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -13,12 +13,18 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qapi-commands-virtio.h" +#include "qapi/qapi-commands-qom.h" +#include "qapi/qapi-visit-virtio.h" +#include "qapi/qmp/qjson.h" #include "cpu.h" #include "trace.h" #include "qemu/error-report.h" #include "qemu/log.h" #include "qemu/main-loop.h" #include "qemu/module.h" +#include "qom/object_interfaces.h" #include "hw/virtio/virtio.h" #include "migration/qemu-file-types.h" #include "qemu/atomic.h" @@ -29,6 +35,9 @@ #include "sysemu/runstate.h" #include "standard-headers/linux/virtio_ids.h" =20 +/* QAPI list of realized 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 @@ -3687,6 +3696,7 @@ static void virtio_device_realize(DeviceState *dev, E= rror **errp) vdev->listener.commit =3D virtio_memory_listener_commit; vdev->listener.name =3D "virtio"; memory_listener_register(&vdev->listener, vdev->dma_as); + QTAILQ_INSERT_TAIL(&virtio_list, vdev, next); } =20 static void virtio_device_unrealize(DeviceState *dev) @@ -3701,6 +3711,7 @@ static void virtio_device_unrealize(DeviceState *dev) vdc->unrealize(dev); } =20 + QTAILQ_REMOVE(&virtio_list, vdev, next); g_free(vdev->bus_name); vdev->bus_name =3D NULL; } @@ -3874,6 +3885,8 @@ static void virtio_device_class_init(ObjectClass *kla= ss, void *data) vdc->stop_ioeventfd =3D virtio_device_stop_ioeventfd_impl; =20 vdc->legacy_features |=3D VIRTIO_LEGACY_FEATURES; + + QTAILQ_INIT(&virtio_list); } =20 bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev) @@ -3884,6 +3897,37 @@ bool virtio_device_ioeventfd_enabled(VirtIODevice *v= dev) return virtio_bus_ioeventfd_enabled(vbus); } =20 +VirtioInfoList *qmp_x_query_virtio(Error **errp) +{ + VirtioInfoList *list =3D NULL; + VirtioInfoList *node; + VirtIODevice *vdev; + + QTAILQ_FOREACH(vdev, &virtio_list, next) { + DeviceState *dev =3D DEVICE(vdev); + Error *err =3D NULL; + QObject *obj =3D qmp_qom_get(dev->canonical_path, "realized", &err= ); + + if (err =3D=3D NULL) { + GString *is_realized =3D qobject_to_json_pretty(obj, true); + /* virtio device is NOT realized, remove it from list */ + if (!strncmp(is_realized->str, "false", 4)) { + QTAILQ_REMOVE(&virtio_list, vdev, next); + } else { + node =3D g_new0(VirtioInfoList, 1); + node->value =3D g_new(VirtioInfo, 1); + node->value->path =3D g_strdup(dev->canonical_path); + node->value->name =3D g_strdup(vdev->name); + QAPI_LIST_PREPEND(list, node->value); + } + g_string_free(is_realized, true); + } + qobject_unref(obj); + } + + return list; +} + static const TypeInfo virtio_device_info =3D { .name =3D TYPE_VIRTIO_DEVICE, .parent =3D TYPE_DEVICE, diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 90e6080..8f4e4c1 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; }; =20 struct VirtioDeviceClass { diff --git a/qapi/meson.build b/qapi/meson.build index c0c49c1..e332f28 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -48,6 +48,7 @@ qapi_all_modules =3D [ '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..aee0e40 --- /dev/null +++ b/qapi/virtio.json @@ -0,0 +1,68 @@ +# -*- Mode: Python -*- +# vim: filetype=3Dpython +# + +## +# =3D Virtio devices +## + +## +# @VirtioInfo: +# +# Basic information about a given VirtIODevice +# +# @path: The VirtIODevice's canonical QOM path +# +# @name: Name of the VirtIODevice +# +# Since: 7.0 +# +## +{ 'struct': 'VirtioInfo', + 'data': { 'path': 'str', + 'name': 'str' } } + +## +# @x-query-virtio: +# +# Returns a list of all realized VirtIODevices +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: List of gathered VirtIODevices +# +# Since: 7.0 +# +# Example: +# +# -> { "execute": "x-query-virtio" } +# <- { "return": [ +# { +# "path": "/machine/peripheral-anon/device[4]/virtio-backend", +# "name": "virtio-input" +# }, +# { +# "path": "/machine/peripheral/crypto0/virtio-backend", +# "name": "virtio-crypto" +# }, +# { +# "path": "/machine/peripheral-anon/device[2]/virtio-backend", +# "name": "virtio-scsi" +# }, +# { +# "path": "/machine/peripheral-anon/device[1]/virtio-backend", +# "name": "virtio-net" +# }, +# { +# "path": "/machine/peripheral-anon/device[0]/virtio-backend", +# "name": "virtio-serial" +# } +# ] +# } +# +## + +{ 'command': 'x-query-virtio', + 'returns': [ 'VirtioInfo' ], + 'features': [ 'unstable' ] } diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c index 7f103ea..fd00ee2 100644 --- a/tests/qtest/qmp-cmd-test.c +++ b/tests/qtest/qmp-cmd-test.c @@ -103,6 +103,7 @@ static bool query_is_ignored(const char *cmd) "query-gic-capabilities", /* arm */ /* Success depends on target-specific build configuration: */ "query-pci", /* CONFIG_PCI */ + "x-query-virtio", /* CONFIG_VIRTIO */ /* Success depends on launching SEV guest */ "query-sev-launch-measure", /* Success depends on Host or Hypervisor SEV support */ --=20 1.8.3.1 From nobody Sat May 4 07:55:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1642687035; cv=pass; d=zohomail.com; s=zohoarc; b=dyGodT0KuUuuXLv6o5+2yyGrtUbJASZYPsnYf6rtYHyq+0DkaBUp3Gr5ZZJena+/BbeU1UgyGKFJyfod9HIGnzu12RlAuAKWRE0HHCsQygtwWy8mL5b6EUz5tHQg1aNBiZqYpwytEFxxfpYWcHjwDYg+D72VuIUA6F7GcdViOHs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642687035; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5C3A/LTzRbXyDRQK3LFG+ih/nDytojNRInU06Gtw2z0=; b=h2mO3J65q4st5OeIInogN18iq9ckYgQLctRzuoCcCnYbd0b2pwbH6GAv2/qf4YGYDH7OTaQd9JFA6YqR3EURs9YIiv9NN6cBnfirGD4EPL9iiJ2I0w+DdFeGTshJalqUZikmbRb/0lVmjtTit1NnndBBGmZyrXYOnswRVI4uNjs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642687035559132.14902073264284; Thu, 20 Jan 2022 05:57:15 -0800 (PST) Received: from localhost ([::1]:42848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAXw9-0008CJ-8s for importer@patchew.org; Thu, 20 Jan 2022 08:57:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAVey-0005c9-RL; Thu, 20 Jan 2022 06:31:23 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:1262) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAVep-0006Ye-OQ; Thu, 20 Jan 2022 06:31:18 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20K9r3ia031238; Thu, 20 Jan 2022 11:30:19 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3dnbrnyu2w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jan 2022 11:30:19 +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 20KBGTOS159003; Thu, 20 Jan 2022 11:30:18 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by aserp3020.oracle.com with ESMTP id 3dkp37g99x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jan 2022 11:30:18 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (20.182.107.75) by CY4PR10MB1381.namprd10.prod.outlook.com (10.169.254.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Thu, 20 Jan 2022 11:30:14 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::95b1:2ba7:964c:d3cb]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::95b1:2ba7:964c:d3cb%9]) with mapi id 15.20.4909.010; Thu, 20 Jan 2022 11:30:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=5C3A/LTzRbXyDRQK3LFG+ih/nDytojNRInU06Gtw2z0=; b=FaMSh7KwmJQ1KKjBnsPSTEin3YW1CM5hSGBffIiW86JFbaK5Cz0oAFU+MxIy30Ew6wAJ f5h74eFwasLnmbHDKnYdmr0L+UwcUGaOHR0ZMKSkAfmN9Mh0MzIqxQri6GvOwI+CPMLK R/y7IDdDd0+GM3YS/AW5nvvD9wecewZLLOCeblNTj+KEKE4xDOJQ3Q9CupHpi3pdmebn /vXTcKUdsNWT5QVzLwCNqX1fgjqG2/DksHbdfEn2MdWURUZglJV7pkc517W6DDQMHCLj r+SotsRxPRXTVvj7tuwh+rYtst8z42kanhJzr+2tEQfn144bgpwubjzK01SwkAKQbVlS qQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jmnje3vsnniGXOZFe53ql/A1OcB9M4U2O78Ui7bDGxB5q3/7RzsP8sutvNUAEANNrVtLs/UwWZ9mp24CG+kMWh44TnQLOlUZCoivOaL77XO6x40EH1FwS6xssfCXKovsV4EuAvY43ow9ZE44XFJPJukhX3ft0N7L+SRh2rb1VNBhWzlq/2MC4H/PNMTDutxxQnR/wzrdt6vtqOHMktCgBPx85SWMhHMIcrH5OJXfCn2+EYL3sP365XNvrH9CAdtIp3VCCkLhsH12UCUmW+Oo9yAjenr3+m2d2Cu9SCshdTQKm/YFOrmlARHYU9H7U6xSwvfdVhYLdoTcd1GE4yZ9pw== 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=5C3A/LTzRbXyDRQK3LFG+ih/nDytojNRInU06Gtw2z0=; b=XY4hniWhjHGGNfL/qGoh9rBoq9SbziE5UVFIiASzPg1dFOY4zr8ZL/fWLFyu7sWIx4Z97tkMTwUEoZA1sxStc2uR90WwRyJ2QDUsWwkl1v6GAQjpN5QXzYkBx++RQ8s4oJ3UxJzxtE8b8A1GX85KPTXFkOc3t9w7HxtZu3tgkiLLgPbYfLJl8cBnTtlIAVUPqvE0gh424DPf3S9nipyrOz9UVzw7Q3wyb2YD1zihX+al1GqkVkuB5MpMJRPEGZXh9E8+5UZg7fTgj/iew3CYS8GvF11C5QNfLtHBMADmETXmC/OiC5t52pWwy6gU6ltwpQYFDrCJLN1WvHyEMoo3RA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=5C3A/LTzRbXyDRQK3LFG+ih/nDytojNRInU06Gtw2z0=; b=VdALdfWwyE8WirP9L4CBhINS/w/VUTuf6udR52c5Az+KcXnLiAztjEC3MvMHwtPDeMxB5E/dNr4JPZsP25Yi+3EfCE1hRHaRULHkrmoUgUeEYfkI1mCQYHQ0rirxd7lPrAIdZx9J9n1VL7NLRvvboHjzX8UWsHFC/udqi924KrI= From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v11 4/8] qmp: add QMP command x-query-virtio-status Date: Thu, 20 Jan 2022 06:29:24 -0500 Message-Id: <1642678168-20447-5-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1642678168-20447-1-git-send-email-jonah.palmer@oracle.com> References: <1642678168-20447-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SA9PR11CA0025.namprd11.prod.outlook.com (2603:10b6:806:6e::30) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 10aac47e-ddbd-4173-2faf-08d9dc083a36 X-MS-TrafficTypeDiagnostic: CY4PR10MB1381:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:568; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E/s3acHAcWQqNOuUiD78qZwzM4biac6UOV9xSOM9wenxzLLsb11jGEEjvV1rRgkOvSRZoFYasT8xxFUG4392UYEQctOG7xMA783WE2g+c2xVL0D1Igu1OEz4rBNVbAoVxAE4OALZplU0MvvxUORGQaP5Lf+KJYq5KQMu6mtyX7txItiOYk+89meJE+YQ0fKA6wFsNfNnrzTdQ1RNlz2NhIZjX2Oy5ewYupZBatXMD4sHKyG590VUA0I6cMC8H3rDvfRrS5yKYirR8EQCwPBB35j2uDBB24nvs8F5rMRED3ci+CW9ZqLTqmXt/ttmU2O+h1FzOaZ2Ysn1DOJ1IT/qchw4uW8ACIqRCa8fnOOV2WnJxXQLndF9GJRqBMeyCub861kvTU5YUwWyjsyNC4wYcv/AhtdE3JHqiF8rJqMxjKO8H9VBTZP7j+pGcnB1LS9d/1XOQuSWkdvulWoyO5DN1YmtEdSqoWjGLvlHkIOoQau8uZtXlBiLs4FAq6P5NbChq7EVYPl0pn3spKhXvMNbiQPHpiYfxwlVURKqy8lZlxJar+QUzPnLiJCRgnJ8xRxZTf+H7gcpqs90osRE70YQ/si4MuM2HSqoDKyL/a+n+oyXR5y1z4M5yS3Ab15FewUQx6S6kyS+ibiaF1ZjBGOKAOtbeIFHeHjWalp7Ty0F7FQ6tfF5651XNbTmuDjAQKfJzppkGdqHNfg2axAcJh2PPQ== 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)(6512007)(38100700002)(38350700002)(6666004)(6486002)(30864003)(2906002)(6916009)(7416002)(83380400001)(8676002)(86362001)(8936002)(4326008)(508600001)(316002)(5660300002)(26005)(186003)(44832011)(6506007)(66946007)(52116002)(66476007)(66556008)(2616005)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?d7eqiPeV7WrOHZhfLWuh+msNGiHOBtI70pyvJhKPahK+UPmqh+d+S4rJZRDn?= =?us-ascii?Q?xf0KL/dqFDT+OUlqGh+ezTFlCW3QXdns9/FRmt9d8xpwkmImmd57JlwN0Mhz?= =?us-ascii?Q?isFxWgAf9t2iCKtRzGFlw2B3tMGJL1IWWwjLOx55nGa8aQH4l4WDVdNFnT09?= =?us-ascii?Q?mWpIqrfp5y/xpnu+Pr4bjCuKIcIINtfxUb+kfteewX1TEveU01dsW6c1zjti?= =?us-ascii?Q?zkhAxZkiSdVbbvbvhh2DevX1C4obrKkj5WGd+6SyLO/6/RQQKGemXZ5FpY4z?= =?us-ascii?Q?+uiMvrEcMOOSlH7QidyLuOn8s1RJELSDXzbXi1qBuxZtdCGuTbAVUB6FaBaG?= =?us-ascii?Q?tYRWOPQoaAMQEw4wyBKwTm2w1LoeUkoe7LtSNoxDe4TjH1X60PMbX8+Z3UV8?= =?us-ascii?Q?c1xZcw/HGWrjqZTNbbqOq97LkWEkcO6Frjwk6yTTMjwV55VzjsmEqJy+1Xd0?= =?us-ascii?Q?51NSkBbNBtuKkqMaYDBddOHDiPfpE41tHdKkICkOPURo8/EQ6nAas8BSLFrV?= =?us-ascii?Q?foGtrujijeu02UHYtMFSuzVYgxHno7Mnu7Q9SbtVdaNbkrYL11PyG3hZ6mKg?= =?us-ascii?Q?BQ76RyNvrfjJYj152XcF5OSlNHl+HzRKuyoyk6PFjhh31Ps0T3XlGCmlx0aC?= =?us-ascii?Q?Efe7S74JGGOsOD+sAlLZHv1exJ9Wp5jZK3c4l/pIGbzvhGQsVRmrBjDD3g0X?= =?us-ascii?Q?HVVS0c7YhUF46qjljxmjhfgYvVIw2HgZwCI2+p226xe3dhaH3hiolCWnTWm6?= =?us-ascii?Q?XL6Ei04FJ1kW2fbfenOEzmG+bCcuMd3mCzCRXMI9ZdDec5iL7AmHIlfPQyIJ?= =?us-ascii?Q?WQDOfDT0Ep0SsvTY20qQZccLlP9GKtM/339bsLy+3ut+0vLZjWccogOr8YMk?= =?us-ascii?Q?wJL9HRgNBxNxpIvniXetcsO5l+Xfd4ZtPBXNRQXc0RWs1/Y1c6n4Emk/lqBe?= =?us-ascii?Q?sOJiH/hPPM9jax+mHmitLQk/Aiig2AJZaW8VLWruRu7oP45hF9pnZAosuRsR?= =?us-ascii?Q?O6+/ocQo5+HN0jZ3jfg39W6XovHYhlFhl7ww5bQ61zPoVNl3T5LI/2HNWjmc?= =?us-ascii?Q?bUCGhoON7CidU4x2pKph62CaQUy6CxUnSrn89fcbey0gsrCbKW4MsUloWScF?= =?us-ascii?Q?JeUmya4xd2nL0Z4OnOvaPEM3H0xOgztdjTlsbwC747PRmSKJpYPfb+jPhYr5?= =?us-ascii?Q?tpqLNExIxSaeIoONF8XndZhBaG817FdH70qIBBsT8GBPm13BhguwiUWwOFnw?= =?us-ascii?Q?b6BpZ1uDjw5sIT+f8+QAtchy7Z7+W1FOuRqEfKtm2Aw37pNHLlPAl23u9F9c?= =?us-ascii?Q?Quwuv+j0W4iRYv0stKrLfFUujZR92QIIs1vwk+DYb4x3uhEs/XLTCd9UEUcc?= =?us-ascii?Q?bignh3WKI8HEl9PHTIG20Oq61iKs4ONrJHyt0TfQTuNhp3qmAl8/Xm+NbV1R?= =?us-ascii?Q?NIz9v8ONxBNbXP0C0XAtcciVs9MIPJUZ3d2TrhevPmlhZynlSRCyg7tbuol7?= =?us-ascii?Q?c0DWwT3wxcmF/kzdJJo3CafDeU7+ozMdrTANMTNOEGSKxRVCSJAUyLmJ4TcH?= =?us-ascii?Q?TdARu7g4EtKpUiYE3xiDooj3K7Hx3QgXAEa7v55m9bH9rxu2nbPE9OBGEYgX?= =?us-ascii?Q?ZannmZMAB3jAqbwO6h5ukSc=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10aac47e-ddbd-4173-2faf-08d9dc083a36 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2022 11:30:14.5364 (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: qde9EmM9Kl4W+WpLWYnflg8KkWqU+TBldDC6s1ACXcpMBdl3iHsi9b4S3DT5nFObT0a0Zc3/M+mSi7rsKFeVEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1381 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10232 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201200058 X-Proofpoint-GUID: Gw7BIC-Ie6FDrqbfsDFr7cTXWAvAjzlc X-Proofpoint-ORIG-GUID: Gw7BIC-Ie6FDrqbfsDFr7cTXWAvAjzlc Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1642687037268100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This new command shows the status of a VirtIODevice, including its corresponding vhost device's 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. [Jonah: Similar to previous patch, added a check to @virtio_device_find to ensure synchronicity between @virtio_list and the devices in the QOM composition tree.] Signed-off-by: Jonah Palmer Acked-by: Markus Armbruster --- hw/virtio/virtio-stub.c | 5 ++ hw/virtio/virtio.c | 104 +++++++++++++++++++++++ qapi/virtio.json | 222 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 331 insertions(+) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index 05a81ed..0b432e8 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -12,3 +12,8 @@ VirtioInfoList *qmp_x_query_virtio(Error **errp) { return qmp_virtio_unsupported(errp); } + +VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index e59f0d7..30ccd7b 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3928,6 +3928,110 @@ VirtioInfoList *qmp_x_query_virtio(Error **errp) return list; } =20 +static VirtIODevice *virtio_device_find(const char *path) +{ + VirtIODevice *vdev; + + QTAILQ_FOREACH(vdev, &virtio_list, next) { + DeviceState *dev =3D DEVICE(vdev); + + if (strcmp(dev->canonical_path, path) !=3D 0) { + continue; + } + + Error *err =3D NULL; + QObject *obj =3D qmp_qom_get(dev->canonical_path, "realized", &err= ); + if (err =3D=3D NULL) { + GString *is_realized =3D qobject_to_json_pretty(obj, true); + /* virtio device is NOT realized, remove it from list */ + if (!strncmp(is_realized->str, "false", 4)) { + g_string_free(is_realized, true); + qobject_unref(obj); + QTAILQ_REMOVE(&virtio_list, vdev, next); + return NULL; + } + g_string_free(is_realized, true); + } else { + /* virtio device doesn't exist in QOM tree */ + QTAILQ_REMOVE(&virtio_list, vdev, next); + qobject_unref(obj); + return NULL; + } + /* device exists in QOM tree & is realized */ + qobject_unref(obj); + return vdev; + } + return NULL; +} + +VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) +{ + VirtIODevice *vdev; + VirtioStatus *status; + + vdev =3D virtio_device_find(path); + if (vdev =3D=3D NULL) { + error_setg(errp, "Path %s is not a VirtIODevice", path); + return NULL; + } + + status =3D g_new0(VirtioStatus, 1); + status->name =3D g_strdup(vdev->name); + status->device_id =3D vdev->device_id; + status->vhost_started =3D vdev->vhost_started; + status->guest_features =3D vdev->guest_features; + status->host_features =3D vdev->host_features; + status->backend_features =3D vdev->backend_features; + + switch (vdev->device_endian) { + case VIRTIO_DEVICE_ENDIAN_LITTLE: + status->device_endian =3D g_strdup("little"); + break; + case VIRTIO_DEVICE_ENDIAN_BIG: + status->device_endian =3D g_strdup("big"); + break; + default: + status->device_endian =3D g_strdup("unknown"); + break; + } + + status->num_vqs =3D virtio_get_num_queues(vdev); + status->status =3D vdev->status; + status->isr =3D vdev->isr; + status->queue_sel =3D vdev->queue_sel; + status->vm_running =3D vdev->vm_running; + status->broken =3D vdev->broken; + status->disabled =3D vdev->disabled; + status->use_started =3D vdev->use_started; + status->started =3D vdev->started; + status->start_on_kick =3D vdev->start_on_kick; + status->disable_legacy_check =3D vdev->disable_legacy_check; + status->bus_name =3D g_strdup(vdev->bus_name); + status->use_guest_notifier_mask =3D vdev->use_guest_notifier_mask; + status->has_vhost_dev =3D vdev->vhost_started; + + if (vdev->vhost_started) { + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); + struct vhost_dev *hdev =3D vdc->get_vhost(vdev); + + status->vhost_dev =3D g_new0(VhostStatus, 1); + status->vhost_dev->n_mem_sections =3D hdev->n_mem_sections; + status->vhost_dev->n_tmp_sections =3D hdev->n_tmp_sections; + status->vhost_dev->nvqs =3D hdev->nvqs; + status->vhost_dev->vq_index =3D hdev->vq_index; + status->vhost_dev->features =3D hdev->features; + status->vhost_dev->acked_features =3D hdev->acked_features; + status->vhost_dev->backend_features =3D hdev->backend_features; + status->vhost_dev->protocol_features =3D hdev->protocol_features; + status->vhost_dev->max_queues =3D hdev->max_queues; + status->vhost_dev->backend_cap =3D hdev->backend_cap; + status->vhost_dev->log_enabled =3D hdev->log_enabled; + status->vhost_dev->log_size =3D hdev->log_size; + } + + return status; +} + static const TypeInfo virtio_device_info =3D { .name =3D TYPE_VIRTIO_DEVICE, .parent =3D TYPE_DEVICE, diff --git a/qapi/virtio.json b/qapi/virtio.json index aee0e40..ba61d83 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -66,3 +66,225 @@ { 'command': 'x-query-virtio', 'returns': [ 'VirtioInfo' ], 'features': [ 'unstable' ] } + +## +# @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 (number of virtqueues being used) +# +# @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: 7.0 +# +## + +{ '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 (VirtioDeviceStatus) +# +# @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. +# Present if the given VirtIODevice has an active vhost +# device. +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtioStatus', + 'data': { 'name': 'str', + 'device-id': 'uint16', + 'vhost-started': 'bool', + 'device-endian': 'str', + 'guest-features': 'uint64', + 'host-features': 'uint64', + 'backend-features': 'uint64', + 'num-vqs': 'int', + 'status': 'uint8', + 'isr': 'uint8', + 'queue-sel': 'uint16', + 'vm-running': 'bool', + 'broken': 'bool', + 'disabled': 'bool', + 'use-started': 'bool', + 'started': 'bool', + 'start-on-kick': 'bool', + 'disable-legacy-check': 'bool', + 'bus-name': 'str', + 'use-guest-notifier-mask': 'bool', + '*vhost-dev': 'VhostStatus' } } + +## +# @x-query-virtio-status: +# +# Poll for a comprehensive status of a given virtio device +# +# @path: Canonical QOM path of the VirtIODevice +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: VirtioStatus of the virtio device +# +# Since: 7.0 +# +# Examples: +# +# 1. Poll for the status of virtio-crypto (no vhost-crypto active) +# +# -> { "execute": "x-query-virtio-status", +# "arguments": { "path": "/machine/peripheral/crypto0/virtio-backend"= } +# } +# <- { "return": { +# "device-endian": "little", +# "bus-name": "", +# "disable-legacy-check": false, +# "name": "virtio-crypto", +# "started": true, +# "device-id": 20, +# "backend-features": 0, +# "start-on-kick": false, +# "isr": 1, +# "broken": false, +# "status": 15, +# "num-vqs": 2, +# "guest-features": 5100273664, +# "host-features": 6325010432, +# "use-guest-notifier-mask": true, +# "vm-running": true, +# "queue-sel": 1, +# "disabled": false, +# "vhost-started": false, +# "use-started": true +# } +# } +# +# 2. Poll for the status of virtio-net (vhost-net is active) +# +# -> { "execute": "x-query-virtio-status", +# "arguments": { "path": "/machine/peripheral-anon/device[1]/virtio-b= ackend" } +# } +# <- { "return": { +# "device-endian": "little", +# "bus-name": "", +# "disabled-legacy-check": false, +# "name": "virtio-net", +# "started": true, +# "device-id": 1, +# "vhost-dev": { +# "n-tmp-sections": 4, +# "n-mem-sections": 4, +# "max-queues": 1, +# "backend-cap": 2, +# "log-size": 0, +# "backend-features": 0, +# "nvqs": 2, +# "protocol-features": 0, +# "vq-index": 0, +# "log-enabled": false, +# "acked-features": 5100306432, +# "features": 13908344832 +# }, +# "backend-features": 6337593319, +# "start-on-kick": false, +# "isr": 1, +# "broken": false, +# "status": 15, +# "num-vqs": 3, +# "guest-features": 5111807911, +# "host-features": 6337593319, +# "use-guest-notifier-mask": true, +# "vm-running": true, +# "queue-sel": 2, +# "disabled": false, +# "vhost-started": true, +# "use-started": true +# } +# } +# +## + +{ 'command': 'x-query-virtio-status', + 'data': { 'path': 'str' }, + 'returns': 'VirtioStatus', + 'features': [ 'unstable' ] } --=20 1.8.3.1 From nobody Sat May 4 07:55:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1642690127; cv=pass; d=zohomail.com; s=zohoarc; b=Bnzrq2r0YY94HRlS2VCbNnpqOCOAiJDikUyTbqZHlfTiYK0/ZnFxK7Fl8BgfAnE6CEitTk9fMf8T4D8zCS3iC8RMdmTsaBcP3+DiUhbJ9LWjUpwfFS9hHKWd/ikF1Sbs9JL4kVolpfQE+SYIuC1ZaiB6QDdI/PpaNpmJBNfYMWw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642690127; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IgF0W33hXYiRz1X+NWG4EhwUylCuOBuAPBno2CdDA+A=; b=k3K1Gr7vPUgwDRpAw/8lui8lrxY2vpKSko2VQr+GzIQXnaU67ZNurHGc9/DWY/DMIA/Be+GItykjb4/lVSuTqSVCBvKc0A8ekPxTcbadcNDLntsHWGlIzNsYOxGHxT1Xjr7SguefZwU8uUVyri6h/pKo0vXEgxLV2AyCjnZBbyQ= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642690127365796.8142708922849; Thu, 20 Jan 2022 06:48:47 -0800 (PST) Received: from localhost ([::1]:55020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAYk2-0006dS-1I for importer@patchew.org; Thu, 20 Jan 2022 09:48:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAVer-0005b4-V3; Thu, 20 Jan 2022 06:31:19 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:14462) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAVem-0006af-PP; Thu, 20 Jan 2022 06:31:13 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20K8TZCx032605; Thu, 20 Jan 2022 11:30:22 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3dnc4q84fa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jan 2022 11:30:22 +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 20KBGfhs031354; Thu, 20 Jan 2022 11:30:21 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2171.outbound.protection.outlook.com [104.47.56.171]) by userp3030.oracle.com with ESMTP id 3dkkd24hjf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jan 2022 11:30:20 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (20.182.107.75) by CY4PR10MB1381.namprd10.prod.outlook.com (10.169.254.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Thu, 20 Jan 2022 11:30:17 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::95b1:2ba7:964c:d3cb]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::95b1:2ba7:964c:d3cb%9]) with mapi id 15.20.4909.010; Thu, 20 Jan 2022 11:30:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=IgF0W33hXYiRz1X+NWG4EhwUylCuOBuAPBno2CdDA+A=; b=BDiTdQ1ehbfNfE1Gxi0QVnOQQyZ6vDtRQ7snQbpRMEcW9dD7sHxojap4kOCLe/Aji/R7 2smkn6lJHmJpcfHAgApB8Ol9FZRYTaR46maOYr+aoNRKgEmbPMN/DS3xJLnfRM0m8ayw FKrxj81LDQCmJ7r3HFEjwN5pixzq3aUxQ1acyEpXG66vRRYmrcdZJxR/6yxAVP7YkZ+A 59eFIKErulJ4Zs8n8q83uAUoX7hPMRe8pPe/MyJCp8HFYBctLM2qPA41FsDrR+ivIOE8 Rq2PsOr7N/UzanvIum6VGNkRJnwnFgQmDMCN/MIR0WrOW8gPtYnBHJttpRp9Rvny7AXk 0w== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TE2u/vrViJ865yg7xUp648SFW7vLiQI4ze1FJMTsLj9TRMjp3kbZk8L2hLvtdg6Me6nd56SRrykICGhmf5U+2e/OPFuRKFNYnHGDoxMwukjVkFO7dfrTMT6t4TiIEJnteWSAqKWeqaF4ZPpRMczf4Y7gLpQURlx3vNtwfkMbyl1H/VczrFiZSQmMLqfzmHvK0w9kI1jcSfRMR0b0f+RYrSb9w95NCuehxF3usq2nsDFDkQrLV/WPrCEf/9VUFTcNwlYpOj1pVLNPTL3YkJt09Tu71eud9+drOpZusn/XFYbFFVFdW6WJHLjX5E1fgz+/Mf0ILZXk6/IRNsDo1T15+w== 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=IgF0W33hXYiRz1X+NWG4EhwUylCuOBuAPBno2CdDA+A=; b=fF1cyu9z97fryjoStErv7StG4Hqy+vJv9uCsBjyMhag9n45fWf1FFS4sm0dC5qHLElsCgEnwVbrYxKWWoBFCzF/5Wjy4MLhSt3hgSKWeSj6LdA6vptp3q4xozHWKiYklE8iC60jKgSrApN4VqapAngvKGeKW1G3hYi1GaO17qN8f0Ov5EP8RiUyQMyORL2Wq2/CXzgqEqHLiFaHXGOtJtnIexLVnloR4xjH0qf3HCiTPxBlvMEcC5sLSXqiwA3MFS/LWbNwplIVQZKF5GMhRgpCIwZ+bXUgGRU9aDubbQh6jawJVGjL2s0jiRSyHDwoljKIWTTXMjJVOBv+o90Q8sg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=IgF0W33hXYiRz1X+NWG4EhwUylCuOBuAPBno2CdDA+A=; b=W/z25PbjzghHnsGQ9V6DrtH687tzmcS38JaX37ovHHLvmHMG+8CJZjYd3STpVQVgF86Qj1GHM5VPYb8E5uUP7XNZSXc5QUAoqrFtJxKdSsi86cuIVPAGmFwmkaW6br2cLstEHs5gVzpjozRomsR9D+YLbRPmmY7T+6BGHB28Qu4= From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v11 5/8] qmp: decode feature & status bits in virtio-status Date: Thu, 20 Jan 2022 06:29:25 -0500 Message-Id: <1642678168-20447-6-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1642678168-20447-1-git-send-email-jonah.palmer@oracle.com> References: <1642678168-20447-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SA9PR11CA0025.namprd11.prod.outlook.com (2603:10b6:806:6e::30) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b1d3bf32-d370-4d68-4020-08d9dc083baa X-MS-TrafficTypeDiagnostic: CY4PR10MB1381:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NscF5to2K4qkT4bIlhU76LCTPCLvSpJ/HPpVayl175hjyA3woEgpRkx/hTqLfWI+TPlNAlOcU+ZaABWhvGAcdsww2ithGpQJ7r2AhdTtVA7ccQKO+Jx3/QCrvZ5xdC+Lbzpb3UNjEefIM0/UtubKmhZIE3q2Re/Ypn0ygaoq9ErbcZ6Z3yS67o53EAPSC/hLph/9LRcu1VQjrWW3xkTZ5Tkw5wKFBm96m4uy9630NZszAmGdeTfuPk6SsH4LKYsbUzI8ZedkDUxzq/6smTdXWO6es8Vupr8UbgYGOWtKCWeOMlnXi2Ti+dZ0Nc/M8Qwb8zr6VlMXO4Y2pxXoVn/Ywa8fMYUsnSYubXxoFikgi7Pt3+p4E3QXNGNGEgatQoK6hwzSp/vRwuS+ptYi6fb0xMBGI7CHIGnaKtOJy4piSVNa9Xp/wqHUPh9QeeUIjtXsPE2zReFMGL+Ye7aYDhDvukz48EaCSEvvAqoLZr683+vcI8+4sETjaDH7iNfdEmvzQz4neeNzTcDzHQkdybN9Le0rDKbn6OPDzyK+1ZE/6TZ8NgOi820mR4guEYOJTsLPGcPGP7CWDHXPnFchvyea05YNALLW6Go5QsXqUIHuqqiSC6a8Ar2zWq8KcYeoaf76uOksQVtee141pvXh6qTnkjWuPAte7eN9LncrwuEvmoHUHbuZOnhJzshnh6LMU2iEPl/LE0SaeOCvHvHbGw0CmA== 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)(6512007)(38100700002)(38350700002)(6666004)(6486002)(30864003)(2906002)(6916009)(7416002)(83380400001)(8676002)(86362001)(8936002)(4326008)(508600001)(316002)(5660300002)(26005)(186003)(44832011)(6506007)(66946007)(52116002)(66476007)(66556008)(2616005)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?iQZW9OnI9cRn6nrMU/h4RugNRIHhJ2QcfeLQVJdytbTFvQkpAM1j+0BWB2nO?= =?us-ascii?Q?j4lYN0SrN2NoLz8uXE89+Mo9UX3rc49tX9PIDcTnijEm7bozHBleMmYd0JtV?= =?us-ascii?Q?GVnIFWdo6IEtMrQM0UGcm7d++EpAnoxh6CmsktHudNrVpeWLbYKMuTr8L5UZ?= =?us-ascii?Q?ytq/nisQfPeS4MZ/vU/Xyd14B9gw1mnx9KSPc8e2QjMWcBiMUlcEb0a7UVQJ?= =?us-ascii?Q?ypFxN4BOVULN6sYgoCIWDhtzu7tRcyrvQRQZpKy7eQblN8vy0411uj9+zD7J?= =?us-ascii?Q?uxTxLQY/lp0FZeu1SEscx0oZj0sgQLqGeaFAAZhYU2Ixn8phwBVnx0ELs/Xx?= =?us-ascii?Q?fdqbLxywr77usqWTptfJ31Dk82jc6pbQlNenlvCJ+ns/YG1L5og11SIEzG3h?= =?us-ascii?Q?qgLtj2EZTUVfdnlBPtcsJFvkPKytfsO5m4IyDuCv3EnT0l3vjdobjHSq7JgN?= =?us-ascii?Q?N5Gd56kuZaI0iG0ajyZvHV/A0Kbv2tOWuDVXQPPvnIjwxeaCjEyADJW7chhT?= =?us-ascii?Q?sV06SawItFcul8fa/GzN38X/aYaszLQ3KPvHKjf0DRBZD5Q0XvFp/ciu8p0X?= =?us-ascii?Q?gdJVUvg9asyFic2z5oWnfzI9TGLB5dEr6wl7gPy3yMKaA9hkbRdiAS6z9SZF?= =?us-ascii?Q?n+TB9xM7V8XLtcIbuWZvaP7syXXvkQYVqYLdNlNLNkK+U2i35GMqiQ+IcA4V?= =?us-ascii?Q?S38zo4FVGfymHERvRwqXvOc/cSrDJTbyDq/jPyFbqeqxT7KLocFMVufyfkGI?= =?us-ascii?Q?w74hkrix8eR2bYo1g4J4h2lNoU89tHJVL4bQIVr6ZZFIa9b0vz632m0ek02t?= =?us-ascii?Q?BIamH3TqvRVaAMW0c+XB1C9j8Lfiy05uHjtYmUDW+5nyPAoEYQeCjKaBZ3m9?= =?us-ascii?Q?jgoDl7BryrsLdR3jk94b/m4N2mcRvWbEgzHWo/s+UbRB/U5ETSXpJnAMhH2X?= =?us-ascii?Q?NfRKy5KWK774ScAf6Lw2o0xJRFzTItLhGqiJP+J447voWXgJmltxIEoNK+mr?= =?us-ascii?Q?JF6xXrt0inbHtSbulH0X3ysIx/L+5+jyDMsjUu5X+IqakHvlsBC1g1SeiE2n?= =?us-ascii?Q?isXspeRH2dFxbFA1+5MtV9ocRHgoT8XAvOHrokE+3OYm80ufy+D0DI3ir3oW?= =?us-ascii?Q?S0znXGL6fN/Nf82zE1xbkik6Sbmz+DCQWekbsZKRc85t5/0OCGIl9xGAYSyy?= =?us-ascii?Q?wfeUzlYkf+N8AMhKn+Xfm0S/gV6fpA5l5FF8YrpabHXpyLE3+tjLNr0vhXDt?= =?us-ascii?Q?DYONPSi5mBzr5II6asO3U8AJ4gGamnyIoL/wPpgiPK5xHx/HOc6U2NEzOxHg?= =?us-ascii?Q?dUepWa85NEOu0RFJbbj0q0msIrWM7fVtnM4BW7nWiUPDKnn+oDAB/7uIoK6k?= =?us-ascii?Q?a4X1wkziGL8sbzU71MKne9c3HSR05jwBdoYq0ASD5QCf5L4iqc6CMOmfRZ8M?= =?us-ascii?Q?ZTjxn9UNXMyLaKeprkkujv1Rj0mbE+MZRqlSVq1hHnVQI1rq3LevjTwZHf82?= =?us-ascii?Q?TLgDmji78Q/uFL11bUCP5GRvRfnM0S/3hcx4YOAWdv3Zrr1RiSvmKgdLhLa7?= =?us-ascii?Q?rTp8Ykr+Y2HCQVyhUrq9FCEjh5I5PodURY1w8rv9iccDUDv4wXvh61Tzj6Ja?= =?us-ascii?Q?aqWvDC1PmLkTcaNeMXV+UpY=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1d3bf32-d370-4d68-4020-08d9dc083baa X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2022 11:30:17.0372 (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: ByGAjAZEeVmpLPyzKw1kERheGJ2M4BORt/jieX5DMegcGdcpxQsgHhfEC5e/OEe6mRX39HmtnX0kJyAYeWOC0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1381 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10232 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 adultscore=0 phishscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201200058 X-Proofpoint-GUID: V8CXbSB1qWHAQ-XR_AAtCQ7zXw0kcToq X-Proofpoint-ORIG-GUID: V8CXbSB1qWHAQ-XR_AAtCQ7zXw0kcToq Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1642690129838100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier Display feature names instead of bitmaps for host, guest, and backend for VirtIODevices. Display status names instead of bitmaps for VirtIODevices. Display feature names instead of bitmaps for backend, protocol, acked, and features (hdev->features) for vhost devices. Decode features according to device ID. Decode statuses 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. Signed-off-by: Jonah Palmer --- hw/block/virtio-blk.c | 29 ++++ hw/char/virtio-serial-bus.c | 11 ++ hw/display/virtio-gpu-base.c | 18 ++- hw/input/virtio-input.c | 10 ++ hw/net/virtio-net.c | 47 +++++++ hw/scsi/virtio-scsi.c | 17 +++ hw/virtio/vhost-user-fs.c | 10 ++ hw/virtio/vhost-vsock-common.c | 10 ++ hw/virtio/virtio-balloon.c | 14 ++ hw/virtio/virtio-crypto.c | 10 ++ hw/virtio/virtio-iommu.c | 14 ++ hw/virtio/virtio-mem.c | 11 ++ hw/virtio/virtio.c | 297 +++++++++++++++++++++++++++++++++++++= ++-- include/hw/virtio/vhost.h | 3 + include/hw/virtio/virtio.h | 18 +++ qapi/virtio.json | 156 +++++++++++++++++++--- 16 files changed, 646 insertions(+), 29 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 2e3809d..55d291e 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -13,6 +13,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/iov.h" #include "qemu/module.h" #include "qemu/error-report.h" @@ -32,10 +33,38 @@ #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" =20 /* Config size before the discard support (hide associated config fields) = */ #define VIRTIO_BLK_CFG_SIZE offsetof(struct virtio_blk_config, \ max_discard_sectors) + +qmp_virtio_feature_map_t blk_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_BLK_F_##name, #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, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; + /* * Starting from the discard feature, we can use this array to properly * set the config size depending on the features enabled. diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 9f19fd0..9de2575 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -20,6 +20,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/iov.h" #include "qemu/main-loop.h" #include "qemu/module.h" @@ -32,6 +33,16 @@ #include "hw/virtio/virtio-serial.h" #include "hw/virtio/virtio-access.h" =20 +qmp_virtio_feature_map_t serial_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_CONSOLE_F_##name, #name } + FEATURE_ENTRY(SIZE), + FEATURE_ENTRY(MULTIPORT), + FEATURE_ENTRY(EMERG_WRITE), +#undef FEATURE_ENTRY + { -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 8ba5da4..796786a 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -12,13 +12,29 @@ */ =20 #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" =20 +qmp_virtio_feature_map_t gpu_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_GPU_F_##name, #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, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; + void virtio_gpu_base_reset(VirtIOGPUBase *g) { diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c index 5b5398b..fe0ed6d 100644 --- a/hw/input/virtio-input.c +++ b/hw/input/virtio-input.c @@ -6,6 +6,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/iov.h" #include "qemu/module.h" #include "trace.h" @@ -14,10 +15,19 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-input.h" =20 +#include "standard-headers/linux/vhost_types.h" #include "standard-headers/linux/input.h" =20 #define VIRTIO_INPUT_VM_VERSION 1 =20 +qmp_virtio_feature_map_t input_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; + /* ----------------------------------------------------------------- */ =20 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 21328dc..db3d4a0 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" @@ -90,6 +92,51 @@ VIRTIO_NET_RSS_HASH_TYPE_TCP_EX |= \ VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) =20 +qmp_virtio_feature_map_t net_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_NET_F_##name, #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, #name } + FEATURE_ENTRY(VIRTIO_NET_HDR), +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; + static const VirtIOFeature feature_sizes[] =3D { {.flags =3D 1ULL << VIRTIO_NET_F_MAC, .end =3D endof(struct virtio_net_config, mac)}, diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 2a6141d..9ca8faa 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -15,7 +15,9 @@ =20 #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" =20 +qmp_virtio_feature_map_t scsi_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_SCSI_F_##name, #name } + FEATURE_ENTRY(INOUT), + FEATURE_ENTRY(HOTPLUG), + FEATURE_ENTRY(CHANGE), + FEATURE_ENTRY(T10_PI), +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -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..096cc07 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[] =3D { +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; =20 static const int user_feature_bits[] =3D { VIRTIO_F_VERSION_1, diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 416daf8..047ebb7 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[] =3D { +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; =20 const int feature_bits[] =3D { VIRTIO_VSOCK_F_SEQPACKET, diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 236542f..6705314 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 @@ =20 #define BALLOON_PAGE_SIZE (1 << VIRTIO_BALLOON_PFN_SHIFT) =20 +qmp_virtio_feature_map_t balloon_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_BALLOON_F_##name, #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, "" } +}; + 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..b938bd8 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" =20 #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" =20 #define VIRTIO_CRYPTO_VM_VERSION 1 =20 +qmp_virtio_feature_map_t crypto_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -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 15b3fa0..bbb7382 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -25,6 +25,7 @@ #include "hw/virtio/virtio.h" #include "sysemu/kvm.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/error-report.h" #include "trace.h" =20 @@ -40,6 +41,19 @@ #define VIOMMU_DEFAULT_QUEUE_SIZE 256 #define VIOMMU_PROBE_SIZE 512 =20 +qmp_virtio_feature_map_t iommu_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_IOMMU_F_##name, #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, "" } +}; + typedef struct VirtIOIOMMUDomain { uint32_t id; GTree *mappings; diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index e886e5b..6dbac7f 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -25,6 +25,7 @@ #include "hw/virtio/virtio-mem.h" #include "qapi/error.h" #include "qapi/visitor.h" +#include "qapi/qapi-visit-virtio.h" #include "exec/ram_addr.h" #include "migration/misc.h" #include "hw/boards.h" @@ -32,6 +33,16 @@ #include CONFIG_DEVICES #include "trace.h" =20 +qmp_virtio_feature_map_t mem_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_MEM_F_##name, #name } +#ifndef CONFIG_ACPI + FEATURE_ENTRY(ACPI_PXM), +#endif /* CONFIG_ACPI */ +#undef FEATURE_ENTRY + { -1, "" } +}; + /* * We only had legacy x86 guests that did not support * VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE. Other targets don't have legacy gu= ests. diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 30ccd7b..41823cd 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -34,11 +34,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 =20 /* QAPI list of realized VirtIODevices */ static QTAILQ_HEAD(, VirtIODevice) virtio_list; =20 /* + * Maximum size of virtio device config space + */ +#define VHOST_USER_MAX_CONFIG_SIZE 256 + +enum VhostUserProtocolFeature { + VHOST_USER_PROTOCOL_F_MQ =3D 0, + VHOST_USER_PROTOCOL_F_LOG_SHMFD =3D 1, + VHOST_USER_PROTOCOL_F_RARP =3D 2, + VHOST_USER_PROTOCOL_F_REPLY_ACK =3D 3, + VHOST_USER_PROTOCOL_F_NET_MTU =3D 4, + VHOST_USER_PROTOCOL_F_SLAVE_REQ =3D 5, + VHOST_USER_PROTOCOL_F_CROSS_ENDIAN =3D 6, + VHOST_USER_PROTOCOL_F_CRYPTO_SESSION =3D 7, + VHOST_USER_PROTOCOL_F_PAGEFAULT =3D 8, + VHOST_USER_PROTOCOL_F_CONFIG =3D 9, + VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD =3D 10, + VHOST_USER_PROTOCOL_F_HOST_NOTIFIER =3D 11, + VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD =3D 12, + VHOST_USER_PROTOCOL_F_RESET_DEVICE =3D 13, + VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS =3D 14, + VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS =3D 15, + VHOST_USER_PROTOCOL_F_MAX +}; + +static qmp_virtio_feature_map_t transport_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_F_##name, #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, #name } + FEATURE_ENTRY(INDIRECT_DESC), + FEATURE_ENTRY(EVENT_IDX), +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_USER_F_##name, #name } + FEATURE_ENTRY(PROTOCOL_FEATURES), +#undef FEATURE_ENTRY + { -1, "" } +}; + +static qmp_virtio_feature_map_t vhost_user_protocol_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VHOST_USER_PROTOCOL_F_##name, #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, "" } +}; + +/* virtio device configuration statuses */ +static qmp_virtio_feature_map_t config_status_map[] =3D { +#define STATUS_ENTRY(name) \ + { VIRTIO_CONFIG_S_##name, #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, "" } +}; + +/* * 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 alignmen= t. @@ -3964,6 +4053,191 @@ static VirtIODevice *virtio_device_find(const char = *path) return NULL; } =20 +#define CONVERT_FEATURES(type, map, is_status, bitmap) \ + ({ \ + type *list =3D NULL; \ + type *node; \ + for (i =3D 0; map[i].virtio_bit !=3D -1; i++) { \ + if (is_status) { \ + bit =3D map[i].virtio_bit; \ + } \ + else { \ + bit =3D 1ULL << map[i].virtio_bit; \ + } \ + if ((bitmap & bit) =3D=3D 0) { \ + continue; \ + } \ + node =3D g_new0(type, 1); \ + node->value =3D g_strdup(map[i].feature_name); \ + node->next =3D list; \ + list =3D node; \ + bitmap ^=3D bit; \ + } \ + list; \ + }) + +static VirtioDeviceStatus *qmp_decode_status(uint8_t bitmap) +{ + VirtioDeviceStatus *status; + uint8_t bit; + int i; + + status =3D g_new0(VirtioDeviceStatus, 1); + status->statuses =3D CONVERT_FEATURES(strList, config_status_map, 1, b= itmap); + status->has_unknown_statuses =3D bitmap !=3D 0; + if (status->has_unknown_statuses) { + status->unknown_statuses =3D bitmap; + } + + return status; +} + +static VhostDeviceProtocols *qmp_decode_protocols(uint64_t bitmap) +{ + VhostDeviceProtocols *vhu_protocols; + uint64_t bit; + int i; + + vhu_protocols =3D g_new0(VhostDeviceProtocols, 1); + vhu_protocols->protocols =3D + CONVERT_FEATURES(strList, + vhost_user_protocol_map, 0, bitmap); + vhu_protocols->has_unknown_protocols =3D bitmap !=3D 0; + if (vhu_protocols->has_unknown_protocols) { + vhu_protocols->unknown_protocols =3D bitmap; + } + + return vhu_protocols; +} + +static VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id, + uint64_t bitmap) +{ + VirtioDeviceFeatures *features; + uint64_t bit; + int i; + + features =3D g_new0(VirtioDeviceFeatures, 1); + features->has_dev_features =3D true; + + /* transport features */ + features->transports =3D CONVERT_FEATURES(strList, transport_map, 0, b= itmap); + + /* device features */ + switch (device_id) { +#ifdef CONFIG_VIRTIO_SERIAL + case VIRTIO_ID_CONSOLE: + features->dev_features =3D + CONVERT_FEATURES(strList, serial_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_BLK + case VIRTIO_ID_BLOCK: + features->dev_features =3D + CONVERT_FEATURES(strList, blk_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_GPU + case VIRTIO_ID_GPU: + features->dev_features =3D + CONVERT_FEATURES(strList, gpu_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_NET + case VIRTIO_ID_NET: + features->dev_features =3D + CONVERT_FEATURES(strList, net_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_SCSI + case VIRTIO_ID_SCSI: + features->dev_features =3D + CONVERT_FEATURES(strList, scsi_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_BALLOON + case VIRTIO_ID_BALLOON: + features->dev_features =3D + CONVERT_FEATURES(strList, balloon_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_IOMMU + case VIRTIO_ID_IOMMU: + features->dev_features =3D + CONVERT_FEATURES(strList, iommu_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_INPUT + case VIRTIO_ID_INPUT: + features->dev_features =3D + CONVERT_FEATURES(strList, input_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VHOST_USER_FS + case VIRTIO_ID_FS: + features->dev_features =3D + CONVERT_FEATURES(strList, fs_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VHOST_VSOCK + case VIRTIO_ID_VSOCK: + features->dev_features =3D + CONVERT_FEATURES(strList, vsock_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_CRYPTO + case VIRTIO_ID_CRYPTO: + features->dev_features =3D + CONVERT_FEATURES(strList, crypto_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_MEM + case VIRTIO_ID_MEM: + features->dev_features =3D + CONVERT_FEATURES(strList, mem_map, 0, bitmap); + break; +#endif + /* No features */ + case VIRTIO_ID_9P: + case VIRTIO_ID_PMEM: + case VIRTIO_ID_RNG: + case VIRTIO_ID_IOMEM: + case VIRTIO_ID_RPMSG: + case VIRTIO_ID_CLOCK: + case VIRTIO_ID_MAC80211_WLAN: + case VIRTIO_ID_MAC80211_HWSIM: + case VIRTIO_ID_RPROC_SERIAL: + case VIRTIO_ID_MEMORY_BALLOON: + case VIRTIO_ID_CAIF: + case VIRTIO_ID_SIGNAL_DIST: + case VIRTIO_ID_PSTORE: + case VIRTIO_ID_SOUND: + case VIRTIO_ID_BT: + case VIRTIO_ID_I2C_ADAPTER: + case VIRTIO_ID_RPMB: + case VIRTIO_ID_VIDEO_ENCODER: + case VIRTIO_ID_VIDEO_DECODER: + case VIRTIO_ID_SCMI: + case VIRTIO_ID_NITRO_SEC_MOD: + case VIRTIO_ID_WATCHDOG: + case VIRTIO_ID_CAN: + case VIRTIO_ID_DMABUF: + case VIRTIO_ID_PARAM_SERV: + case VIRTIO_ID_AUDIO_POLICY: + case VIRTIO_ID_GPIO: + break; + default: + g_assert_not_reached(); + } + + features->has_unknown_dev_features =3D bitmap !=3D 0; + if (features->has_unknown_dev_features) { + features->unknown_dev_features =3D bitmap; + } + + return features; +} + VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) { VirtIODevice *vdev; @@ -3979,9 +4253,12 @@ VirtioStatus *qmp_x_query_virtio_status(const char *= path, Error **errp) status->name =3D g_strdup(vdev->name); status->device_id =3D vdev->device_id; status->vhost_started =3D vdev->vhost_started; - status->guest_features =3D vdev->guest_features; - status->host_features =3D vdev->host_features; - status->backend_features =3D vdev->backend_features; + status->guest_features =3D qmp_decode_features(vdev->device_id, + vdev->guest_features); + status->host_features =3D qmp_decode_features(vdev->device_id, + vdev->host_features); + status->backend_features =3D qmp_decode_features(vdev->device_id, + vdev->backend_features); =20 switch (vdev->device_endian) { case VIRTIO_DEVICE_ENDIAN_LITTLE: @@ -3996,7 +4273,7 @@ VirtioStatus *qmp_x_query_virtio_status(const char *p= ath, Error **errp) } =20 status->num_vqs =3D virtio_get_num_queues(vdev); - status->status =3D vdev->status; + status->status =3D qmp_decode_status(vdev->status); status->isr =3D vdev->isr; status->queue_sel =3D vdev->queue_sel; status->vm_running =3D vdev->vm_running; @@ -4019,10 +4296,14 @@ VirtioStatus *qmp_x_query_virtio_status(const char = *path, Error **errp) status->vhost_dev->n_tmp_sections =3D hdev->n_tmp_sections; status->vhost_dev->nvqs =3D hdev->nvqs; status->vhost_dev->vq_index =3D hdev->vq_index; - status->vhost_dev->features =3D hdev->features; - status->vhost_dev->acked_features =3D hdev->acked_features; - status->vhost_dev->backend_features =3D hdev->backend_features; - status->vhost_dev->protocol_features =3D hdev->protocol_features; + status->vhost_dev->features =3D + qmp_decode_features(vdev->device_id, hdev->features); + status->vhost_dev->acked_features =3D + qmp_decode_features(vdev->device_id, hdev->acked_features); + status->vhost_dev->backend_features =3D + qmp_decode_features(vdev->device_id, hdev->backend_features); + status->vhost_dev->protocol_features =3D + qmp_decode_protocols(hdev->protocol_features); status->vhost_dev->max_queues =3D hdev->max_queues; status->vhost_dev->backend_cap =3D hdev->backend_cap; status->vhost_dev->log_enabled =3D hdev->log_enabled; diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 58a73e7..4aaa21f 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" =20 +#define VHOST_F_DEVICE_IOTLB 63 +#define VHOST_USER_F_PROTOCOL_FEATURES 30 + /* Generic structures common for any vhost based device. */ =20 struct vhost_inflight { diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 8f4e4c1..183d431 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -71,6 +71,24 @@ typedef struct VirtQueueElement #define TYPE_VIRTIO_DEVICE "virtio-device" OBJECT_DECLARE_TYPE(VirtIODevice, VirtioDeviceClass, VIRTIO_DEVICE) =20 +typedef struct { + int virtio_bit; + const char *feature_name; +} qmp_virtio_feature_map_t; + +extern qmp_virtio_feature_map_t serial_map[]; +extern qmp_virtio_feature_map_t blk_map[]; +extern qmp_virtio_feature_map_t gpu_map[]; +extern qmp_virtio_feature_map_t net_map[]; +extern qmp_virtio_feature_map_t scsi_map[]; +extern qmp_virtio_feature_map_t balloon_map[]; +extern qmp_virtio_feature_map_t iommu_map[]; +extern qmp_virtio_feature_map_t input_map[]; +extern qmp_virtio_feature_map_t fs_map[]; +extern qmp_virtio_feature_map_t vsock_map[]; +extern qmp_virtio_feature_map_t crypto_map[]; +extern qmp_virtio_feature_map_t mem_map[]; + enum virtio_device_endian { VIRTIO_DEVICE_ENDIAN_UNKNOWN, VIRTIO_DEVICE_ENDIAN_LITTLE, diff --git a/qapi/virtio.json b/qapi/virtio.json index ba61d83..474a8bd 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -106,10 +106,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', @@ -176,11 +176,11 @@ 'device-id': 'uint16', 'vhost-started': 'bool', 'device-endian': 'str', - 'guest-features': 'uint64', - 'host-features': 'uint64', - 'backend-features': 'uint64', + 'guest-features': 'VirtioDeviceFeatures', + 'host-features': 'VirtioDeviceFeatures', + 'backend-features': 'VirtioDeviceFeatures', 'num-vqs': 'int', - 'status': 'uint8', + 'status': 'VirtioDeviceStatus', 'isr': 'uint8', 'queue-sel': 'uint16', 'vm-running': 'bool', @@ -222,14 +222,28 @@ # "name": "virtio-crypto", # "started": true, # "device-id": 20, -# "backend-features": 0, +# "backend-features": { +# "transports": [], +# "dev-features": [] +# }, # "start-on-kick": false, # "isr": 1, # "broken": false, -# "status": 15, +# "status": { +# "statuses": ["ACKNOWLEDGE", "DRIVER", "FEATURES_OK", +# "DRIVER_OK"] +# }, # "num-vqs": 2, -# "guest-features": 5100273664, -# "host-features": 6325010432, +# "guest-features": { +# "transports": ["EVENT_IDX", "INDIRECT_DESC", "VERSION_1"], +# "dev-features": [] +# }, +# "host-features": { +# "transports": ["PROTOCOL_FEATURES", "EVENT_IDX", +# "INDIRECT_DESC", "VERSION_1", "ANY_LAYOUT", +# "NOTIFY_ON_EMPTY"], +# "dev-features": [] +# }, # "use-guest-notifier-mask": true, # "vm-running": true, # "queue-sel": 1, @@ -257,22 +271,65 @@ # "max-queues": 1, # "backend-cap": 2, # "log-size": 0, -# "backend-features": 0, +# "backend-features": { +# "transports": [], +# "dev-features": [] +# }, # "nvqs": 2, -# "protocol-features": 0, +# "protocol-features": { +# "protocols": [] +# }, # "vq-index": 0, # "log-enabled": false, -# "acked-features": 5100306432, -# "features": 13908344832 +# "acked-features": { +# "transports": ["EVENT_IDX", "INDIRECT_DESC", "VERSION_1= ", +# "ANY_LAYOUT", "NOTIFY_ON_EMPTY"], +# "dev-features": ["MRG_RXBUF"] +# }, +# "features": { +# "transports": ["EVENT_IDX", "INDIRECT_DESC", +# "IOMMU_PLATFORM", "VERSION_1", "ANY_LAYO= UT", +# "NOTIFY_ON_EMPTY"], +# "dev-features": ["LOG_ALL", "MRG_RXBUF"] +# } +# }, +# "backend-features": { +# "transports": ["PROTOCOL_FEATURES", "EVENT_IDX", "INDIRECT= _DESC", +# "VERSION_1", "ANY_LAYOUT", "NOTIFY_ON_EMPTY= "], +# "dev-features": ["GSO", "CTRL_MAC_ADDR", "GUEST_ANNOUNCE",= "CTRL_RX_EXTRA", +# "CTRL_VLAN", "CTRL_RX", "CTRL_VQ", "STATU= S", "MRG_RXBUF", +# "HOST_UFO", "HOST_ECN", "HOST_TSO6", "HOS= T_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": { +# "statuses": ["ACKNOWLEDGE", "DRIVER", "FEATURES_OK", "DRIV= ER_OK"] +# }, # "num-vqs": 3, -# "guest-features": 5111807911, -# "host-features": 6337593319, +# "guest-features": { +# "transports": ["EVENT_IDX", "INDIRECT_DESC", "VERSION_1"], +# "dev-features": ["CTRL_MAC_ADDR", "GUEST_ANNOUNCE", "CTRL_= VLAN", +# "CTRL_RX", "CTRL_VQ", "STATUS", "MRG_RXBU= F", +# "HOST_UFO", "HOST_ECN", "HOST_TSO6", +# "HOST_TSO4", "GUEST_UFO", "GUEST_ECN", +# "GUEST_TSO6", "GUEST_TSO4", "MAC", +# "CTRL_GUEST_OFFLOADS", "GUEST_CSUM", "CSU= M"] +# }, +# "host-features": { +# "transports": ["PROTOCOL_FEATURES", "EVENT_IDX", +# "INDIRECT_DESC", "VERSION_1", "ANY_LAYOUT", +# "NOTIFY_ON_EMPTY"], +# "dev-features": ["GSO", "CTRL_MAC_ADDR", "GUEST_ANNOUNCE", +# "CTRL_RX_EXTRA", "CTRL_VLAN", "CTRL_RX", +# "CTRL_VQ", "STATUS", "MRG_RXBUF", "HOST_U= FO", +# "HOST_ECN", "HOST_TSO4", "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, @@ -288,3 +345,62 @@ 'data': { 'path': 'str' }, 'returns': 'VirtioStatus', 'features': [ 'unstable' ] } + +## +# @VirtioDeviceStatus: +# +# A structure defined to list the configuration statuses of a virtio +# device +# +# @statuses: List of decoded configuration statuses of the virtio +# device +# +# @unknown-statuses: Virtio device statuses bitmap that have not been deco= ded +# +# Since: 7.0 +## + +{ 'struct': 'VirtioDeviceStatus', + 'data': { 'statuses': [ 'str' ], + '*unknown-statuses': 'uint8' } } + +## +# @VhostDeviceProtocols: +# +# A structure defined to list the vhost user protocol features of a +# Vhost User device +# +# @protocols: 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: 7.0 +## + +{ 'struct': 'VhostDeviceProtocols', + 'data': { 'protocols': [ 'str' ], + '*unknown-protocols': 'uint64' } } + +## +# @VirtioDeviceFeatures: +# +# The common fields that apply to most Virtio devices. Some devices +# may not have their own device-specific features (e.g. virtio-rng). +# +# @transports: List of transport features of the virtio device +# +# @dev-features: List of device-specific features (if the device has +# unique features) +# +# @unknown-dev-features: Virtio device features bitmap that have not +# been decoded +# +# Since: 7.0 +## + +{ 'struct': 'VirtioDeviceFeatures', + 'data': { 'transports': [ 'str' ], + '*dev-features': [ 'str' ], + '*unknown-dev-features': 'uint64' } } --=20 1.8.3.1 From nobody Sat May 4 07:55:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1642688391; cv=pass; d=zohomail.com; s=zohoarc; b=lSKetme8zlc/beTRITSxuXoXLO24pJLZC0tKRyYC3SB3Ql9GrxaHvjFqMkyEDUSUoq+93qxkvSChe9/H0BQ7ZdsY7VE5F+0gtMMA36uh5WmQ4DVhSjAbwBU9VpgiUfzUqa8BKiXR02d4vi6tA36MoPVhsMea9HuM45v9Hs/QH70= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642688391; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dGSfCYH+VYBX/QzCjdnWhzqW7H0CrTTINipkr/xichA=; b=WTLcfxsl7TGsz3ED5oz2WMBrxQ4oPFhXEVB+P9OeOWsXSdE5lqFkrZYFQdPPsNOvk6MAS4MyUZhd01aHJZ21MeteJ75m5lXj2E6wmQ/xz+cK8sUbNFv/bkcq1vHubC1O82dLvkfFp4s4+9Wl7nZUxLKC+nT8PfM3sZ/8xd9eYLU= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642688391274442.15691607341194; Thu, 20 Jan 2022 06:19:51 -0800 (PST) Received: from localhost ([::1]:56322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAYHy-0002tQ-Fq for importer@patchew.org; Thu, 20 Jan 2022 09:19:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAVey-0005c7-Q4; Thu, 20 Jan 2022 06:31:23 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:16072) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAVep-0006al-J1; Thu, 20 Jan 2022 06:31:17 -0500 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 20K8i7QL031213; Thu, 20 Jan 2022 11:30:23 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3dnc4vr29y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jan 2022 11:30:23 +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 20KBGfht031354; Thu, 20 Jan 2022 11:30:22 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2171.outbound.protection.outlook.com [104.47.56.171]) by userp3030.oracle.com with ESMTP id 3dkkd24hjf-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jan 2022 11:30:22 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (20.182.107.75) by CY4PR10MB1381.namprd10.prod.outlook.com (10.169.254.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Thu, 20 Jan 2022 11:30:19 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::95b1:2ba7:964c:d3cb]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::95b1:2ba7:964c:d3cb%9]) with mapi id 15.20.4909.010; Thu, 20 Jan 2022 11:30:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=dGSfCYH+VYBX/QzCjdnWhzqW7H0CrTTINipkr/xichA=; b=qCpexL/c9EGwBqx1FS0v04GwGxiJPH1gCsgMC5P31i6uJlAMxw47arEiHPSkRdWYGxEo 4I/fjnOyqDs9pGmAl1PM0Bk8pe6DmG9+cbtTqjd4OeuWSoCcXDS8QzrfbEMNMvFTd4aM s+DNUSfGObyC2ol7dghP6bXpCStE3EEeepvQQW8FqFIOnvLdNJtfwTCTEdbkMTh3x5bd 9uaZ/oyO1rJkjjwL4tsXpILIyipkazzgrXvjUKJ7cXC0jq7TBmhnY6PJ/Jzt5Ubb9HFj /FqWkdKkozjzyYhan46xrvQB7XKRJzDSFN6SYp882BE/7XEKbQiatHLMryt0A9UYAMLo mw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZSuW4TxZRtVr+mWZjTRIHQDQM2vbXKhJF6MSJfr/TfjgbJ9cT1Ttu4shca+1VesViELJpmrciJ07Jhh42swPHWYxLefCFj1tt/K7xJM2qgPdruDq4+H6GPwBEHdDfySxNhGv8WWJ6omz4o/yq23OPOwiXONEmKCXxzUo7D2mVM+0Uy46f8yC2RA0nX+BI06pYiKd8E1ID2R93AjiLJrsUkR4PI3J1efwx6w8LOZhV6EtfxAEADAuOxFFx3u10a4YK9oqOqRoSq0V0nrM8IneQGH06uHvtN1zsZ9rMvNEBAXcp9F3XwF3lFzCB73u2EjBXImD93WhmAwauwLWb4lPpw== 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=dGSfCYH+VYBX/QzCjdnWhzqW7H0CrTTINipkr/xichA=; b=dIQz4jqXYKEMfCtdIXGmw5sIS3Ngad6xdXHrH/jjouzCmhynrqQqQv/NYvrH0jmSGNg2ZJrwgg7IQosN5RzcknB2rz3eEkBbH0pjIVLLDBNmT5Vcmf7zygxAI5jKp0W2Vg+IkSyWvL5SU278welO7y7xkSOWuIXJ21G90fu3irdx7uX7BFgklDRvlMfkdb4b3bIgrK92cIf1cdjWEFs2kofbUfohKWx5kgIfdzWhRYcx4LH1XDGQJOCLJKq0MpSzRvP8pdsR8i4dZ99hMM4o4XNZWrzSJ9xzjit2/L4M/O1t+bi3ZdjwARaOPA9+FcghqDoMuV7jiDC9/bKsss/+Bg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=dGSfCYH+VYBX/QzCjdnWhzqW7H0CrTTINipkr/xichA=; b=x6tnDRL3+L/WDuWckAe3mmHKT3E0Fdc6oUyGB6hV7+gcXjiPqjcgv11tgEJjLHX6NgEbq5Rp2V8cU6pDJgCFzOmKgKhB19Qku8Py/otRKp+LHF56LJEp/kseUA7BSZ9Lu8Gt9mRtZGIPTs6RrYsjeIe/Y8yF3D2bNGNflmMoAmA= From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v11 6/8] qmp: add QMP commands for virtio/vhost queue-status Date: Thu, 20 Jan 2022 06:29:26 -0500 Message-Id: <1642678168-20447-7-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1642678168-20447-1-git-send-email-jonah.palmer@oracle.com> References: <1642678168-20447-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SA9PR11CA0025.namprd11.prod.outlook.com (2603:10b6:806:6e::30) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 87acd8fb-ddf6-4d85-1f62-08d9dc083d26 X-MS-TrafficTypeDiagnostic: CY4PR10MB1381:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:221; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QpMkO/foZcXoObijbpFOZp9tqaQPJqWDVJ2TYtKcza2x2lTyyam2zZYetJD+Zm7jXt+fkHk85Wm1eZdOEuh4LI0oGQZUUeJCbfbEczjfRff4wP+mBQf42ZtLhFVcGfrCKCAHah9uBjSkGULdd0y4sWrYo7SI9uxYM7MBP6+CMMCV9DNvlPAtX7Bvqk02fI7mfC63XRMSnOKQEL3zoRr7F/aObBjugecV72b5/B1WVX7Rz+LkTM9eg+z2hodmsqWhtFNyReHJ6xn4v28L2i52+b33IbZn13RQ1DxboTNHJMYe2gGQNnYs84pOWDVOXf/NU54GwCyGD0m3QQJMjCFyDerrora16AtHX8F3C5RHaH2R4RhscZeYwqQ7lRdlnlucsUxih3ScTKFZBYvqtsbJ4GYXt1i9jY1iaKFtKdWFx26OWius4U5uDvYSa2oi+Z20Uk7ZVNVo6OyGsgR068bqfOJ3mVYn+HfVSs4ClpYkMrj0JlTzOIY8/+SqRj2L6tVusBE5ik0FiLXXrtOFh0F6TX0ENzNfNRtH2jZJ9hZxtQpRIINHvwpyQtvPbHQHAzNHy68sSLzFCDISM5olx/6UEi0OhG/Z1V/UOIKq74OPlRECHX3k5Is5F9HEFW21SMsYahZGq6JIarXIU358srWEgmPnjIIFO4n0Iy9YNwVAtyTD2j9lQjKX7WgC96tgiSyGpSR+wLjH/32DPygk8O/Mjw== 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)(6512007)(38100700002)(38350700002)(6666004)(6486002)(30864003)(2906002)(6916009)(7416002)(8676002)(86362001)(8936002)(4326008)(508600001)(316002)(5660300002)(26005)(186003)(44832011)(6506007)(66946007)(52116002)(66476007)(66556008)(2616005)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Hal80/pP+Vidh3r3OoYw5PJ+VqfRlqFYn6o6KZpxFPPVSnsB5g9u9KFN/I50?= =?us-ascii?Q?KJMRbXL3P15hCqqxm7kiv+VhVje88g3YNEW5UpZp2SYcBlP9MMsvENnNeKXK?= =?us-ascii?Q?7v5Iuxh51ts6STJAFUKJVq90sbNfj9Egfmc2GM/Xh9TwNEAsgJBDGaC1z23x?= =?us-ascii?Q?mV/urXJdz32wjds9b47ZUP5JO9Hj4T9PyPvh68QfRfJiNj0ljfkD913h1Z3S?= =?us-ascii?Q?RMozh81Sc6ZmM5k5fbfb93rA9FtPF430viRPzZq67Nw12Xf0F0Lz5q9XBTjN?= =?us-ascii?Q?1GqmEqBn+26CipfpU37xu+In4ubXHcTdF609Bmj0CHHzsXHAIa5EnUUQNX/I?= =?us-ascii?Q?mVIIT0X3Kxo7W2hJOpyYp7LRbWM2vsnOB700qH1XYWN4k+DWczYX4G+05Bpa?= =?us-ascii?Q?zB9VrDK13bbOKQNf9hRP+imb7ZNTyRuYSnf6ObU1wsuLU4kf2hscC8vx7gkF?= =?us-ascii?Q?o8XvaLhYOewhSHQKq0tQGs9n2npFEmHvv+19sMGQvly1aNwXB6teenuHgbYM?= =?us-ascii?Q?dyB4m79d0OEEBIb0pRDHucZmjv940FX0WlLp8P2ud4RkWFOHdyNCXWCMuENd?= =?us-ascii?Q?qiFpO2GmjyOmoZ0I6Z5teSGF63C2PakK9fc57Hl91+H7/6WBCP2BctR7qp3T?= =?us-ascii?Q?rwimGa97/o2A+jVKtl2dc+bK3vGAC1WolOqaXmY9cqJy08r8gQs7eU4uipS3?= =?us-ascii?Q?H+H6FETVyKlTURRzKsTmaNM01CcD+er7QjyZMUcIV/haTSZERbBFN+L5fnVB?= =?us-ascii?Q?6XpCv6VUn4dATpgPe4/PXWsC/8r9bVdMgEvlIB09gfylJx/CRAl6QTp0hYeS?= =?us-ascii?Q?dZW+1NHxlj+wliFqWhK3opXyp4faevOvVxxvqglPWSuxRpwGIuPIJMQZPit9?= =?us-ascii?Q?VWnfG3x/IOIxsAjsXs9OmuFPMGx/3Z+H2lii2P/n3KLty/ZDVdKvjUBSG2jM?= =?us-ascii?Q?op/ecWPilP1Yas3jmAgyofy2fVwQhQ17LXQ+9IkXwLV/s3UbbY4z02Hw155/?= =?us-ascii?Q?9QBhqAEsdRf5GMfxZklgW8azv+GH+DSsg1quouLnlC2A15yBJv5uKiiNH6Ix?= =?us-ascii?Q?hKxR/hls9KJS7hIKpspuyIQd+R6y2sXgIXBTt9b+WJkT0ZqGfrgpN1j6K0mF?= =?us-ascii?Q?q/LbR3tPusqvAvws/rMKnAqefJbIpNyEF9pgOhniBtcU08cYqwGjzAbj6oMn?= =?us-ascii?Q?f+VDu59ZKi9QW205O98yQ0rcwSqMWaRXEXd8111Wc8eSq2Db5mF9D7YNc45W?= =?us-ascii?Q?iKB9vp02eF5B+TMIIrQ8a1kdxIvwocPHSB99wl0GrWF3eAGbvMRczFUNPtWz?= =?us-ascii?Q?w/+lFIiArz/AactK/IeRvYSPya8zU2A2rrEBiJnPNOADriHDdBU6HjNuEFXJ?= =?us-ascii?Q?XxObjD/h9WZ9hP9v57OHTsHtTbGTrWhI6th9Y4oVAAL3TwrzPuy67SCK6uCN?= =?us-ascii?Q?yr6GS/enSyVRxMOTG+5QHGu5VReVcZ0COtRSScIX3bjD3gmz8qr3ZH97E6Ka?= =?us-ascii?Q?9HcC8PyjHj4duwUUFn6Jq+IBKoRrU9C3+sHPT1MlSHp4xH6VYpBWrWLAd9g1?= =?us-ascii?Q?b5QothxenVQwR0u3k4ASV1XZb1ugwy+W0iXRVTHZYvkaC6iYnb0ey2jy7aNC?= =?us-ascii?Q?oIE8l4ar12J3cvvl2P7gxFk=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 87acd8fb-ddf6-4d85-1f62-08d9dc083d26 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2022 11:30:19.4642 (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: 6UP1uSXDLzzw6y80Vm8cQz7ruSftVxX2xsLt99C3nu8otRI6zBykroCXFdTcR99e1BjW9LFFbaZEhubXDz6OrQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1381 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10232 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 adultscore=0 phishscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201200058 X-Proofpoint-GUID: WHk3o5UVKXPUgrFqz-Jt70jtaDcA9bZF X-Proofpoint-ORIG-GUID: WHk3o5UVKXPUgrFqz-Jt70jtaDcA9bZF Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1642688393210100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Acked-by: Markus Armbruster --- hw/virtio/virtio-stub.c | 14 +++ hw/virtio/virtio.c | 103 ++++++++++++++++++++ qapi/virtio.json | 252 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 369 insertions(+) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index 0b432e8..13e5f93 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -17,3 +17,17 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path= , Error **errp) { return qmp_virtio_unsupported(errp); } + +VirtVhostQueueStatus *qmp_x_query_virtio_vhost_queue_status(const char *pa= th, + uint16_t queue, + Error **errp) +{ + return qmp_virtio_unsupported(errp); +} + +VirtQueueStatus *qmp_x_query_virtio_queue_status(const char *path, + uint16_t queue, + Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 41823cd..c81210b 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -4313,6 +4313,109 @@ VirtioStatus *qmp_x_query_virtio_status(const char = *path, Error **errp) return status; } =20 +VirtVhostQueueStatus *qmp_x_query_virtio_vhost_queue_status(const char *pa= th, + uint16_t queue, + Error **errp) +{ + VirtIODevice *vdev; + VirtVhostQueueStatus *status; + + vdev =3D virtio_device_find(path); + if (vdev =3D=3D 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 =3D VIRTIO_DEVICE_GET_CLASS(vdev); + struct vhost_dev *hdev =3D vdc->get_vhost(vdev); + + if (queue < hdev->vq_index || queue >=3D hdev->vq_index + hdev->nvqs) { + error_setg(errp, "Invalid vhost virtqueue number %d", queue); + return NULL; + } + + status =3D g_new0(VirtVhostQueueStatus, 1); + status->name =3D g_strdup(vdev->name); + status->kick =3D hdev->vqs[queue].kick; + status->call =3D hdev->vqs[queue].call; + status->desc =3D (uint64_t)(unsigned long)hdev->vqs[queue].desc; + status->avail =3D (uint64_t)(unsigned long)hdev->vqs[queue].avail; + status->used =3D (uint64_t)(unsigned long)hdev->vqs[queue].used; + status->num =3D hdev->vqs[queue].num; + status->desc_phys =3D hdev->vqs[queue].desc_phys; + status->desc_size =3D hdev->vqs[queue].desc_size; + status->avail_phys =3D hdev->vqs[queue].avail_phys; + status->avail_size =3D hdev->vqs[queue].avail_size; + status->used_phys =3D hdev->vqs[queue].used_phys; + status->used_size =3D hdev->vqs[queue].used_size; + + return status; +} + +VirtQueueStatus *qmp_x_query_virtio_queue_status(const char *path, + uint16_t queue, + Error **errp) +{ + VirtIODevice *vdev; + VirtQueueStatus *status; + + vdev =3D virtio_device_find(path); + if (vdev =3D=3D NULL) { + error_setg(errp, "Path %s is not a VirtIODevice", path); + return NULL; + } + + if (queue >=3D VIRTIO_QUEUE_MAX || !virtio_queue_get_num(vdev, queue))= { + error_setg(errp, "Invalid virtqueue number %d", queue); + return NULL; + } + + status =3D g_new0(VirtQueueStatus, 1); + status->name =3D g_strdup(vdev->name); + status->queue_index =3D vdev->vq[queue].queue_index; + status->inuse =3D vdev->vq[queue].inuse; + status->vring_num =3D vdev->vq[queue].vring.num; + status->vring_num_default =3D vdev->vq[queue].vring.num_default; + status->vring_align =3D vdev->vq[queue].vring.align; + status->vring_desc =3D vdev->vq[queue].vring.desc; + status->vring_avail =3D vdev->vq[queue].vring.avail; + status->vring_used =3D vdev->vq[queue].vring.used; + status->used_idx =3D vdev->vq[queue].used_idx; + status->signalled_used =3D vdev->vq[queue].signalled_used; + status->signalled_used_valid =3D vdev->vq[queue].signalled_used_valid; + + if (vdev->vhost_started) { + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); + struct vhost_dev *hdev =3D vdc->get_vhost(vdev); + + /* check if vq index exists for vhost as well */ + if (queue >=3D hdev->vq_index && queue < hdev->vq_index + hdev->nv= qs) { + status->has_last_avail_idx =3D true; + + int vhost_vq_index =3D + hdev->vhost_ops->vhost_get_vq_index(hdev, queue); + struct vhost_vring_state state =3D { + .index =3D vhost_vq_index, + }; + + status->last_avail_idx =3D + hdev->vhost_ops->vhost_get_vring_base(hdev, &state); + } + } else { + status->has_shadow_avail_idx =3D true; + status->has_last_avail_idx =3D true; + status->last_avail_idx =3D vdev->vq[queue].last_avail_idx; + status->shadow_avail_idx =3D vdev->vq[queue].shadow_avail_idx; + } + + return status; +} + static const TypeInfo virtio_device_info =3D { .name =3D TYPE_VIRTIO_DEVICE, .parent =3D TYPE_DEVICE, diff --git a/qapi/virtio.json b/qapi/virtio.json index 474a8bd..44cc05c 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -404,3 +404,255 @@ 'data': { 'transports': [ 'str' ], '*dev-features': [ 'str' ], '*unknown-dev-features': 'uint64' } } + +## +# @VirtQueueStatus: +# +# Information of a VirtIODevice VirtQueue, including most members of +# the VirtQueue data structure. +# +# @name: Name of the VirtIODevice that uses this VirtQueue +# +# @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: 7.0 +# +## + +{ 'struct': 'VirtQueueStatus', + 'data': { 'name': 'str', + 'queue-index': 'uint16', + 'inuse': 'uint32', + 'vring-num': 'uint32', + 'vring-num-default': 'uint32', + 'vring-align': 'uint32', + 'vring-desc': 'uint64', + 'vring-avail': 'uint64', + 'vring-used': 'uint64', + '*last-avail-idx': 'uint16', + '*shadow-avail-idx': 'uint16', + 'used-idx': 'uint16', + 'signalled-used': 'uint16', + 'signalled-used-valid': 'bool' } } + +## +# @x-query-virtio-queue-status: +# +# Return the status of a given VirtIODevice's VirtQueue +# +# @path: VirtIODevice canonical QOM path +# +# @queue: VirtQueue index to examine +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: VirtQueueStatus of the VirtQueue +# +# Notes: last_avail_idx will not be displayed in the case where +# the selected VirtIODevice has a running vhost device and +# the VirtIODevice VirtQueue index (queue) does not exist for +# the corresponding vhost device vhost_virtqueue. Also, +# shadow_avail_idx will not be displayed in the case where +# the selected VirtIODevice has a running vhost device. +# +# Since: 7.0 +# +# Examples: +# +# 1. Get VirtQueueStatus for virtio-vsock (vhost-vsock running) +# +# -> { "execute": "x-query-virtio-queue-status", +# "arguments": { "path": "/machine/peripheral/vsock0/virtio-backend", +# "queue": 1 } +# } +# <- { "return": { +# "signalled-used": 0, +# "inuse": 0, +# "vring-align": 4096, +# "vring-desc": 5217370112, +# "signalled-used-valid": false, +# "vring-num-default": 128, +# "vring-avail": 5217372160, +# "queue-index": 1, +# "last-avail-idx": 0, +# "vring-used": 5217372480, +# "used-idx": 0, +# "name": "vhost-vsock", +# "vring-num": 128 } +# } +# +# 2. Get VirtQueueStatus for virtio-serial (no vhost) +# +# -> { "execute": "x-query-virtio-queue-status", +# "arguments": { "path": "/machine/peripheral-anon/device[0]/virtio-b= ackend", +# "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, +# "name": "virtio-serial", +# "shadow-avail-idx": 0, +# "vring-num": 128 } +# } +# +## + +{ 'command': 'x-query-virtio-queue-status', + 'data': { 'path': 'str', 'queue': 'uint16' }, + 'returns': 'VirtQueueStatus', + 'features': [ 'unstable' ] } + +## +# @VirtVhostQueueStatus: +# +# Information of a vhost device's vhost_virtqueue, including most +# members of the vhost_dev vhost_virtqueue data structure. +# +# @name: Name of the VirtIODevice that uses this vhost_virtqueue +# +# @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 phys. addr.) +# +# @desc-size: vhost_virtqueue desc_size +# +# @avail-phys: vhost_virtqueue avail_phys (driver area phys. addr.) +# +# @avail-size: vhost_virtqueue avail_size +# +# @used-phys: vhost_virtqueue used_phys (device area phys. addr.) +# +# @used-size: vhost_virtqueue used_size +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtVhostQueueStatus', + 'data': { 'name': 'str', + 'kick': 'int', + 'call': 'int', + 'desc': 'uint64', + 'avail': 'uint64', + 'used': 'uint64', + 'num': 'int', + 'desc-phys': 'uint64', + 'desc-size': 'uint32', + 'avail-phys': 'uint64', + 'avail-size': 'uint32', + 'used-phys': 'uint64', + 'used-size': 'uint32' } } + +## +# @x-query-virtio-vhost-queue-status: +# +# Return information of a given vhost device's vhost_virtqueue +# +# @path: VirtIODevice canonical QOM path +# +# @queue: vhost_virtqueue index to examine +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: VirtVhostQueueStatus of the vhost_virtqueue +# +# Since: 7.0 +# +# Examples: +# +# 1. Get vhost_virtqueue status for vhost-crypto +# +# -> { "execute": "x-query-virtio-vhost-queue-status", +# "arguments": { "path": "/machine/peripheral/crypto0/virtio-backend", +# "queue": 0 } +# } +# <- { "return": { +# "avail-phys": 5216124928, +# "used-phys": 5216127040, +# "avail-size": 2054, +# "desc-size": 16384, +# "used-size": 8198, +# "desc": 140141447430144, +# "num": 1024, +# "name": "virtio-crypto", +# "call": 0, +# "avail": 140141447446528, +# "desc-phys": 5216108544, +# "used": 140141447448640, +# "kick": 0 } +# } +# +# 2. Get vhost_virtqueue status for vhost-vsock +# +# -> { "execute": "x-query-virtio-vhost-queue-status", +# "arguments": { "path": "/machine/peripheral/vsock0/virtio-backend", +# "queue": 0 } +# } +# <- { "return": { +# "avail-phys": 5182261248, +# "used-phys": 5182261568, +# "avail-size": 262, +# "desc-size": 2048, +# "used-size": 1030, +# "desc": 140141413580800, +# "num": 128, +# "name": "vhost-vsock", +# "call": 0, +# "avail": 140141413582848, +# "desc-phys": 5182259200, +# "used": 140141413583168, +# "kick": 0 } +# } +# +## + +{ 'command': 'x-query-virtio-vhost-queue-status', + 'data': { 'path': 'str', 'queue': 'uint16' }, + 'returns': 'VirtVhostQueueStatus', + 'features': [ 'unstable' ] } --=20 1.8.3.1 From nobody Sat May 4 07:55:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1642687593; cv=pass; d=zohomail.com; s=zohoarc; b=jAAkLpIUsaidNZM7O/m9JKs2gMj+uLPN2aJuZCME+Lf0WEBIb2pvRImp9eBnmFDgIphUtw+e2w0sWSlL+bz17g+Mil1bhB9Wk2s/aSPFBsxhO/Pc4IBMp9vwf7ESoGcDV/VGiEebixz5V4hg6LbDr8OAe+yNwswqdKbwyoogNDk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642687593; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VamJNEfyhwrr0aWodf9MIZUnI/sZRbIb5rj6dtei9wo=; b=npNsnJ16zCvfAhpXUWhG3MDD7VEWEXapz49AVw/jiHggHtgdFMaipmmt85rolhqUw+JE5QFPeG13fBiiWG9O6Mj9Zxq8JWoH0cBioB3OnW29/gvRyJaV3hgI9ySMRWswZFuknaHb9gYZhIfHCOr+TjJSyj1nnb1mFxj4WMY/axU= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642687593294994.0915761533925; Thu, 20 Jan 2022 06:06:33 -0800 (PST) Received: from localhost ([::1]:46692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAY58-0003Zg-1r for importer@patchew.org; Thu, 20 Jan 2022 09:06:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAVey-0005c6-Q8; Thu, 20 Jan 2022 06:31:23 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:34032) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAVen-0006bh-Gq; Thu, 20 Jan 2022 06:31:16 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20K8LTOf032608; Thu, 20 Jan 2022 11:30:27 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3dnc4q84fh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jan 2022 11:30:27 +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 20KBG8hh069950; Thu, 20 Jan 2022 11:30:26 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2174.outbound.protection.outlook.com [104.47.56.174]) by userp3020.oracle.com with ESMTP id 3dkqqs8hvn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jan 2022 11:30:26 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (20.182.107.75) by CY4PR10MB1381.namprd10.prod.outlook.com (10.169.254.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Thu, 20 Jan 2022 11:30:22 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::95b1:2ba7:964c:d3cb]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::95b1:2ba7:964c:d3cb%9]) with mapi id 15.20.4909.010; Thu, 20 Jan 2022 11:30:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=VamJNEfyhwrr0aWodf9MIZUnI/sZRbIb5rj6dtei9wo=; b=PlC3S0UGBotzv8Nr9b0FDtQlEsc9wASfhSVhE+3BuSGoJe/jps5LU7e8IFPANj1Ask5Y trC2lUzt5eCE8hn0LUnonW8YdDDhlXRvO1BIzTYF57clVYixTcsPKGRRB8Q+tRYjhwCR oj0gPa0AFIYp7EayVKSKEq6TvEpfdJmV7azpH5WmoXsr2XJXAmj+DJQa3ResHTOdhec+ OPkKn9VKrp/xlPleBfcAe4RZMJ4XpfG3QksNMIkDNdpeBUQNH3VxH3/OhBL8l0dL4f4B fyghTKuHf0sE05OG4jYNkfvZnK/C/UW65Nl9fXon0eAvWMSVN+XNUCS75i+mbqd8e916 lw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UeeQtqxlj2GW1H3Cm6Z8V1Wu37BSVOUsEoCMnVSTNE8lhYgwf2hzpaGaYREEgqgAwaOjZEx7/h0yMrORnp161l6A54QE2/ITaKwp+S/jtfpdq1OPAh1XCbYR80tPhHjezlh1S8W+8rSQn1vPhUjsBByBJ/aV1NjlzTcz8eCYpa0+Hxa6wr/I8mUKoV+acW1Nf8TQJlDHIUo/cRDMMPepeeEu8eJKlw8GFAJt+pVLIl6Mncig56R824/wiGow/bl72LevklpF9ZStWzUdjW+HJZYfRzJ51aRyxfYBR/VmQQ9kNCGuUEdVDmGsywleudxSTBYtNe6+beRshWWS56WuNA== 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=VamJNEfyhwrr0aWodf9MIZUnI/sZRbIb5rj6dtei9wo=; b=JLI9lccoiA3FP/PksV0OM6WjAMWicqw2+E6WpZ0gx7mDqQhn+unRZ4t8HxPqvlO7KoZfPnYIt5RlRH1cDgbRdvQFsDk86mZSPumyXYayU1qESFMf6RgASub0O3J9DebCUX3uR3CemqabhfexIiSfk+ZLHGcOjocV3dh2z4e9cTe6HVMoyYfYaZTldG/b3sfXQfOU7sKFPjVHehzSmnbCEE7bylteeD4opnSYTku0fXii5CgDp/MhGr/m1QXvzA9rIO6psaMmhkkFhJqYT2NLBtV1BjCLspWIjl+QzsAKAR3NRVl4pjDOuLGqrOKkp4TMUxYqnn4aRvTFEFSr7XeqMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=VamJNEfyhwrr0aWodf9MIZUnI/sZRbIb5rj6dtei9wo=; b=K3eqgIsXfZKIx6J0PpuHyaiL5j/Km+CFoOA0G+CI10dztmnP/rbykTYGzywf83uMguNSUCdmrub7xqfq4r3MQCguUX8s5uCUTlqjA715/dVk7IIN61STTHIR+lX+nJGy5IbfaPIKzrFxcOOmbwA7a1xWah5ckZ+e7RXkrJ4WHuU= From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v11 7/8] qmp: add QMP command x-query-virtio-queue-element Date: Thu, 20 Jan 2022 06:29:27 -0500 Message-Id: <1642678168-20447-8-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1642678168-20447-1-git-send-email-jonah.palmer@oracle.com> References: <1642678168-20447-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SA9PR11CA0025.namprd11.prod.outlook.com (2603:10b6:806:6e::30) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cd4b1f31-eae5-4ef1-54a4-08d9dc083e9a X-MS-TrafficTypeDiagnostic: CY4PR10MB1381:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2399; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4gHgijWLcdOrR/8aDe2ZBmLQlIlwXnBtv+OPPS5HCrY2z7ZVJuG1yu8YLQdQrQx5b9FIbVc2/WVqbvKDv10HBTHFXWYnFqmZ91x6KLVINZmt6d4s5Ev1DjQsVzwLo3/clIFJl6y4ferv0KUy67PVxye7J54reOVG5ihSepDm05dkeq5Fc7kN5kp0B/v4z991pbAEqchuBbpHYaFIw8Z0XBIUaFVMWlXINHKtYLiAXVZLEDHFAP6xoclcUwIpUzz311SeGxLLVZ7ikPdJd0MQgE6C7HMWXvXc7xGhQGsKFPd0OnlcCJ5K6otLwWasbMfT08sYMQD9yGT+ipPsBUG7jzxER/mCmXRpQ8AsqDELF/v99oL/m3HrWsShyEH1qePDzOVkB110cjWc+ylNJVozr2E68lLYqqRPZk8672Js9deN2ik86Di4V9vGz/tx8KOWlIGXFqBdYG98e8EIZcS71IFl9VoInJN9l8HuSXMX9OazmjCahdGNRRE+lpsfLi3gjgDP1jaAbZlqVyQWfhDCwpyB26X8fpoS0Hy4KiXLXf5bNzRHD9KsEzP2rrocBtOB1AGrIILMn8156LhTcl9S4Igo+EfHbhRe86Lkx28ocDsYTiHoFd2D+/1mNv6B2JTi9/xy3Qz34UXHyhL8lP8kYG1G5O3XRIcrDuJZMZSHbwzOJZOTnB0TDDASnlRENcL7Gg/yf+sruWjFfiJUkVAaKQ== 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)(6512007)(38100700002)(38350700002)(6486002)(2906002)(6916009)(7416002)(83380400001)(8676002)(86362001)(8936002)(4326008)(508600001)(316002)(5660300002)(26005)(186003)(44832011)(6506007)(66946007)(52116002)(66476007)(66556008)(2616005)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?6p/Uc7duO5XiBYvkiyzjym4oSCP9k2lIQjPlf2QoKMPxyTYIOVXqXvAumXsx?= =?us-ascii?Q?P+XeR8zBas670tCS+k9goW1Zo+KTE0gdd9vLtFAuKBo7FJimx4S3vvKO/b5I?= =?us-ascii?Q?oGXNFEksOOQ67Ihyoi3ccWTfMMtLFbBoLmCXhYK1K8mreVECHGoIYB5D/dpT?= =?us-ascii?Q?1pW18f2TU9cRBVS4i2udXzdvHzQAgeqdPVrFWll81h1NXJ6adky+lPZ8neg0?= =?us-ascii?Q?q5suJyhzLZhXUptzmew2MdU1c9KHljQwIVjS4j9xYNYYBBx2m5GwzWgMlVOq?= =?us-ascii?Q?52O3pji5JQePYdslE/9RuqT0JsEmItgwcrlZE1VI8jO7tByReLGwyeO1nG7r?= =?us-ascii?Q?fN7ewbHI+4AJvQzsZHe7pLaK4qfq+McaryE7odqyibOjqjqnqWcI/b5041M9?= =?us-ascii?Q?I+QVHCZLX+hGsHBf1zS03e+j/sZVEz8ZZqAF+udhJS9oSlEtS0IR3YWQM3wN?= =?us-ascii?Q?N5VXB+fZSvrXqCR4VyW96qBwJHKRw+lf5vnlCZJgKPCcrEnKXd9+wkzD3QqA?= =?us-ascii?Q?ov7gFsNNg/7zLR1JTrAfnYyvuvZPw9+HLD5sDe4yn9KmwYW01BrFTxL7B7gU?= =?us-ascii?Q?RqegXuUaRdHGhclDw4TyyzePXkWbyKPFtP3Rwt8YmA7sjT2sKGkQKcFwuU+U?= =?us-ascii?Q?K+SFS2hzpaZZVcbNlSMTopaGePFdR8Zti31xaAMPOs54DzVj7zrqJiU4qioq?= =?us-ascii?Q?Xa2Ky+nddNz90+obE6UQmjrgrSmXjX38GgLRoxOEqn3WjygpGXUUBiMuoaPg?= =?us-ascii?Q?3OUAYpu2SZkbJm4o05AHI6dZZ1TDLPiWg1J4KK7xy85QGHVWLlmxX16cyjql?= =?us-ascii?Q?5t4AzvMdd7NJlwyNEjv9bhDz6p/nk6OVEqmlnvCG5GtH17d3/+PoRgsahkX/?= =?us-ascii?Q?PH0U2O4WsZlb6ZpH99O7NA+JHcDpoXHhaE/+eZzMeM93LzWJ/T1kru605EqG?= =?us-ascii?Q?p+0NVW9LlANbkiKd5wfgUdmjYb8JFIIEZFtGLfTbFg0Fx8CS2hafu29iv4qF?= =?us-ascii?Q?p7o1ngHLnMLafWy02iAiW1Cc+R/CAx6CyyXv09TsIuTbDxTfnaXAioirIUFW?= =?us-ascii?Q?QHqJMubiIxle4gJXqSwqn1J7MnRxILLw7Sf2EVeuGtCw1NoR9bhsWrukn0SX?= =?us-ascii?Q?94UWVEdPN7bVWua5eZM9z9uZhan2VPCv28PvanunQyHMZSJyWWwihWkBUxbv?= =?us-ascii?Q?VX/bto44NzN89yjAQv1BuJlYeZ3hpqFYz2eQSYS06oEAgD7AQrw8Gklk2w2c?= =?us-ascii?Q?ipHgL9W+aLDY35KYrGvyH719ZLYa3P+m75FTVD2zrYudiijS8o9dAwqv0ZRh?= =?us-ascii?Q?2aLnDHo1D8hIXqf/CCSQQY6olGMUTJ8xSUZn0bv7FdXnsTM8CR2tejA5Csgd?= =?us-ascii?Q?rjfgETA7s1OToSeIT6mE7oUKm127i73ocLtbYRCRkaJ7dAKWiYIJvfehto0u?= =?us-ascii?Q?SK0abkYwBqm0rBv+TBHUZoNsHZ7P2MxmxrsDnhnuLHlBlOJBbt14FjH3RWm5?= =?us-ascii?Q?NhBujnhf7rQMi8icku580nsSMZBAx3kbawe7fE8WU2IIZPjgdaH1hdWbdF4M?= =?us-ascii?Q?Qfg3A34S0tqm5JHs1ku/+KzzM/akceePvewtQzVQtXOnOKqnAjB4phkapf3D?= =?us-ascii?Q?Fyqy0Sa8jmzTFqCxR5VmV2E=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd4b1f31-eae5-4ef1-54a4-08d9dc083e9a X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2022 11:30:21.9036 (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: 1O4h0X0Rsfi7IM9ZyK+YsTQukdFIgv7wgLDIiQsnLnGFfqDRX2/zCJYOO0rnUs/VVVqq80GRV4aERtZaArsapQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1381 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10232 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201200058 X-Proofpoint-GUID: wEbsK_qydPTIdgyZGov6Chp34p5D-7qe X-Proofpoint-ORIG-GUID: wEbsK_qydPTIdgyZGov6Chp34p5D-7qe Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1642687597911100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This new command shows the information of a VirtQueue element. [Note: Up until v10 of this patch series, virtio.json had many (15+) enums defined (e.g. decoded device features, statuses, etc.). In v10 most of these enums were removed and replaced with string literals. By doing this we get (1) simpler schema, (2) smaller generated code, and (3) less maintenance burden for when new things are added (e.g. devices, device features, etc.).] Signed-off-by: Jonah Palmer Acked-by: Markus Armbruster --- hw/virtio/virtio-stub.c | 9 +++ hw/virtio/virtio.c | 154 ++++++++++++++++++++++++++++++++++++++++ qapi/virtio.json | 183 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 346 insertions(+) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index 13e5f93..7ddb22c 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -31,3 +31,12 @@ VirtQueueStatus *qmp_x_query_virtio_queue_status(const c= har *path, { return qmp_virtio_unsupported(errp); } + +VirtioQueueElement *qmp_x_query_virtio_queue_element(const char *path, + uint16_t queue, + bool has_index, + uint16_t index, + Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index c81210b..ec37235 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -489,6 +489,19 @@ static inline void vring_used_write(VirtQueue *vq, VRi= ngUsedElem *uelem, address_space_cache_invalidate(&caches->used, pa, sizeof(VRingUsedElem= )); } =20 +/* Called within rcu_read_lock(). */ +static inline uint16_t vring_used_flags(VirtQueue *vq) +{ + VRingMemoryRegionCaches *caches =3D vring_get_region_caches(vq); + hwaddr pa =3D 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) { @@ -4416,6 +4429,147 @@ VirtQueueStatus *qmp_x_query_virtio_queue_status(co= nst char *path, return status; } =20 +static strList *qmp_decode_vring_desc_flags(uint16_t flags) +{ + strList *list =3D NULL; + strList *node; + int i; + + struct { + uint16_t flag; + const char *value; + } map[] =3D { + { VRING_DESC_F_NEXT, "next" }, + { VRING_DESC_F_WRITE, "write" }, + { VRING_DESC_F_INDIRECT, "indirect" }, + { 1 << VRING_PACKED_DESC_F_AVAIL, "avail" }, + { 1 << VRING_PACKED_DESC_F_USED, "used" }, + { 0, "" } + }; + + for (i =3D 0; map[i].flag; i++) { + if ((map[i].flag & flags) =3D=3D 0) { + continue; + } + node =3D g_malloc0(sizeof(strList)); + node->value =3D g_strdup(map[i].value); + node->next =3D list; + list =3D node; + } + + return list; +} + +VirtioQueueElement *qmp_x_query_virtio_queue_element(const char *path, + uint16_t queue, + bool has_index, + uint16_t index, + Error **errp) +{ + VirtIODevice *vdev; + VirtQueue *vq; + VirtioQueueElement *element =3D NULL; + + vdev =3D virtio_device_find(path); + if (vdev =3D=3D NULL) { + error_setg(errp, "Path %s is not a VirtIO device", path); + return NULL; + } + + if (queue >=3D VIRTIO_QUEUE_MAX || !virtio_queue_get_num(vdev, queue))= { + error_setg(errp, "Invalid virtqueue number %d", queue); + return NULL; + } + vq =3D &vdev->vq[queue]; + + if (virtio_vdev_has_feature(vdev, VIRTIO_F_RING_PACKED)) { + error_setg(errp, "Packed ring not supported"); + return NULL; + } else { + unsigned int head, i, max; + VRingMemoryRegionCaches *caches; + MemoryRegionCache indirect_desc_cache =3D MEMORY_REGION_CACHE_INVA= LID; + MemoryRegionCache *desc_cache; + VRingDesc desc; + VirtioRingDescList *list =3D NULL; + VirtioRingDescList *node; + int rc; int ndescs; + + RCU_READ_LOCK_GUARD(); + + max =3D vq->vring.num; + + if (!has_index) { + head =3D vring_avail_ring(vq, vq->last_avail_idx % vq->vring.n= um); + } else { + head =3D vring_avail_ring(vq, index % vq->vring.num); + } + i =3D head; + + caches =3D vring_get_region_caches(vq); + if (!caches) { + error_setg(errp, "Region caches not initialized"); + return NULL; + } + if (caches->desc.len < max * sizeof(VRingDesc)) { + error_setg(errp, "Cannot map descriptor ring"); + return NULL; + } + + desc_cache =3D &caches->desc; + vring_split_desc_read(vdev, &desc, desc_cache, i); + if (desc.flags & VRING_DESC_F_INDIRECT) { + int64_t len; + len =3D address_space_cache_init(&indirect_desc_cache, vdev->d= ma_as, + desc.addr, desc.len, false); + desc_cache =3D &indirect_desc_cache; + if (len < desc.len) { + error_setg(errp, "Cannot map indirect buffer"); + goto done; + } + + max =3D desc.len / sizeof(VRingDesc); + i =3D 0; + vring_split_desc_read(vdev, &desc, desc_cache, i); + } + + element =3D g_new0(VirtioQueueElement, 1); + element->avail =3D g_new0(VirtioRingAvail, 1); + element->used =3D g_new0(VirtioRingUsed, 1); + element->name =3D g_strdup(vdev->name); + element->index =3D head; + element->avail->flags =3D vring_avail_flags(vq); + element->avail->idx =3D vring_avail_idx(vq); + element->avail->ring =3D head; + element->used->flags =3D vring_used_flags(vq); + element->used->idx =3D vring_used_idx(vq); + ndescs =3D 0; + + do { + /* A buggy driver may produce an infinite loop */ + if (ndescs >=3D max) { + break; + } + node =3D g_new0(VirtioRingDescList, 1); + node->value =3D g_new0(VirtioRingDesc, 1); + node->value->addr =3D desc.addr; + node->value->len =3D desc.len; + node->value->flags =3D qmp_decode_vring_desc_flags(desc.flags); + node->next =3D list; + list =3D node; + + ndescs++; + rc =3D virtqueue_split_read_next_desc(vdev, &desc, desc_cache, + max, &i); + } while (rc =3D=3D VIRTQUEUE_READ_DESC_MORE); + element->descs =3D list; +done: + address_space_cache_destroy(&indirect_desc_cache); + } + + return element; +} + static const TypeInfo virtio_device_info =3D { .name =3D TYPE_VIRTIO_DEVICE, .parent =3D TYPE_DEVICE, diff --git a/qapi/virtio.json b/qapi/virtio.json index 44cc05c..bb93d6d 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -656,3 +656,186 @@ 'data': { 'path': 'str', 'queue': 'uint16' }, 'returns': 'VirtVhostQueueStatus', 'features': [ 'unstable' ] } + +## +# @VirtioRingDesc: +# +# Information regarding the vring descriptor area +# +# @addr: Guest physical address of the descriptor area +# +# @len: Length of the descriptor area +# +# @flags: List of descriptor flags +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtioRingDesc', + 'data': { 'addr': 'uint64', + 'len': 'uint32', + 'flags': [ 'str' ] } } + +## +# @VirtioRingAvail: +# +# Information regarding the avail vring (a.k.a. driver area) +# +# @flags: VRingAvail flags +# +# @idx: VRingAvail index +# +# @ring: VRingAvail ring[] entry at provided index +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtioRingAvail', + 'data': { 'flags': 'uint16', + 'idx': 'uint16', + 'ring': 'uint16' } } + +## +# @VirtioRingUsed: +# +# Information regarding the used vring (a.k.a. device area) +# +# @flags: VRingUsed flags +# +# @idx: VRingUsed index +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtioRingUsed', + 'data': { 'flags': 'uint16', + 'idx': 'uint16' } } + +## +# @VirtioQueueElement: +# +# Information regarding a VirtQueue's VirtQueueElement including +# descriptor, driver, and device areas +# +# @name: Name of the VirtIODevice that uses this VirtQueue +# +# @index: Index of the element in the queue +# +# @descs: List of descriptors (VirtioRingDesc) +# +# @avail: VRingAvail info +# +# @used: VRingUsed info +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtioQueueElement', + 'data': { 'name': 'str', + 'index': 'uint32', + 'descs': [ 'VirtioRingDesc' ], + 'avail': 'VirtioRingAvail', + 'used': 'VirtioRingUsed' } } + +## +# @x-query-virtio-queue-element: +# +# Return the information about a VirtQueue's VirtQueueElement +# (default: head of the queue) +# +# @path: VirtIODevice canonical QOM path +# +# @queue: VirtQueue index to examine +# +# @index: Index of the element in the queue +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: VirtioQueueElement information +# +# Since: 7.0 +# +# Examples: +# +# 1. Introspect on virtio-net's VirtQueue 0 at index 5 +# +# -> { "execute": "x-query-virtio-queue-element", +# "arguments": { "path": "/machine/peripheral-anon/device[1]/virtio-b= ackend", +# "queue": 0, +# "index": 5 } +# } +# <- { "return": { +# "index": 5, +# "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's VirtQueue 1 at head +# +# -> { "execute": "x-query-virtio-queue-element", +# "arguments": { "path": "/machine/peripheral/crypto0/virtio-backend", +# "queue": 1 } +# } +# <- { "return": { +# "index": 0, +# "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's VirtQueue 2 at head +# +# -> { "execute": "x-query-virtio-queue-element", +# "arguments": { "path": "/machine/peripheral-anon/device[2]/virtio-b= ackend", +# "queue": 2 } +# } +# <- { "return": { +# "index": 19, +# "name": "virtio-scsi", +# "descs": [ +# { "flags": ["used", "indirect", "write"], "len": 409932794= 4, +# "addr": 12055409292258155293 } +# ], +# "avail": { +# "idx": 1147, +# "flags": 0, +# "ring": 19 +# }, +# "used": { +# "idx": 280, +# "flags": 0 +# } +# } +# +## + +{ 'command': 'x-query-virtio-queue-element', + 'data': { 'path': 'str', 'queue': 'uint16', '*index': 'uint16' }, + 'returns': 'VirtioQueueElement', + 'features': [ 'unstable' ] } --=20 1.8.3.1 From nobody Sat May 4 07:55:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1642689175; cv=pass; d=zohomail.com; s=zohoarc; b=a3+anuM0Tk1E3KM0NRBbkeg+HASE5T0UMUttEKfvaqyugcngj1HVAo0BIY1yuCJLl9CDwwebP6GPCfDVJtgcIvk0STJvwK2HuRAQZ0iMPzW4aTTTg20sRNgD+v6xl4QC1eRXQXQf7T3rJOJCZTXYgTbrAXs6I0q+N9Vujmnx7xU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642689175; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jVfDpx8m+kaH2KUNUQ7sr7n46fAnoFaQ1nov9PbMJC4=; b=BA8DG/6ZWgfH7pKc1UlbvcCP9OMrbdeCiEq8oM+gpfGuxewLeuL62uGF/Ovz5qbtBQjzYCimXfwWzRJLDsWZ6rjb4BiBY9f7amBkhBloSvzxIdWvz5z+a1z8jbS4r9fMKsGx4dOa6s38KfTLjWzTOMaw5eLDgY3NafnwLTyNOvc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642689174986714.6710403460424; Thu, 20 Jan 2022 06:32:54 -0800 (PST) Received: from localhost ([::1]:37866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAYUf-0002Hw-R7 for importer@patchew.org; Thu, 20 Jan 2022 09:32:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54220) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAVey-0005cC-SL; Thu, 20 Jan 2022 06:31:23 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:48904) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAVep-0006bW-QP; Thu, 20 Jan 2022 06:31:19 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20K8wxKX010641; Thu, 20 Jan 2022 11:30:30 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3dnc5301tc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jan 2022 11:30:29 +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 20KBG83x069913; Thu, 20 Jan 2022 11:30:28 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by userp3020.oracle.com with ESMTP id 3dkqqs8hys-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jan 2022 11:30:28 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by CH0PR10MB5052.namprd10.prod.outlook.com (2603:10b6:610:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Thu, 20 Jan 2022 11:30:24 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::95b1:2ba7:964c:d3cb]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::95b1:2ba7:964c:d3cb%9]) with mapi id 15.20.4909.010; Thu, 20 Jan 2022 11:30:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=jVfDpx8m+kaH2KUNUQ7sr7n46fAnoFaQ1nov9PbMJC4=; b=ddxgC+0Ol0u09uCYBWnAOjzRhShApLa8scsWlydyVrygU50cVP7KqO5fVpzh8qONYKqy yKzASv0PyWLTKL7okkJz8gLwFJRB4795B91goE7l7XH5hHjYVJY5+dmVtJHT50DD2fRh kpvT2U9vVs7yy95tqzMZ4BxtdEStfsTNVzejXwVTqMuPQ75hNBJ2X6Bs3jRjYG1gsFNs mZMlxHewi9Oi/PmAOBKnARy4b7axG0pD41SlH0rc1O5qFh1ub3KPOVmdSlIaEWoDJabO Dpu821BpKNl/wgjrTV4fvhuhFs71OWq6kB0A1qaI1Yfmb0gOsD/Pv5gST0RbZhq6qdHe Rw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UUIYR1C5e/d0j2Cy2WrnIznuoVgfV6X2EZpxEtMlPnBKsVQgEsNKPgGXkwxF7stqVpcpJ8FRymIzi9mYobnV6GAZU5CT2Ks21HwrqdSrIbM3afCponszD7hb+y0XCUIBfeHU9R0DoTJitlZg00P18tnExJ0PR6KcrDFzQcE9PlUas/8upP86N3U+gUNOCkmrlmgMc+M91+Oex2FZmUmzJCIRtxNJECbgYjzaInxDjHEW4e1maQ5YOJJo0zgXHlsCpxz6PcLHu+htVANU5py1Dix8gGIdlu94RoSfRclGcvSeT9Nj0Dx7d1LHjHJl3g/MfGwljLeHdY3/xX+dBLyY7w== 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=jVfDpx8m+kaH2KUNUQ7sr7n46fAnoFaQ1nov9PbMJC4=; b=aWFyucTfo1O/qerunKIkpzgq1MH9QuTmEuCDI79UAuf1xHI5JDTXxMh6RKAkHQSqwyj6t2h6FJ7LIbFJvHCI+ZX8r7KZgXx/wQ9m58SGMIm/pz3HqEWEoUY+YwC9pFbMb/+n4y5qeAbPxlA+kcGaUWsuMAvp2CXvXDi6/dEQXwbvP6yalSsauUwyFZm57CdzaZx/LLnv6HceY6Q5JwluhDx/U/5RBW8W/+LHm1APqtQfzU7RIWiSudPwwVe7d1wSIX2r4mTxOIzwp2QQl0bVJUY8CZLOdLFXs6zpebATdEpdOXUDugxFV7GOSzwXMA7+ExYoK+Q6ROAcRQZ0UUmYyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=jVfDpx8m+kaH2KUNUQ7sr7n46fAnoFaQ1nov9PbMJC4=; b=iVUdMOmfohQwc0PQ7gHnk0do4i/GE1/S70uSGXkBrauQmx1F08jNL43v/Fm+iHBjWyIBDbQDtDpoqcbPBwDbw5reWWv+6KYyIMaxRP9Bd1hoKhoa595H/quiLjaEkL+0sSaHO4SPM5zbMBuJFU2bLzPzM9fjt3qq6QyvevFiqT4= From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v11 8/8] hmp: add virtio commands Date: Thu, 20 Jan 2022 06:29:28 -0500 Message-Id: <1642678168-20447-9-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1642678168-20447-1-git-send-email-jonah.palmer@oracle.com> References: <1642678168-20447-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SA9PR11CA0025.namprd11.prod.outlook.com (2603:10b6:806:6e::30) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 68cbbf2c-c166-4876-a850-08d9dc084010 X-MS-TrafficTypeDiagnostic: CH0PR10MB5052:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:120; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VmQXaAx1GLCOpJ7kXACeVAo67NQSm40pCt5rXk7tTzByXxfvC0LS6fDKgtmkwwJTGAedDBQ752o1EmZ/oBl+TRaZgxWmioQKPawysVeJo9YDeBciZ1QC7bV5t1K3oBf4BONEPjQnG5D4ZEO8MHz51xLpo7AcSrF1ABGKvTE8MZfLfB1gD7urejcng1NA/QXDDysgxMx5QfuRfVYePIdWawbojmhvtq6esimJY4Q1Ynt2h8+jqo1MZDuqoZOVmh3L8em7Pze82qAsNKjB6r4gQKUd01gqQ7y5c6SFgWV07dyusRdPq5Vlgu1NiHVPFZcpHUYyXXknbrawj4CDQ5NvZSlM9kYEtrTwsFbyPj249/J42f8TeXltYawT0ids6UGoCa1HoMQYnDJzVQEWu6deClj5rL8ow2WEcFrD+uVoL4V2+6aHvokAsxGpLbMsYogttwqcqoLURSycFS4MnzkoIYA8VuHFfTXpckM/fJ844lAVkq1mDvGE1D9BHgPHmc4krvFyZHHhKYNPgY3xiBnB4D2suAVB5JKajAtSlnrLcBIs9FBPnOf3PJI+ETjmOOLoOdFft+BodEyYKrhYHEEU3NijDZvBzqNogXwxupb0VbiaA1Co3Wjvdyx7zuusCBQlFdMAvLeuamEFlBwQTkMQWY6+g385ZxBhWmil+/+Gxq0+r09ORMwYZfEaxrDGxC15f4kT/HdkrzWsSjIyY+ps1g== 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)(2616005)(7416002)(30864003)(52116002)(6512007)(316002)(38100700002)(38350700002)(5660300002)(4326008)(86362001)(66476007)(66556008)(66946007)(44832011)(2906002)(508600001)(8936002)(36756003)(6916009)(8676002)(26005)(186003)(83380400001)(6486002)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?bbAF6SsWlujmgwWN5MvYs4MnXGy9+dQceQUwBLOxwwku+uA3Iir5RR3r5Ir/?= =?us-ascii?Q?iYvg6Sg1IcAs3LQxvK/e/V0yppKdLc3m3oUINh3OgQ8uXJI+1VqheO2irJ6t?= =?us-ascii?Q?KmkZPqqbWh06OjCTVX89mXNcXL9hymL/K8HFNRF89NosPffHH+hX4UF1uh8d?= =?us-ascii?Q?J5vH4YDncgv5bBOkXiUZCcX0o+/quIeDQbRa2JlbkkV8/2KrAPLECKOy5hbE?= =?us-ascii?Q?fcxa/kKg0+gSPtSFTFpeqJ5IZYUFaJolXKxSsnuebjC+qiDavwipfu83OFyR?= =?us-ascii?Q?J8jU69ZchhJ6YLppW4gCgyzEDZkm+c4xNodQtFlEHugGr7aDUAziP364cNGX?= =?us-ascii?Q?Zr5jYugtVx5YZYkYs0PSIvQazZRWWhsTVaKHjAsTjD8ffc1IIjSO8Z3idK7X?= =?us-ascii?Q?D48rmfY8m+DxY31iD315OHi+00nZnVqhOm2CKWi9TyG8SIaPnK1xX7/7areS?= =?us-ascii?Q?fZ7xjG2Up0rY5ddBvYyN0hvNdzioCaRLdAWMHgkXcPwRAi08JvRaPUgcRscE?= =?us-ascii?Q?pNY5wgG7GVPvL/2Rp/VCqdV9ongcvINH0ogJv2axnS91HMQDtm46Rt78xKmd?= =?us-ascii?Q?g5oXbYUwtFhE/De3SCwgkshJDAD9zHg71FBDwY4raY+4qvUxaRE5aPHWXixU?= =?us-ascii?Q?5W0pEfAWGj04tYMiblpt9EmtN8yYJFMJrNdbBevDb0UrHKd3JhRDVs5/thex?= =?us-ascii?Q?UfGbXTJbd6rtYnOc22M31pkbdS367rLqcDxGwHYqSCnDkvATeOQ2lqlnzQCx?= =?us-ascii?Q?y9xGY8+tDvqOkWmi9vIUKZk/frSV9kzzlFaNxvllDkislEEhmm0n7onZGhU4?= =?us-ascii?Q?x95ueMPDMl0+0JBKvslBFn4vYlKnWrrzkTG8TYqlDzJrv8gO6ip+XnX+tdSN?= =?us-ascii?Q?fqtZLsuF3f/h6dy0o9D3rGIVqjynyC1eIOyZxhvbalk6npARAdRicu8pI8mh?= =?us-ascii?Q?6rFM85pMO+1YccWzq0fX//Gc0BBznCDnlEZxYO6WfM5XwRc+YR3+4BqoJzya?= =?us-ascii?Q?vOGxpr6oPvHWiDORsq1XpKj2AwOAYxyN+m97Iigx9j4rGIG5L5Wen66UmfLs?= =?us-ascii?Q?NDDx8F4XxGA5KlJCHk2fPSqHTxIbz2gfum9mJkL64MJtjGpUshttmbJkpyb+?= =?us-ascii?Q?Z3yiQzNYZT1V60mcopMIvtN0w0+DVy7GEAEcjw5wPI50kFV60T75gQMKPwnh?= =?us-ascii?Q?T3m+4Iw12qvn00XnPwEQjaQyLqhhev5a5X9IXBphCwSdhCVOMJJxsFj0QsH8?= =?us-ascii?Q?N5cenaTZK46WbxIemm4Z1P8EHsqomnVZLjOnFixvznNGDdyTRHonYvpireW4?= =?us-ascii?Q?FJObmb7a2ydOoPMTEr6HyDthpBsyXbL6r2PfNDhxtcPbm13wrfVuA9YfUctm?= =?us-ascii?Q?Twsb63u/u/7w1YkOG26Xafa0lXFtFV1Qcxf4wSps/XbLxtjbvignrC9AU0gB?= =?us-ascii?Q?UFyBxPhuiajdi+EpypwmWWnekDvWR5Ea8V1w7cy84qmrnldRt5FkGttZPme2?= =?us-ascii?Q?uXg5kQwiSzVKQ9zaQ5KuB8wmv+L/EysZfA667JaKGVQXEV7zaaj7bx5iWwf6?= =?us-ascii?Q?6oiktIXscEJsd/5gMW2xtPysVHnupW7sgjdGXXttB+rYRn+5/hW7a+daOSQ/?= =?us-ascii?Q?NBdzYq2ZA5hHjOASUN0U/so=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68cbbf2c-c166-4876-a850-08d9dc084010 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2022 11:30:24.3724 (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: ibqomZuLwWN+3KtbkEPHoDv3fVwNN8sa0aVq1SFe9bh89JHpIVHCSjfS92xCfhHmvr1iVhP7JKQ/5eXjsSKhYg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5052 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10232 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201200058 X-Proofpoint-GUID: AKkC8t4QuRto1_DP5DUzufiyh6Puu8iE X-Proofpoint-ORIG-GUID: AKkC8t4QuRto1_DP5DUzufiyh6Puu8iE Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1642689176164100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This patch implements the HMP versions of the virtio QMP commands. Signed-off-by: Jonah Palmer --- hmp-commands-info.hx | 70 ++++++++++++ include/monitor/hmp.h | 5 + monitor/hmp-cmds.c | 311 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 386 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 407a1da..e49d852 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -877,3 +877,73 @@ SRST ``info sgx`` Show intel SGX information. ERST + + { + .name =3D "virtio", + .args_type =3D "", + .params =3D "", + .help =3D "List all available virtio devices", + .cmd =3D hmp_virtio_query, + .flags =3D "p", + }, + +SRST + ``info virtio`` + List all available virtio devices +ERST + + { + .name =3D "virtio-status", + .args_type =3D "path:s", + .params =3D "path", + .help =3D "Display status of a given virtio device", + .cmd =3D hmp_virtio_status, + .flags =3D "p", + }, + +SRST + ``info virtio-status`` *path* + Display status of a given virtio device +ERST + + { + .name =3D "virtio-queue-status", + .args_type =3D "path:s,queue:i", + .params =3D "path queue", + .help =3D "Display status of a given virtio queue", + .cmd =3D hmp_virtio_queue_status, + .flags =3D "p", + }, + +SRST + ``info virtio-queue-status`` *path* *queue* + Display status of a given virtio queue +ERST + + { + .name =3D "virtio-vhost-queue-status", + .args_type =3D "path:s,queue:i", + .params =3D "path queue", + .help =3D "Display status of a given vhost queue", + .cmd =3D hmp_vhost_queue_status, + .flags =3D "p", + }, + +SRST + ``info virtio-vhost-queue-status`` *path* *queue* + Display status of a given vhost queue +ERST + + { + .name =3D "virtio-queue-element", + .args_type =3D "path:s,queue:i,index:i?", + .params =3D "path queue [index]", + .help =3D "Display element of a given virtio queue", + .cmd =3D hmp_virtio_queue_element, + .flags =3D "p", + }, + +SRST + ``info virtio-queue-element`` *path* *queue* [*index*] + Display element of a given virtio queue +ERST diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 96d0148..47446d8 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -95,6 +95,11 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict); void hmp_qom_get(Monitor *mon, const QDict *qdict); void hmp_qom_set(Monitor *mon, const QDict *qdict); void hmp_info_qom_tree(Monitor *mon, const QDict *dict); +void hmp_virtio_query(Monitor *mon, const QDict *qdict); +void hmp_virtio_status(Monitor *mon, const QDict *qdict); +void hmp_virtio_queue_status(Monitor *mon, const QDict *qdict); +void hmp_vhost_queue_status(Monitor *mon, const QDict *qdict); +void hmp_virtio_queue_element(Monitor *mon, const QDict *qdict); void object_add_completion(ReadLineState *rs, int nb_args, const char *str= ); void object_del_completion(ReadLineState *rs, int nb_args, const char *str= ); void device_add_completion(ReadLineState *rs, int nb_args, const char *str= ); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 2669156..be3b7c0 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -42,6 +42,8 @@ #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-tpm.h" #include "qapi/qapi-commands-ui.h" +#include "qapi/qapi-commands-virtio.h" +#include "qapi/qapi-visit-virtio.h" #include "qapi/qapi-visit-net.h" #include "qapi/qapi-visit-migration.h" #include "qapi/qmp/qdict.h" @@ -2166,3 +2168,312 @@ void hmp_info_memory_size_summary(Monitor *mon, con= st QDict *qdict) } hmp_handle_error(mon, err); } + +static void hmp_virtio_dump_protocols(Monitor *mon, + VhostDeviceProtocols *pcol) +{ + strList *pcol_list =3D pcol->protocols; + while (pcol_list) { + monitor_printf(mon, "%s", pcol_list->value); + pcol_list =3D pcol_list->next; + if (pcol_list !=3D 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) +{ + strList *status_list =3D status->statuses; + while (status_list) { + monitor_printf(mon, "%s", status_list->value); + status_list =3D status_list->next; + if (status_list !=3D 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) +{ + strList *transport_list =3D features->transports; + while (transport_list) { + monitor_printf(mon, "%s", transport_list->value); + transport_list =3D transport_list->next; + if (transport_list !=3D NULL) { + monitor_printf(mon, ", "); + } + } + + monitor_printf(mon, "\n"); + strList *list =3D features->dev_features; + if (list) { + monitor_printf(mon, " "); + while (list) { + monitor_printf(mon, "%s", list->value); + list =3D list->next; + if (list !=3D NULL) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, "\n"); + } + + if (features->has_unknown_dev_features) { + monitor_printf(mon, " unknown-features(0x%016"PRIx64")\n", + features->unknown_dev_features); + } +} + +void hmp_virtio_query(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + VirtioInfoList *list =3D qmp_x_query_virtio(&err); + VirtioInfoList *node; + + if (err !=3D NULL) { + hmp_handle_error(mon, err); + return; + } + + if (list =3D=3D NULL) { + monitor_printf(mon, "No VirtIO devices\n"); + return; + } + + node =3D list; + while (node) { + monitor_printf(mon, "%s [%s]\n", node->value->path, + node->value->name); + node =3D node->next; + } + qapi_free_VirtioInfoList(list); +} + +void hmp_virtio_status(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + const char *path =3D qdict_get_try_str(qdict, "path"); + VirtioStatus *s =3D qmp_x_query_virtio_status(path, &err); + + if (err !=3D 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", + s->device_endian); + monitor_printf(mon, " status: "); + hmp_virtio_dump_status(mon, s->status); + monitor_printf(mon, " Guest features: "); + hmp_virtio_dump_features(mon, s->guest_features); + monitor_printf(mon, " Host features: "); + hmp_virtio_dump_features(mon, s->host_features); + monitor_printf(mon, " Backend features: "); + hmp_virtio_dump_features(mon, s->backend_features); + + if (s->has_vhost_dev) { + monitor_printf(mon, " VHost:\n"); + monitor_printf(mon, " nvqs: %d\n", + s->vhost_dev->nvqs); + monitor_printf(mon, " vq_index: %ld\n", + s->vhost_dev->vq_index); + monitor_printf(mon, " max_queues: %lu\n", + s->vhost_dev->max_queues); + monitor_printf(mon, " n_mem_sections: %ld\n", + s->vhost_dev->n_mem_sections); + monitor_printf(mon, " n_tmp_sections: %ld\n", + s->vhost_dev->n_tmp_sections); + monitor_printf(mon, " backend_cap: %lu\n", + s->vhost_dev->backend_cap); + monitor_printf(mon, " log_enabled: %s\n", + s->vhost_dev->log_enabled ? "true" : "false"); + monitor_printf(mon, " log_size: %lu\n", + s->vhost_dev->log_size); + monitor_printf(mon, " Features: "); + hmp_virtio_dump_features(mon, s->vhost_dev->features); + monitor_printf(mon, " Acked features: "); + hmp_virtio_dump_features(mon, s->vhost_dev->acked_features); + monitor_printf(mon, " Backend features: "); + hmp_virtio_dump_features(mon, s->vhost_dev->backend_features); + monitor_printf(mon, " Protocol features: "); + hmp_virtio_dump_protocols(mon, s->vhost_dev->protocol_features); + } + + qapi_free_VirtioStatus(s); +} + +void hmp_vhost_queue_status(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + const char *path =3D qdict_get_try_str(qdict, "path"); + int queue =3D qdict_get_int(qdict, "queue"); + VirtVhostQueueStatus *s =3D + qmp_x_query_virtio_vhost_queue_status(path, queue, &err); + + if (err !=3D NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " device_name: %s (vhost)\n", + s->name); + monitor_printf(mon, " kick: %ld\n", s->kick); + monitor_printf(mon, " call: %ld\n", s->call); + monitor_printf(mon, " VRing:\n"); + monitor_printf(mon, " num: %ld\n", s->num); + monitor_printf(mon, " desc: 0x%016"PRIx64"\n", s->desc); + monitor_printf(mon, " desc_phys: 0x%016"PRIx64"\n", + s->desc_phys); + monitor_printf(mon, " desc_size: %"PRId32"\n", s->desc_size); + monitor_printf(mon, " avail: 0x%016"PRIx64"\n", s->avail); + monitor_printf(mon, " avail_phys: 0x%016"PRIx64"\n", + s->avail_phys); + monitor_printf(mon, " avail_size: %"PRId32"\n", s->avail_size); + monitor_printf(mon, " used: 0x%016"PRIx64"\n", s->used); + monitor_printf(mon, " used_phys: 0x%016"PRIx64"\n", + s->used_phys); + monitor_printf(mon, " used_size: %"PRId32"\n", s->used_size); + + qapi_free_VirtVhostQueueStatus(s); +} + +void hmp_virtio_queue_status(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + const char *path =3D qdict_get_try_str(qdict, "path"); + int queue =3D qdict_get_int(qdict, "queue"); + VirtQueueStatus *s =3D qmp_x_query_virtio_queue_status(path, queue, &e= rr); + + if (err !=3D NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " device_name: %s\n", s->name); + monitor_printf(mon, " queue_index: %d\n", s->queue_index); + monitor_printf(mon, " inuse: %d\n", s->inuse); + monitor_printf(mon, " used_idx: %d\n", s->used_idx); + monitor_printf(mon, " signalled_used: %d\n", + s->signalled_used); + monitor_printf(mon, " signalled_used_valid: %s\n", + s->signalled_used_valid ? "true" : "false"); + if (s->has_last_avail_idx) { + monitor_printf(mon, " last_avail_idx: %d\n", + s->last_avail_idx); + } + if (s->has_shadow_avail_idx) { + monitor_printf(mon, " shadow_avail_idx: %d\n", + s->shadow_avail_idx); + } + monitor_printf(mon, " VRing:\n"); + monitor_printf(mon, " num: %"PRId32"\n", s->vring_num); + monitor_printf(mon, " num_default: %"PRId32"\n", + s->vring_num_default); + monitor_printf(mon, " align: %"PRId32"\n", + s->vring_align); + monitor_printf(mon, " desc: 0x%016"PRIx64"\n", + s->vring_desc); + monitor_printf(mon, " avail: 0x%016"PRIx64"\n", + s->vring_avail); + monitor_printf(mon, " used: 0x%016"PRIx64"\n", + s->vring_used); + + qapi_free_VirtQueueStatus(s); +} + +void hmp_virtio_queue_element(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + const char *path =3D qdict_get_try_str(qdict, "path"); + int queue =3D qdict_get_int(qdict, "queue"); + int index =3D qdict_get_try_int(qdict, "index", -1); + VirtioQueueElement *e; + VirtioRingDescList *list; + + e =3D qmp_x_query_virtio_queue_element(path, queue, index !=3D -1, + index, &err); + if (err !=3D NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " device_name: %s\n", e->name); + monitor_printf(mon, " index: %d\n", e->index); + monitor_printf(mon, " desc:\n"); + monitor_printf(mon, " descs: "); + + list =3D e->descs; + while (list) { + monitor_printf(mon, "addr 0x%"PRIx64" len %d", list->value->addr, + list->value->len); + if (list->value->flags) { + strList *flag =3D list->value->flags; + monitor_printf(mon, " ("); + while (flag) { + monitor_printf(mon, "%s", flag->value); + flag =3D flag->next; + if (flag) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, ")"); + } + list =3D list->next; + if (list) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, "\n"); + 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); +} --=20 1.8.3.1