From nobody Fri Dec 19 06:18:07 2025 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=1626086308; cv=pass; d=zohomail.com; s=zohoarc; b=OtgRSytUe2oqCzg6qLGvNNBqa6T2vLI3x0BNyyFt6w3kwiyQgoSCGrq8xy2Pd5rAdMaVImgdPt5BJ9Lbh7iRk1YsPiEB/4mQUUNzJLMrSYsYTxiD/6vghlvOxxM9I4utwnEoWvbSeU+3ZbsIxeBymjp/WfQZcCjNBzorLRBs6zg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626086308; 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=iryMaJkm/yx0lqHXu6U/A9OeKSPigm3nkmR4paCI36c=; b=N4Ge13sbhu3izT6irEBJhEu0ArDZn4aZQZlk1UrV21+W62QcwIGOvrccqYwl84XPGws7iVpK/s4YtBaUp/XmoU40erzT9pMNVbmUE4yyzmyjDHa9UuZQrtMCWVshnFNpV7t+HlNGKPemoNtsD311xNs6q7g4bi+GBwMQbsYFdcs= 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 162608630886274.29249197763761; Mon, 12 Jul 2021 03:38:28 -0700 (PDT) Received: from localhost ([::1]:34826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2tKV-0003t1-Q1 for importer@patchew.org; Mon, 12 Jul 2021 06:38:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2tIs-0001Zz-29; Mon, 12 Jul 2021 06:36:46 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:12198) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2tIn-0008Qq-Gp; Mon, 12 Jul 2021 06:36:45 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16CAVCPL019199; Mon, 12 Jul 2021 10:36:28 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 39q1ybabyd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jul 2021 10:36:28 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 16CAYmFS001192; Mon, 12 Jul 2021 10:36:27 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2175.outbound.protection.outlook.com [104.47.73.175]) by aserp3030.oracle.com with ESMTP id 39qycr83yy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jul 2021 10:36:27 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB4552.namprd10.prod.outlook.com (2603:10b6:510:42::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Mon, 12 Jul 2021 10:36:25 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::c0ec:e3aa:9d8f:61c0]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::c0ec:e3aa:9d8f:61c0%6]) with mapi id 15.20.4308.026; Mon, 12 Jul 2021 10:36:25 +0000 Received: from jonpalme-lnx.us.oracle.com (209.17.40.41) by SN4PR0701CA0019.namprd07.prod.outlook.com (2603:10b6:803:28::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Mon, 12 Jul 2021 10:36:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=iryMaJkm/yx0lqHXu6U/A9OeKSPigm3nkmR4paCI36c=; b=dDBbVUw2SmV/oN+shSPWwnUIyVmvQ0LUzR5MUyud0aUjnzOyaDLJLEkV39WcDxItibNV eQcCYHXKm9osWWhaJlBq05TQjnh6Loq8g4LlansoifgD5QscJUWe9MF3/f1qu5x8d7jL +xi/RUh4j14IZn7XWM1IHG5TwksJ5X5vTAVcdDEEDBFHolayCjVlut67OySJ2E7lK1Hv 16+eg2gtrta3Q+xpIxNlzIMn04k9UtdLSet4jk46OPTG2wuY1TR+R56oSsvoGmi2/36R PtbV8NucPsSY2gkaSVOwlsXFJ+cSZJFnkmmthUch06lUvbW9a33RFULPPX1bTcgFD1vq 6w== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NY79NJWHEqxYjJIWdJrGVV19Q2Iy8MVf4Jexmwr6ilI0m+Yu/PzWrYCj0b4nVOdcj46wkzapBgNdr5edFAO92XsU/n0WR971Du4/WuLyKmNcuC/qmmqNPc3/GDUXfZnswT75MP9m17uP4HqA3hk5CA+R8DR/AAVnHsERxNcQ7D/cjE51hdPUvs7EQFS77GRuncHiGVXh318tBxrvlxPZHdCVvygXLWd6lIFobcE/T0gJ4H871ApZRETHw4Zfej91dOQ9dgN9ZzhM1tWMGXTbVDfBDfncSrkXDdde7Lg9sb5xrJ9IEaWjx8KQlZ3ta4o61+BhzMVW+hJMM0hCg73XLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iryMaJkm/yx0lqHXu6U/A9OeKSPigm3nkmR4paCI36c=; b=UEJaOf4Qt19YUAgqcrrBB/SKb8auCpsRxSBMSVTDOLn5elAuyafQuK6+p0462N9YpHSG/ep+XG8umA1DzV/SYfkio9btqMC3cf5c46eN1DW+cSWhJvicQ0fqalFZG1NPob97hTzq6NotcpbiW+GSB3C8NRQ3oGeo6jQqaoTOHY9GG8ip3YU+TC2zOiMK4F3UtDbdSFUpLsqVuKjYNpj4WO+ECVNpgVzAMeayOAPziMDRsM785Amj/yw1kBxxhIbVgXIDCQY7qcWdzUizxa5+9JFQ8m+BXCXOLo0+v/haVhuR2RV7OCo96EpaZgYAoeNiwqvw7F0K44Ld4pZTSvxujw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iryMaJkm/yx0lqHXu6U/A9OeKSPigm3nkmR4paCI36c=; b=T99h/3fmSytBzk6ETAHCDfNJ2z9UmOuK+M0//qOgcKv8Et5YIvxD7Y8ebPqOqxhdZBdklRiGpeiTn4eGlca9yYzctBHke4pR31fNeFDQopn75m4LzetaHKI7CFMMgsntINVo6/jMEFDg/J8oyO8taqNqSGkmJKK1N3LV3AXHwq0= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v6 1/6] qmp: add QMP command x-debug-query-virtio Date: Mon, 12 Jul 2021 06:35:32 -0400 Message-Id: <1626086137-16292-2-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1626086137-16292-1-git-send-email-jonah.palmer@oracle.com> References: <1626086137-16292-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SN4PR0701CA0019.namprd07.prod.outlook.com (2603:10b6:803:28::29) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2189394f-00ad-42a8-2d5d-08d94520e607 X-MS-TrafficTypeDiagnostic: PH0PR10MB4552: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:820; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YazLG5BIDMZacx7zWdO0g48GE3ltcc+OAhQRgNjI0+3pZGvyIeC5alW4NsokdNOGlF/VKoEFBUkeeUZpuNpOOJkI1l/QODT9DIM7HyMQbxQKHSJti8vSc6rYEyQNdRaRNVR5i/a/br49dThLVDAsndfVpJli7YF6RdmKNu2MWGJ4OWLKl/5WvXOuxVOBKoIbpUAcvrl8tZ4H884xUaU7Sn+6ynLtb3G4IeSHWoWvudSbaRnDLxJW04VPFa0ZvH8Y6OYOAKMVARroZf5Y25fMlw7Ycm34Gs2hkxn+JPu5+scrW2/WmL2bGnOzfD97C5V+f8Du6OtyhR3DoSRlFxObF0ZdvWwQylL1uhG8IRQ8M0xZdrw1lBGFWAWhCV5tvjgNZHp1eAtiwO7tys2fILfae+t0uJYbiwLrXztd/eo2AvdlmrC6nOXvhpMf2kyacc3idjxU9lX2gWuRGdATkdZr3Rkdcf5jSIUZ2qDWqStUFzcVDrjzzZL4dmK/ZKbcAj99Pj+PF420ePgANP9uUehIvxv0KWzNcJSmR7jF+vx4Y7hocMNaFXGEB+YuF3NsJJxnciiEXvmrW161/rCXYwazQGn4BLXdaCpraSM+oJIwTDyNdX/A+golhV2pFEqidgLuKGT89xCX96nJd21jCC8DzlU1Kz0/cfhKBu0WTOjhn4m7mVXovgdMn5VSXXLlus3SrDn22xWJfIEHJ4thC1wzAw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR10MB4664.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(39860400002)(346002)(366004)(136003)(376002)(83380400001)(7416002)(956004)(6486002)(7696005)(2616005)(186003)(316002)(36756003)(4326008)(2906002)(8936002)(52116002)(6666004)(86362001)(107886003)(66476007)(66946007)(44832011)(66556008)(6916009)(38100700002)(5660300002)(8676002)(38350700002)(478600001)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?g4H/uRcQ6QXy8NFQda/vInXIM3RS5cAyDt0e8S4klQqN93z+XgVpm5Fr7+9x?= =?us-ascii?Q?EgRtaQN1ZoAzRGNeEc3x78ybhuX/qpsAg6msMoR9ckmAlBoKO+ty7DrsekRK?= =?us-ascii?Q?8lNGmxFkkhBin74nxF4YPBO0qF0W8yJptC2YeEDSpDHsSNhgy/1vlpzVmCdW?= =?us-ascii?Q?G6zNDJfOX6k525uAuZtl5gG5RAJaTEBSLLIR/yy/YUF+obAJJ6v7ECx/ObW2?= =?us-ascii?Q?elgvEIw/iJlcWIOXZc8/m/Cy4RbPY1xyl37EbU/N8yb6e5J6+0iZQM2FyZue?= =?us-ascii?Q?aHAs0kWjR4rx8oOq5S0Y7EMLl0kjeBEHb+H6D+V4+Frgltwo2iGBjPXcgIYp?= =?us-ascii?Q?GzO7dV5tGHGSoXK528GotuRmvInFV63uHuhvGiorOK25NUYK/5FEC25ZQ192?= =?us-ascii?Q?5opxNmOgQPwHYjXXbLUaHgt1ahVRB4prKCl2MuDeLf0mqHVqm7/BLEkL+Lzj?= =?us-ascii?Q?c3buUrHUz0wi5HEH0gh3QXsUiTV7eYK5AFFZzroPxVYOZ4hMU16Kj2ASq0fI?= =?us-ascii?Q?MM4QACUQF3VTlf+1THs+WpDHDSrbEjVOo5lvXKTUqFKxxpIqYn5asphL+Uzi?= =?us-ascii?Q?Td/KjUKhkoV+H1eqn81spOcqQBMjf1gGJEQM1oaERHat8+BsGQAq7Cbi2F0N?= =?us-ascii?Q?tsJYT1mtxWtXDh6x7Ac4Tf56/bFdbPgH2rH5F86FDOrZd0LD3FxT8T8Uou44?= =?us-ascii?Q?M+8f7j4m9Td6PfImtOp8CofIlpNSUv56Gv/cHzzIbt67dCDDRI7H+Jk5XTkz?= =?us-ascii?Q?7ca9RWxyUZK4eFtuTGIwotGR22IWrwU2f3/Xhp0I663KEY3sTkmedzmxz/AC?= =?us-ascii?Q?AzZrHNXZ4rNB5RVG4cBY7BDvZSA3TljnudiDXCKcLp9GpiMMG5AYN1dJRXE7?= =?us-ascii?Q?JFleQB2zY//bwSdM1Z+9hoi0yJUglRBp7WKqrPYMtfe90fpacj1XbmGAaZ6O?= =?us-ascii?Q?ID265ahQemq14DaknOKN/22dczi5iYmlJJcggNRodfo5jVIy1bUeL1mIJsYY?= =?us-ascii?Q?b+E9T2EpSw8GcfOS2ECpcW0eH3TdUeoj1hLXX8KN9AYKJiJSds/7PXBccYFB?= =?us-ascii?Q?LsrGUum2lmHqH4lhj+SvTMYUZumbfcdq37F5vX11F/KqvcmqBWQk5g4EPT/y?= =?us-ascii?Q?IDuDteWrVkS64IgtZNNsGy4zXEXQ8fGGxcX/Ijy+UIg+fOyAjWIhSJlk+vY1?= =?us-ascii?Q?MJN3O6E8J9sLI0Ygft/qC61TnpudgG+0UmyJfO9ux0b0Tjm+nJwdCUheo0xF?= =?us-ascii?Q?SeDIp99PtmYJ2Z/iPjCENG/1ML0Ej/SGnKn5XooNZ4CmT58fufPW66HTm+o6?= =?us-ascii?Q?9RVnQ3oTDoEPzbbgUtYEgA8G?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2189394f-00ad-42a8-2d5d-08d94520e607 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2021 10:36:25.1728 (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: D7PxWIwneQJLo/qYvHMTbrlY/rWzfwr4Bn83pA/+EbhA4XuzcxDyOzlQOUjBjGiLpXwuDO6L9x4d51oaVFF5vw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4552 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10042 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 bulkscore=0 mlxscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107120082 X-Proofpoint-GUID: XeVLqgRQ-xY4Zlj2jZzgxtA2ls9xmOHG X-Proofpoint-ORIG-GUID: XeVLqgRQ-xY4Zlj2jZzgxtA2ls9xmOHG 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: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_BL=0.01, RCVD_IN_MSPIKE_L3=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, marcandre.lureau@redhat.com, jonah.palmer@oracle.com, thuth@redhat.com, amit@kernel.org, michael.roth@amd.com, dgilbert@redhat.com, eric.auger@redhat.com, dmitrii.stepanov@cloud.ionos.com, stefanha@redhat.com, kwolf@redhat.com, laurent@vivier.eu, mreitz@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1626086311030100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This new command lists all the instances of VirtIODevice with their path and virtio type. Signed-off-by: Laurent Vivier Reviewed-by: Eric Blake Signed-off-by: Jonah Palmer Acked-by: Michael S. Tsirkin --- hw/virtio/meson.build | 2 ++ hw/virtio/virtio-stub.c | 14 +++++++++ hw/virtio/virtio.c | 27 +++++++++++++++++ include/hw/virtio/virtio.h | 1 + qapi/meson.build | 1 + qapi/qapi-schema.json | 1 + qapi/virtio.json | 72 ++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qtest/qmp-cmd-test.c | 1 + 8 files changed, 119 insertions(+) create mode 100644 hw/virtio/virtio-stub.c create mode 100644 qapi/virtio.json [Jonah: Added all virtio/vhost types in same order from include/standard-headers/linux/virtio_ids.h to qapi/virtio.json so that the QAPI generated enum values for 'VirtioType' match the virtio_ids constants (to avoid conversion errors). Iterating through realized virtio devices in qmp_x_debug_query_virtio now uses QAPI_LIST_PREPEND rather than open coding.] diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index fbff9bc..81dc4c9 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -6,8 +6,10 @@ softmmu_virtio_ss.add(when: 'CONFIG_VHOST', if_false: file= s('vhost-stub.c')) =20 softmmu_ss.add_all(when: 'CONFIG_VIRTIO', if_true: softmmu_virtio_ss) softmmu_ss.add(when: 'CONFIG_VIRTIO', if_false: files('vhost-stub.c')) +softmmu_ss.add(when: 'CONFIG_VIRTIO', if_false: files('virtio-stub.c')) =20 softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-stub.c')) +softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('virtio-stub.c')) =20 virtio_ss =3D ss.source_set() virtio_ss.add(files('virtio.c')) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c new file mode 100644 index 0000000..d4a88f5 --- /dev/null +++ b/hw/virtio/virtio-stub.c @@ -0,0 +1,14 @@ +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-virtio.h" + +static void *qmp_virtio_unsupported(Error **errp) +{ + error_setg(errp, "Virtio is disabled"); + return NULL; +} + +VirtioInfoList *qmp_x_debug_query_virtio(Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 874377f..f3fc1bb 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -13,6 +13,8 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-commands-virtio.h" +#include "qapi/qapi-visit-virtio.h" #include "cpu.h" #include "trace.h" #include "qemu/error-report.h" @@ -29,6 +31,8 @@ #include "sysemu/runstate.h" #include "standard-headers/linux/virtio_ids.h" =20 +static QTAILQ_HEAD(, VirtIODevice) virtio_list; + /* * The alignment to use between consumer and producer parts of vring. * x86 pagesize again. This is the default, used by transports like PCI @@ -3672,6 +3676,7 @@ static void virtio_device_realize(DeviceState *dev, E= rror **errp) =20 vdev->listener.commit =3D virtio_memory_listener_commit; memory_listener_register(&vdev->listener, vdev->dma_as); + QTAILQ_INSERT_TAIL(&virtio_list, vdev, next); } =20 static void virtio_device_unrealize(DeviceState *dev) @@ -3686,6 +3691,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; } @@ -3859,6 +3865,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) @@ -3869,6 +3877,25 @@ bool virtio_device_ioeventfd_enabled(VirtIODevice *v= dev) return virtio_bus_ioeventfd_enabled(vbus); } =20 +VirtioInfoList *qmp_x_debug_query_virtio(Error **errp) +{ + VirtioInfoList *list =3D NULL; + VirtioInfoList *node; + VirtIODevice *vdev; + + QTAILQ_FOREACH(vdev, &virtio_list, next) { + DeviceState *dev =3D DEVICE(vdev); + node =3D g_new0(VirtioInfoList, 1); + node->value =3D g_new(VirtioInfo, 1); + node->value->path =3D g_strdup(dev->canonical_path); + node->value->type =3D qapi_enum_parse(&VirtioType_lookup, vdev->na= me, + VIRTIO_TYPE_UNKNOWN, NULL); + QAPI_LIST_PREPEND(list, node->value); + } + + 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 8bab9cf..f7da326 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -108,6 +108,7 @@ struct VirtIODevice bool use_guest_notifier_mask; AddressSpace *dma_as; QLIST_HEAD(, VirtQueue) *vector_queues; + QTAILQ_ENTRY(VirtIODevice) next; }; =20 struct VirtioDeviceClass { diff --git a/qapi/meson.build b/qapi/meson.build index 376f4ce..4e1da08 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -44,6 +44,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..0c89789 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -91,5 +91,6 @@ { 'include': 'misc.json' } { 'include': 'misc-target.json' } { 'include': 'audio.json' } +{ 'include': 'virtio.json' } { 'include': 'acpi.json' } { 'include': 'pci.json' } diff --git a/qapi/virtio.json b/qapi/virtio.json new file mode 100644 index 0000000..804adbe --- /dev/null +++ b/qapi/virtio.json @@ -0,0 +1,72 @@ +## +# =3D Virtio devices +## + +## +# @VirtioType: +# +# An enumeration of Virtio device types. +# +# Since: 6.1 +## +{ 'enum': 'VirtioType', + 'data': [ 'unknown', 'virtio-net', 'virtio-blk', 'virtio-console', + 'virtio-rng', 'virtio-balloon', 'virtio-iomem', 'virtio-rpmsg', + 'virtio-scsi', 'virtio-9p', 'virtio-mac80211-wlan', + 'virtio-serial', 'virtio-caif', 'virtio-memory-balloon', + 'unknown-14', 'unknown-15', 'virtio-gpu', 'virtio-clock', + 'virtio-input', 'vhost-vsock', 'virtio-crypto', 'virtio-signal= -dist', + 'virtio-pstore', 'virtio-iommu', 'virtio-mem', 'unknown-25', + 'vhost-user-fs', 'virtio-pmem', 'unknown-28', 'virtio-mac80211= -hwsim' ] +} + +## +# @VirtioInfo: +# +# Information about a given VirtIODevice +# +# @path: VirtIO device canonical path. +# +# @type: VirtIO device type. +# +# Since: 6.1 +# +## +{ 'struct': 'VirtioInfo', + 'data': { + 'path': 'str', + 'type': 'VirtioType' + } +} + +## +# @x-debug-query-virtio: +# +# Return the list of all VirtIO devices +# +# Returns: list of @VirtioInfo +# +# Since: 6.1 +# +# Example: +# +# -> { "execute": "x-debug-query-virtio" } +# <- { "return": [ +# { +# "path": "/machine/peripheral-anon/device[3]/virtio-backend", +# "type": "virtio-net" +# }, +# { +# "path": "/machine/peripheral-anon/device[1]/virtio-backend", +# "type": "virtio-serial" +# }, +# { +# "path": "/machine/peripheral-anon/device[0]/virtio-backend", +# "type": "virtio-blk" +# } +# ] +# } +# +## + +{ 'command': 'x-debug-query-virtio', 'returns': ['VirtioInfo'] } diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c index c98b78d..b2cf0628 100644 --- a/tests/qtest/qmp-cmd-test.c +++ b/tests/qtest/qmp-cmd-test.c @@ -95,6 +95,7 @@ static bool query_is_ignored(const char *cmd) "query-gic-capabilities", /* arm */ /* Success depends on target-specific build configuration: */ "query-pci", /* CONFIG_PCI */ + "x-debug-query-virtio", /* CONFIG_VIRTIO */ /* Success depends on launching SEV guest */ "query-sev-launch-measure", /* Success depends on Host or Hypervisor SEV support */ --=20 1.8.3.1 From nobody Fri Dec 19 06:18:07 2025 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=1626086305; cv=pass; d=zohomail.com; s=zohoarc; b=HwSIGSY/1DyBwuchK1FKXc4fUdgSmFo7QPXSrxu2sPhVG5utC78Zlphfb/wX3Fg09EMiFT12RIgju2j+wD+JU3RAM8sRIpIt/4q4LUS57oJnJbhxx8vKrwpBM4UH3m4bz6uLux7eQ+SRuKF18Hm7rS3nnjZHo8AZaVU5TDBUTUk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626086305; 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=PaOGqDBwYCcn/aEJ1WufMq1IolZV9dkh33ie+9TbkAg=; b=TuRBqYR4qkHOSEJatRMPFvA5PSUS7FoLCV9z5nit+ejerlV1Gx2jpxy5Y8bz37kXjNVAmPf4IjiUOQYOqO25B+xvUZ/7xNBAG21fyctYRqZVQ4fvUMe+s5sYIDwjruKSX00P8QnyjFKeAbA8/QtLBUNRK2o4P6IZbfbhUkDKvIw= 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 1626086305939749.1955113309152; Mon, 12 Jul 2021 03:38:25 -0700 (PDT) Received: from localhost ([::1]:34694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2tKS-0003ne-Fv for importer@patchew.org; Mon, 12 Jul 2021 06:38:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2tIp-0001YC-Qb; Mon, 12 Jul 2021 06:36:43 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:12200) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2tIn-0008Qp-Md; Mon, 12 Jul 2021 06:36:43 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16CAVCPM019199; Mon, 12 Jul 2021 10:36:30 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 39q1ybabye-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jul 2021 10:36:30 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 16CAYlAx001126; Mon, 12 Jul 2021 10:36:29 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2172.outbound.protection.outlook.com [104.47.59.172]) by aserp3030.oracle.com with ESMTP id 39qycr841p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jul 2021 10:36:29 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB4584.namprd10.prod.outlook.com (2603:10b6:510:37::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Mon, 12 Jul 2021 10:36:27 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::c0ec:e3aa:9d8f:61c0]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::c0ec:e3aa:9d8f:61c0%6]) with mapi id 15.20.4308.026; Mon, 12 Jul 2021 10:36:27 +0000 Received: from jonpalme-lnx.us.oracle.com (209.17.40.41) by SN4PR0701CA0019.namprd07.prod.outlook.com (2603:10b6:803:28::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Mon, 12 Jul 2021 10:36:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=PaOGqDBwYCcn/aEJ1WufMq1IolZV9dkh33ie+9TbkAg=; b=rZDzgBhRlmsEZU/1x2VDbkg6bRt5tltmEQkyoDaUSjZTAKxRUQ2RJf+y0pPI9C/4Fn6w Gc718qmoJXvYsveEWzi+3u+diIRH14Y1sLLK7X/5UVsA2hD1tzGA0N3AhjQ6PJYUd0br /5PY45REL4dEfiSptJFR/pSL5DQQsZ4Gal6GQVN/l2o4T00CcSzw94U249zoy5D82NhZ /qGxl9eZbjE11HXLLxh9fAEN5eHm6Tbb9qTTBFpAeGa988xxF5OJUj8Szxka5F6iRO8h UabAHzHLefMaD3aYJJJ4BNDC5bkR95fJ0d5rO0DhRWnRIex8XR3u/4KK2fJOeCELMyhB uw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N0+pa0wy+L2j4YquJJk45GptKE6ESZsDVR01x/TAMHaWeWTNBViCdqsDHTs2onVDXE6RTDzZVQ3kloMmAFXeNIjUaRS3BxUUITu1DFd512NNL4ByzvTfhjt2a4wl5dXSb5HfKhRJTGrMfvezBwbYqKw3fdsRIIkvPy5AuSmzV2w1qgz9snrUcP1qIHhUtDPegMYdmeNTMz2UfRCTd3aDFwbL7My3nWr9+1U/FF7iXDD6tdVD3UOV3Q4mvzZ+E/TbYhGiuKVpfpf0dt3W08FBJBmSig8wARDhStzQtG4z161GQ0HtjIEK2W1kezNpYr/0ycyI6b1WwrA/Sqr8LDw17Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PaOGqDBwYCcn/aEJ1WufMq1IolZV9dkh33ie+9TbkAg=; b=jFHA1FZ+9HMlklG0sQH6GW+FX4FCEPPHaufGY71OEDNY2B0En0jJCN7mGjMRmDq1F/tO6UU9okU37QPcf89H2JG2bmoVhY64kmBm7TKx3OBoX5n+NoCtuaqTnFVI5qC6/wy3Gf3u1FU/MoId1RAYiRvxwFJPbVjBRTrAHj+GsKGBpTxWukicc3EZeWFg6uX/Xg9I946WRL2BVFon8vesIk+wqYTDL5v7vu0uMrLLXgrluiLjaSDPB/7ulVeeowOsRziF+63hS8gu9RF1BbMbBdRjZBEEQdsPIxzI4cU7b+2zx7SvQniOBV9P0V4BU/3aqAkrQyP3VccYeLTZUUm5Sw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PaOGqDBwYCcn/aEJ1WufMq1IolZV9dkh33ie+9TbkAg=; b=Qde02EyV3RRYpLUoc6Y+C1d5bQvLcf5M/oKPGFY2zZGvPhIr3Ty7xovNYg2gP3EQdUfFP9CBL37H4nTc/VQqinoV6VJk1njM6PXjC385jR81URp95ZU/5jxZlSqGA59BM2i9T/f9mlVjnibIhQ/bTZo7TtI664DZvBTPyWrSiog= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v6 2/6] qmp: add QMP command x-debug-virtio-status Date: Mon, 12 Jul 2021 06:35:33 -0400 Message-Id: <1626086137-16292-3-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1626086137-16292-1-git-send-email-jonah.palmer@oracle.com> References: <1626086137-16292-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SN4PR0701CA0019.namprd07.prod.outlook.com (2603:10b6:803:28::29) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 63fb6e18-24ef-4bcb-9204-08d94520e772 X-MS-TrafficTypeDiagnostic: PH0PR10MB4584: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:400; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mdD6rPWllsCeXm+XMI1Mx8rvvguBFkScSXjJiVPJ9UNs2nhwBxPtAD0T5S0VOKEWXUK5bMZlXxQZVghVUmz5gfPM6B/b9K7cdslwXqizDPwOMnzAxB/v2t0NgMPyLKj6tJGWrqT2dQd3KPoUTlq59LXdPBTyVIc3h73Pk+bArkghJudBlrenH0ps6zGEFiHfE9ez4VtJH64R5l4+OSLVrgS1Ie7+g1DBMPJenuq32G+vClgIATtuWcdn9LO3MuY03HMUPIRPZHioy/Dbt4q5fFSTfxdXABhhetMV0p7s85pIiAYCu9hJ9OXMNIfCockoVG5Vv9hcRJDKWNVwzYb9ba10YnqmvtOLSvUzc/13JMKJ4RQVGOnwXhhc9mev8llPW6v4zaBbccmZI2TnC2p7/IZWmywHA56w8p9ONk9jdYfrGjxD1IyUnrsLpwcJg7xJp9i3o/rueOAKCSUqK4kdQA9IXnx/fLIdgduBDSe1T+ESYBaIZ1xIqvicYhC91iLJHNnmIcjNte8GkGVP8QheqMQhFoa6LuAQ3d7VlTsMfiK7Bm9FB4iVPvkk+Vt2KFE5bIS6KTD6iuhIufDK7JClmfuJlrc7zypWgojx1LJhKRWH1oGstpsxo7B0RaYbd/XIpVW7w2j6q0itKKKlcnwrl1L0AbtrlEqIgxwHj/JsX/f5PVbFRxH5q3EXLVcPDsUN6mxF1n58rCbR2ic7H3n/Xg== 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)(346002)(136003)(396003)(39860400002)(376002)(36756003)(6916009)(66476007)(66946007)(186003)(66556008)(6486002)(478600001)(6666004)(7416002)(52116002)(8676002)(2616005)(8936002)(86362001)(2906002)(44832011)(38350700002)(38100700002)(26005)(7696005)(956004)(4326008)(316002)(5660300002)(107886003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?yCDrP7p+bmA2g137tfzH8HACNk6DB4AWP9Z3Cd71cSvI6Fr/uGGWr2ROaWJT?= =?us-ascii?Q?BzJ4uxv5Ymln9Uq5XRKYsR9aObyJzlkRSsdDew3wvTAK75Jd9BnH1GmDISIo?= =?us-ascii?Q?KGzxTaHNZrZhcp5YDE3zKsAWnocEvsIxdTGWmfNEStpEfoM16NjTskdHcvPN?= =?us-ascii?Q?PjRF1erLoATiIXdiD9p8/HJEV1K4nkJIST/Y/ekSvqy7MYl4CMYONAZxd3AI?= =?us-ascii?Q?/xceqTh/US+lCWvrJluXV/hFKMZNHW3DibStK7qnYGAz2u6020KcaCZ22lCr?= =?us-ascii?Q?jhUk2g95md9/nxWaSoG0QNW8XveqRCUrOUvPJxEk6ctJHpPcOIli6nQqUxuO?= =?us-ascii?Q?RZZTz2bpj726CfzyFAqKBCW+t12DdXFxeTXsSvgoMbbxTDBY0UC0pl0OyJHX?= =?us-ascii?Q?ghmgLsQPuS385PrxoHWa3JWzo94gjWIJ0FSO/SU7Pvol8NIUhQGz91LTnpcZ?= =?us-ascii?Q?W1623Ov5R/WSCN19Zfdi4svablbuVoL3B4bx682cgSvMYZ6RSfeU96Rim1gx?= =?us-ascii?Q?ut1wvYNjmNCq1hA4Hq5BbhbU0JmCu08o9pvhsayeWvLqxIz5sMKbXGsyWDip?= =?us-ascii?Q?XjvofOOtH5O/gJrOApp54lopJ0d6KwuS05jN4ZNmCa4+gO6bDcEukbXtuuqZ?= =?us-ascii?Q?bxdYdwzzoRDzcYO8o6vpLq9tncYdZ2LoVvynaNytY58Pw3ofu7BQX0RjKJo8?= =?us-ascii?Q?Ite0GblUN58FSRO2T2O+BAlW5eRLoWf50yrehRtddRkoyiTRy3OL/o0rgTjc?= =?us-ascii?Q?up3g92bW4MqYm+2l6iNl/IlecSBKypVGbfrEmssfJ8d1oHW8zVuUWf87Tc/N?= =?us-ascii?Q?cxjRKlz/Pi1DubgCUQuFtw94FXxEy0j5mpf60mNfKydOF/U+S+Elg29/N9Fm?= =?us-ascii?Q?yperpoB+Od204Dt+FOB3k4fOWZFXxFc86/7x47zqlCA84LEXciSe8wlBO/iJ?= =?us-ascii?Q?+NbYX9NJ+tRYbxihyC7FZeBrekti6ybAP5uDyS7doD9pk6yW1HKPKfkNRABG?= =?us-ascii?Q?hEzCOvrCvoe+lyD0xu9j0A4xYHwWrLQYjFibRUmAqdD8OlLGbR4eUPSUsB3Y?= =?us-ascii?Q?XecEcK0DrozLHQ89skR9tGPSjVSbPnspbzU9BlOmFSUI63K+sOd+Gk4SrrSU?= =?us-ascii?Q?A0ZuYOZUwE2xfkN/bzuR6oHE5eF3vi3oH1bt5fGx7TBGCWgUjmLhIMloP9Cm?= =?us-ascii?Q?nZH9r8IieDt42+nMAHMy3iLq5QDgijDOx6fGH6CKYyZyw9LZph+p7wfebSA1?= =?us-ascii?Q?W1sv0b2+8rngCAiXpdcdLkVPvIO5PGzwn+LbueKV+7OQoX4IljsEcCUM4IO8?= =?us-ascii?Q?gHSqRUqvued3BUWb6QAB53Bv?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63fb6e18-24ef-4bcb-9204-08d94520e772 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2021 10:36:27.6091 (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: ey0qoK478e0lNubzTY3znFffR/xdnho4yO3Gu7Tc3us1ttgh5lD1j11qaam5wA1A7QjT6yxsGEBY4OhRVTb5VA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4584 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10042 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 bulkscore=0 mlxscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107120082 X-Proofpoint-GUID: p4T2lZTRwDfDUwqJ4rDvsV-F_qW17PlZ X-Proofpoint-ORIG-GUID: p4T2lZTRwDfDUwqJ4rDvsV-F_qW17PlZ 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: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_BL=0.01, RCVD_IN_MSPIKE_L3=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, marcandre.lureau@redhat.com, jonah.palmer@oracle.com, thuth@redhat.com, amit@kernel.org, michael.roth@amd.com, dgilbert@redhat.com, eric.auger@redhat.com, dmitrii.stepanov@cloud.ionos.com, stefanha@redhat.com, kwolf@redhat.com, laurent@vivier.eu, mreitz@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1626086307469100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This new command shows the status of a VirtIODevice (features, endianness and number of virtqueues) Next patch will improve output by decoding feature bits. Signed-off-by: Laurent Vivier Signed-off-by: Jonah Palmer Acked-by: Michael S. Tsirkin --- hw/virtio/virtio-stub.c | 5 ++++ hw/virtio/virtio.c | 50 ++++++++++++++++++++++++++++++++ qapi/virtio.json | 76 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 131 insertions(+) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index d4a88f5..ddb592f 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -12,3 +12,8 @@ VirtioInfoList *qmp_x_debug_query_virtio(Error **errp) { return qmp_virtio_unsupported(errp); } + +VirtioStatus *qmp_x_debug_virtio_status(const char* path, Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index f3fc1bb..222330a 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3896,6 +3896,56 @@ VirtioInfoList *qmp_x_debug_query_virtio(Error **err= p) return list; } =20 +static VirtIODevice *virtio_device_find(const char *path) +{ + VirtIODevice *vdev; + + QTAILQ_FOREACH(vdev, &virtio_list, next) { + DeviceState *dev =3D DEVICE(vdev); + + if (strcmp(dev->canonical_path, path) !=3D 0) { + continue; + } + return vdev; + } + + return NULL; +} + +VirtioStatus *qmp_x_debug_virtio_status(const char* path, Error **errp) +{ + VirtIODevice *vdev; + VirtioStatus *status; + + vdev =3D virtio_device_find(path); + if (vdev =3D=3D NULL) { + error_setg(errp, "Path %s is not a VirtIO device", path); + return NULL; + } + + status =3D g_new0(VirtioStatus, 1); + status->guest_features =3D vdev->guest_features; + status->host_features =3D vdev->host_features; + status->backend_features =3D vdev->backend_features; + status->device_id =3D vdev->device_id; + + switch (vdev->device_endian) { + case VIRTIO_DEVICE_ENDIAN_LITTLE: + status->device_endian =3D VIRTIO_STATUS_ENDIANNESS_LITTLE; + break; + case VIRTIO_DEVICE_ENDIAN_BIG: + status->device_endian =3D VIRTIO_STATUS_ENDIANNESS_BIG; + break; + default: + status->device_endian =3D VIRTIO_STATUS_ENDIANNESS_UNKNOWN; + break; + } + + status->num_vqs =3D virtio_get_num_queues(vdev); + + return status; +} + static const TypeInfo virtio_device_info =3D { .name =3D TYPE_VIRTIO_DEVICE, .parent =3D TYPE_DEVICE, diff --git a/qapi/virtio.json b/qapi/virtio.json index 804adbe..4bd09c9 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -70,3 +70,79 @@ ## =20 { 'command': 'x-debug-query-virtio', 'returns': ['VirtioInfo'] } + +## +# @VirtioStatusEndianness: +# +# Enumeration of endianness for VirtioDevice +# +# Since: 6.1 +## +{ 'enum': 'VirtioStatusEndianness', + 'data': [ 'unknown', 'little', 'big' ] +} + +## +# @VirtioStatus: +# +# @device-id: VirtIODevice status +# +# @device-endian: VirtIODevice device_endian +# +# @guest-features: VirtIODevice guest_features +# +# @host-features: VirtIODevice host_features +# +# @backend-features: VirtIODevice backend_features +# +# @num-vqs: number of VirtIODevice queues +# +# Since: 6.1 +# +## + +{ 'struct': 'VirtioStatus', + 'data': { + 'device-id': 'int', + 'device-endian': 'VirtioStatusEndianness', + 'guest-features': 'uint64', + 'host-features': 'uint64', + 'backend-features': 'uint64', + 'num-vqs': 'uint16' + } +} + +## +# @x-debug-virtio-status: +# +# Return the status of virtio device +# +# @path: QOBject path of the VirtIODevice +# +# Returns: status of the VirtIODevice +# +# Since: 6.1 +# +# Example: +# +# -> { "execute": "x-debug-virtio-status", +# "arguments": { +# "path": "/machine/peripheral-anon/device[3]/virtio-backend" +# } +# } +# <- { "return": { +# "backend-features": 0, +# "guest-features": 5111807911, +# "num-vqs": 3, +# "host-features": 6337593319, +# "device-endian": "little", +# "device-id": 1 +# } +# } +# +## + +{ 'command': 'x-debug-virtio-status', + 'data': { 'path': 'str' }, + 'returns': 'VirtioStatus' +} --=20 1.8.3.1 From nobody Fri Dec 19 06:18:07 2025 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=1626086750; cv=pass; d=zohomail.com; s=zohoarc; b=CnXHUpPMPfEuWNrY824exm/sOwUH/vZuFInBnjAukc0RS5TCrUTDctKvDWvMOrQ719obhiUNjmUxi1/kScwOa2q0Crwfh0jpbn1/nw86DsCkRbJIhoTs7fsbQEigO5cF7dzVDYIRaUJvr3P2/NQLsiYkUBiP0SkfZmHMJOc/o9U= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626086750; 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=aDVTnIMhVqobBL591y8efZa80r2a3h30perjSqL0iqU=; b=VC7xLh5drmiSNJ0oMIGQ9AXndnk9uug25ZwP4/a5/fBmFdXVbIM2pO23bwgG+QsQZeSvEkW/zxsLKknmiZ5lfvd1Wtd06Si90jlDnJAukiM3eptZxRieaGvNnuV6q+hXglNmf26R1P3Z+Gnb2uFapb4HitExP7FpTF1ESadm/ro= 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 1626086750174706.2452028757693; Mon, 12 Jul 2021 03:45:50 -0700 (PDT) Received: from localhost ([::1]:47834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2tRc-0004Ob-SE for importer@patchew.org; Mon, 12 Jul 2021 06:45:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2tJ6-0001nf-6q; Mon, 12 Jul 2021 06:37:00 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:27916) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2tIy-00008z-Uk; Mon, 12 Jul 2021 06:36:58 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16CAVccO021376; Mon, 12 Jul 2021 10:36:44 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 39q35s2bw3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jul 2021 10:36:44 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 16CAabrQ181205; Mon, 12 Jul 2021 10:36:43 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by aserp3020.oracle.com with ESMTP id 39q3c6wn8e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jul 2021 10:36:43 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB4584.namprd10.prod.outlook.com (2603:10b6:510:37::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Mon, 12 Jul 2021 10:36:30 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::c0ec:e3aa:9d8f:61c0]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::c0ec:e3aa:9d8f:61c0%6]) with mapi id 15.20.4308.026; Mon, 12 Jul 2021 10:36:30 +0000 Received: from jonpalme-lnx.us.oracle.com (209.17.40.41) by SN4PR0701CA0019.namprd07.prod.outlook.com (2603:10b6:803:28::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Mon, 12 Jul 2021 10:36:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=aDVTnIMhVqobBL591y8efZa80r2a3h30perjSqL0iqU=; b=OSLpw+dDcxCHRz0IjsEaVvmkNmqe+UY2f4VFlEztpcdSNUnotcGy0s61khenpGq+X8Se /siZX3bw7ERXPsGQppyaHMG7/m8wttsPb+h6i3pr4mCEelznkhOZ7aDFB8jwv+VnBsVI 2s2KyxzBu0BQl47PXzN8PejfkvAaeMKG3Qguuc2G+5decRix+IWgln+JXq3wJj2N1BEa LTYzSobJoqk+WgLn5ayZpIoqyIQtKM9bB572rvEyenYnLC8sFCxS4kC+39wQxHrw/LvX fI50HZL0NZlqfEkhP81QCIqrGj789+VvHu3bWvD9/uNkqxyXfA8aAKiSuGp1PAEwvISM kA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fAV2r08nNEsSzXwtFkYRhkBcVpUDr43Fsh1c4I0qRRwHU+C95H1a7CEHaGOhO3w1yC7p2ANaozX+Q7U0UJ6EVwcTlr5FqmFOhlnhPCinENbRXHBoN7mhuKhchD2nGNmZETGEMWw6t/xGsExYi0vQox0VIf50gU1fUpvbMuQ6/AewpyrLpxBT2h+LZ9hjxl7Q7hYHWL+vyl8CRymLiPRrb83nwK5zsdeUFbvwt7JVL93U05ScacqlxdjBJqZncyaRmUX1ZfYRRiTBLa2xcXqzkjbXgGdMWHkStgqYFKlVXqZDwwCrJf4M/uq/SzHQni+SNS7nUPlTyQeq5ylnHGTT1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aDVTnIMhVqobBL591y8efZa80r2a3h30perjSqL0iqU=; b=Fi0U7xTIEDqCXDxaOb4w4lLVCbb80spd4FMUNFoT5D0+Chs70kDHdhZVX54U8Fq7tC0RT2M+3RVwbJ0G7ONGOHVQ7reZ/Pp2vxRcoTyGEO0ExXggSoJxWpdISSVtW4x8rSSHVD8HDoJNFkqlSMk59/cew9l7+AWQKqsen8guJR/WL5/RGsMR8Stp2EM4RrU9B99epJUzEFbgoFXEL2Fsrs5dRhudnX6I5TZp1dpjATvMLv7JYMAnDAnGwwZaioL2nr+e0LNrkGsi4rzAVId2JKqeV6vdTgkiB0uEz2KeeYwHQvegI6KlWhCf39AohFXzbPfTUQjYNQyqTb851Q8v1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aDVTnIMhVqobBL591y8efZa80r2a3h30perjSqL0iqU=; b=QeSuoENWa/XQdjQECpElmN2eMAvzgJZ01QEgBHPbjq54LDXkLimnBrR7WmvkXAzSigKsqevFo9Sll2Avl0Q/nYAr3dRLHbIM4R/uHrWmYnOUwHYGXHuye3vW38Qk6priKbLHjaQdeixW493K/iGnkkKujLB+/uEPzEbtFO1qDQQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v6 3/6] qmp: decode feature bits in virtio-status Date: Mon, 12 Jul 2021 06:35:34 -0400 Message-Id: <1626086137-16292-4-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1626086137-16292-1-git-send-email-jonah.palmer@oracle.com> References: <1626086137-16292-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SN4PR0701CA0019.namprd07.prod.outlook.com (2603:10b6:803:28::29) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c5c366dd-8c8c-40cf-6ec7-08d94520e8e3 X-MS-TrafficTypeDiagnostic: PH0PR10MB4584: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:483; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QKvNTbHMOE/vusR5TNBWB3yJZfdOO5gDX+/MvBJoGRmXnLxUVhhZMCiKzdEf6ybmahZ8p6lpGZUNWzvkgB39ZJ8QDLvmkKzJk226QkxHGDzcvwN/HbVN1i8qISSnlKv/EmTca5oqd6UKOTv3pJT15/h2dLbU8TZWSjNcAhAR/mIwp27hlL50RuSEQM8h1BOG2po4Tq43zQygyFHKrth+98fpnrFpr2/Vpzz8g2ZqM/ppkFBjkWgjuT5P5L+nP4d5jrZGq8DLUKBSfo/4NpMdWotHwk+cWnD36LVdDxtD5E73UdUD+9N6N9sUnLq/4lLhrJpjtDzZ3o/TL67Nai/oE6BIunu16+tbJlTSivD8stGMpzhKmJU4MU4wN8tP7+dYsEuXMTFSjWFC5FfBVoE0QAaQNMqyTtXA1XrlLB1SeCpGBZA/frw/534ajWTJBA04v4tbjGBaZVlwt2vxWv8MoWFHXi2uLgij4nZd93YJybksDSxOjyAAIZtS1bq5MTV8hA3Ap7kBSNWeU3POfwkornYrxm0JWoyrDMuGAToGSuHwy1ym7JJZVzpr2ybuw7u2DzshYr6ovGEbP7hpwLJtrtTvD6dS821txGfKwAFWhJRZz4E/gigQT/g3r0Id+8tfnCjGSPwRBMxKfcJX6Zf9ko/EaGBZlc7lqT3UUWngopEzsMWgyaPli2G0crmW1OweSeuTMO4w3HUzRKhFI7mc5A== 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)(346002)(136003)(396003)(39860400002)(376002)(36756003)(6916009)(66476007)(66946007)(186003)(66556008)(6486002)(478600001)(30864003)(83380400001)(6666004)(7416002)(52116002)(8676002)(2616005)(8936002)(86362001)(2906002)(44832011)(38350700002)(38100700002)(26005)(7696005)(956004)(4326008)(316002)(5660300002)(107886003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Hv2gACZXKQt764AGt+/WGTV8DQOiKjpMJxtJv8Abp1jXMO6F8HwZ1XG1nk2g?= =?us-ascii?Q?59ecMJTJvSiIhYdlGSZ7/30h+4qdkgVaO+TfywO8uQVATQPe3s4HDJ7v3jaT?= =?us-ascii?Q?2/NU2+RlTDgkoD66zXjpiEARPgePLheI2D0JpSGLxsNMJo0MjnfOTaYKRWdj?= =?us-ascii?Q?9zyWf6EJ4JcgtOEgHsUmxIZD5KVvdaacq25hEvtQB6itKsehv4Dmv0Srk8Ch?= =?us-ascii?Q?JvnA2ZSfxgODUMfwXb9ZvGGO8712DXVCmGjZjOsYC8Vgdas+FglZRokqq6sG?= =?us-ascii?Q?C2ST2r69KNphcSimcVs1rA/mWFdvf68OHG5kMaeZaRmt0R2NuKu0txDesJC8?= =?us-ascii?Q?t+fDhb3nptyhe39F1uAvQ24yBN+OhOPau1wwEqwaNUsoVfvORdYH/a5ERumg?= =?us-ascii?Q?nv5CQk3ndC4wz1AI4bY6KSQAbnHQu4/h9JZ+OOcr89sk/Pl6ifuUODfNQCLY?= =?us-ascii?Q?Sj7VPdyRP0poTSFjlcoX3120IbPlzbhjZZyBURwTA9LFUdfvJzC+S2Q4hcpT?= =?us-ascii?Q?+MBguBDxmcVV1+ffeiZsGJsWSUcZDRGGQO/1tq5X40ChH2URff60BBFOEISj?= =?us-ascii?Q?OxtklwFRUVwujJL43A3uy14txe0+gY1vaOjFEo4w8HTQCU6Us/723W4sbJ6V?= =?us-ascii?Q?FJrG7AEXL0C+oOXQ9AtPGP+MH1QKrZtnuPYhOSpEBXfEcwETTg/6IKXTaNvQ?= =?us-ascii?Q?/VGKsJqXNBE8N9C2lbjLeAGAOyYiZMk41lMqe1r3FnIr+vtNTNDVvnAPIOBM?= =?us-ascii?Q?TBSD176q9T9MLe6nfH6oa8N+wcvisD87aBKAbVBnkG5yqst1hrUYlRh9wHuZ?= =?us-ascii?Q?1e7h/VUfV2UNJTuMuU4VtafWrpP1xFGL5DqbBK3GJJFBUKRkieTfPD3S+NVh?= =?us-ascii?Q?wjpvf/YGp1Bkh3yIoXIDCGmPvEq/K5cHTsyMjSdp2ddKF+bgOxZvy7bre5Ar?= =?us-ascii?Q?7oB8prQ7kwTVJITeolIqHD1mDcQpz9vzxHoGDlLAi0QH9QPhJPviTntjGpCr?= =?us-ascii?Q?MniUI20ngI0KC0WwMkozMB569Bo1citm3tJEUn1HDxBRFLVW8iMzLmtcQMEs?= =?us-ascii?Q?VHj9MbLGB7FoMmlJ4GonqYuUFO9jqxBFKcFeqePMJZia5JQnYq3JHvAqSCc4?= =?us-ascii?Q?p8m3+O7qxdm5bmu3a2Azi5+uzoCBirCJ1YDI+4sFtbvkq+rYEhbv1/hdqsCx?= =?us-ascii?Q?+MehCopNQkx9We+quvheg/8X/jRQxJZ10XrR8TibLp9r3uH4Cr5lUk5EAiwg?= =?us-ascii?Q?Fx79YCd0rwu3YqUPXKy5jTxVFs7c7qAhOTI2nAPj/wtxiqeq9d3vYk7Mfihw?= =?us-ascii?Q?F6hLWan094zGmW2xDPPY6vvl?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c5c366dd-8c8c-40cf-6ec7-08d94520e8e3 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2021 10:36:29.9897 (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: yam57dzSysf371XSzgKwtT8EoNu+Wec3MnwuaSnhrrhHCfEnwRuspT1HzwpkP460U4bwh9uONuU4JoLoxCdq9Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4584 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10042 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 suspectscore=0 phishscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107120082 X-Proofpoint-GUID: 2ZAUgQtPApaQhmp3iAa350IJt7uvOQEV X-Proofpoint-ORIG-GUID: 2ZAUgQtPApaQhmp3iAa350IJt7uvOQEV 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: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_BL=0.01, RCVD_IN_MSPIKE_L3=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, marcandre.lureau@redhat.com, jonah.palmer@oracle.com, thuth@redhat.com, amit@kernel.org, michael.roth@amd.com, dgilbert@redhat.com, eric.auger@redhat.com, dmitrii.stepanov@cloud.ionos.com, stefanha@redhat.com, kwolf@redhat.com, laurent@vivier.eu, mreitz@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1626086750871100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier Display feature names instead of a features bitmap for host, guest, and backend. Decode features according to device type, transport features are on the first line. Undecoded bits (if any) are stored in a separate field. Signed-off-by: Laurent Vivier Signed-off-by: Jonah Palmer Acked-by: Michael S. Tsirkin --- hw/block/virtio-blk.c | 23 ++++ hw/char/virtio-serial-bus.c | 11 ++ hw/display/virtio-gpu-base.c | 12 ++ hw/net/virtio-net.c | 38 ++++++ hw/scsi/virtio-scsi.c | 12 ++ hw/virtio/virtio-balloon.c | 14 +++ hw/virtio/virtio-iommu.c | 14 +++ hw/virtio/virtio.c | 129 +++++++++++++++++++- include/hw/virtio/virtio.h | 13 ++ qapi/virtio.json | 280 +++++++++++++++++++++++++++++++++++++++= ++-- 10 files changed, 533 insertions(+), 13 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index f139cd7..e66c5eb 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -13,6 +13,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/iov.h" #include "qemu/module.h" #include "qemu/error-report.h" @@ -48,6 +49,28 @@ static const VirtIOFeature feature_sizes[] =3D { {} }; =20 +qmp_virtio_feature_map_t blk_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_BLK_F_##name, VIRTIO_BLK_FEATURE_##name } + FEATURE_ENTRY(SIZE_MAX), + FEATURE_ENTRY(SEG_MAX), + FEATURE_ENTRY(GEOMETRY), + FEATURE_ENTRY(RO), + FEATURE_ENTRY(BLK_SIZE), + FEATURE_ENTRY(TOPOLOGY), + FEATURE_ENTRY(MQ), + FEATURE_ENTRY(DISCARD), + FEATURE_ENTRY(WRITE_ZEROES), +#ifndef VIRTIO_BLK_NO_LEGACY + FEATURE_ENTRY(BARRIER), + FEATURE_ENTRY(SCSI), + FEATURE_ENTRY(FLUSH), + FEATURE_ENTRY(CONFIG_WCE), +#endif /* !VIRTIO_BLK_NO_LEGACY */ +#undef FEATURE_ENTRY + { -1, -1 } +}; + static void virtio_blk_set_config_size(VirtIOBlock *s, uint64_t host_featu= res) { s->config_size =3D MAX(VIRTIO_BLK_CFG_SIZE, diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index dd6bc27..4a626e6 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, VIRTIO_SERIAL_FEATURE_##name } + FEATURE_ENTRY(SIZE), + FEATURE_ENTRY(MULTIPORT), + FEATURE_ENTRY(EMERG_WRITE), +#undef FEATURE_ENTRY + { -1, -1 } +}; + static struct VirtIOSerialDevices { QLIST_HEAD(, VirtIOSerial) devices; } vserdevices; diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index dd29427..34c1ead 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -16,9 +16,21 @@ #include "hw/virtio/virtio-gpu.h" #include "migration/blocker.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/error-report.h" #include "trace.h" =20 +qmp_virtio_feature_map_t gpu_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_GPU_F_##name, VIRTIO_GPU_FEATURE_##name } + FEATURE_ENTRY(VIRGL), + FEATURE_ENTRY(EDID), + FEATURE_ENTRY(RESOURCE_UUID), + FEATURE_ENTRY(RESOURCE_BLOB), +#undef FEATURE_ENTRY + { -1, -1 } +}; + void virtio_gpu_base_reset(VirtIOGPUBase *g) { diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 16d20cd..0a05fe6 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -35,6 +35,7 @@ #include "hw/qdev-properties.h" #include "qapi/qapi-types-migration.h" #include "qapi/qapi-events-migration.h" +#include "qapi/qapi-visit-virtio.h" #include "hw/virtio/virtio-access.h" #include "migration/misc.h" #include "standard-headers/linux/ethtool.h" @@ -89,6 +90,43 @@ VIRTIO_NET_RSS_HASH_TYPE_TCP_EX |= \ VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) =20 +qmp_virtio_feature_map_t net_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_NET_F_##name, VIRTIO_NET_FEATURE_##name } + FEATURE_ENTRY(CSUM), + FEATURE_ENTRY(GUEST_CSUM), + FEATURE_ENTRY(CTRL_GUEST_OFFLOADS), + FEATURE_ENTRY(MTU), + FEATURE_ENTRY(MAC), + FEATURE_ENTRY(GUEST_TSO4), + FEATURE_ENTRY(GUEST_TSO6), + FEATURE_ENTRY(GUEST_ECN), + FEATURE_ENTRY(GUEST_UFO), + FEATURE_ENTRY(HOST_TSO4), + FEATURE_ENTRY(HOST_TSO6), + FEATURE_ENTRY(HOST_ECN), + FEATURE_ENTRY(HOST_UFO), + FEATURE_ENTRY(MRG_RXBUF), + FEATURE_ENTRY(STATUS), + FEATURE_ENTRY(CTRL_VQ), + FEATURE_ENTRY(CTRL_RX), + FEATURE_ENTRY(CTRL_VLAN), + FEATURE_ENTRY(CTRL_RX_EXTRA), + FEATURE_ENTRY(GUEST_ANNOUNCE), + FEATURE_ENTRY(MQ), + FEATURE_ENTRY(CTRL_MAC_ADDR), + FEATURE_ENTRY(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 + { -1, -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 6d80730..8187dc3 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -15,6 +15,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "standard-headers/linux/virtio_ids.h" #include "hw/virtio/virtio-scsi.h" #include "migration/qemu-file-types.h" @@ -29,6 +30,17 @@ #include "hw/virtio/virtio-access.h" #include "trace.h" =20 +qmp_virtio_feature_map_t scsi_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_SCSI_F_##name, VIRTIO_SCSI_FEATURE_##name } + FEATURE_ENTRY(INOUT), + FEATURE_ENTRY(HOTPLUG), + FEATURE_ENTRY(CHANGE), + FEATURE_ENTRY(T10_PI), +#undef FEATURE_ENTRY + { -1, -1 } +}; + static inline int virtio_scsi_get_lun(uint8_t *lun) { return ((lun[2] << 8) | lun[3]) & 0x3FFF; diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 4b5d9e5..4bc05de 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -27,6 +27,7 @@ #include "qapi/error.h" #include "qapi/qapi-events-machine.h" #include "qapi/visitor.h" +#include "qapi/qapi-visit-virtio.h" #include "trace.h" #include "qemu/error-report.h" #include "migration/misc.h" @@ -34,6 +35,19 @@ #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" =20 +qmp_virtio_feature_map_t balloon_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_BALLOON_F_##name, VIRTIO_BALLOON_FEATURE_##name } + FEATURE_ENTRY(MUST_TELL_HOST), + FEATURE_ENTRY(STATS_VQ), + FEATURE_ENTRY(DEFLATE_ON_OOM), + FEATURE_ENTRY(FREE_PAGE_HINT), + FEATURE_ENTRY(PAGE_POISON), + FEATURE_ENTRY(REPORTING), +#undef FEATURE_ENTRY + { -1, -1 } +}; + #define BALLOON_PAGE_SIZE (1 << VIRTIO_BALLOON_PFN_SHIFT) =20 typedef struct PartiallyBalloonedPage { diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 1b23e8e..6deddcb 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -25,6 +25,7 @@ #include "hw/virtio/virtio.h" #include "sysemu/kvm.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/error-report.h" #include "trace.h" =20 @@ -36,6 +37,19 @@ #include "hw/pci/pci_bus.h" #include "hw/pci/pci.h" =20 +qmp_virtio_feature_map_t iommu_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_IOMMU_F_##name, VIRTIO_IOMMU_FEATURE_##name } + FEATURE_ENTRY(INPUT_RANGE), + FEATURE_ENTRY(DOMAIN_RANGE), + FEATURE_ENTRY(MAP_UNMAP), + FEATURE_ENTRY(BYPASS), + FEATURE_ENTRY(PROBE), + FEATURE_ENTRY(MMIO), +#undef FEATURE_ENTRY + { -1, -1 } +}; + /* Max size */ #define VIOMMU_DEFAULT_QUEUE_SIZE 256 #define VIOMMU_PROBE_SIZE 512 diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 222330a..81a0ee8 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -30,9 +30,32 @@ #include "sysemu/dma.h" #include "sysemu/runstate.h" #include "standard-headers/linux/virtio_ids.h" +#include CONFIG_DEVICES =20 static QTAILQ_HEAD(, VirtIODevice) virtio_list; =20 +static qmp_virtio_feature_map_t transport_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_F_##name, VIRTIO_TRANSPORT_FEATURE_##name } +#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), + FEATURE_ENTRY(BAD_FEATURE), +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VIRTIO_RING_F_##name, VIRTIO_TRANSPORT_FEATURE_##name } + FEATURE_ENTRY(INDIRECT_DESC), + FEATURE_ENTRY(EVENT_IDX), +#undef FEATURE_ENTRY + { -1, -1 } +}; + /* * The alignment to use between consumer and producer parts of vring. * x86 pagesize again. This is the default, used by transports like PCI @@ -3912,6 +3935,103 @@ static VirtIODevice *virtio_device_find(const char = *path) return NULL; } =20 +#define CONVERT_FEATURES(type, map) \ + ({ \ + type *list =3D NULL; \ + type *node; \ + for (i =3D 0; map[i].virtio_bit !=3D -1; i++) {\ + bit =3D 1ULL << map[i].virtio_bit; \ + if ((bitmap & bit) =3D=3D 0) { \ + continue; \ + } \ + node =3D g_new0(type, 1); \ + node->value =3D map[i].qapi_virtio_enum; \ + node->next =3D list; \ + list =3D node; \ + bitmap ^=3D bit; \ + } \ + list; \ + }) + +static VirtioDeviceFeatures *qmp_decode_features(const char *name, + uint64_t bitmap) +{ + VirtioDeviceFeatures *features; + uint64_t bit; + int i; + + features =3D g_new0(VirtioDeviceFeatures, 1); + + /* transport features */ + features->transport =3D CONVERT_FEATURES(VirtioTransportFeatureList, \ + transport_map); + + /* device features */ + features->type =3D qapi_enum_parse(&VirtioType_lookup, + name, -1, NULL); + switch (features->type) { +#ifdef CONFIG_VIRTIO_SERIAL + case VIRTIO_TYPE_VIRTIO_SERIAL: + features->u.virtio_serial.features =3D + CONVERT_FEATURES(VirtioSerialFeatureList, serial= _map); + break; +#endif +#ifdef CONFIG_VIRTIO_BLK + case VIRTIO_TYPE_VIRTIO_BLK: + features->u.virtio_blk.features =3D + CONVERT_FEATURES(VirtioBlkFeatureList, blk= _map); + break; +#endif +#ifdef CONFIG_VIRTIO_GPU + case VIRTIO_TYPE_VIRTIO_GPU: + features->u.virtio_gpu.features =3D + CONVERT_FEATURES(VirtioGpuFeatureList, gpu= _map); + break; +#endif +#ifdef CONFIG_VIRTIO_NET + case VIRTIO_TYPE_VIRTIO_NET: + features->u.virtio_net.features =3D + CONVERT_FEATURES(VirtioNetFeatureList, net= _map); + break; +#endif +#ifdef CONFIG_VIRTIO_SCSI + case VIRTIO_TYPE_VIRTIO_SCSI: + features->u.virtio_scsi.features =3D + CONVERT_FEATURES(VirtioScsiFeatureList, scsi= _map); + break; +#endif +#ifdef CONFIG_VIRTIO_BALLOON + case VIRTIO_TYPE_VIRTIO_BALLOON: + features->u.virtio_balloon.features =3D + CONVERT_FEATURES(VirtioBalloonFeatureList, balloon= _map); + break; +#endif +#ifdef CONFIG_VIRTIO_IOMMU + case VIRTIO_TYPE_VIRTIO_IOMMU: + features->u.virtio_iommu.features =3D + CONVERT_FEATURES(VirtioIommuFeatureList, iommu= _map); + break; +#endif + /* No features */ + case VIRTIO_TYPE_VIRTIO_9P: + case VIRTIO_TYPE_VIRTIO_INPUT: + case VIRTIO_TYPE_VHOST_USER_FS: + case VIRTIO_TYPE_VHOST_VSOCK: + case VIRTIO_TYPE_VIRTIO_CRYPTO: + case VIRTIO_TYPE_VIRTIO_PMEM: + case VIRTIO_TYPE_VIRTIO_RNG: + break; + default: + g_assert_not_reached(); + } + features->has_unknown_features =3D bitmap !=3D 0; + if (features->has_unknown_features) { + features->unknown_features =3D bitmap; + } + + return features; +} + VirtioStatus *qmp_x_debug_virtio_status(const char* path, Error **errp) { VirtIODevice *vdev; @@ -3924,9 +4044,12 @@ VirtioStatus *qmp_x_debug_virtio_status(const char* = path, Error **errp) } =20 status =3D g_new0(VirtioStatus, 1); - status->guest_features =3D vdev->guest_features; - status->host_features =3D vdev->host_features; - status->backend_features =3D vdev->backend_features; + status->guest_features =3D qmp_decode_features(vdev->name, + vdev->guest_features); + status->host_features =3D qmp_decode_features(vdev->name, + vdev->host_features); + status->backend_features =3D qmp_decode_features(vdev->name, + vdev->backend_features); status->device_id =3D vdev->device_id; =20 switch (vdev->device_endian) { diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index f7da326..b872dcf 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -163,6 +163,19 @@ struct VirtioDeviceClass { bool (*primary_unplug_pending)(void *opaque); }; =20 +typedef struct { + int virtio_bit; + int qapi_virtio_enum; +} qmp_virtio_feature_map_t; + +extern qmp_virtio_feature_map_t serial_map[]; +extern qmp_virtio_feature_map_t blk_map[]; +extern qmp_virtio_feature_map_t gpu_map[]; +extern qmp_virtio_feature_map_t net_map[]; +extern qmp_virtio_feature_map_t scsi_map[]; +extern qmp_virtio_feature_map_t balloon_map[]; +extern qmp_virtio_feature_map_t iommu_map[]; + void virtio_instance_init_common(Object *proxy_obj, void *data, size_t vdev_size, const char *vdev_name); =20 diff --git a/qapi/virtio.json b/qapi/virtio.json index 4bd09c9..78873cd 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -83,6 +83,253 @@ } =20 ## +# @VirtioTransportFeature: +# +# An enumeration of Virtio device transport features, including virtio-ring +# +# Since: 6.1 +## + +{ 'enum': 'VirtioTransportFeature', + 'data': [ 'notify-on-empty', 'any-layout', 'version-1', 'iommu-platform', + 'ring-packed', 'order-platform', 'sr-iov', 'indirect-desc', + 'event-idx', 'bad-feature' ] +} + +## +# @VirtioSerialFeature: +# +# An enumeration of Virtio serial features +# +# Since: 6.1 +## + +{ 'enum': 'VirtioSerialFeature', + 'data': [ 'size', 'multiport', 'emerg-write' ] +} + +## +# @VirtioBlkFeature: +# +# An enumeration of Virtio block features +# +# Since: 6.1 +## + +{ 'enum': 'VirtioBlkFeature', + 'data': [ 'size-max', 'seg-max', 'geometry', 'ro', 'blk-size', 'topology= ', + 'mq', 'discard', 'write-zeroes', 'barrier', 'scsi', 'flush', + 'config-wce' ] +} + +## +# @VirtioGpuFeature: +# +# An enumeration of Virtio gpu features +# +# Since: 6.1 +## + +{ 'enum': 'VirtioGpuFeature', + 'data': [ 'virgl', 'edid', 'resource-uuid', 'resource-blob' ] +} + +## +# @VirtioNetFeature: +# +# An enumeration of Virtio net features +# +# Since: 6.1 +## + +{ 'enum': 'VirtioNetFeature', + 'data': [ 'csum', 'guest-csum', 'ctrl-guest-offloads', 'mtu', 'mac', + 'guest-tso4', 'guest-tso6', 'guest-ecn', 'guest-ufo', + 'host-tso4', 'host-tso6', 'host-ecn', 'host-ufo', 'mrg-rxbuf', + 'status', 'ctrl-vq', 'ctrl-rx', 'ctrl-vlan', 'ctrl-rx-extra', + 'guest-announce', 'mq', 'ctrl-mac-addr', 'standby', + 'speed-duplex', 'gso', 'hash-report', 'rss', 'rsc-ext' ] +} + +## +# @VirtioScsiFeature: +# +# An enumeration of Virtio scsi features +# +# Since: 6.1 +## + +{ 'enum': 'VirtioScsiFeature', + 'data': [ 'inout', 'hotplug', 'change', 't10-pi' ] +} + +## +# @VirtioBalloonFeature: +# +# An enumeration of Virtio balloon features +# +# Since: 6.1 +## + +{ 'enum': 'VirtioBalloonFeature', + 'data': [ 'must-tell-host', 'stats-vq', 'deflate-on-oom', 'free-page-hin= t', + 'page-poison', 'reporting' ] +} + +## +# @VirtioIommuFeature: +# +# An enumeration of Virtio iommu features +# +# Since: 6.1 +## + +{ 'enum': 'VirtioIommuFeature', + 'data': [ 'input-range', 'domain-range', 'map-unmap', 'bypass', 'probe', + 'mmio' ] +} + +## +# @VirtioDeviceFeaturesBase: +# +# The common fields that apply to all Virtio devices +# +# @type: virtio device type +# @transport: the list of transport features of the virtio device +# @unknown-features: virtio device features bitmap that have not been deco= ded +# +# Since: 6.1 +## + +{ 'struct': 'VirtioDeviceFeaturesBase', + 'data': { + 'type': 'VirtioType', + 'transport': [ 'VirtioTransportFeature' ], + '*unknown-features': 'uint64' + } +} + +## +# @VirtioDeviceFeaturesOptionsSerial: +# +# The options that apply to Virtio serial device +# +# @features: List of the device features +# +# Since: 6.1 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsSerial', + 'data': { 'features': [ 'VirtioSerialFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsBlk: +# +# The options that apply to Virtio block device +# +# @features: List of the device features +# +# Since: 6.1 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsBlk', + 'data': { 'features': [ 'VirtioBlkFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsGpu: +# +# The options that apply to Virtio GPU device +# +# @features: List of the device features +# +# Since: 6.1 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsGpu', + 'data': { 'features': [ 'VirtioGpuFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsNet: +# +# The options that apply to Virtio net device +# +# @features: List of the device features +# +# Since: 6.1 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsNet', + 'data': { 'features': [ 'VirtioNetFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsScsi: +# +# The options that apply to Virtio SCSI device +# +# @features: List of the device features +# +# Since: 6.1 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsScsi', + 'data': { 'features': [ 'VirtioScsiFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsBalloon: +# +# The options that apply to Virtio balloon device +# +# @features: List of the device features +# +# Since: 6.1 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsBalloon', + 'data': { 'features': [ 'VirtioBalloonFeature' ] } +} + +## +# @VirtioDeviceFeaturesOptionsIommu: +# +# The options that apply to Virtio IOMMU device +# +# @features: List of the device features +# +# Since: 6.1 +## + +{ 'struct': 'VirtioDeviceFeaturesOptionsIommu', + 'data': { 'features': [ 'VirtioIommuFeature' ] } +} + +## +# @VirtioDeviceFeatures: +# +# A union to define the list of features for a virtio device +# +# Since: 6.1 +## + +{ 'union': 'VirtioDeviceFeatures', + 'base': 'VirtioDeviceFeaturesBase', + 'discriminator': 'type', + 'data': { + 'virtio-serial': 'VirtioDeviceFeaturesOptionsSerial', + 'virtio-blk': 'VirtioDeviceFeaturesOptionsBlk', + 'virtio-gpu': 'VirtioDeviceFeaturesOptionsGpu', + 'virtio-net': 'VirtioDeviceFeaturesOptionsNet', + 'virtio-scsi': 'VirtioDeviceFeaturesOptionsScsi', + 'virtio-balloon': 'VirtioDeviceFeaturesOptionsBalloon', + 'virtio-iommu': 'VirtioDeviceFeaturesOptionsIommu' + } +} + +## # @VirtioStatus: # # @device-id: VirtIODevice status @@ -105,9 +352,9 @@ 'data': { 'device-id': 'int', 'device-endian': 'VirtioStatusEndianness', - 'guest-features': 'uint64', - 'host-features': 'uint64', - 'backend-features': 'uint64', + 'guest-features': 'VirtioDeviceFeatures', + 'host-features': 'VirtioDeviceFeatures', + 'backend-features': 'VirtioDeviceFeatures', 'num-vqs': 'uint16' } } @@ -127,18 +374,31 @@ # # -> { "execute": "x-debug-virtio-status", # "arguments": { -# "path": "/machine/peripheral-anon/device[3]/virtio-backend" +# "path": "/machine/peripheral-anon/device[1]/virtio-backend" # } # } # <- { "return": { -# "backend-features": 0, -# "guest-features": 5111807911, -# "num-vqs": 3, -# "host-features": 6337593319, # "device-endian": "little", -# "device-id": 1 +# "device-id": 3, +# "backend-features": { +# "transport": [], +# "type": "virtio-serial", +# "features": [] +# }, +# "num-vqs": 64, +# "guest-features": { +# "transport": [ "event-idx", "indirect-desc", "version-1" ], +# "type": "virtio-serial", +# "features": [ "multiport" ] +# }, +# "host-features": { +# "transport": [ "event-idx", "indirect-desc", "bad-feature", +# "version-1", "any-layout", "notify-on-empty"= ], +# "type": "virtio-serial", +# "features": [ "emerg-write", "multiport" ] +# } # } -# } +# } # ## =20 --=20 1.8.3.1 From nobody Fri Dec 19 06:18:07 2025 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=1626086449; cv=pass; d=zohomail.com; s=zohoarc; b=D8uN8WEYqMGehsLUccgGiH94icwQVb34SFvXVILLYJWrsM4z0V2+ikQsDz0RO06XE30srmqYpDOKczc/rDu6E7V0Ot0U8NoAcVbeuCR0d1d/3i/giNbNYFwlh8MjybFsNl8vmwHk1f5wX4LH6sseKcBkVA+T1KNmsWCb/xJnsv4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626086449; 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=dUDhwEyPAjmD/cBYeorGq6OTH0rEjCWg3QMtIOO2GrU=; b=Wyd3yJPLIFa9LVhdXB5dCfm0tYBm6Hx3VSXeylIJGeTobYwwVZdzB1HRBxKFKLtT+cmnh6OFOA42bOVwFyFiW4BYeO+jEJeUfo3D6eOgXkEdP8mJIs4ojrnlEMo1H25rtMBeOskoIFi6W1U96L0WjZd6XjwQSLDQ3oWG+jC3P4w= 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 162608644981449.302477421042454; Mon, 12 Jul 2021 03:40:49 -0700 (PDT) Received: from localhost ([::1]:39554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2tMm-00077w-M4 for importer@patchew.org; Mon, 12 Jul 2021 06:40:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2tIs-0001aS-7X; Mon, 12 Jul 2021 06:36:46 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:17782) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2tIp-0008US-VN; Mon, 12 Jul 2021 06:36:45 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16CAVunf029748; Mon, 12 Jul 2021 10:36:36 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 39q2b2jcn1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jul 2021 10:36:36 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 16CAaQTC067272; Mon, 12 Jul 2021 10:36:35 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2175.outbound.protection.outlook.com [104.47.73.175]) by userp3030.oracle.com with ESMTP id 39q0nyse56-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jul 2021 10:36:34 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB4552.namprd10.prod.outlook.com (2603:10b6:510:42::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Mon, 12 Jul 2021 10:36:32 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::c0ec:e3aa:9d8f:61c0]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::c0ec:e3aa:9d8f:61c0%6]) with mapi id 15.20.4308.026; Mon, 12 Jul 2021 10:36:32 +0000 Received: from jonpalme-lnx.us.oracle.com (209.17.40.41) by SN4PR0701CA0019.namprd07.prod.outlook.com (2603:10b6:803:28::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Mon, 12 Jul 2021 10:36:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=dUDhwEyPAjmD/cBYeorGq6OTH0rEjCWg3QMtIOO2GrU=; b=rq+j09jJMIV8dzRQTEd7DpZ8MPv57r6fYYWN4O+HWlQqYUi6sKI2wXA3z4V/K3rx9scC k4VutuQ+8zQBEHxCQex5mAhW3VQNAp3sCFJngzCJjoI/ypnZ3OfRALYAewzuubAd4nnl Yl/j8R7BBSAkKgPyCXn3ZXow1cgmdBIIs99pfkO7QeTq94jZnQaQKZ/LZ4lZGuk9+yZX 0O0Wps41ReOQ+AbGklqcE10XJzfWHU000/HnoZgneGmj1gChfFUPM5KM/KwnNiD+7BTM cl3RmEfLUvFr+6K9D/8WwYACY//W3wcg+tW+/ubo4hXcwnLPqG6aqCZNesA2geEuaDxu Jg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RW7fT3ldcjs8iYu2485IJ6xyCf4esYw1B5V0UOplyPLxqpIzX4xo0J/ivDKfJZqvbcaI5fD26aZZ54c6qQ3XpcDpGOhE7aMZRaY9zVrLs333y1uE8ouZb7uEbIvRk+Ur5rLJvHHNcu91B2wwwVPwfJyNJ3cmeUC0J6JQudaNBKwILLlB5n5wxj+XbHjM50iSI2KhK9dHEZrl9WZGYP6Z+cksnyeC05mq25m/3SvuI4ACRxLGdmI8q1Qh+ogq02waFve9E1kIVWsrHn8Mn3HuTBHjdIjjjiY4qQs7Vs2vDFKrTi8aL57Z3blE/dFDSwDwuW8nEfAVMHs8IkFUVoagww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dUDhwEyPAjmD/cBYeorGq6OTH0rEjCWg3QMtIOO2GrU=; b=j9fXL0/qwRGPMbBnBima8I1Lvwuxb2QsVFnfmulYbnSfinYlFTxmnJVD1yjUEJjdoKT9ka3oW74Ua8YmydfoPTlvruSs+joxGCJgaQqRtnfKHIs29udFMplh6Mz5VPxd12PFw7qyumCi8/aECWD6VqYNEUeapTmcb4hnOftgoz/sc6OwX76zmwriqEneB9Z7Vr6xodBIGC90b32Bga35TlZTZ/OG//gqw1CdaKzUFMNI4f9WGMzNXovvHwJm755ctOS5Axxup2Gj1jpJTHRx+U88nScSul66+qF+n2fQQ30Q+33obegPztjnVT1trdlzpAyNFAbYfgIIpsV17hcFQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dUDhwEyPAjmD/cBYeorGq6OTH0rEjCWg3QMtIOO2GrU=; b=Xlsp+8Z6yDAmpJLO4lK/pgpBjlWEW2G7+0k9+4cCkFEZ9mfmuUgHVHZqJIY0Rk7rOC6MdOU9WxuT+rC5tqSFHDyVcwz+yvct5jBXkdZJY571iDRdcIMfZzZI7cjSvnRVFYf6P0MRiu0XTKcgT0XVK0gkPk+eMlNc2YPx+COY4RU= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v6 4/6] qmp: add QMP command x-debug-virtio-queue-status Date: Mon, 12 Jul 2021 06:35:35 -0400 Message-Id: <1626086137-16292-5-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1626086137-16292-1-git-send-email-jonah.palmer@oracle.com> References: <1626086137-16292-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SN4PR0701CA0019.namprd07.prod.outlook.com (2603:10b6:803:28::29) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 86477d9a-16ae-4fe4-f079-08d94520ea4b X-MS-TrafficTypeDiagnostic: PH0PR10MB4552: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2399; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eSxYwe3PscsjwLUdBjO1c0EJzEOj8alBa9a54Fa9ts4f8jplbeTJtyyXUx2c8qrbu1OmQVMKQA8uEL5HvvzNWBlznDAIGOcAvkU36HHTb3lXTD9JnrAQEHFUj0a0xedhsosUEa2Qj810v+pFLHWPN6XsY/gBMSuzC0N4Osiu97TdNy0icwK/KISEV7OT3/RMXerImcTJcBWPtvnMmu+AIUruqAWq9B658etjUA8bhDzV0eq7nUGOzpRXB5K9vBj64wr0glQTDyEpmcPoUBZeWG2wgxgnHfQhGGcdPJtN/e9nZ0++K8dV5oFDj3oWJdknwSfMJL3uI71qECZsFKN/dBWSpCO10zqHW+RQnEmCGpWUUv+/CO7B+HV+M3jgiOt0lttGPue2BvIuNrZ6gIcCobvFjKlmfBz750i5gWTyanc28iwfyC8pWVmpp6pRxqXbaW7v/y9OBh35LBnyjMsSrBjf5WykpbKFuJWN61oyJq0F7rF7/uJ66yUGwblgQ57t4y1oaE0WBFeXq/EYNjI9V/y/9ns0TyyHqUjTF/jLXhkhyAaoIb7eR3BC8Ayc376lbBNG64wT2B/W7c8cd3VEQZPNUgZYydGO56pWfTbD0Ue/YmEpTlTpAcDqKtaV/yxJp0ODATuitwAhzbIqr3sNfCWzJjTTnUYh93F0TNiVWO6OOp3C0fAvsKuNrizVxtczcMJm529TUHzmwdyqHba2oQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR10MB4664.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(39860400002)(346002)(366004)(136003)(376002)(7416002)(956004)(6486002)(7696005)(2616005)(186003)(316002)(36756003)(4326008)(2906002)(8936002)(52116002)(86362001)(107886003)(66476007)(66946007)(44832011)(66556008)(6916009)(38100700002)(5660300002)(8676002)(38350700002)(478600001)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?s3tARezmQsUYSu4GCLOvX7193t4/sxDr/LSiQWa7nCps6j+eutCmUTQnFa6S?= =?us-ascii?Q?6RmH61iXWX3cwbRYnvXzKmbHlL/Ls4Htb+gMlLM0LvmS0V6bzHi1Rhv+4HPp?= =?us-ascii?Q?OCRM0xFbCVkzAnmxQTdrDyLfxfjxu3jcKfdLqAG/U3K403s3pJnxDUNLfJJf?= =?us-ascii?Q?OQgUuxwuWlMVjw/yTkPvKuaJIsh/Xw5QhXilKkPK9fnmn74fSNTEb92A+gO9?= =?us-ascii?Q?LyCVAKE2R89r185Eu631ZB/pyhUehZp3YM6Z5XBt39fNsHYaP5GcviumtR+O?= =?us-ascii?Q?ThvHJbkyrZfF9KEmPV/4LE9F3YmNKhox4SWCYAT4Sjiz75XP9xFr3lETvjIX?= =?us-ascii?Q?EvRM8UFA2ML+4vyGmlE9tFA5Ab6WxPUTr2aXEZKSpkCkuVbLYEXkoA3v7IoM?= =?us-ascii?Q?6663R4OR2qv67fNBSaSTjTtRMxo6rab/zZC61W7O//5JJNHF+XCYySwmFpFp?= =?us-ascii?Q?XDg/jNUZKldfjyRUN0UMiYMvR84yvR2ACbVLY9SJXZExZPqRxtgv/oFjpETB?= =?us-ascii?Q?qkrW2axS3jG3G1aR+JJv4tYit9w0kT+GWYnAyXL81oIS6YNcvZfUYa55i5SS?= =?us-ascii?Q?OQEewTxpo1wKdGc6ZSrToEACjTeY8xskDVA6Cq5cSMEhUgkfYa6l8DDtoMd0?= =?us-ascii?Q?wxZ/ASE03Ghov/MsMzjq3H7YL+uPTobgJTJasgoa0FAFGW9gDe/juq7AzFah?= =?us-ascii?Q?iFd+jz9YPGMzSDgQ/yDwqVGDqB6xYj+28/AgdBoOj1NNSqjp3h1/vrLIn5wU?= =?us-ascii?Q?IUWzlrvRQc+Bfn6SxBAJKC9AI9feQKSiskwn8dkglVLQE5fq90HAHag8Jh4v?= =?us-ascii?Q?jbtsBkGEEmrKpy1ipV1oTR1LrLFClsZ7ryPVvLJ/bRl8C+B/WUOLZv44EMTJ?= =?us-ascii?Q?9xiVwezIUdjHNni0UmqXTdlrusBKqgzMcDYPEgp6MQBRlv68qNPDdVq7327J?= =?us-ascii?Q?rog+Zpv/6xTzbrkVzQwZ4bBq++xKIUIRzl+E9bSRpIQQcRRp0fddb51bGh+N?= =?us-ascii?Q?FUc3pcD/TLNf1VibV84f4adiq8jyp8Z4mrh196cMW74DPsmTl75pYyp5RL4F?= =?us-ascii?Q?VyTFk1yNcVEdnfjrzySavFIzeDm4YeigneXXukZj9nIY1paxqmcVH9k588RN?= =?us-ascii?Q?Ulh5Ayad11YCJJ4/8iPIlltZy2ZohEjY4ixgrXkgxSuaReYnQ7bQL/S8ZXs+?= =?us-ascii?Q?fhBY6O21mrX6MUDNGaHr5YXn4KImi3AK5zXvbvW08dgHj+9DWNPhsNVaSL/R?= =?us-ascii?Q?inCqp8hBaTxoaTYsli1N47HN1QZF2PlK6GQZFVas+VEuC5arQ3vlta8BwumI?= =?us-ascii?Q?pv6ICH6R3bsRNe+ARIlzJ+NW?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86477d9a-16ae-4fe4-f079-08d94520ea4b X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2021 10:36:32.3603 (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: y6F2uWTVeB/H4iCYdGbWDlqXEIiOtOkDP/taZJXjwDwtDwTy4b/mIKqqmIzq+cqBjHbu4cGU7Vc+tUJ41GGdVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4552 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10042 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107120082 X-Proofpoint-GUID: iIIk7IwWvc-AbSsWdFmQUY59BmiGahcT X-Proofpoint-ORIG-GUID: iIIk7IwWvc-AbSsWdFmQUY59BmiGahcT 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: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_BL=0.01, RCVD_IN_MSPIKE_L3=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, marcandre.lureau@redhat.com, jonah.palmer@oracle.com, thuth@redhat.com, amit@kernel.org, michael.roth@amd.com, dgilbert@redhat.com, eric.auger@redhat.com, dmitrii.stepanov@cloud.ionos.com, stefanha@redhat.com, kwolf@redhat.com, laurent@vivier.eu, mreitz@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1626086451074100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This new command shows internal status of a VirtQueue. (vrings and indexes). Signed-off-by: Laurent Vivier Signed-off-by: Jonah Palmer Acked-by: Michael S. Tsirkin --- hw/virtio/virtio-stub.c | 6 +++ hw/virtio/virtio.c | 37 ++++++++++++++++++ qapi/virtio.json | 102 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 145 insertions(+) [Jonah: Added 'device-type' field to VirtQueueStatus and qmp command x-debug-virtio-queue-status.] diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index ddb592f..3c1bf17 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -17,3 +17,9 @@ VirtioStatus *qmp_x_debug_virtio_status(const char* path,= Error **errp) { return qmp_virtio_unsupported(errp); } + +VirtQueueStatus *qmp_x_debug_virtio_queue_status(const char *path, + uint16_t queue, Error **e= rrp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 81a0ee8..ccd4371 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3935,6 +3935,43 @@ static VirtIODevice *virtio_device_find(const char *= path) return NULL; } =20 +VirtQueueStatus *qmp_x_debug_virtio_queue_status(const char *path, + uint16_t queue, Error **e= rrp) +{ + VirtIODevice *vdev; + VirtQueueStatus *status; + + vdev =3D virtio_device_find(path); + if (vdev =3D=3D NULL) { + error_setg(errp, "Path %s is not a VirtIO device", path); + return NULL; + } + + if (queue >=3D VIRTIO_QUEUE_MAX || !virtio_queue_get_num(vdev, queue))= { + error_setg(errp, "Invalid virtqueue number %d", queue); + return NULL; + } + + status =3D g_new0(VirtQueueStatus, 1); + status->device_type =3D qapi_enum_parse(&VirtioType_lookup, vdev->name, + VIRTIO_TYPE_UNKNOWN, NULL); + status->queue_index =3D vdev->vq[queue].queue_index; + status->inuse =3D vdev->vq[queue].inuse; + status->vring_num =3D vdev->vq[queue].vring.num; + status->vring_num_default =3D vdev->vq[queue].vring.num_default; + status->vring_align =3D vdev->vq[queue].vring.align; + status->vring_desc =3D vdev->vq[queue].vring.desc; + status->vring_avail =3D vdev->vq[queue].vring.avail; + status->vring_used =3D vdev->vq[queue].vring.used; + status->last_avail_idx =3D vdev->vq[queue].last_avail_idx; + status->shadow_avail_idx =3D vdev->vq[queue].shadow_avail_idx; + status->used_idx =3D vdev->vq[queue].used_idx; + status->signalled_used =3D vdev->vq[queue].signalled_used; + status->signalled_used_valid =3D vdev->vq[queue].signalled_used_valid; + + return status; +} + #define CONVERT_FEATURES(type, map) \ ({ \ type *list =3D NULL; \ diff --git a/qapi/virtio.json b/qapi/virtio.json index 78873cd..7007e0c 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -406,3 +406,105 @@ 'data': { 'path': 'str' }, 'returns': 'VirtioStatus' } + +## +# @VirtQueueStatus: +# +# Status of a VirtQueue +# +# @device-type: VirtIO device type +# +# @queue-index: VirtQueue queue_index +# +# @inuse: VirtQueue inuse +# +# @vring-num: VirtQueue vring.num +# +# @vring-num-default: VirtQueue vring.num_default +# +# @vring-align: VirtQueue vring.align +# +# @vring-desc: VirtQueue vring.desc +# +# @vring-avail: VirtQueue vring.avail +# +# @vring-used: VirtQueue vring.used +# +# @last-avail-idx: VirtQueue last_avail_idx +# +# @shadow-avail-idx: VirtQueue shadow_avail_idx +# +# @used-idx: VirtQueue used_idx +# +# @signalled-used: VirtQueue signalled_used +# +# @signalled-used-valid: VirtQueue signalled_used_valid +# +# Since: 6.1 +# +## + +{ 'struct': 'VirtQueueStatus', + 'data': { + 'device-type': 'VirtioType', + 'queue-index': 'uint16', + 'inuse': 'uint32', + 'vring-num': 'int', + 'vring-num-default': 'int', + 'vring-align': 'int', + 'vring-desc': 'uint64', + 'vring-avail': 'uint64', + 'vring-used': 'uint64', + 'last-avail-idx': 'uint16', + 'shadow-avail-idx': 'uint16', + 'used-idx': 'uint16', + 'signalled-used': 'uint16', + 'signalled-used-valid': 'uint16' + } +} + +## +# @x-debug-virtio-queue-status: +# +# Return the status of a given VirtQueue +# +# @path: QOBject path of the VirtIODevice +# +# @queue: queue number to examine +# +# Returns: Status of the VirtQueue +# +# Since: 6.1 +# +# Example: +# +# -> { "execute": "x-debug-virtio-queue-status", +# "arguments": { +# "path": "/machine/peripheral-anon/device[3]/virtio-backend", +# "queue": 0 +# } +# } +# <- { "return": { +# "signalled-used": 373, +# "inuse": 0, +# "vring-align": 4096, +# "vring-desc": 864411648, +# "signalled-used-valid": 0, +# "vring-num-default": 256, +# "vring-avail": 864415744, +# "queue-index": 0, +# "last-avail-idx": 373, +# "vring-used": 864416320, +# "used-idx": 373, +# "device-type": "virtio-net", +# "shadow-avail-idx": 619, +# "vring-num": 256 +# } +# } +# +## + +{ 'command': 'x-debug-virtio-queue-status', + 'data': { 'path': 'str', 'queue': 'uint16' }, + 'returns': 'VirtQueueStatus' +} --=20 1.8.3.1 From nobody Fri Dec 19 06:18:07 2025 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=1626086544; cv=pass; d=zohomail.com; s=zohoarc; b=Oxni3MBS0CsxDdCluIx3kjsLcUFSSO1li8ra63u+ywMcMne6uwo9HvNAueco2fSCaWccC25cqRXWdkYRT4zBmztEbE9NSyX5dc8Ygr9aauaygQZCfH0t4D5koSHUDC8kguN3Z8grmDsNMZAOLU+kXA8Wv2MZcBpXkZbS+Zj0XiI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626086544; 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=za22V4R2iw31jbrY/zw+IT3wFS8/Ba5oaZsJkCjZhig=; b=Unhksg0mrG8Pq9+SV/kYdz/DTv+hqSrN0bHqUpux1S5JJ/3Y2X7U5HBMBWuWpg4DPkHHGq6ltDMA/LDWG0dPwJigzzQt4Ozl0RqtBJL7V0nfUaepW67cIRy+sE5RkCqSc3IltK79POjNExTeInpwxcU6bi7v4UwuP/raRkopLSc= 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 16260865446441000.660760624212; Mon, 12 Jul 2021 03:42:24 -0700 (PDT) Received: from localhost ([::1]:43006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2tOJ-000117-8o for importer@patchew.org; Mon, 12 Jul 2021 06:42:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2tJ0-0001kj-Op; Mon, 12 Jul 2021 06:36:56 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:23860) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2tIv-00006p-NE; Mon, 12 Jul 2021 06:36:52 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16CAVgF6029706; Mon, 12 Jul 2021 10:36:41 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39q2b2jcn9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jul 2021 10:36:41 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 16CAYovV098181; Mon, 12 Jul 2021 10:36:40 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2170.outbound.protection.outlook.com [104.47.73.170]) by userp3020.oracle.com with ESMTP id 39qnatj8y0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jul 2021 10:36:40 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB4552.namprd10.prod.outlook.com (2603:10b6:510:42::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Mon, 12 Jul 2021 10:36:34 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::c0ec:e3aa:9d8f:61c0]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::c0ec:e3aa:9d8f:61c0%6]) with mapi id 15.20.4308.026; Mon, 12 Jul 2021 10:36:34 +0000 Received: from jonpalme-lnx.us.oracle.com (209.17.40.41) by SN4PR0701CA0019.namprd07.prod.outlook.com (2603:10b6:803:28::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Mon, 12 Jul 2021 10:36:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=za22V4R2iw31jbrY/zw+IT3wFS8/Ba5oaZsJkCjZhig=; b=gefRa7s5niFB+49gGDm2FmDimMaWT3e0Mh4ful1xlkM7KFVVt8lMwdIaU42WlsABtJq4 TgLCCBvcIk8+gSCdX0CRiLeDCAMhWJVgqr1DweOXtZ0vWkeXYq1/ACldXq3Ry8C7qpo7 IyYwqWfAYO3aXzKC688kKmWqY3GqopyKACZCB2EAn0B5v7WrYu55Sp82j5JufRH83AfW +ajkVDMF4jLWfnB+4zbD9hhsaw1i/gWq65yMRhryNIQF4jlPeHUxlm+mrgx8LONxP1W4 ncfSFPjy1nOiDRuqCseJsKaEA1fazCvR6fUf8BJeGj9ISer7iEtfSYtmtwhJak7B/Cqj +Q== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VxhaT8t7AuZp/+0RGMA4D4ipjCWyA/3NIzrlsthEclPUm/Ql2qn8HMLt56yTVxSzrMuHmJ+9HBUofjGm3QxdRnb2oj1EqWuw4DElT25JAyWL6Gtc+VX95I3U75MsBJ5+MvvR8we3JxD+B5j+/lq3PMOfuBgDbwKmS2kfvVvcUhzCdSg6sNhwMPhDXzoK4fPplUvbLIS9EMAPQoUTE8QuaZJQJMzaNlZnuvokpt6QYz91lCdfG0/FZlxeQ6G4vckCLQttCxFll38Lco8H4WrO0YPn7XWy2gUQVEGRaJ6xenciCdi+ZwiOYDD5Zw7dej61Iq9jxZ2jnsXm9yQe8LBDgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=za22V4R2iw31jbrY/zw+IT3wFS8/Ba5oaZsJkCjZhig=; b=gJ/G5i2LPJ5m3oxpcQEmQtvkMNcwAZtSOA2D9W48cMOeegNFBCmB6CSlvsYluhks2Yy79WN5f2h/FiZ6eNu90i2yCswop0ED+fi85KUMI2tG9aih6u/mNqFGzNUsvQGUyyahN+8W6YyJG6gvSU5O7OOlod4IC9AyzSvbT9jrn0Dc6O+4iKBM3rF8hywu76b8PGTP6Lecu7n7OiR+G+5ExyRevR7DzmHgDJq+q6XG2Ya9R8uz0YpAwKJSMk+Ebzh2D7PJuN78qfEjCUzZtQi3o4+77/0wf80rKQz9XyjIwmdiGC3M8m7zU1d1pGQzf+EzTtEF8M5feZRnfuMR1lQPfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=za22V4R2iw31jbrY/zw+IT3wFS8/Ba5oaZsJkCjZhig=; b=dUrkSfNjkS67GRtRROT6UWB4Pvg7MeTV2CGODqbZEbA8lI7dv3kbPA9NVlaPIVW4vRibMvho9DTrWCHF8/W2mAlUFjvH145BCMMliUsLUzSSueCliWqXPpUluAWjzd7C0elyQhFH+dhuuX4msGWbDKW/nC18e0QPpc68GC5nl74= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v6 5/6] qmp: add QMP command x-debug-virtio-queue-element Date: Mon, 12 Jul 2021 06:35:36 -0400 Message-Id: <1626086137-16292-6-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1626086137-16292-1-git-send-email-jonah.palmer@oracle.com> References: <1626086137-16292-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SN4PR0701CA0019.namprd07.prod.outlook.com (2603:10b6:803:28::29) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 38d56a8a-7cd0-49bd-588e-08d94520ebbc X-MS-TrafficTypeDiagnostic: PH0PR10MB4552: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:883; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FFpi5Lx03bQ25Qgb2Yvq43iWNm4pw0VcH7GaoiYE/bzaFBqV0dHhKz7nc01JsDQaAbqt+GPJWwKFPCyX9uV9vSwGv6VDcay0M2J8LkzeOg2OTrIzAnPRUMPfjv6IYhyxODDNwI2fPpukB2+ZeXZu2mghpp8eJze3YhtdkYNr7K+6lf88W+8m+B/5keVDZBGfunGtAknlhsEN41Ko3bg4C307Nu/U0LYTXVh2fRWc/t3am5qxP3Dq21pk1bC0iLJ6GR9hK3DaTAAiF8v90ilG3jVp4o9x/RLjSg546R+4426wa00SVRk82DmIRFrvnhYoNlqqOU6w70KVDivzgqDWUBeIz1aXzu+K7GYn4e7GTXUbagbOyWsDAsXrh7KDU3HXg/P5hwhIb2CkrsSiTM/izvzAuqHT37/TLtBh/rZJpw73cpUkB8WVBXceeQz1xvFOhYRHq5Ifspn0YV+FHARB0kNvVyM30db3rtQv/m7c/pG12137iJnjNuyT/p0mzwDDSkIspQtXydgJDQUzf3rDoKw86Y5j3xswDOQM0N0Y7IR1jfhyGC8WVJUUkDaA7CTz+tNHZ1RA5MEd9F3Rsc46BKY7p3IM8P6EtAnT9lbPMzg7/8fjscsniRmjf+IVVdNgKJ+ZKh3EwXR/fwShKeYw53eK8JEJkzAonSwojqyjo14utChpZSgxsFd8fKugnOrS X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR10MB4664.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(39860400002)(346002)(366004)(136003)(376002)(83380400001)(7416002)(956004)(6486002)(7696005)(2616005)(186003)(316002)(36756003)(4326008)(2906002)(8936002)(52116002)(86362001)(107886003)(66476007)(66946007)(44832011)(66556008)(6916009)(38100700002)(5660300002)(8676002)(38350700002)(478600001)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?CXk+R1eGvA8XXmwpOF8gWwhqDOwkiXIgFkgpIy71sVsWBQ/Edn6f2UaUUPz7?= =?us-ascii?Q?r1U1S2dDBFuzkNgj8ND/AxzDBXXSX1oSU6ObqiUrYeR4H96BQF0AOBOObcXk?= =?us-ascii?Q?lGyMT7KbP3BNkJ23Nv1QEpvprYemfOLcFXMTLcxaqA6JhiXEvJn2gRYIwik/?= =?us-ascii?Q?ij+q2uA6OADq8hBtQTia7YEGVlovXbOj31X5HfcYxKu5QPSthJag/sJCfJXA?= =?us-ascii?Q?8nv3TtwsbbvQ8NMKU0mkgRmXyxb6+dmDmn9oTeyhS2ZEymcl3KvHyuEpl9I/?= =?us-ascii?Q?Gb17gib3m+VQ3AjPMnrtJPwAu3l5+yzkh+H3psTzxzLGb8frYFPHZsadojPL?= =?us-ascii?Q?QPqL76KpNphO8e9zlkffnidUu9/RUfUAA+lS7zEFXw/Tdl6pQwCfet5NMDIz?= =?us-ascii?Q?6Rqo14zuqpjQzJpENjJ0YJ/BVdtC8yH6/W2MrffSRDFq8ux/0fLpPIelh+JN?= =?us-ascii?Q?HD6T4q5RAXL6KZ1jVMoH019Jz8wWppC5+vyfCyRvZokfE+xL+BOjXywPuPJA?= =?us-ascii?Q?9AveMtpydonslHXHi6Su/zv1dOwRLR0PFmt5NpTRW2vFsZXj3xVg5oSoK8Cr?= =?us-ascii?Q?HLirkgDJsyBlaIB8ap1R14/hEV4HLIo/Or6+RaBhkDUEuyAKlrF4q5bzzfRN?= =?us-ascii?Q?5cHokJX6Z6Tb0+kyluz+LfEqrw/LUgaiLaLpZdITOEEl6ckJEEyUfBUS3M5j?= =?us-ascii?Q?akUGVQ09pYiG0kS99xD+i+wiHdxivnQUkYqs0DL47eIO/oclKoru+fkKRM1g?= =?us-ascii?Q?2XIurk2aAWsJmvbVt5Cf91/Agh7azlcI47Gk4PWcvUjbNh+pQLije8rdEq+H?= =?us-ascii?Q?+m7kp+3g3caJ2CgSB1IpAp/4Tl8UFzzZb7nPCbynrww4jZXwHeznUvrdSsLI?= =?us-ascii?Q?T7a3TEMfO5r2UOSFrBzPm7/Lvzi3K07sloAvZdytrHuYpqvkXsciECY8mljy?= =?us-ascii?Q?iOpjO3d57bTIOu7ZSt7i/Z88RFyN+TcVoKyOe54FUUbB9Y4FZPsljXECRxgi?= =?us-ascii?Q?jrikCHqSwdoOYqfOypZ1vDPezavQLAbL54wCdjXE6CiqJLYbx5ilgGD2x56h?= =?us-ascii?Q?ars/dI51Y22SI1ufuf6ceB+1GCpiI1hbliJ7p5xGmI+SfxvfmyQzpQqQk0hu?= =?us-ascii?Q?Fu9KzpLL5j/JZQxLjdzG6X1KwHPK1n7FgONR1U/OA66t3hsZgdL7AZvaPIQf?= =?us-ascii?Q?+IsjmO6BDFW7ER/drKJoDCB9f7Wrz/bBlJ3XVOHOTkucp+ygqFDZKtkb5ALq?= =?us-ascii?Q?VrWMyns+owjjm2g+DLXTWpxYyb7KkVwDCZS26E3hrm7I6K4jI7ZdalK78mwm?= =?us-ascii?Q?B23dbDRHjSvKlog1SU6URJeD?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 38d56a8a-7cd0-49bd-588e-08d94520ebbc X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2021 10:36:34.7707 (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: DRHLRF4bh0faNPtyZJDPH557u3h81IoybzoXomgPUWRfsOQFWuvV5E8+ztTs+LNPJ24HIVbtEFIS900ApOEvJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4552 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10042 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107120082 X-Proofpoint-GUID: mKCs1pHj10tTjXpZnfap8ND8-hgWg0u0 X-Proofpoint-ORIG-GUID: mKCs1pHj10tTjXpZnfap8ND8-hgWg0u0 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: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_BL=0.01, RCVD_IN_MSPIKE_L3=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, marcandre.lureau@redhat.com, jonah.palmer@oracle.com, thuth@redhat.com, amit@kernel.org, michael.roth@amd.com, dgilbert@redhat.com, eric.auger@redhat.com, dmitrii.stepanov@cloud.ionos.com, stefanha@redhat.com, kwolf@redhat.com, laurent@vivier.eu, mreitz@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1626086545695100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This new command shows the information of a VirtQueue element. Signed-off-by: Laurent Vivier Signed-off-by: Jonah Palmer Acked-by: Michael S. Tsirkin --- hw/virtio/virtio-stub.c | 9 ++++ hw/virtio/virtio.c | 135 ++++++++++++++++++++++++++++++++++++++++++++= ++++ qapi/virtio.json | 94 +++++++++++++++++++++++++++++++++ 3 files changed, 238 insertions(+) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index 3c1bf17..8275e31 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -23,3 +23,12 @@ VirtQueueStatus *qmp_x_debug_virtio_queue_status(const c= har *path, { return qmp_virtio_unsupported(errp); } + +VirtioQueueElement *qmp_x_debug_virtio_queue_element(const char* path, + uint16_t queue, + bool has_index, + uint16_t index, + Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index ccd4371..bd4d13d 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -4106,6 +4106,141 @@ VirtioStatus *qmp_x_debug_virtio_status(const char*= path, Error **errp) return status; } =20 +static VirtioRingDescFlagsList *qmp_decode_vring_desc_flags(uint16_t flags) +{ + VirtioRingDescFlagsList *list =3D NULL; + VirtioRingDescFlagsList *node; + int i; + struct { + uint16_t flag; + VirtioRingDescFlags value; + } map[] =3D { + { VRING_DESC_F_NEXT, VIRTIO_RING_DESC_FLAGS_NEXT }, + { VRING_DESC_F_WRITE, VIRTIO_RING_DESC_FLAGS_WRITE }, + { VRING_DESC_F_INDIRECT, VIRTIO_RING_DESC_FLAGS_INDIRECT }, + { 1 << VRING_PACKED_DESC_F_AVAIL, VIRTIO_RING_DESC_FLAGS_AVAIL }, + { 1 << VRING_PACKED_DESC_F_USED, VIRTIO_RING_DESC_FLAGS_USED }, + { 0, -1 } + }; + + for (i =3D 0; map[i].flag; i++) { + if ((map[i].flag & flags) =3D=3D 0) { + continue; + } + node =3D g_malloc0(sizeof(VirtioRingDescFlagsList)); + node->value =3D map[i].value; + node->next =3D list; + list =3D node; + } + + return list; +} + +VirtioQueueElement *qmp_x_debug_virtio_queue_element(const char* path, + uint16_t queue, + bool has_index, + uint16_t index, + Error **errp) +{ + VirtIODevice *vdev; + VirtQueue *vq; + VirtioQueueElement *element =3D NULL; + + vdev =3D virtio_device_find(path); + if (vdev =3D=3D NULL) { + error_setg(errp, "Path %s is not a VirtIO device", path); + return NULL; + } + + if (queue >=3D VIRTIO_QUEUE_MAX || !virtio_queue_get_num(vdev, queue))= { + error_setg(errp, "Invalid virtqueue number %d", queue); + return NULL; + } + vq =3D &vdev->vq[queue]; + + if (virtio_vdev_has_feature(vdev, VIRTIO_F_RING_PACKED)) { + error_setg(errp, "Packed ring not supported"); + return NULL; + } else { + unsigned int head, i, max; + VRingMemoryRegionCaches *caches; + MemoryRegionCache indirect_desc_cache =3D MEMORY_REGION_CACHE_INVA= LID; + MemoryRegionCache *desc_cache; + VRingDesc desc; + VirtioRingDescList *list =3D NULL; + VirtioRingDescList *node; + int rc; + + RCU_READ_LOCK_GUARD(); + + max =3D vq->vring.num; + + if (!has_index) { + head =3D vring_avail_ring(vq, vq->last_avail_idx % vq->vring.n= um); + } else { + head =3D vring_avail_ring(vq, index % vq->vring.num); + } + i =3D head; + + caches =3D vring_get_region_caches(vq); + if (!caches) { + error_setg(errp, "Region caches not initialized"); + return NULL; + } + + if (caches->desc.len < max * sizeof(VRingDesc)) { + error_setg(errp, "Cannot map descriptor ring"); + return NULL; + } + + desc_cache =3D &caches->desc; + vring_split_desc_read(vdev, &desc, desc_cache, i); + if (desc.flags & VRING_DESC_F_INDIRECT) { + int64_t len; + + len =3D address_space_cache_init(&indirect_desc_cache, vdev->d= ma_as, + desc.addr, desc.len, false); + desc_cache =3D &indirect_desc_cache; + if (len < desc.len) { + error_setg(errp, "Cannot map indirect buffer"); + goto done; + } + max =3D desc.len / sizeof(VRingDesc); + i =3D 0; + vring_split_desc_read(vdev, &desc, desc_cache, i); + } + + element =3D g_new0(VirtioQueueElement, 1); + element->index =3D head; + element->ndescs =3D 0; + + do { + /* A buggy driver may produce an infinite loop */ + if (element->ndescs >=3D max) { + break; + } + node =3D g_new0(VirtioRingDescList, 1); + node->value =3D g_new0(VirtioRingDesc, 1); + node->value->addr =3D desc.addr; + node->value->len =3D desc.len; + node->value->flags =3D qmp_decode_vring_desc_flags(desc.flags); + node->next =3D list; + list =3D node; + + element->ndescs++; + + rc =3D virtqueue_split_read_next_desc(vdev, &desc, desc_cache, + max, &i); + } while (rc =3D=3D VIRTQUEUE_READ_DESC_MORE); + + element->descs =3D list; +done: + address_space_cache_destroy(&indirect_desc_cache); + } + + return element; +} + static const TypeInfo virtio_device_info =3D { .name =3D TYPE_VIRTIO_DEVICE, .parent =3D TYPE_DEVICE, diff --git a/qapi/virtio.json b/qapi/virtio.json index 7007e0c..6bd9524 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -508,3 +508,97 @@ 'data': { 'path': 'str', 'queue': 'uint16' }, 'returns': 'VirtQueueStatus' } + +## +# @VirtioRingDescFlags: +# +# An enumeration of the virtio ring descriptor flags +# +# Since: 6.1 +# +## + +{ 'enum': 'VirtioRingDescFlags', + 'data': [ 'next', 'write', 'indirect', 'avail', 'used' ] +} + +## +# @VirtioRingDesc: +# +# @addr: guest physical address of the descriptor data +# +# @len: length of the descriptor data +# +# @flags: descriptor flags +# +# Since: 6.1 +# +## + +{ 'struct': 'VirtioRingDesc', + 'data': { + 'addr': 'uint64', + 'len': 'uint32', + 'flags': [ 'VirtioRingDescFlags' ] + } +} + +## +# @VirtioQueueElement: +# +# @index: index of the element in the queue +# +# @ndescs: number of descriptors +# +# @descs: list of the descriptors +# +# Since: 6.1 +# +## + +{ 'struct': 'VirtioQueueElement', + 'data': { + 'index': 'uint32', + 'ndescs': 'uint32', + 'descs': ['VirtioRingDesc'] + } +} + +## +# @x-debug-virtio-queue-element: +# +# Return the information about an element queue (by default head) +# +# @path: QOBject path of the VirtIODevice +# +# @queue: queue number to examine +# +# @index: the index in the queue, by default head +# +# Returns: the element information +# +# Since: 6.1 +# +# Example: +# +# -> { "execute": "x-debug-virtio-queue-element", +# "arguments": { +# "path": "/machine/peripheral-anon/device[3]/virtio-backend", +# "queue": 0 +# } +# } +# -> { "return": { +# "index": 24, +# "ndescs": 1, +# "descs": [ +# { "flags": ["write"], "len": 1536, "addr": 2027557376 } +# ] +# } +# } +# +## + +{ 'command': 'x-debug-virtio-queue-element', + 'data': { 'path': 'str', 'queue': 'uint16', '*index': 'uint16' }, + 'returns': 'VirtioQueueElement' +} --=20 1.8.3.1 From nobody Fri Dec 19 06:18:07 2025 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=1626086440; cv=pass; d=zohomail.com; s=zohoarc; b=DrORogbR1Tcql6T17NACIXwXNMN3axCK8wJXS1wRYkmfx21SSl1ONKnSZY+9vnzA8KjYqyQWSnG/29oaFIih+KyXIg1DxHJ/8Ixd04nsfXC10iGHO1VvJab/i+rfXqiAGF6dx4Sv+HtIK0GhpRBGY2ocptqBus2R+5m/YGqtV5A= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626086440; 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=zYUS30rGHwtq1sZZ4vJAlCuKgE6OMy9EmfsXdC+v/y0=; b=ZZ9qLJg8MW2Udp4SqT/sxoXWu0s1v51EpE1XbeRHmeSfl9/F1GTl//a81mqgyCJlqCYGBF6SZRmg9mKoF/2VjA/mdKpy4SMm3PoWMwp1+f5kuKAcJSxp/fteLZoWLy3ZmbMt/IvAuNudVzSpxTAAwpMnA1kkBsXDe3TG3GI10ms= 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 1626086440857805.3306532096619; Mon, 12 Jul 2021 03:40:40 -0700 (PDT) Received: from localhost ([::1]:39030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2tMd-0006iH-Kv for importer@patchew.org; Mon, 12 Jul 2021 06:40:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2tJ0-0001l2-Re; Mon, 12 Jul 2021 06:36:56 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:24382) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2tIw-00007D-Vq; Mon, 12 Jul 2021 06:36:54 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16CAVB8k019169; Mon, 12 Jul 2021 10:36:42 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39q1ybabyu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jul 2021 10:36:42 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 16CAYovW098181; Mon, 12 Jul 2021 10:36:41 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2170.outbound.protection.outlook.com [104.47.73.170]) by userp3020.oracle.com with ESMTP id 39qnatj8y0-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jul 2021 10:36:41 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB4552.namprd10.prod.outlook.com (2603:10b6:510:42::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Mon, 12 Jul 2021 10:36:37 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::c0ec:e3aa:9d8f:61c0]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::c0ec:e3aa:9d8f:61c0%6]) with mapi id 15.20.4308.026; Mon, 12 Jul 2021 10:36:37 +0000 Received: from jonpalme-lnx.us.oracle.com (209.17.40.41) by SN4PR0701CA0019.namprd07.prod.outlook.com (2603:10b6:803:28::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Mon, 12 Jul 2021 10:36:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=zYUS30rGHwtq1sZZ4vJAlCuKgE6OMy9EmfsXdC+v/y0=; b=L2gR8yBz3kQ8/dQqprpGh1UKci9nfUhqXbdDxB1iEaK4zsZL5pjnEr4jtQGLllJ/BJKw 6tagCSiehxdRoA/SEc9mLFSjZUZEFTJ7zM7pksPV92d/cG5zTpB/99cltq4UXpVSktY6 zkNJ3OnOVY+IBhhd1s2zdUcG0m7kPAZ/X96R1zP9HZzQ53LeZPv5URI0zk0knp1jZGkP 4sprtlyLYWj55ClYHIWEvVxd7ZMGwy8hRcA/eDGszom63TOPYRkptTuAm6cnXEJ9VYJX rfhhAuYWh1zd4ibk8GeIT14vbfyHN9j+vfzzK0KYE69adgcgo5SQHsmPPijf5+BoIxIn 2w== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ejim+KEvJ5tMQ59SV5EUTuoKXf0exiQLS+xMv/77Rc77q81yrWKie9zp57P4nmPSp2tpXzGpPsLVHCATXWUavejOkplG+t+yYee8S35nF3RFewo0uwMp9BdtOz0xXLUCr/4E4pz2Y02hu1WEtzwRw5/M5TConW49VU3fGVLmFjE8bPX+Nr6MMKJ19mnmTrTKJw4AcMYHzLaS3Vbaj0SzzOgzpvMPBRWc8rs7nD+rMBHnJ6tyEXuQd/LcWoYg+N9X4npFV88zfz27HWXJoqPPxOLAsbZOKwK6EG3x7AZcVb2zdS5CTMgftwVrM2qwhZoi82XJ0XIFYjwGlNAompHmBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zYUS30rGHwtq1sZZ4vJAlCuKgE6OMy9EmfsXdC+v/y0=; b=ks5y2BuoPI7wei/cFiIGljFzDijCZ1/owWXWegdoi6KYDhHnB3alqyvqvTZHCJAjiUrU/rhs1t7OF0Fu5q0mGxMUsGrmNUPTNJJ9s9lQZtnuibIU+h7WQLLXy1PjdyKBG26GZp9HX69I4Hnj97tZOde6XPtmCH8rrgSTRoTC/V/uCPOrEFD73sSaDc1DzjsIdTBU/ECcg1q7X0jbQB+7tZtzHFgML1h+B0NUvSnVcwvPG1NJLA/xzgg5cHeK3aSg7e/v6bBBtJDxsdD0hIs2dqMPBt1QSxiO2AZov5hlUackJ3TdkUwFaato4aPSmzwEgiQwcMyIyhG8SBRaZYfDZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zYUS30rGHwtq1sZZ4vJAlCuKgE6OMy9EmfsXdC+v/y0=; b=zNlmmOkKk+RjN8IiYKxn701pByx9FPGTEmPPhVRj6SzPnbEBj0hO9d6vsvrOsnjgiuXBaayi1mM130M4JFh921Zw9WAL0/fPbq8yox7PxEzf1MDoPaCLwek9yVDSi8T/2etotGlaFydx0ShLUt3PM7M9FmN3yyQYk7yZhwrr4tM= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v6 6/6] hmp: add virtio commands Date: Mon, 12 Jul 2021 06:35:37 -0400 Message-Id: <1626086137-16292-7-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1626086137-16292-1-git-send-email-jonah.palmer@oracle.com> References: <1626086137-16292-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SN4PR0701CA0019.namprd07.prod.outlook.com (2603:10b6:803:28::29) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 824f8200-9d5f-4d08-421d-08d94520ed29 X-MS-TrafficTypeDiagnostic: PH0PR10MB4552: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:312; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lIqi5rnKEQx8Rftf9/YJ9PECYUhXKdY18Eu+BwZb8KeIAWrf4Fmm0QuvWbGOszrP2/+d5NU5Qn2nNJ2qBEF+xS6B7t2C+EaQwqorq4otpdYrXSWWyETwCgjZJLzhoSMRB7pFIFTvbC0LQGPA3VIUkOBl452+PRV/Nvpx0FexxVhK/2SXx+rd6ve0sH9U/8ZHGp+tKnfSX/ztvDOLcAm+LiDatrHuiLhE3L44dLcnIsWkuq2SAaSUumwH9gUMg3SJBkiHd64vPOlA2ZqdGiIGK8sqOP50hv3NqBWkdPO/D8D0Eg5d86AysVqrJ5KXYAF6vgFjBlpoEYcbpmtDPxWxxocIk3iVV0OmF792ye7cPLUjg4Y9HTXwxvLPCIKQuuHAlo2/mEvHai6YCMox/ME+E1kINc2uqvmzmaAdOJWYpkWVVypWzKe+sfHnSW6mLOqB9aObyoqf3ed46HTevE40iBMTc6B8uxrvfnbRL2//Rg4UmabnRh0+A5uhLpvo8lGDgNRcLEzVBGl4fjAZZ+PZAvOheNnck4Mji1PQiqUOP9EVIWfcQ3vS7X8TG4zCJGk0t3DkRuXIa7Eh4d5bNoOYQSozmGyUWwm/izIPVull0P92kgnoVXkcM1WQOtFHQQHf3XOp+ydpyBf12aZk58W18eG9m+lcExKyfExus7JFD6i6IcI+x9lpeYabYqfafEiCUTr8c1+sEah7EeZJKUoUww== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR10MB4664.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(39860400002)(346002)(366004)(136003)(376002)(83380400001)(7416002)(956004)(6486002)(7696005)(2616005)(186003)(316002)(36756003)(4326008)(2906002)(8936002)(52116002)(86362001)(107886003)(66476007)(66946007)(44832011)(66556008)(6916009)(38100700002)(5660300002)(8676002)(30864003)(38350700002)(478600001)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?E9iplWp9kk3L+3OkULck4RlYmnsjcSoZGa1GwaxQ+26lSKRD9QTa6TdzkVrE?= =?us-ascii?Q?yeNx7I64Mrh6myzrldz4SyaoK7VN6hAu5Co0ypVwSuHahDIQtSvQ9MGp2ALQ?= =?us-ascii?Q?Asxq1v0bPRzMOLcbg6XD091UCimGIF3cSmVVzLORYUT7Ev0m58ZMjQ/80oW2?= =?us-ascii?Q?3UsTwhHVy2HmYuZ2uER9JXft+T2Wo2askV4BZ7Aa1DnkKbCsR2dgTfhYgZla?= =?us-ascii?Q?diHA67VdJV6mKTRwHTl+6+wBRK0phWd7/rFlGoIt93Cy2tj3WFZv699NOQVw?= =?us-ascii?Q?0NCDJDHWvBcjXA3r1zV28p7sxgw0P60pzR9gquRjyp+RdabJ5IH86B7XUM/0?= =?us-ascii?Q?vHi+cNVo84RByZZChWHI/KNFqsth199xr1A3IG+O71HozUkcp82Y/Tc6BER5?= =?us-ascii?Q?D0GAnWn/YaB+psbbz5SCcEpoaMGqJQ2iEJGLK08y+r4xsos6cukEZNBoOcZD?= =?us-ascii?Q?FGqq85BBDKW68Om0pqjS/1iQYhDXDNkmAchXzEK1eksVGRAnbaRP/DsBpsa8?= =?us-ascii?Q?G7zxNZ+d9rXjov64uE4jcZqK6DdXhJccXxUA+ADXtb5xllICOpzrr8tyMMVy?= =?us-ascii?Q?0itjqIFemkAs0FHYC9nS+0Zcr6aBGeFbgq3fJcYui6lXjCzXO8v+8FjOVr6l?= =?us-ascii?Q?BTAZbOyobg+LY28G5v3aF64nO9qEvqt58jCUzcBfeQfgS4Zkry2K45iGRvXO?= =?us-ascii?Q?SpnZoCBVQcPeSaxqn14Tyt+vhu1TmD4210oyEdeiVPOeWUOx40H0GsoClpZf?= =?us-ascii?Q?EHkZcloUMFrwoEBodf55pGxBll63Op1/L4WIeUoh+AeVV4q4wUT3x+lEB43/?= =?us-ascii?Q?99srVs9wCGzJ80MgEJP9X+oHO0aFyw96iwohgaZFsLQ1RIKu+SgzEVCdz1Ym?= =?us-ascii?Q?lOOvwvtbvU+Na3SccNuYgXNeZnCkUDEeUDBRan9oUu8jCXkM1wl6uceivGjI?= =?us-ascii?Q?BBXyiXjyv/IImWbGipYM9YNwf2CNSaKmEF7sLiNzuoswn5MZcPSyidRwP5BD?= =?us-ascii?Q?3WqCE8oUs+Ln+M6htOTvw0O76f7yA5szqv7MEZoRSkevHsqq7LQStU0SE0Gv?= =?us-ascii?Q?RLKG0Hryhfemw8EMQEXpfdLjjShjBVo9hN5V/nhqL+B5LyxDMp2Gm2Ws/8e7?= =?us-ascii?Q?1JwzHVaKGaFbG8ufWA7e0ibiCb/1ugjthGUp9P/GuP6UnFSjd2VOVy9U0Ih+?= =?us-ascii?Q?jyxmhegiCGseu4rmIwzd/3s5FHb/PJUFI/xdDox9YtmZmwJdmrYAZDjbZXra?= =?us-ascii?Q?pk0pAZJElvlSBt/6ivcDQKHRJWlI6qqp0CwyBmu2e6pnPKItnkGrsRYLyc/s?= =?us-ascii?Q?WYvmr7EMAhDyZwdbDUUuEPS1?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 824f8200-9d5f-4d08-421d-08d94520ed29 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2021 10:36:37.1870 (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: 2M7czwS6fYN+copdiuAjqteWivQwV2K/BITkGBThy6fRthBMINUzUXlxjg+aIRPd3GYdZEiUTi7XU9mlVGfjHQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4552 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10042 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107120082 X-Proofpoint-GUID: Cjx50ZTqcDcVRS0ABgMGq89Q2cmEp16u X-Proofpoint-ORIG-GUID: Cjx50ZTqcDcVRS0ABgMGq89Q2cmEp16u 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: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_BL=0.01, RCVD_IN_MSPIKE_L3=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, marcandre.lureau@redhat.com, jonah.palmer@oracle.com, thuth@redhat.com, amit@kernel.org, michael.roth@amd.com, dgilbert@redhat.com, eric.auger@redhat.com, dmitrii.stepanov@cloud.ionos.com, stefanha@redhat.com, kwolf@redhat.com, laurent@vivier.eu, mreitz@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1626086442010100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This patch implements HMP version of the virtio QMP commands Signed-off-by: Laurent Vivier Signed-off-by: Jonah Palmer Acked-by: Michael S. Tsirkin --- docs/system/monitor.rst | 2 + hmp-commands-virtio.hx | 162 ++++++++++++++++++++++++++++++++++++++ hmp-commands.hx | 10 +++ hw/virtio/virtio.c | 204 ++++++++++++++++++++++++++++++++++++++++++++= +++- include/monitor/hmp.h | 4 + meson.build | 1 + monitor/misc.c | 17 ++++ 7 files changed, 399 insertions(+), 1 deletion(-) create mode 100644 hmp-commands-virtio.hx [Jonah: Added relative indicies, device type, and used index in HMP virtio queue-status command.] diff --git a/docs/system/monitor.rst b/docs/system/monitor.rst index ff5c434..10418fc 100644 --- a/docs/system/monitor.rst +++ b/docs/system/monitor.rst @@ -21,6 +21,8 @@ The following commands are available: =20 .. hxtool-doc:: hmp-commands.hx =20 +.. hxtool-doc:: hmp-commands-virtio.hx + .. hxtool-doc:: hmp-commands-info.hx =20 Integer expressions diff --git a/hmp-commands-virtio.hx b/hmp-commands-virtio.hx new file mode 100644 index 0000000..0ef01b9 --- /dev/null +++ b/hmp-commands-virtio.hx @@ -0,0 +1,162 @@ +HXCOMM Use DEFHEADING() to define headings in both help text and rST. +HXCOMM Text between SRST and ERST is copied to the rST version and +HXCOMM discarded from C version. +HXCOMM DEF(command, args, callback, arg_string, help) is used to construct +HXCOMM monitor info commands +HXCOMM HXCOMM can be used for comments, discarded from both rST and C. +HXCOMM +HXCOMM In this file, generally SRST fragments should have two extra +HXCOMM spaces of indent, so that the documentation list item for "virtio c= md" +HXCOMM appears inside the documentation list item for the top level +HXCOMM "virtio" documentation entry. The exception is the first SRST +HXCOMM fragment that defines that top level entry. + +SRST +``virtio`` *subcommand* + Show various information about virtio. + + Example: + + List all sub-commands:: + + (qemu) virtio + virtio query -- List all available virtio devices + virtio status path -- Display status of a given virtio device + virtio queue-status path queue -- Display status of a given virtio que= ue + virtio queue-element path queue [index] -- Display element of a given = virtio queue + +ERST + + { + .name =3D "query", + .args_type =3D "", + .params =3D "", + .help =3D "List all available virtio devices", + .cmd =3D hmp_virtio_query, + .flags =3D "p", + }, + +SRST + ``virtio query`` + List all available virtio devices + + Example: + + List all available virtio devices in the machine:: + + (qemu) virtio query + /machine/peripheral-anon/device[3]/virtio-backend [virtio-net] + /machine/peripheral-anon/device[1]/virtio-backend [virtio-serial] + /machine/peripheral-anon/device[0]/virtio-backend [virtio-blk] + +ERST + + { + .name =3D "status", + .args_type =3D "path:s", + .params =3D "path", + .help =3D "Display status of a given virtio device", + .cmd =3D hmp_virtio_status, + .flags =3D "p", + }, + +SRST + ``virtio status`` *path* + Display status of a given virtio device + + Example: + + Dump the status of the first virtio device:: + + (qemu) virtio status /machine/peripheral-anon/device[3]/virtio-backe= nd + /machine/peripheral-anon/device[3]/virtio-backend: + Device Id: 1 + Guest features: event-idx, indirect-desc, version-1 + ctrl-mac-addr, guest-announce, ctrl-vlan, ctrl-r= x, ctrl-vq, status, mrg-rxbuf, host-ufo, host-ecn, host-tso6, host-tso4, gu= est-ufo, guest-ecn, guest-tso6, guest-tso4, mac, ctrl-guest-offloads, guest= -csum, csum + Host features: event-idx, indirect-desc, bad-feature, version-1= , any-layout, notify-on-empty + gso, ctrl-mac-addr, guest-announce, ctrl-rx-extr= a, ctrl-vlan, ctrl-rx, ctrl-vq, status, mrg-rxbuf, host-ufo, host-ecn, host= -tso6, host-tso4, guest-ufo, guest-ecn, guest-tso6, guest-tso4, mac, ctrl-g= uest-offloads, guest-csum, csum + Backend features: + Endianness: little + VirtQueues: 3 + +ERST + + { + .name =3D "queue-status", + .args_type =3D "path:s,queue:i", + .params =3D "path queue", + .help =3D "Display status of a given virtio queue", + .cmd =3D hmp_virtio_queue_status, + .flags =3D "p", + }, + +SRST + ``virtio queue-status`` *path* *queue* + Display status of a given virtio queue + + Example: + + Dump the status of the first queue of the first virtio device:: + + (qemu) virtio queue-status /machine/peripheral-anon/device[3]/virtio= -backend 0 + /machine/peripheral-anon/device[3]/virtio-backend: + device_type: virtio-net + index: 0 + inuse: 0 + last_avail_idx: 61 (61 % 256) + shadow_avail_idx: 292 (36 % 256) + used_idx: 61 (61 % 256) + signalled_used: 61 (61 % 256) + signalled_used_valid: 1 + VRing: + num: 256 + num_default: 256 + align: 4096 + desc: 0x000000006c352000 + avail: 0x000000006c353000 + used: 0x000000006c353240 + +ERST + + { + .name =3D "queue-element", + .args_type =3D "path:s,queue:i,index:i?", + .params =3D "path queue [index]", + .help =3D "Display element of a given virtio queue", + .cmd =3D hmp_virtio_queue_element, + .flags =3D "p", + }, + +SRST + ``virtio queue-element`` *path* *queue* [*index*] + Display element of a given virtio queue + + Example: + + Dump the information of the head element of the first queue of + the first virtio device:: + + (qemu) virtio queue-element/machine/peripheral-anon/device[3]/virtio= -backend 0 + index: 67 + ndescs: 1 + descs: addr 0x6fe69800 len 1536 (write) + + (qemu) xp/128bx 0x6fe69800 + 000000006fe69800: 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00 + 000000006fe69808: 0x00 0x00 0x01 0x00 0x52 0x54 0x00 0x12 + 000000006fe69810: 0x34 0x56 0x52 0x54 0x00 0x09 0x51 0xde + 000000006fe69818: 0x08 0x00 0x45 0x00 0x00 0x4c 0x8f 0x32 + + device[3] is a virtio-net device and we can see in the element buffer = the + MAC address of the card:: + + [root@localhost ~]# ip link show ens4 + 2: ens4: mtu 1500 qdisc fq_codel s= tate UP m0 + link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff + + and the MAC address of the gateway:: + + [root@localhost ~]# arp -a + _gateway (192.168.122.1) at 52:54:00:09:51:de [ether] on ens4 + +ERST diff --git a/hmp-commands.hx b/hmp-commands.hx index 8e45bce..4ef0630 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1720,6 +1720,16 @@ SRST ERST =20 { + .name =3D "virtio", + .args_type =3D "name:S?", + .params =3D "[cmd]", + .help =3D "show various information about virtio", + .cmd =3D hmp_virtio_help, + .sub_table =3D hmp_virtio_cmds, + .flags =3D "p", + }, + + { .name =3D "info", .args_type =3D "item:s?", .params =3D "[subcommand]", diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index bd4d13d..db0c5b8 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -31,6 +31,9 @@ #include "sysemu/runstate.h" #include "standard-headers/linux/virtio_ids.h" #include CONFIG_DEVICES +#include "monitor/hmp.h" +#include "monitor/monitor.h" +#include "qapi/qmp/qdict.h" =20 static QTAILQ_HEAD(, VirtIODevice) virtio_list; =20 @@ -3919,6 +3922,32 @@ VirtioInfoList *qmp_x_debug_query_virtio(Error **err= p) return list; } =20 +void hmp_virtio_query(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + VirtioInfoList *list =3D qmp_x_debug_query_virtio(&err); + VirtioInfoList *node; + + if (err !=3D NULL) { + hmp_handle_error(mon, err); + return; + } + + if (list =3D=3D NULL) { + monitor_printf(mon, "No VirtIO devices\n"); + return; + } + + node =3D list; + while (node) { + monitor_printf(mon, "%s [%s]\n", node->value->path, + VirtioType_str(node->value->type)); + node =3D node->next; + } + + qapi_free_VirtioInfoList(list); +} + static VirtIODevice *virtio_device_find(const char *path) { VirtIODevice *vdev; @@ -3972,8 +4001,48 @@ VirtQueueStatus *qmp_x_debug_virtio_queue_status(con= st char *path, return status; } =20 +void hmp_virtio_queue_status(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + const char *path =3D qdict_get_try_str(qdict, "path"); + int queue =3D qdict_get_int(qdict, "queue"); + VirtQueueStatus *s =3D qmp_x_debug_virtio_queue_status(path, queue, &e= rr); + + if (err !=3D NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " device_type: %s\n", + VirtioType_str(s->device_type)); + monitor_printf(mon, " index: %d\n", s->queue_index); + monitor_printf(mon, " inuse: %d\n", s->inuse); + monitor_printf(mon, " last_avail_idx: %d (%"PRId64" %% %"PRId64= ")\n", + s->last_avail_idx, s->last_avail_idx % s->vring_num, + s->vring_num); + monitor_printf(mon, " shadow_avail_idx: %d (%"PRId64" %% %"PRId64= ")\n", + s->shadow_avail_idx, s->shadow_avail_idx % s->vring_num, + s->vring_num); + monitor_printf(mon, " used_idx: %d (%"PRId64" %% %"PRId64= ")\n", + s->used_idx, s->used_idx % s->vring_num, s->vring_num); + monitor_printf(mon, " signalled_used: %d (%"PRId64" %% %"PRId64= ")\n", + s->signalled_used, s->signalled_used % s->vring_num, + s->vring_num); + monitor_printf(mon, " signalled_used_valid: %d\n", s->signalled_used_= valid); + monitor_printf(mon, " VRing:\n"); + monitor_printf(mon, " num: %"PRId64"\n", s->vring_num); + monitor_printf(mon, " num_default: %"PRId64"\n", s->vring_num_defau= lt); + monitor_printf(mon, " align: %"PRId64"\n", s->vring_align); + monitor_printf(mon, " desc: 0x%016"PRIx64"\n", s->vring_desc= ); + monitor_printf(mon, " avail: 0x%016"PRIx64"\n", s->vring_avai= l); + monitor_printf(mon, " used: 0x%016"PRIx64"\n", s->vring_used= ); + + qapi_free_VirtQueueStatus(s); +} + #define CONVERT_FEATURES(type, map) \ - ({ \ + ({ \ type *list =3D NULL; \ type *node; \ for (i =3D 0; map[i].virtio_bit !=3D -1; i++) {\ @@ -4106,6 +4175,93 @@ VirtioStatus *qmp_x_debug_virtio_status(const char* = path, Error **errp) return status; } =20 +#define DUMP_FEATURES(type, field) = \ + do { = \ + type##FeatureList * list =3D features->u.field.features; = \ + if (list) { = \ + monitor_printf(mon, " "); = \ + while (list) { = \ + monitor_printf(mon, "%s", type##Feature_str(list->value));= \ + list =3D list->next; = \ + if (list !=3D NULL) { = \ + monitor_printf(mon, ", "); = \ + } = \ + } = \ + monitor_printf(mon, "\n"); = \ + } = \ + } while (0) + +static void hmp_virtio_dump_features(Monitor *mon, + VirtioDeviceFeatures *features) +{ + VirtioTransportFeatureList *transport_list =3D features->transport; + while (transport_list) { + monitor_printf(mon, "%s", + VirtioTransportFeature_str(transport_list->value)); + transport_list =3D transport_list->next; + if (transport_list !=3D NULL) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, "\n"); + switch (features->type) { + case VIRTIO_TYPE_VIRTIO_SERIAL: + DUMP_FEATURES(VirtioSerial, virtio_serial); + break; + case VIRTIO_TYPE_VIRTIO_BLK: + DUMP_FEATURES(VirtioBlk, virtio_blk); + break; + case VIRTIO_TYPE_VIRTIO_GPU: + DUMP_FEATURES(VirtioGpu, virtio_gpu); + break; + case VIRTIO_TYPE_VIRTIO_NET: + DUMP_FEATURES(VirtioNet, virtio_net); + break; + case VIRTIO_TYPE_VIRTIO_SCSI: + DUMP_FEATURES(VirtioScsi, virtio_scsi); + break; + case VIRTIO_TYPE_VIRTIO_BALLOON: + DUMP_FEATURES(VirtioBalloon, virtio_balloon); + break; + case VIRTIO_TYPE_VIRTIO_IOMMU: + DUMP_FEATURES(VirtioIommu, virtio_iommu); + break; + default: + g_assert_not_reached(); + } + if (features->has_unknown_features) { + monitor_printf(mon, " " + "unknown-features(0x%016"PRIx64")\n", + features->unknown_features); + } +} + +void hmp_virtio_status(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + const char *path =3D qdict_get_try_str(qdict, "path"); + VirtioStatus *s =3D qmp_x_debug_virtio_status(path, &err); + + if (err !=3D NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " Device Id: %"PRId64"\n", s->device_id); + monitor_printf(mon, " Guest features: "); + hmp_virtio_dump_features(mon, s->guest_features); + monitor_printf(mon, " Host features: "); + hmp_virtio_dump_features(mon, s->host_features); + monitor_printf(mon, " Backend features: "); + hmp_virtio_dump_features(mon, s->backend_features); + monitor_printf(mon, " Endianness: %s\n", + VirtioStatusEndianness_str(s->device_endian)); + monitor_printf(mon, " VirtQueues: %d\n", s->num_vqs); + + qapi_free_VirtioStatus(s); +} + static VirtioRingDescFlagsList *qmp_decode_vring_desc_flags(uint16_t flags) { VirtioRingDescFlagsList *list =3D NULL; @@ -4241,6 +4397,52 @@ done: return element; } =20 +void hmp_virtio_queue_element(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + const char *path =3D qdict_get_try_str(qdict, "path"); + int queue =3D qdict_get_int(qdict, "queue"); + int index =3D qdict_get_try_int(qdict, "index", -1); + VirtioQueueElement *element; + VirtioRingDescList *list; + + element =3D qmp_x_debug_virtio_queue_element(path, queue, index !=3D -= 1, + index, &err); + if (err !=3D NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "index: %d\n", element->index); + monitor_printf(mon, "ndescs: %d\n", element->ndescs); + monitor_printf(mon, "descs: "); + + list =3D element->descs; + while (list) { + monitor_printf(mon, "addr 0x%"PRIx64" len %d", list->value->addr, + list->value->len); + if (list->value->flags) { + VirtioRingDescFlagsList *flag =3D list->value->flags; + monitor_printf(mon, " ("); + while (flag) { + monitor_printf(mon, "%s", VirtioRingDescFlags_str(flag->va= lue)); + flag =3D flag->next; + if (flag) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, ")"); + } + list =3D list->next; + if (list) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, "\n"); + + qapi_free_VirtioQueueElement(element); +} + static const TypeInfo virtio_device_info =3D { .name =3D TYPE_VIRTIO_DEVICE, .parent =3D TYPE_DEVICE, diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 3baa105..e777b32 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -94,6 +94,10 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict); void hmp_qom_get(Monitor *mon, const QDict *qdict); void hmp_qom_set(Monitor *mon, const QDict *qdict); void hmp_info_qom_tree(Monitor *mon, const QDict *dict); +void hmp_virtio_query(Monitor *mon, const QDict *qdict); +void hmp_virtio_status(Monitor *mon, const QDict *qdict); +void hmp_virtio_queue_status(Monitor *mon, const QDict *qdict); +void hmp_virtio_queue_element(Monitor *mon, const QDict *qdict); void object_add_completion(ReadLineState *rs, int nb_args, const char *str= ); void object_del_completion(ReadLineState *rs, int nb_args, const char *str= ); void device_add_completion(ReadLineState *rs, int nb_args, const char *str= ); diff --git a/meson.build b/meson.build index eb362ee..d690de2 100644 --- a/meson.build +++ b/meson.build @@ -1964,6 +1964,7 @@ if have_system hx_headers +=3D [ ['hmp-commands.hx', 'hmp-commands.h'], ['hmp-commands-info.hx', 'hmp-commands-info.h'], + ['hmp-commands-virtio.hx', 'hmp-commands-virtio.h'], ] endif foreach d : hx_headers diff --git a/monitor/misc.c b/monitor/misc.c index 1539e18..ef8f87c 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -23,6 +23,7 @@ */ =20 #include "qemu/osdep.h" +#include CONFIG_DEVICES #include "monitor-internal.h" #include "monitor/qdev.h" #include "hw/usb.h" @@ -219,6 +220,15 @@ static void hmp_info_help(Monitor *mon, const QDict *q= dict) help_cmd(mon, "info"); } =20 +static void hmp_virtio_help(Monitor *mon, const QDict *qdict) +{ +#if defined(CONFIG_VIRTIO) + help_cmd(mon, "virtio"); +#else + monitor_printf(mon, "Virtio is disabled\n"); +#endif +} + static void monitor_init_qmp_commands(void) { /* @@ -1451,6 +1461,13 @@ static HMPCommand hmp_info_cmds[] =3D { { NULL, NULL, }, }; =20 +static HMPCommand hmp_virtio_cmds[] =3D { +#if defined(CONFIG_VIRTIO) +#include "hmp-commands-virtio.h" +#endif + { NULL, NULL, }, +}; + /* hmp_cmds and hmp_info_cmds would be sorted at runtime */ HMPCommand hmp_cmds[] =3D { #include "hmp-commands.h" --=20 1.8.3.1