From patchwork Mon Dec 6 12:43:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 12658269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 007DCC433F5 for ; Mon, 6 Dec 2021 12:53:12 +0000 (UTC) Received: from localhost ([::1]:41132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muDUV-0007Xi-Op for qemu-devel@archiver.kernel.org; Mon, 06 Dec 2021 07:53:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDMB-0000XI-Lz; Mon, 06 Dec 2021 07:44:35 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:60424) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDM6-0001wO-9e; Mon, 06 Dec 2021 07:44:34 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6CCqZY012705; Mon, 6 Dec 2021 12:44:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=R/+cK31eegqPIBAakeDUO/azvVEn3rKHttf+DjWWvoM=; b=tAB+rUQ4bmCdF1PJwJmDoYIhPPjmhXbUrIk1hpWvM4f3Qb+WdW0XstdOZ1qM9xE/4itu 8CL/r53AsK+Bg3i9SpB9mweFM3pLPzxcM9AJ88dI+Pb5OiK0LpygMzFC7GYvgXi23yL3 hg5V0vsqpCIUzPQGfZgtsJKKXWywcJpp6mS0scWzlXCnkL+ocxoigrLvfuNfhK7FyjTT 5WmvLk9Dgb2y7ibpMskI585pktWKyIto9OhNIgARVAiJjj5B+YqEu8Sm49028+TG77Un HGFzdnwZVq+us2Z5LJ2h2c7jV8cWuHWpwc4RPZO689Hj7VEcXU4w/H7XKg2D4Q/Wj/Mn sg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3csdfj9hdu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Dec 2021 12:44:12 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B6Cf9Rw139616; Mon, 6 Dec 2021 12:44:12 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by aserp3030.oracle.com with ESMTP id 3csc4rqj15-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Dec 2021 12:44:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nW88DO8snhZEcdt3dPQzrqJnog/86gFq3XTETPupoMeVAg25ce1htIrjkYcAQ2dGjLA3CgjLo+doB1DvFH7KQXRRWKtovRAGT3QLch4tIwZnhyEHqK8Oww1CdiPmN4TuAXDpuIIclc+p8hT5eId86wsGlDXhUARRZgG3WJvI4RGnicOOWp4xYAsAjbRuGSpWOHpC/fY8L13wCwTw7Qyk8qKuh/i67jkPtA+6fHFL7LwOV/C62+n036zS70fOY39u6V98xi4esvWAReuFrl+yuWirvJjYI7rpI67/ay6+7CNflG9JYl7m6DzLjqI2p+QawiEF/SYP8PEodsKuO/DgoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=R/+cK31eegqPIBAakeDUO/azvVEn3rKHttf+DjWWvoM=; b=jn81fZPTSjkg5izn+tSY6mGfiuuMWSzG97sCgY2HeFQuDSouNUJ/im8GVD3AqEfeSuDl0HXB+CdNx0pZkyj/X+rMVe6n7RfxhKQ/Q3fSIdYSdCCjp/zP9mfClhFOaT9S8Sh4U8JiBGyy3mw+Ul3FUQtfmHna4zQJqIMOTAACQSA9tw8PL7/UG7K+IedAqa4nPA5My1G7kwBoAGDLHeAM+c6o/a9EoJ/qkby2RnPYU3TLP3TYkD6+9EjR3chOgWoV20KwH+FKR3M5tugegS4S/dg7EZib2jUbbmA1jmz3ToA9tOzBwG2w2cu5xliwJuM61vxalQ29LbB9M7vBlPv2UQ== 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=R/+cK31eegqPIBAakeDUO/azvVEn3rKHttf+DjWWvoM=; b=e/gTWPiF1fzq7Yp+v5IAfajPBHRT25HI4Bt7U55G+VtXotXuADeAuDBzOUsD35nZlXIxIw2PxWZdRy9XennV/lE812xJ5coT7PWlDDYxEcysIvJGR6r3CxdEnPokeHJmyo1xe+W2GreGW9/wx2fn57lZYuCOCJz4GuNPTogNFo4= Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB5820.namprd10.prod.outlook.com (2603:10b6:510:146::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21; Mon, 6 Dec 2021 12:44:09 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%5]) with mapi id 15.20.4755.022; Mon, 6 Dec 2021 12:44:09 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v10 1/8] virtio: drop name parameter for virtio_init() Date: Mon, 6 Dec 2021 07:43:19 -0500 Message-Id: <1638794606-19631-2-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1638794606-19631-1-git-send-email-jonah.palmer@oracle.com> References: <1638794606-19631-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SA9P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::35) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 Received: from jonpalme-lnx.us.oracle.com (209.17.40.42) by SA9P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21 via Frontend Transport; Mon, 6 Dec 2021 12:44:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 36801ac0-9278-44bf-61c6-08d9b8b6190a X-MS-TrafficTypeDiagnostic: PH0PR10MB5820:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1728; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WOEyr6bM0TNcbLDeSlh9BwAp2aEcL79oAgLOghvOAfPFAWd9TkB6/pUqEcZe+x4fqt2eG1UrFwL+wQ96/oK9mbeyWflpUQe+kjXNBtFW5Wc7wNtEuLsdeeEYsKS0vSbSATtG+xOEpXHYyPxXTLblw1JIADzW2TaC56Xzn4C6Xy/yRVvIOPo5+3zoe5KUH09oBCvDGOpQfOGGUWJb/h3HLnWwDLTHGvEHT9DdsS/4rMmlsJPov32Rh/XSIrTwtBPR3mrEEAqPh89U0ip87Az0K5GGU9c8tJFiXjoir3R4S2oD2Wmr1mE1ftGg+4M3OlEs3GLCihdUCj7/t1TzNA022XtBg0/hg7bjpOBtvMhi7m9ckooVGkrEpPCG+1KLlhXe15hRrQbR39PPeYsROx7QH9Y/tngnbyGLNGEqOkm3W6+YkdWscFWF8cUkd0/yUkrpKb0eHOdMRePTN9L1irYh+rWLoQihEGqyYalkhmVNrWJrrArujzQqhb78DjJg6qubcv1e6UisRlJWsjV+NkE0MAV/uxhVRMzC1N1Tqd5zqDrfrLzte58acRU1/5AMapAOdVHT9Rde5VN5CeiLbfw1aoANRSJUjAzhtNt4ayQPWYcjzlTNRgDfVhuMW5MJVm1b8n9OqlLtq6UHBdwMIb+1HiSMUB+K4wiJ02AXhmcb4I4yIhcikb1HF81Lw6zvXDEsL5CxBV3VzSaYfvXw9YwcWg== 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)(44832011)(6486002)(6916009)(508600001)(7416002)(316002)(36756003)(956004)(8936002)(4326008)(2616005)(38350700002)(38100700002)(7696005)(52116002)(26005)(186003)(6666004)(86362001)(8676002)(66476007)(5660300002)(30864003)(66556008)(2906002)(66946007)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: E2fN303si/k3JNEs6GN0e8kjVrjpCyN9R5x8DTvr4rWeX2f8u2uuRkCtEl2+LQCh7VQzoW92uys+gcGyo/b2PQ7kAyY6iPwOicNsjIbmlmn8vE2X+XIb5OUrIOMCA88SkRXdgKw2Fm85hm5ssPo17iVpdplVvQeiNU1E+qGuoytkxqb3YTwYemw+Ums7PPdAlA0bKEIW/feXwkCfsJt7Q5nIuMIvU6pvy1LhQtMpqh/gSO5NHW7Y0fSPEP/It8BQxQFR6vnwetTdWLjD31hnOaj6Zgb9zTvL216haBMQwnXx2xI+29IbEo/uzo7iV+tiXKMqZf21VmsC37f8M9vkvSiFNiDUIrfmAlUXYzkkCp1aZ4ccGHy8Np0RFH2CUVkfjLeAaDRoU+DWhs3f+0qlDrKW9xutEKWKE7Bfcp+i88U4D8xhDaJ74Kl899EpIiBd6OScM4OLVCFvK527eF2pvOboZYXGPD6/yIv7z+OcwBwrdcEtgBlN2X6VUuxUvvMS7jqoXYjdviE3H3n/ZYEfOqWb/puZoNsNPWvwLqds9MIweAd7JbLYCgv74y0S0eVo0q4c9bXjLujQ4xPb6ib0DdyLKYjU6XIORuB2VNsZoLAzU/G7cDyysM0xlVFGOe/7yONvpBnqLUYTLGiPPhB3LDbeJoW93SIbJJjD8thw84gDHWGnxooMEeqBUJ1273uoy4nXiYbSDDA/4Uqm3wimrcH6BEo83n/bqkf1zQ4xXvOnlymhPi7YD4+Jnw8zjURmhFtj+pi8Q9xoun3AzVaMUD/71G36XeARg4TPbJ1vb+I8yJ+3d2OA+GtyDmwkzbxaNGriQys7qtUUzSWXFbBKUO3vaDpru6S4Cm48wa7AGYKi0KLjiu+fTm9f449MBt1Rel5v81zCfyDB1y0dOMVrRYnssHQGEZrO7r7XPRtzpFlUNGxO1FtTF68Hzs6SYAfmKOjkzsEaD/GvrXM0HyzJP18EKqGQVNRzz+o0bQLUM3uaa45kbsgVIBQqDrZQfrVsRcDLVblsxEupP4iOah/7vU95MqEMvgUGts9dXl49tnQsB1KnhPr5ch+skLiHnc3p/fkLUN1R9XzKmM1JmlrB4YK9kpjxO1VCmDTAXk+uflcLvBvRQveXosB8ntYEI9T+M9AoY+4Dw29I3vfcDfBspS3Dx05ATKXZvXYbZB6ou+7vHti6RmdJqv0nuMLo5lkUX6TfAcKkmuq7iExkShpdLUmszH5tAH9cjE2wkAZI2dXumYjkfbsfDXzn7+Gkwqdr9v3oL3iXKTMKvAKThzlJhmgw7gTa6HEzNcBnSjaw9aiVKhcPM4MSXAW0NAHhYJOJM/e+TgKybQS8nJ2uFjCIjsR+geagMo/3ZGzj1+klydkMZVVYzxABsLSUNeLgOxfyTtBoob9mmJdSOfzp9N5msWS6eJlZV+uV8bfxDlGM/ziucRAbvrm+wTpBqAf9UHOHGxp+JAnf+lkGhnUtCDy/6/LLmBrjYXLe38Ab7xcE4R8awJpyyTfF2UgMRMFY08BDo0O6LlJb3y4h5u4LC9g53YgYed9VbWQ1LkVJYPrrq7Oc/t94/bRX9bkiHJ+a9Yp6kIv0RLDLDqqirwLu/eRvAZe2QLi2sNVtMV+QyuLbMoU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36801ac0-9278-44bf-61c6-08d9b8b6190a X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2021 12:44:09.5525 (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: ZoTiXEkgqZrfPEMOmGoIIGrkjIPCF1+OnnpFLb6oT9JpXSV32dJpFTqtmyvlcxwFMYsWD95BIwvWVt34Ql5Iyg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5820 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10189 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112060078 X-Proofpoint-GUID: Q4hiu--XC2AT2gbF-DKLsMIbgyUq9GUj X-Proofpoint-ORIG-GUID: Q4hiu--XC2AT2gbF-DKLsMIbgyUq9GUj Received-SPF: pass client-ip=205.220.177.32; envelope-from=jonah.palmer@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This patch drops the name parameter for the virtio_init function. The pair between the numeric device ID and the string device ID (name) of a virtio device already exists, but not in a way that lets us map between them. This patch lets us do this and removes the need for the name parameter in the virtio_init function. Signed-off-by: Jonah Palmer Acked-by: Christian Schoenebeck --- hw/9pfs/virtio-9p-device.c | 2 +- hw/block/vhost-user-blk.c | 2 +- hw/block/virtio-blk.c | 2 +- hw/char/virtio-serial-bus.c | 3 +- hw/display/virtio-gpu-base.c | 2 +- hw/input/virtio-input.c | 3 +- hw/net/virtio-net.c | 2 +- hw/scsi/virtio-scsi.c | 3 +- hw/virtio/vhost-user-fs.c | 3 +- hw/virtio/vhost-user-i2c.c | 7 +---- hw/virtio/vhost-user-rng.c | 2 +- hw/virtio/vhost-user-vsock.c | 2 +- hw/virtio/vhost-vsock-common.c | 5 ++-- hw/virtio/vhost-vsock.c | 2 +- hw/virtio/virtio-balloon.c | 3 +- hw/virtio/virtio-crypto.c | 2 +- hw/virtio/virtio-iommu.c | 3 +- hw/virtio/virtio-mem.c | 3 +- hw/virtio/virtio-pmem.c | 3 +- hw/virtio/virtio-rng.c | 2 +- hw/virtio/virtio.c | 44 +++++++++++++++++++++++++++-- include/hw/virtio/vhost-vsock-common.h | 2 +- include/hw/virtio/virtio-gpu.h | 3 +- include/hw/virtio/virtio.h | 4 +-- include/standard-headers/linux/virtio_ids.h | 1 + 25 files changed, 67 insertions(+), 43 deletions(-) diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index 54ee93b..5f522e6 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -216,7 +216,7 @@ static void virtio_9p_device_realize(DeviceState *dev, Error **errp) } v->config_size = sizeof(struct virtio_9p_config) + strlen(s->fsconf.tag); - virtio_init(vdev, "virtio-9p", VIRTIO_ID_9P, v->config_size); + virtio_init(vdev, VIRTIO_ID_9P, v->config_size); v->vq = virtio_add_queue(vdev, MAX_REQ, handle_9p_output); } diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index ba13cb8..f61f8c1 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -490,7 +490,7 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp) return; } - virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, + virtio_init(vdev, VIRTIO_ID_BLOCK, sizeof(struct virtio_blk_config)); s->virtqs = g_new(VirtQueue *, s->num_queues); diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index f139cd7..505e574 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1213,7 +1213,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp) virtio_blk_set_config_size(s, s->host_features); - virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, s->config_size); + virtio_init(vdev, VIRTIO_ID_BLOCK, s->config_size); s->blk = conf->conf.blk; s->rq = NULL; diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index f01ec21..9f19fd0 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -1044,8 +1044,7 @@ static void virtio_serial_device_realize(DeviceState *dev, Error **errp) VIRTIO_CONSOLE_F_EMERG_WRITE)) { config_size = offsetof(struct virtio_console_config, emerg_wr); } - virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE, - config_size); + virtio_init(vdev, VIRTIO_ID_CONSOLE, config_size); /* Spawn a new virtio-serial bus on which the ports will ride as devices */ qbus_init(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS, diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index c8da480..5411a7b 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -170,7 +170,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev, } g->virtio_config.num_scanouts = cpu_to_le32(g->conf.max_outputs); - virtio_init(VIRTIO_DEVICE(g), "virtio-gpu", VIRTIO_ID_GPU, + virtio_init(VIRTIO_DEVICE(g), VIRTIO_ID_GPU, sizeof(struct virtio_gpu_config)); if (virtio_gpu_virgl_enabled(g->conf)) { diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c index 54bcb46..5b5398b 100644 --- a/hw/input/virtio-input.c +++ b/hw/input/virtio-input.c @@ -257,8 +257,7 @@ static void virtio_input_device_realize(DeviceState *dev, Error **errp) vinput->cfg_size += 8; assert(vinput->cfg_size <= sizeof(virtio_input_config)); - virtio_init(vdev, "virtio-input", VIRTIO_ID_INPUT, - vinput->cfg_size); + virtio_init(vdev, VIRTIO_ID_INPUT, vinput->cfg_size); vinput->evt = virtio_add_queue(vdev, 64, virtio_input_handle_evt); vinput->sts = virtio_add_queue(vdev, 64, virtio_input_handle_sts); } diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index f2014d5..b275acf 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3383,7 +3383,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) } virtio_net_set_config_size(n, n->host_features); - virtio_init(vdev, "virtio-net", VIRTIO_ID_NET, n->config_size); + virtio_init(vdev, VIRTIO_ID_NET, n->config_size); /* * We set a lower limit on RX queue size to what it always was. diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 51fd095..ce71939 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -972,8 +972,7 @@ void virtio_scsi_common_realize(DeviceState *dev, VirtIOSCSICommon *s = VIRTIO_SCSI_COMMON(dev); int i; - virtio_init(vdev, "virtio-scsi", VIRTIO_ID_SCSI, - sizeof(VirtIOSCSIConfig)); + virtio_init(vdev, VIRTIO_ID_SCSI, sizeof(VirtIOSCSIConfig)); if (s->conf.num_queues == VIRTIO_SCSI_AUTO_NUM_QUEUES) { s->conf.num_queues = 1; diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index c595957..b875640 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -219,8 +219,7 @@ static void vuf_device_realize(DeviceState *dev, Error **errp) return; } - virtio_init(vdev, "vhost-user-fs", VIRTIO_ID_FS, - sizeof(struct virtio_fs_config)); + virtio_init(vdev, VIRTIO_ID_FS, sizeof(struct virtio_fs_config)); /* Hiprio queue */ fs->hiprio_vq = virtio_add_queue(vdev, fs->conf.queue_size, vuf_handle_output); diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c index d172632..58fd729 100644 --- a/hw/virtio/vhost-user-i2c.c +++ b/hw/virtio/vhost-user-i2c.c @@ -14,11 +14,6 @@ #include "qemu/error-report.h" #include "standard-headers/linux/virtio_ids.h" -/* Remove this once the header is updated in Linux kernel */ -#ifndef VIRTIO_ID_I2C_ADAPTER -#define VIRTIO_ID_I2C_ADAPTER 34 -#endif - static void vu_i2c_start(VirtIODevice *vdev) { BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); @@ -220,7 +215,7 @@ static void vu_i2c_device_realize(DeviceState *dev, Error **errp) return; } - virtio_init(vdev, "vhost-user-i2c", VIRTIO_ID_I2C_ADAPTER, 0); + virtio_init(vdev, VIRTIO_ID_I2C_ADAPTER, 0); i2c->vhost_dev.nvqs = 1; i2c->vq = virtio_add_queue(vdev, 4, vu_i2c_handle_output); diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index 209ee5b..08bccba 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -203,7 +203,7 @@ static void vu_rng_device_realize(DeviceState *dev, Error **errp) return; } - virtio_init(vdev, "vhost-user-rng", VIRTIO_ID_RNG, 0); + virtio_init(vdev, VIRTIO_ID_RNG, 0); rng->req_vq = virtio_add_queue(vdev, 4, vu_rng_handle_output); if (!rng->req_vq) { diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 52bd682..0f8ff99 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -107,7 +107,7 @@ static void vuv_device_realize(DeviceState *dev, Error **errp) return; } - vhost_vsock_common_realize(vdev, "vhost-user-vsock"); + vhost_vsock_common_realize(vdev); vhost_dev_set_config_notifier(&vvc->vhost_dev, &vsock_ops); diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 3f37712..6146d25 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -220,12 +220,11 @@ int vhost_vsock_common_post_load(void *opaque, int version_id) return 0; } -void vhost_vsock_common_realize(VirtIODevice *vdev, const char *name) +void vhost_vsock_common_realize(VirtIODevice *vdev) { VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); - virtio_init(vdev, name, VIRTIO_ID_VSOCK, - sizeof(struct virtio_vsock_config)); + virtio_init(vdev, VIRTIO_ID_VSOCK, sizeof(struct virtio_vsock_config)); /* Receive and transmit queues belong to vhost */ vvc->recv_vq = virtio_add_queue(vdev, VHOST_VSOCK_QUEUE_SIZE, diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 478c0c9..3d4ede9 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -166,7 +166,7 @@ static void vhost_vsock_device_realize(DeviceState *dev, Error **errp) qemu_set_nonblock(vhostfd); } - vhost_vsock_common_realize(vdev, "vhost-vsock"); + vhost_vsock_common_realize(vdev); ret = vhost_dev_init(&vvc->vhost_dev, (void *)(uintptr_t)vhostfd, VHOST_BACKEND_TYPE_KERNEL, 0, errp); diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 9a4f491..236542f 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -888,8 +888,7 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp) VirtIOBalloon *s = VIRTIO_BALLOON(dev); int ret; - virtio_init(vdev, "virtio-balloon", VIRTIO_ID_BALLOON, - virtio_balloon_config_size(s)); + virtio_init(vdev, VIRTIO_ID_BALLOON, virtio_balloon_config_size(s)); ret = qemu_add_balloon_handler(virtio_balloon_to_target, virtio_balloon_stat, s); diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 54f9bbb..cca5237 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -810,7 +810,7 @@ static void virtio_crypto_device_realize(DeviceState *dev, Error **errp) return; } - virtio_init(vdev, "virtio-crypto", VIRTIO_ID_CRYPTO, vcrypto->config_size); + virtio_init(vdev, VIRTIO_ID_CRYPTO, vcrypto->config_size); vcrypto->curr_queues = 1; vcrypto->vqs = g_malloc0(sizeof(VirtIOCryptoQueue) * vcrypto->max_queues); for (i = 0; i < vcrypto->max_queues; i++) { diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 1b23e8e..92c5eb7 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -973,8 +973,7 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtIOIOMMU *s = VIRTIO_IOMMU(dev); - virtio_init(vdev, "virtio-iommu", VIRTIO_ID_IOMMU, - sizeof(struct virtio_iommu_config)); + virtio_init(vdev, VIRTIO_ID_IOMMU, sizeof(struct virtio_iommu_config)); memset(s->iommu_pcibus_by_bus_num, 0, sizeof(s->iommu_pcibus_by_bus_num)); diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index d5a5781..e217520 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -769,8 +769,7 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp) vmem->block_size; vmem->bitmap = bitmap_new(vmem->bitmap_size); - virtio_init(vdev, TYPE_VIRTIO_MEM, VIRTIO_ID_MEM, - sizeof(struct virtio_mem_config)); + virtio_init(vdev, VIRTIO_ID_MEM, sizeof(struct virtio_mem_config)); vmem->vq = virtio_add_queue(vdev, 128, virtio_mem_handle_request); host_memory_backend_set_mapped(vmem->memdev, true); diff --git a/hw/virtio/virtio-pmem.c b/hw/virtio/virtio-pmem.c index d1aeb90..8cbbd78 100644 --- a/hw/virtio/virtio-pmem.c +++ b/hw/virtio/virtio-pmem.c @@ -123,8 +123,7 @@ static void virtio_pmem_realize(DeviceState *dev, Error **errp) } host_memory_backend_set_mapped(pmem->memdev, true); - virtio_init(vdev, TYPE_VIRTIO_PMEM, VIRTIO_ID_PMEM, - sizeof(struct virtio_pmem_config)); + virtio_init(vdev, VIRTIO_ID_PMEM, sizeof(struct virtio_pmem_config)); pmem->rq_vq = virtio_add_queue(vdev, 128, virtio_pmem_flush); } diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c index cc8e9f7..7e12fc0 100644 --- a/hw/virtio/virtio-rng.c +++ b/hw/virtio/virtio-rng.c @@ -215,7 +215,7 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp) return; } - virtio_init(vdev, "virtio-rng", VIRTIO_ID_RNG, 0); + virtio_init(vdev, VIRTIO_ID_RNG, 0); vrng->vq = virtio_add_queue(vdev, 8, handle_input); vrng->quota_remaining = vrng->conf.max_bytes; diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index ea7c079..36eebd9 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -133,6 +133,45 @@ struct VirtQueue QLIST_ENTRY(VirtQueue) node; }; +const char *virtio_device_names[] = { + [VIRTIO_ID_NET] = "virtio-net", + [VIRTIO_ID_BLOCK] = "virtio-blk", + [VIRTIO_ID_CONSOLE] = "virtio-serial", + [VIRTIO_ID_RNG] = "virtio-rng", + [VIRTIO_ID_BALLOON] = "virtio-balloon", + [VIRTIO_ID_IOMEM] = "virtio-iomem", + [VIRTIO_ID_RPMSG] = "virtio-rpmsg", + [VIRTIO_ID_SCSI] = "virtio-scsi", + [VIRTIO_ID_9P] = "virtio-9p", + [VIRTIO_ID_MAC80211_WLAN] = "virtio-mac-wlan", + [VIRTIO_ID_RPROC_SERIAL] = "virtio-rproc-serial", + [VIRTIO_ID_CAIF] = "virtio-caif", + [VIRTIO_ID_MEMORY_BALLOON] = "virtio-mem-balloon", + [VIRTIO_ID_GPU] = "virtio-gpu", + [VIRTIO_ID_CLOCK] = "virtio-clk", + [VIRTIO_ID_INPUT] = "virtio-input", + [VIRTIO_ID_VSOCK] = "vhost-vsock", + [VIRTIO_ID_CRYPTO] = "virtio-crypto", + [VIRTIO_ID_SIGNAL_DIST] = "virtio-signal", + [VIRTIO_ID_PSTORE] = "virtio-pstore", + [VIRTIO_ID_IOMMU] = "virtio-iommu", + [VIRTIO_ID_MEM] = "virtio-mem", + [VIRTIO_ID_SOUND] = "virtio-sound", + [VIRTIO_ID_FS] = "virtio-user-fs", + [VIRTIO_ID_PMEM] = "virtio-pmem", + [VIRTIO_ID_MAC80211_HWSIM] = "virtio-mac-hwsim", + [VIRTIO_ID_I2C_ADAPTER] = "vhost-user-i2c", + [VIRTIO_ID_BT] = "virtio-bluetooth" +}; + +static const char *virtio_id_to_name(uint16_t device_id) +{ + assert(device_id < G_N_ELEMENTS(virtio_device_names)); + const char *name = virtio_device_names[device_id]; + assert(name != NULL); + return name; +} + /* Called within call_rcu(). */ static void virtio_free_region_cache(VRingMemoryRegionCaches *caches) { @@ -3227,8 +3266,7 @@ void virtio_instance_init_common(Object *proxy_obj, void *data, qdev_alias_all_properties(vdev, proxy_obj); } -void virtio_init(VirtIODevice *vdev, const char *name, - uint16_t device_id, size_t config_size) +void virtio_init(VirtIODevice *vdev, uint16_t device_id, size_t config_size) { BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); @@ -3257,7 +3295,7 @@ void virtio_init(VirtIODevice *vdev, const char *name, vdev->vq[i].host_notifier_enabled = false; } - vdev->name = name; + vdev->name = virtio_id_to_name(device_id); vdev->config_len = config_size; if (vdev->config_len) { vdev->config = g_malloc0(config_size); diff --git a/include/hw/virtio/vhost-vsock-common.h b/include/hw/virtio/vhost-vsock-common.h index d8b565b..076b7ab 100644 --- a/include/hw/virtio/vhost-vsock-common.h +++ b/include/hw/virtio/vhost-vsock-common.h @@ -44,7 +44,7 @@ int vhost_vsock_common_start(VirtIODevice *vdev); void vhost_vsock_common_stop(VirtIODevice *vdev); int vhost_vsock_common_pre_save(void *opaque); int vhost_vsock_common_post_load(void *opaque, int version_id); -void vhost_vsock_common_realize(VirtIODevice *vdev, const char *name); +void vhost_vsock_common_realize(VirtIODevice *vdev); void vhost_vsock_common_unrealize(VirtIODevice *vdev); uint64_t vhost_vsock_common_get_features(VirtIODevice *vdev, uint64_t features, Error **errp); diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index acfba7c..ac487d2 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -22,6 +22,7 @@ #include "sysemu/vhost-user-backend.h" #include "standard-headers/linux/virtio_gpu.h" +#include "standard-headers/linux/virtio_ids.h" #include "qom/object.h" #define TYPE_VIRTIO_GPU_BASE "virtio-gpu-base" @@ -37,8 +38,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUGL, VIRTIO_GPU_GL) #define TYPE_VHOST_USER_GPU "vhost-user-gpu" OBJECT_DECLARE_SIMPLE_TYPE(VhostUserGPU, VHOST_USER_GPU) -#define VIRTIO_ID_GPU 16 - struct virtio_gpu_simple_resource { uint32_t resource_id; uint32_t width; diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 8bab9cf..81e5694 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -165,8 +165,8 @@ struct VirtioDeviceClass { void virtio_instance_init_common(Object *proxy_obj, void *data, size_t vdev_size, const char *vdev_name); -void virtio_init(VirtIODevice *vdev, const char *name, - uint16_t device_id, size_t config_size); +void virtio_init(VirtIODevice *vdev, uint16_t device_id, size_t config_size); + void virtio_cleanup(VirtIODevice *vdev); void virtio_error(VirtIODevice *vdev, const char *fmt, ...) GCC_FMT_ATTR(2, 3); diff --git a/include/standard-headers/linux/virtio_ids.h b/include/standard-headers/linux/virtio_ids.h index 4fe842c..0d2af08 100644 --- a/include/standard-headers/linux/virtio_ids.h +++ b/include/standard-headers/linux/virtio_ids.h @@ -55,6 +55,7 @@ #define VIRTIO_ID_FS 26 /* virtio filesystem */ #define VIRTIO_ID_PMEM 27 /* virtio pmem */ #define VIRTIO_ID_MAC80211_HWSIM 29 /* virtio mac80211-hwsim */ +#define VIRTIO_ID_I2C_ADAPTER 34 /* virtio I2C adapter */ #define VIRTIO_ID_BT 40 /* virtio bluetooth */ #endif /* _LINUX_VIRTIO_IDS_H */ From patchwork Mon Dec 6 12:43:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 12658291 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5CA4C433EF for ; Mon, 6 Dec 2021 12:59:59 +0000 (UTC) Received: from localhost ([::1]:60486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muDb4-00040E-IA for qemu-devel@archiver.kernel.org; Mon, 06 Dec 2021 07:59:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDMK-0000ed-OV; Mon, 06 Dec 2021 07:44:48 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:63862) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDM8-0001xA-GD; Mon, 06 Dec 2021 07:44:43 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6C5Art023240; Mon, 6 Dec 2021 12:44:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=ZiBwpPkNQlaBQ7n6a9nybNcEh11gWUjlw+BJXe38bfA=; b=gP7zUbB1AAUUhMwqdPtwZN/v+GgWjgqDqBGJqGKAdL7OcSmNvQvCnK5uOb1bAZ0AuITR HraRqL9rsRMUjJ8OMcbCNgMl9xadxHE6SHdVrG0nMTt5p+UOjUGOfJfMzGEJimZpZEYX 3Hf16++oZDsrTnj7OL6Em6FB8rCZhukxBJ2MJ1OQW2qgK9lJULiVgQeFnQyWkCl5MYHU 6hH1dx9CBTJ2875Lp+ggD41exms8AZpzBwpu5/jMUU3EF6iykIuWDpYZz+9v2hycMHLv uj1fcbsi8/AiAuJPoB2noKlwa5AXo+DSJhvf5R7La8CQXLwZCQAV8d25RwJ8T552XFNp hQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3csbbqj2nd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Dec 2021 12:44:15 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B6Cf8HX139462; Mon, 6 Dec 2021 12:44:14 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2173.outbound.protection.outlook.com [104.47.56.173]) by aserp3030.oracle.com with ESMTP id 3csc4rqj2p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Dec 2021 12:44:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MtBAbHoRYyomyy1eKGjjgYX9TNcGV+XcJDzknFtWFwj5m0sQSWe1r6ZiUCCUb4ENI0dub8mCBnDdjMfFBpd4A11pdzixtvsF2Mh4FVir7tuc1ozhVfI5V34bci+vu6hjfO8OskdVdx9Ge1IwY7Y2FmKVGEX7qclOjiCiNb2coakSliprUZnZ5MoEzuGjPdLQJApcASNJKjP/+PA93hLpNxXOEGuG4uMvrhpgTee8kFNpaLHCfReLXAYGbbs6KIqI2nfaVxsPV1PK1up1aPEmzuw9BHkwk+ev15Rpk3f1neIU1dAHBQUtadeQgKCJ7HRLpNABDmScpIelruDyRWTbYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZiBwpPkNQlaBQ7n6a9nybNcEh11gWUjlw+BJXe38bfA=; b=DM1K7MP3uJjZir56EyPMgu10KDNTGqU4LPAwDx9N6K2C3z8yIgODahmWIUPpvuqLCLdreA9Ebomq9qGDpqTa+liiCJW3Zxr/zGVgWAOzCZaYa22VQ6fuSKPJGrtiMB+Clr5xuOOlQmr0GLdaiEV7V37V53i1ibNAtJTSYMppGvvOAZJRBCURAXBXpVHriXS0otdPb2BhvyGMXwD8xiVnsR19Vie2Xd+S0zsOqj16joNZ8wPUVWCrrEgIcRrrirQS5picIXBH5Icwao8LN/jQpz6wWvfysc3SFgfTiCFGm/0/WjBMX9WzwHPZkiL3hhEPTKmcctmvwXEecIID7qhktQ== 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=ZiBwpPkNQlaBQ7n6a9nybNcEh11gWUjlw+BJXe38bfA=; b=gkMSMkSx1KkYBfaRw8fD6zxWHqA1fXBZpBO79nIWFZCzGREhCH7OKSAKLhWzJ/2ghfyY2RYVezHhF0hd0F+Ya8juTDgUdb+iBHN3oQhLrNPw9fkrWT5mlBQNsN0ixwj+i9ZIp5WtSxBof3A568H6WIt/ikaWyk9tOjvMxSDpUcc= Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB5820.namprd10.prod.outlook.com (2603:10b6:510:146::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21; Mon, 6 Dec 2021 12:44:12 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%5]) with mapi id 15.20.4755.022; Mon, 6 Dec 2021 12:44:12 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v10 2/8] virtio: add vhost support for virtio devices Date: Mon, 6 Dec 2021 07:43:20 -0500 Message-Id: <1638794606-19631-3-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1638794606-19631-1-git-send-email-jonah.palmer@oracle.com> References: <1638794606-19631-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SA9P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::35) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 Received: from jonpalme-lnx.us.oracle.com (209.17.40.42) by SA9P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21 via Frontend Transport; Mon, 6 Dec 2021 12:44:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 76b71f5f-105a-4b91-9da4-08d9b8b61aa0 X-MS-TrafficTypeDiagnostic: PH0PR10MB5820:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:338; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4PDvdSNRZR/lNH5hkNau4uITxFHleqTQiLak7omgmhrvPx29zpaIwlB8ES1djs0+yHflzZeJxl0FELAfIaJWm0r3U0EG0uY463QuZ6txyDWZs61GoINsqd4BMFLwXOOTLnf3SWxFLeoIft5JLW8cBRaGw1RpzXZbw2XLxMBTVKQ1ewyi3fq3JrIbNaWR61gBneUpgMhsTAbzXOuuyEIyzaWNCPpnxIEqa6b5gZ+ftydTAGOPhHwGeNniCX7xsOLcLWkiL1X9pb2GAZcjATBr3b50EPLLRqFm2UC5CsSJ9vz6RvHndDMK2zP9QVLpeDnFTps2RJquKcVXD146W62eEnd/lhNAhOPckSjOlZN0DqvDYwGoYgQnxA1+USWHRQgmYIwaZoPVlhvJ49paMdqMUvycVsFG/CYvul8JkA0PoBlJ9/aAWdEAGQooDxL3e/k1dQ7mURgfa44laCFBXKT7RNLdqIrtxPzpSgUrtA/9aUJfhogo3+Xd0dy3oYfUs1ZJP7tDle/gjSnCoqicMHUS09cAXF5RGdRP1qTNQV31xrNJAy/zxdSTQA4GGWN/2D0PDmP7Tz2CIZ0lrqLwXOmECxZnls4WKdAVOPcgqjlODMr6jxGaLngugDeoK+ul/lyrUuKLO6R0Cg4JaKDbp0s2P9eZTEq7a2J8kurCTgPzCMf74KhHL5fWkunr1hJU8NioiyuIqWmmHTIMoWcHwuVYJw== 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)(44832011)(6486002)(6916009)(508600001)(7416002)(316002)(36756003)(956004)(8936002)(4326008)(2616005)(38350700002)(38100700002)(7696005)(52116002)(26005)(186003)(6666004)(86362001)(8676002)(66476007)(5660300002)(30864003)(66556008)(2906002)(66946007)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AuaF0SFSbNvXWPOkBTTXT8iKQPavhW9keFUyvHFeCFE899cKiALekBgSmPHbhG4+heItGW0O+fWYVxOGVFu1ry+ccgaliV/NTlW007AuaECbMtMvILwjrwo6Gj/tvMZ4wOBhMD0LVrXQkVhmCPNOPShDI+nhgRt/INjwUJhD9REIwV0YW02LHuo3IaNY8LFXfWzXhBgXNmMBeFYUDt+1YsZjeT9S6411kSjtMSZ4POvHj0Wo2gOKXFTaWYifFNzypw4DLeRzZ7Zb6Pe7jW0xWvwLeGTRTqV65Nz7oLfGGnDSjimdTQfLic8QjZLmz16wIlSRTcydqs+YF7gQC4chh+2PP5QwURznruoYiaDKea0OnID++4X3Y3pgpLfeFxMDH4+hetq9IdViUN7VhudBLgkPUNYhQaDlGi5n9cFN9gP1vIKpoGT0brdNIkzgKYlnA8rKZX7qNbAfWrlOFoIk0t5c5rEgK3WX6vQyhFE50dV4SNQ+MMf5hDjrQ6+k24oPzc5kRN7RTg2zfWtZxHvUoc4nj/TJjt1iohoFjdiA77OjaAHzKSxrVh4wdqHRSz7uieSO8TFwy2xdHv340gcOIFcv6heHv8JHqDmmm/DK4gyAVIxwHa3Rp0wNSeK6wM4L5m7TFx07oH5YQwSzSrEv0t1pzb5e587USWaS8xQAvgDIQbC2JPTffOb5l5S9fC8mkhHQ9hbTCnBsYmwiByQ2Hd9jzferJ5RhdGHKdtgY6kaKbsiXK5IMoNivqOE9E5MZeGBZ7voPtFZMji5dfZ4/ol3vKXIO08uVLoiAcuA2jc/tfkKOIeKoGOlAa998mfrxWmXdtT0cILw+c5cFuVKKK1Wb9uyTAC8qvyw9GOdArAKxrBQNLQJqz9aiwxPAsyiLx8wXPqrcBk99fVskdrXhVyifDDScLigIGYlqk8OO9f3UVS3QttSfspYtsxgruilmhizXxEXGTCM36de8uJCzI+EZPF4iEBtIpCLHv/vzv2MVNtlYzlPrRWgtlYlSE0FkxofsvSUyUS+qIqW3DmMyI1S57yQQcQ9wfckEQYKmqDSdV5GAPyCDIlrY10O9RjGw5sK/sucIFQ3Amm+bbXolbHvwyvfeZ3hM7Jis/vGbtIxRYPUOtLzJWdpDAnj8sgmDm/DObDhpGo32hbLAQFNjvfDXf00yWk1VqIWRxrmZu8sS4Qt0wVR18hhsyaHbpnrvAmQbG7ll7FMmn1veKW16kq11RcI0pkUmjJufB89DkIu3tC2OqAK7hYy+RfF3E4NTb/Tbv29lGd5D7yY9igkCcw4Vxb9rwJfo+JXk/3EdQWJ7RuSYCXldwQCiI3pDtLdsU4eTqfXbvFNautPwwE/vn75qr88ZvtSO5lejzYefXzVVMCVRWEfKo967zQHrRyU48MWDrlPc0bU+i6LNP8nyXfHGo0d5N8CfL74snmbt+PUzsEUSoQa2ZwYkFyOquMSbPn+FOneW6YOzbs0yIdg9YcFzBRvAn71myKfpA7QuhpOkqXr8+qDfNmRn36Eq5+mrX5nngwhkOD2vu0bX1Phcr+8ZC9yk5J8mC+FX2Uf3domybCCJp18YDcr9qgrAyxN+fKy+zFWauaVJi8wNtwW9Jaf/zgEIa01e8/fZddZ5sZ0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76b71f5f-105a-4b91-9da4-08d9b8b61aa0 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2021 12:44:12.1750 (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: 64AF4cqfUnqPts+5TRQEZ7jBmRjupfrrrhL+8frKQpphi3blyEPhZp8v/o9g+7J9lRYACkW88FvIuaWavBSi/A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5820 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10189 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112060078 X-Proofpoint-GUID: CQMEW8tsiKTyR_2fIzzVLsPXRXax361d X-Proofpoint-ORIG-GUID: CQMEW8tsiKTyR_2fIzzVLsPXRXax361d Received-SPF: pass client-ip=205.220.177.32; envelope-from=jonah.palmer@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This patch adds a get_vhost() callback function for VirtIODevices that returns the device's corresponding vhost_dev structure, if the vhost device is running. This patch also adds a vhost_started flag for VirtIODevices. Previously, a VirtIODevice wouldn't be able to tell if its corresponding vhost device was active or not. Signed-off-by: Jonah Palmer --- hw/block/vhost-user-blk.c | 7 +++++++ hw/display/vhost-user-gpu.c | 7 +++++++ hw/input/vhost-user-input.c | 7 +++++++ hw/net/virtio-net.c | 9 +++++++++ hw/scsi/vhost-scsi.c | 8 ++++++++ hw/virtio/vhost-user-fs.c | 7 +++++++ hw/virtio/vhost-user-rng.c | 7 +++++++ hw/virtio/vhost-vsock-common.c | 7 +++++++ hw/virtio/vhost.c | 4 +++- hw/virtio/virtio-crypto.c | 10 ++++++++++ hw/virtio/virtio.c | 1 + include/hw/virtio/virtio.h | 3 +++ 12 files changed, 76 insertions(+), 1 deletion(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index f61f8c1..b059da1 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -568,6 +568,12 @@ static void vhost_user_blk_instance_init(Object *obj) "/disk@0,0", DEVICE(obj)); } +static struct vhost_dev *vhost_user_blk_get_vhost(VirtIODevice *vdev) +{ + VHostUserBlk *s = VHOST_USER_BLK(vdev); + return &s->dev; +} + static const VMStateDescription vmstate_vhost_user_blk = { .name = "vhost-user-blk", .minimum_version_id = 1, @@ -602,6 +608,7 @@ static void vhost_user_blk_class_init(ObjectClass *klass, void *data) vdc->get_features = vhost_user_blk_get_features; vdc->set_status = vhost_user_blk_set_status; vdc->reset = vhost_user_blk_reset; + vdc->get_vhost = vhost_user_blk_get_vhost; } static const TypeInfo vhost_user_blk_info = { diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 49df56c..6e93b46 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -565,6 +565,12 @@ vhost_user_gpu_device_realize(DeviceState *qdev, Error **errp) g->vhost_gpu_fd = -1; } +static struct vhost_dev *vhost_user_gpu_get_vhost(VirtIODevice *vdev) +{ + VhostUserGPU *g = VHOST_USER_GPU(vdev); + return &g->vhost->dev; +} + static Property vhost_user_gpu_properties[] = { VIRTIO_GPU_BASE_PROPERTIES(VhostUserGPU, parent_obj.conf), DEFINE_PROP_END_OF_LIST(), @@ -586,6 +592,7 @@ vhost_user_gpu_class_init(ObjectClass *klass, void *data) vdc->guest_notifier_pending = vhost_user_gpu_guest_notifier_pending; vdc->get_config = vhost_user_gpu_get_config; vdc->set_config = vhost_user_gpu_set_config; + vdc->get_vhost = vhost_user_gpu_get_vhost; device_class_set_props(dc, vhost_user_gpu_properties); } diff --git a/hw/input/vhost-user-input.c b/hw/input/vhost-user-input.c index 273e96a..43d2ff3 100644 --- a/hw/input/vhost-user-input.c +++ b/hw/input/vhost-user-input.c @@ -79,6 +79,12 @@ static void vhost_input_set_config(VirtIODevice *vdev, virtio_notify_config(vdev); } +static struct vhost_dev *vhost_input_get_vhost(VirtIODevice *vdev) +{ + VHostUserInput *vhi = VHOST_USER_INPUT(vdev); + return &vhi->vhost->dev; +} + static const VMStateDescription vmstate_vhost_input = { .name = "vhost-user-input", .unmigratable = 1, @@ -93,6 +99,7 @@ static void vhost_input_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_vhost_input; vdc->get_config = vhost_input_get_config; vdc->set_config = vhost_input_set_config; + vdc->get_vhost = vhost_input_get_vhost; vic->realize = vhost_input_realize; vic->change_active = vhost_input_change_active; } diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index b275acf..2449b9c 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3610,6 +3610,14 @@ static bool dev_unplug_pending(void *opaque) return vdc->primary_unplug_pending(dev); } +static struct vhost_dev *virtio_net_get_vhost(VirtIODevice *vdev) +{ + VirtIONet *n = VIRTIO_NET(vdev); + NetClientState *nc = qemu_get_queue(n->nic); + struct vhost_net *net = get_vhost_net(nc->peer); + return &net->dev; +} + static const VMStateDescription vmstate_virtio_net = { .name = "virtio-net", .minimum_version_id = VIRTIO_NET_VM_VERSION, @@ -3712,6 +3720,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data) vdc->post_load = virtio_net_post_load_virtio; vdc->vmsd = &vmstate_virtio_net_device; vdc->primary_unplug_pending = primary_unplug_pending; + vdc->get_vhost = virtio_net_get_vhost; } static const TypeInfo virtio_net_info = { diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 039caf2..b0a9c45 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -264,6 +264,13 @@ static void vhost_scsi_unrealize(DeviceState *dev) virtio_scsi_common_unrealize(dev); } +static struct vhost_dev *vhost_scsi_get_vhost(VirtIODevice *vdev) +{ + VHostSCSI *s = VHOST_SCSI(vdev); + VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s); + return &vsc->dev; +} + static Property vhost_scsi_properties[] = { DEFINE_PROP_STRING("vhostfd", VirtIOSCSICommon, conf.vhostfd), DEFINE_PROP_STRING("wwpn", VirtIOSCSICommon, conf.wwpn), @@ -298,6 +305,7 @@ static void vhost_scsi_class_init(ObjectClass *klass, void *data) vdc->get_features = vhost_scsi_common_get_features; vdc->set_config = vhost_scsi_common_set_config; vdc->set_status = vhost_scsi_set_status; + vdc->get_vhost = vhost_scsi_get_vhost; fwc->get_dev_path = vhost_scsi_common_get_fw_dev_path; } diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index b875640..e513e4f 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -276,6 +276,12 @@ static void vuf_device_unrealize(DeviceState *dev) fs->vhost_dev.vqs = NULL; } +static struct vhost_dev *vuf_get_vhost(VirtIODevice *vdev) +{ + VHostUserFS *fs = VHOST_USER_FS(vdev); + return &fs->vhost_dev; +} + static const VMStateDescription vuf_vmstate = { .name = "vhost-user-fs", .unmigratable = 1, @@ -313,6 +319,7 @@ static void vuf_class_init(ObjectClass *klass, void *data) vdc->set_status = vuf_set_status; vdc->guest_notifier_mask = vuf_guest_notifier_mask; vdc->guest_notifier_pending = vuf_guest_notifier_pending; + vdc->get_vhost = vuf_get_vhost; } static const TypeInfo vuf_info = { diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index 08bccba..3a7bf8e 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -247,6 +247,12 @@ static void vu_rng_device_unrealize(DeviceState *dev) vhost_user_cleanup(&rng->vhost_user); } +static struct vhost_dev *vu_rng_get_vhost(VirtIODevice *vdev) +{ + VHostUserRNG *rng = VHOST_USER_RNG(vdev); + return &rng->vhost_dev; +} + static const VMStateDescription vu_rng_vmstate = { .name = "vhost-user-rng", .unmigratable = 1, @@ -272,6 +278,7 @@ static void vu_rng_class_init(ObjectClass *klass, void *data) vdc->set_status = vu_rng_set_status; vdc->guest_notifier_mask = vu_rng_guest_notifier_mask; vdc->guest_notifier_pending = vu_rng_guest_notifier_pending; + vdc->get_vhost = vu_rng_get_vhost; } static const TypeInfo vu_rng_info = { diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 6146d25..416daf8 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -254,6 +254,12 @@ void vhost_vsock_common_unrealize(VirtIODevice *vdev) virtio_cleanup(vdev); } +static struct vhost_dev *vhost_vsock_common_get_vhost(VirtIODevice *vdev) +{ + VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); + return &vvc->vhost_dev; +} + static Property vhost_vsock_common_properties[] = { DEFINE_PROP_ON_OFF_AUTO("seqpacket", VHostVSockCommon, seqpacket, ON_OFF_AUTO_AUTO), @@ -269,6 +275,7 @@ static void vhost_vsock_common_class_init(ObjectClass *klass, void *data) set_bit(DEVICE_CATEGORY_MISC, dc->categories); vdc->guest_notifier_mask = vhost_vsock_common_guest_notifier_mask; vdc->guest_notifier_pending = vhost_vsock_common_guest_notifier_pending; + vdc->get_vhost = vhost_vsock_common_get_vhost; } static const TypeInfo vhost_vsock_common_info = { diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 437347a..7ec923e 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1745,6 +1745,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) /* should only be called after backend is connected */ assert(hdev->vhost_ops); + vdev->vhost_started = true; hdev->started = true; hdev->vdev = vdev; @@ -1819,7 +1820,7 @@ fail_vq: fail_mem: fail_features: - + vdev->vhost_started = false; hdev->started = false; return r; } @@ -1850,6 +1851,7 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev) } vhost_log_put(hdev, true); hdev->started = false; + vdev->vhost_started = false; hdev->vdev = NULL; } diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index cca5237..7d63b8c 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -961,6 +961,15 @@ static bool virtio_crypto_guest_notifier_pending(VirtIODevice *vdev, int idx) return cryptodev_vhost_virtqueue_pending(vdev, queue, idx); } +static struct vhost_dev *virtio_crypto_get_vhost(VirtIODevice *vdev) +{ + VirtIOCrypto *vcrypto = VIRTIO_CRYPTO(vdev); + CryptoDevBackend *b = vcrypto->cryptodev; + CryptoDevBackendClient *cc = b->conf.peers.ccs[0]; + CryptoDevBackendVhost *vhost_crypto = cryptodev_get_vhost(cc, b, 0); + return &vhost_crypto->dev; +} + static void virtio_crypto_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -977,6 +986,7 @@ static void virtio_crypto_class_init(ObjectClass *klass, void *data) vdc->set_status = virtio_crypto_set_status; vdc->guest_notifier_mask = virtio_crypto_guest_notifier_mask; vdc->guest_notifier_pending = virtio_crypto_guest_notifier_pending; + vdc->get_vhost = virtio_crypto_get_vhost; } static void virtio_crypto_instance_init(Object *obj) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 36eebd9..867834d 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3280,6 +3280,7 @@ void virtio_init(VirtIODevice *vdev, uint16_t device_id, size_t config_size) vdev->start_on_kick = false; vdev->started = false; + vdev->vhost_started = false; vdev->device_id = device_id; vdev->status = 0; qatomic_set(&vdev->isr, 0); diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 81e5694..0a12bd5 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -22,6 +22,7 @@ #include "standard-headers/linux/virtio_config.h" #include "standard-headers/linux/virtio_ring.h" #include "qom/object.h" +#include "hw/virtio/vhost.h" /* A guest should never accept this. It implies negotiation is broken. */ #define VIRTIO_F_BAD_FEATURE 30 @@ -102,6 +103,7 @@ struct VirtIODevice bool started; bool start_on_kick; /* when virtio 1.0 feature has not been negotiated */ bool disable_legacy_check; + bool vhost_started; VMChangeStateEntry *vmstate; char *bus_name; uint8_t device_endian; @@ -160,6 +162,7 @@ struct VirtioDeviceClass { int (*post_load)(VirtIODevice *vdev); const VMStateDescription *vmsd; bool (*primary_unplug_pending)(void *opaque); + struct vhost_dev *(*get_vhost)(VirtIODevice *vdev); }; void virtio_instance_init_common(Object *proxy_obj, void *data, From patchwork Mon Dec 6 12:43:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 12658275 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 35621C433FE for ; Mon, 6 Dec 2021 12:54:19 +0000 (UTC) Received: from localhost ([::1]:45072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muDVZ-0001l3-So for qemu-devel@archiver.kernel.org; Mon, 06 Dec 2021 07:54:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDM9-0000WD-Qi; Mon, 06 Dec 2021 07:44:35 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:60236) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDM6-0001wK-6E; Mon, 06 Dec 2021 07:44:32 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6B4SJ3006615; Mon, 6 Dec 2021 12:44:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=8AAaM2LvTJIng1XrMlNccoRzSFO7cCbEaVik86vz2JQ=; b=iOG2h52Y+zOE+TYRbsG6TUQhtNfoyxSHTjGDb1cF+03ujR/1ojsmtCOPE/kSqr6zej3X n8t9/z2cfCjjqVmdn94bK0qD38qWz7393Y0EIP8PUBaLr9FFctD87+VRoffuCHIaEBeY GRf40AqPvc3ZNHoNcFOAIkWs5snNOycxN8CucQee5bqU1CV4AuLjXM09YA/1b0k71oqk 1oGD7y554MaYb+UAmKV5OQ/ieA1PnmwZs+oaZ0kUpaFgbLfnQG5hRN6/gfAQpuoKJEOt 0v2w+bY0sRpWyjzMkAm3sH+bbg/I207Lla6Tt+6LF6vxI1+YvEI+hVZePz7JO2m2NUh/ 6w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3csc729t8u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Dec 2021 12:44:18 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B6CecWk084171; Mon, 6 Dec 2021 12:44:17 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2175.outbound.protection.outlook.com [104.47.56.175]) by userp3020.oracle.com with ESMTP id 3cr1skys29-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Dec 2021 12:44:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cyyMAlQmIyuEbsVZiz/SC2iQSGdKAT03PW0gKjRiFbspLln7dpd3Q7MY1A3t4sUszE/bHBpnzR6Vn4e+Ta4GR7/DgqulVhuGio0fN73DPvkTgZqr4K+6UT2VJ9utxFu9n8a5FQYO69ReFJX+Fx3lR88C1I8AZjuQ1blAAMThjd1lULHOKlFacS3dmJK53TjODRZEYJ3SXoieFZuTUuBexj9tWbtW62UfJeUCKqAHXFcJra1VramLzA0PJtsRGvi/qQ2BtkB9h6q6ZJEguGsBz2JcIxctYZG/uk/1fPZnsEeM4IimzZTDQWWx2WM38CqzIPgDl25JJtwOMBqxM19pWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8AAaM2LvTJIng1XrMlNccoRzSFO7cCbEaVik86vz2JQ=; b=DIaYrS1et4rnxF2deeyjhMHPU/u3CpGZuZOtnS/YXzzEW2s+1c/cEqDRquYm52SzYb+rvvQFErWAwU4OzyL2/BXF9A50ZQ9Lw84oq64JDZ1J5/0C78yi17ODSF17PyjJyIjkeJORCNIba4Twi6hWZBKpa7LIWCMGtQ//zbdWxZOsx/YVF8k9GUP8GB46y2c37BD3hWyAkELdYLKOhiWPxrpMWCdWitsFutCKSnUdfl2ExOkx7YeNsvABdkXYFqghkuhi/2pCt6KKztDBWr16LyGVQIWwhOxy+6bv7lqMcytkKWnFOD+qb4zgTlh0JgXXj6j8HD1S3WBTC/99HYuKuw== 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=8AAaM2LvTJIng1XrMlNccoRzSFO7cCbEaVik86vz2JQ=; b=k+PAJt6FMbQCkOlBaRsnpds+vNQt50vXLu605+Tfh8E0ETVVDJXMF1Ux86EWABWHFm1S7+zLmeg8Sm/S73nTfGcm3dLm9ljuOi4bY52r2iKIB65Fn17nDUi90WoixWJuy3mpOFLD0ondrqVXW+ehY7RjJeerAhzkE2pBFbuvUqU= Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB5820.namprd10.prod.outlook.com (2603:10b6:510:146::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21; Mon, 6 Dec 2021 12:44:15 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%5]) with mapi id 15.20.4755.022; Mon, 6 Dec 2021 12:44:15 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v10 3/8] qmp: add QMP command x-query-virtio Date: Mon, 6 Dec 2021 07:43:21 -0500 Message-Id: <1638794606-19631-4-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1638794606-19631-1-git-send-email-jonah.palmer@oracle.com> References: <1638794606-19631-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SA9P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::35) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 Received: from jonpalme-lnx.us.oracle.com (209.17.40.42) by SA9P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21 via Frontend Transport; Mon, 6 Dec 2021 12:44:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1ff5b328-ad36-461e-c895-08d9b8b61c78 X-MS-TrafficTypeDiagnostic: PH0PR10MB5820:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:549; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1oSssp+zcRKqAJCLQfWF0ZzBTKCoZE+xtBmxrzXp+rAReZYPtqIoaXmq+z3GdVse35/udzKZLAm8PzXcxFgx5CSGVw4jikrv4mrPfUhiPkRndGxYmQN4xPMTU1IM/ysWgFQ1fZmNh9wxLxGoB/m5yti3P6621qakgG2qJFzXtbplPqus0RDX6gepgc+Az3wWVJSSCv9arqnh6I1zVJlH6mM0kvSH+9RkRgGRaf0FVOHF1UdNG4WPaqCOXpzbP3T5yTD4cwE0OpMKTCkhX4twCnnKwD29fqfjRp7kFhCm8JHdRq2+Ys3t7AOyxSiAH+39T4SnxNrk+nmGsHsFP47ZC2uuoAT6Iyihba42OyEOJasZV3WDlejT+mEwec9sQLAyuBW55O864D0AgDVGb0/51K6PdyBfcS9EZZ3iDdbdHkXX8ouIFaQyIjiWw/DTYYO10lRI18bkLTjtCbrtaC90Z9rLfBK4i5epwhkzCOiknr+IPNgnw+8wFayFs8Dlrh7qk3nne9mvhCNxWLoGoJ0sqiD51sPvrSrDSPLU8MtY1iSAhGwkW7EIjj50ZlXzBMtc5aT7H3AyfbmGZ+7y48GFT8htmV9uN2qkST5doCY+l71Nu7UDX7RuT+VR8oOOwqxp/Taio8N2ueDOyBHq9lc4S26jHQyxCL+cZejHGZYwxQbtEUYuhuNBGQ7c1k4mmq0p2j/LxHTudH23I0855o0qrQ== 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)(44832011)(6486002)(6916009)(508600001)(7416002)(316002)(36756003)(956004)(8936002)(4326008)(2616005)(38350700002)(38100700002)(7696005)(52116002)(26005)(186003)(6666004)(86362001)(8676002)(66476007)(5660300002)(66556008)(2906002)(66946007)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: r9h/+z4vXLZgZDWM52HOxr82Lbsnk3nxJTr5Vu2fBTzubWjgnVkVeHx4j67WgPAMuXpQ7l2oo08tyfq155yeAmielujhQfxfzguB9cmgdWJv+CA+EfOl0nUuGGxZFbn3BcODR93uZv3RtQhSP2KWBtEMuve2FB8TsAzyHH+iFwDbWrn8QX79dn/tIbqX3MkQceyo0AAgZfQbutuKjqRuFZf81oHaCI/th3clA0HUFNiYWiufVohG6UQo3CGR3tRM+/upytzlwQBC5ExeQltPSGWyvGrkFzw8eRX/igzfpMxwo1IAoPPKH0w102eQtbhbmM+/MuvIr0zQ1mP5eGtG/IM7gqQ0gQfdqhXGHAy4YmwwwDeNrA8bxsS+Eh2rLQcZx+34POLj18u4AJvv4/kaZYDNfGi9JswAg4uxeBECcTu5cgxLEJ07dbLEUIF1vyAFxtn37rm9BMjKcRcAxlRVr7EwF1QDfaPp3BPKVVDlhxU/rp4kTsnkj/+XQXNozlU0BOmvFt8C9NYFQejrtIFD9IjbSaDFtvZ45tsQd5UVPuMinyZwD12iwLNiPCi7+uC5IYQmB/m9T+fPzv1iHr0KXhjpw6qK0OvBpeGfqxPnPTvxA6qRBrFhPZDSuqm5ejutS8GtdEHcARrM2jLN6UjTNq9TV1Sjf/X47SjIK7J7V5xJQGhnTPjo4Q3k8uKrdBkNGv0L/f8xTt38ZCRUheHZmtlRNiuKzitSgDx7xX+qVavBNgpxp3dyhX6Bi4L5TdemB0u9Esr4es4eVx/tlzNW2bEab2VajCQsM5JVP8FUQSTf3LLfIQPBkbF1n+wG9VDwXV2ZBUVciMewRyPE94Uopbez2aZ5NPUS8lPlJYsfULlByitBRxJN7wfcggAk0Z+Bqe2ghkZMyni8csVr/WOcd+nAQK/+Qdg0gOW7yJld0gK29e83Fx67EU3atV0BeYUNA8D/OUaJrNtnxfx9E8HRI9adHkCKJrqaC7R/v1+6TfiL7/9krQHnkOZS2zbQSSV6t4RqYk77aXgo4IHrkoAQkyCBcFd+uPpe4/LThih+eoeYAqLxplGAujie9ysOkMqNMG0knH04bdDGWcJK60jSNGxOz7P3+wmO5UqUdB17ihgquSvOELKg4mepdRfuRayWLZy1qKNQdkNP1Y7+PAXePfFom2Qyt9LMakrCN2g8YxSqU4Y+9Jj6HwiDF3YHZOjLMYe4f+7Gj7Fr9HKxwQmesbyzW8LsRx9T7xurZhQwX+pQvqkFZmrOt4W/oO6hA2FgLK62hW7rAVJSnEX1OOcFwtLPdZgqK1lvGaO99U4OcN/CyjFN6Mlh+KfY+txywtep5dORt+hYOkNmMK7rK2YPPbgzQQ7oHLuDSD5oxrWr6SP5JCuGn6RA5rRAMwFQo589oaQTwzt/50V5ELcg8jajmbMRXRyY5dr4sAQELXiccPUAi1cKnRjL+Ph1FP1S1WT4LzhKkNxAc7SY8ImOnZmmiIwz3bMyuU9K4+fOxswRlKpgRPi3p26RJxle7+g+wMjkeVyEyVBfg5kMEd0wfe+lLZl3yoUTyVS4sMqHCkg/0TYRTCZjoIKypTyXWMqzhg1vDGs12bu/QkdlWTSCKNdmcPUfkCPf6hS/FOmHucqJLKA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ff5b328-ad36-461e-c895-08d9b8b61c78 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2021 12:44:15.2803 (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: sFxswqNvI9d82fLT7o2FBzF9AMl7H/FVWKefwgyYIDMhSugdSF2hFNv4QJlF4BFpZQVKVSLgnji/9HP6/qYTQw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5820 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10189 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112060078 X-Proofpoint-ORIG-GUID: zs1y--zu3SjHAKOQfFGo6jeLsic07rCB X-Proofpoint-GUID: zs1y--zu3SjHAKOQfFGo6jeLsic07rCB Received-SPF: pass client-ip=205.220.177.32; envelope-from=jonah.palmer@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier This new command lists all the instances of VirtIODevices with their canonical QOM path and name. Signed-off-by: Jonah Palmer Reviewed-by: Markus Armbruster --- 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 | 68 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qtest/qmp-cmd-test.c | 1 + 8 files changed, 115 insertions(+) create mode 100644 hw/virtio/virtio-stub.c create mode 100644 qapi/virtio.json diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 521f7d6..d893f5f 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -6,8 +6,10 @@ softmmu_virtio_ss.add(when: 'CONFIG_VHOST', if_false: files('vhost-stub.c')) softmmu_ss.add_all(when: 'CONFIG_VIRTIO', if_true: softmmu_virtio_ss) softmmu_ss.add(when: 'CONFIG_VIRTIO', if_false: files('vhost-stub.c')) +softmmu_ss.add(when: 'CONFIG_VIRTIO', if_false: files('virtio-stub.c')) softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-stub.c')) +softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('virtio-stub.c')) virtio_ss = ss.source_set() virtio_ss.add(files('virtio.c')) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c new file mode 100644 index 0000000..05a81ed --- /dev/null +++ b/hw/virtio/virtio-stub.c @@ -0,0 +1,14 @@ +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-virtio.h" + +static void *qmp_virtio_unsupported(Error **errp) +{ + error_setg(errp, "Virtio is disabled"); + return NULL; +} + +VirtioInfoList *qmp_x_query_virtio(Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 867834d..76a63a0 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -13,6 +13,8 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-commands-virtio.h" +#include "qapi/qapi-visit-virtio.h" #include "cpu.h" #include "trace.h" #include "qemu/error-report.h" @@ -29,6 +31,9 @@ #include "sysemu/runstate.h" #include "standard-headers/linux/virtio_ids.h" +/* QAPI list of realized VirtIODevices */ +static QTAILQ_HEAD(, VirtIODevice) virtio_list; + /* * The alignment to use between consumer and producer parts of vring. * x86 pagesize again. This is the default, used by transports like PCI @@ -3700,6 +3705,7 @@ static void virtio_device_realize(DeviceState *dev, Error **errp) vdev->listener.commit = virtio_memory_listener_commit; vdev->listener.name = "virtio"; memory_listener_register(&vdev->listener, vdev->dma_as); + QTAILQ_INSERT_TAIL(&virtio_list, vdev, next); } static void virtio_device_unrealize(DeviceState *dev) @@ -3714,6 +3720,7 @@ static void virtio_device_unrealize(DeviceState *dev) vdc->unrealize(dev); } + QTAILQ_REMOVE(&virtio_list, vdev, next); g_free(vdev->bus_name); vdev->bus_name = NULL; } @@ -3887,6 +3894,8 @@ static void virtio_device_class_init(ObjectClass *klass, void *data) vdc->stop_ioeventfd = virtio_device_stop_ioeventfd_impl; vdc->legacy_features |= VIRTIO_LEGACY_FEATURES; + + QTAILQ_INIT(&virtio_list); } bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev) @@ -3897,6 +3906,24 @@ bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev) return virtio_bus_ioeventfd_enabled(vbus); } +VirtioInfoList *qmp_x_query_virtio(Error **errp) +{ + VirtioInfoList *list = NULL; + VirtioInfoList *node; + VirtIODevice *vdev; + + QTAILQ_FOREACH(vdev, &virtio_list, next) { + DeviceState *dev = DEVICE(vdev); + node = g_new0(VirtioInfoList, 1); + node->value = g_new(VirtioInfo, 1); + node->value->path = g_strdup(dev->canonical_path); + node->value->name = g_strdup(vdev->name); + QAPI_LIST_PREPEND(list, node->value); + } + + return list; +} + static const TypeInfo virtio_device_info = { .name = TYPE_VIRTIO_DEVICE, .parent = TYPE_DEVICE, diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 0a12bd5..3b4eb85 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -110,6 +110,7 @@ struct VirtIODevice bool use_guest_notifier_mask; AddressSpace *dma_as; QLIST_HEAD(, VirtQueue) *vector_queues; + QTAILQ_ENTRY(VirtIODevice) next; }; struct VirtioDeviceClass { diff --git a/qapi/meson.build b/qapi/meson.build index c0c49c1..e332f28 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -48,6 +48,7 @@ qapi_all_modules = [ 'sockets', 'trace', 'transaction', + 'virtio', 'yank', ] if have_system diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index 4912b97..1512ada 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -93,3 +93,4 @@ { 'include': 'audio.json' } { 'include': 'acpi.json' } { 'include': 'pci.json' } +{ 'include': 'virtio.json' } diff --git a/qapi/virtio.json b/qapi/virtio.json new file mode 100644 index 0000000..5372cde --- /dev/null +++ b/qapi/virtio.json @@ -0,0 +1,68 @@ +# -*- Mode: Python -*- +# vim: filetype=python +# + +## +# = Virtio devices +## + +## +# @VirtioInfo: +# +# Basic information about a given VirtIODevice +# +# @path: The VirtIODevice's canonical QOM path +# +# @name: Name of the VirtIODevice +# +# Since: 7.0 +# +## +{ 'struct': 'VirtioInfo', + 'data': { 'path': 'str', + 'name': 'str' } } + +## +# @x-query-virtio: +# +# Returns a list of all realized VirtIODevices +# +# Features: +# @unstable: This command is meant for debugging +# +# Returns: List of gathered VirtIODevices +# +# Since: 7.0 +# +# Example: +# +# -> { "execute": "x-query-virtio" } +# <- { "return": [ +# { +# "path": "/machine/peripheral-anon/device[4]/virtio-backend", +# "name": "virtio-input" +# }, +# { +# "path": "/machine/peripheral/crypto0/virtio-backend", +# "name": "virtio-crypto" +# }, +# { +# "path": "/machine/peripheral-anon/device[2]/virtio-backend", +# "name": "virtio-scsi" +# }, +# { +# "path": "/machine/peripheral-anon/device[1]/virtio-backend", +# "name": "virtio-net" +# }, +# { +# "path": "/machine/peripheral-anon/device[0]/virtio-backend", +# "name": "virtio-serial" +# } +# ] +# } +# +## + +{ 'command': 'x-query-virtio', + 'returns': [ 'VirtioInfo' ], + 'features': [ 'unstable' ] } diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c index 7f103ea..fd00ee2 100644 --- a/tests/qtest/qmp-cmd-test.c +++ b/tests/qtest/qmp-cmd-test.c @@ -103,6 +103,7 @@ static bool query_is_ignored(const char *cmd) "query-gic-capabilities", /* arm */ /* Success depends on target-specific build configuration: */ "query-pci", /* CONFIG_PCI */ + "x-query-virtio", /* CONFIG_VIRTIO */ /* Success depends on launching SEV guest */ "query-sev-launch-measure", /* Success depends on Host or Hypervisor SEV support */ From patchwork Mon Dec 6 12:43:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 12658281 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AF2DCC433F5 for ; Mon, 6 Dec 2021 12:57:00 +0000 (UTC) Received: from localhost ([::1]:53910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muDYB-0007qD-J2 for qemu-devel@archiver.kernel.org; Mon, 06 Dec 2021 07:56:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDMC-0000YP-SD; Mon, 06 Dec 2021 07:44:36 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:64440) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDM8-0001xB-Ic; Mon, 06 Dec 2021 07:44:36 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6CA4Ye023237; Mon, 6 Dec 2021 12:44:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=rInXhSoG/aSjBm1Nw74UrSir7jmVHm5AWcvsXWIDeBY=; b=OjTk1rjKtOYHkMARgiJihleKYP5LoKkhtTDEZ/V2FW13P4QFFEIK3cys8b456AQ6eqqX B56r6p8Vzp5sFurSQhcg4p2G+ADxmmRLTOeOBbYyyhS8q9nETcxKcksjJ4eOso56fS8F sStOr10BorqtRyarXLCz2XFoIjSk+xrb76HUZjiqtLIqxSnBGSlIsBUSM5sT0F6e5syj dChaDrN8LBzgOTjJzK1GIiU/eI1e2qZxM0pfes9sfpPFBcGRd+OM2JOslpKUxxpXLOs/ DHNmj9080UQCNBVhE++QPVNvKSzju00ujoyrmSkJpWshRFC4uiFnAr/L6Bh069FiiXa2 sw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3csbbqj2nx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Dec 2021 12:44:21 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B6Cf9F5139474; Mon, 6 Dec 2021 12:44:20 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2106.outbound.protection.outlook.com [104.47.70.106]) by aserp3030.oracle.com with ESMTP id 3csc4rqj6f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Dec 2021 12:44:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RJmumpmYeT58O/Rf2fj+p/KA3giBvOfIoKjXpt/U5VBM7K2706Ca+zW0jAWBS887LtoqzMAUgSeNhMcylj8oVRYHRJHWJgAg1CMWp8uJMvHrxEh+ADP4rt2dyHKLtw0NT64dCD05AK22NQtdVB6jEk5f3xfFp+8RcjKWOquusiJqkJcBLHXfPsFWnqFce+XdpgSe9LiTT75z9qtdzkI6P6wMumSGmjGbxbilgV4d4BDxUJyYKn0+XEtQFA/G4zCBzrStmnymHINSBPXJbPpblGLXX/DkynUrlGsGazyr4ybn+T4ZzwJC19Xr5E3zaEjB+07p6pP+1lFRToHE3t8Cpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rInXhSoG/aSjBm1Nw74UrSir7jmVHm5AWcvsXWIDeBY=; b=d9ueWNTi3ScRS2nuhBqKV7sXxmMJ9yKThMrGdyGHQiCTAR1WxAIgcp7YaYvhH7ajexXUtxF3JFHDE1vC7ell00JW7T6p0gepCXJWUVVHNLeoSiHHLeoBsZgCzbQGc9rdBhBW790EehTZjOOwh+41HvznzCv7HXCOG+EpdoeDFodGCn0gGhShGffYzbPoS6y+VeWIVOWtX58DP55f4CBmAbgJZGmz+RFXIi+8vAJqRRGqspFsS77aHoTF7upT+9XIYv/fAWP3EUxGKhr5yRE3akcRu2wmN2aGNjOpoENYX2Mx58MGPlxW23PSX7YvK0rUpDUsA7Ty0BFndFVzIfkaLw== 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=rInXhSoG/aSjBm1Nw74UrSir7jmVHm5AWcvsXWIDeBY=; b=swRUqMpOPAHfe//48TRghDx2vPDmaBW/1Xk99C8sIQ5p/pTRKBPwr9GEsKDd1mPxw+eJ7MYjXY0szhLi1Bw/6ForxpW8PuWfp0YGzGSD5tHk0KmErMOb7GuIV3ddLcSA4KqGEGRPIJiSd8Cdb6RZui8VaZ0IQXSTOS7vOcTwm6Q= Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB4791.namprd10.prod.outlook.com (2603:10b6:510:3a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.20; Mon, 6 Dec 2021 12:44:18 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%5]) with mapi id 15.20.4755.022; Mon, 6 Dec 2021 12:44:18 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v10 4/8] qmp: add QMP command x-query-virtio-status Date: Mon, 6 Dec 2021 07:43:22 -0500 Message-Id: <1638794606-19631-5-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1638794606-19631-1-git-send-email-jonah.palmer@oracle.com> References: <1638794606-19631-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SA9P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::35) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 Received: from jonpalme-lnx.us.oracle.com (209.17.40.42) by SA9P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21 via Frontend Transport; Mon, 6 Dec 2021 12:44:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 238f27fe-ad6c-4544-cac5-08d9b8b61e20 X-MS-TrafficTypeDiagnostic: PH0PR10MB4791:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:294; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2p8B5CNMRvcc1kPktabgIAsCIDM2odIf8WGlyd5+HlwwuEi7o3OQleKwM4jWr2a4Vak4PrcvcuWgJemFFRwJloZZ3ZGa/9F+yRN7eg7i9crGR/lmghMLs6jK50yd4Qwf0dJl+6iAPvCQoUGACJVdc6Ki3saskhV8IjUMBznSnqLU2M35aMQXzUzn+3be0iLk7n8UdzpBJR7buZKqRZ4SeakS/MY+UgOq35X+Awdk2JnhJaHE6TNIYfP6sXrP6KyosRukMH8KaO+6ZE+vURLKDb04R1tXRurF07GnXC+FaGCu5zMm14QIyp7km0c7mGYTrVEokVex3DumVz2e+UxhLYF7eq6/YO64unP0YuVB40a+fkf0JoikgxBb+d1x+kUSSyjiegO7yN+fKyMXhCaxJCtE0eItGYW37HugDlsEGlqym2f7HqkLslvIIbE2lQHzmgc53PchxsvR4HE9SSNK51mzrh/l+8B60ucGgkHlAGBBz5yHDMsVDfTemHDJTK5bjUsrrIq1vuObyQkNGu9Htt/LPLgKiCwULzUB7wsjNM6xPsSc7qOr7u9pzeu7WI9cFm+j6RzaM/smv1AIQ8zTLFD8SYCPywmXX/Gm5m7ijMVam6lr+mtXdVYD7luSHkijhPjoEdlEhUrWxM8pWIfd7ZPONXlxfvkn37RzKSLTvjkkGZ0aAXCAjjAZ6mPseM+qhGTvbPIrQ6VSX+A7hjb3Nw== 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)(956004)(66556008)(52116002)(186003)(8936002)(38350700002)(508600001)(6486002)(2616005)(83380400001)(7696005)(36756003)(6916009)(86362001)(38100700002)(66476007)(5660300002)(26005)(316002)(66946007)(4326008)(6666004)(7416002)(8676002)(44832011)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wfDTZz9eAsyQtHziWtVHj0VkzOZp/e2YvUQcAUfxkC//EYT8STdRhBpKm8EJXgcM7HBt9PwnN9181tDI4LqaDcHPVhOq4Y7GveegHPgKFfKMoZxCZEQ9LARt6epNdkD2DHO+XxtdgoehRfp9gMsD0LlC6bz16/A75bdYHmWGOVs/PC8RbYvEK940bcL6FkY8qQJ9XNTlhyp7YuMNMQy538dE8H8i/Bpc/J3tr3VcWpdUi5mEA40wOuLxpT6lqKgykJKdG8SU9fLwx01ZspMRcxoZKqWQzMuZTWIVwdCcyVO8X2B9LbIxhRqDaXHvqeIynKW4roEILMj8oBIhxiaSBbeD0B1yLp1pSv6Rnxb/QEXdVApRwPA6Sw3N3GJ5CrxNxJinIo2rbhSb5YPDSxr5lnGYU9R94FoA5MsgTyVMNvuzcNaQu+IAqEiDD1ASuWFbmoopsQeDm6iGTygE1jIf2Yb3wyVTXHilFDOHA/ee3TB8jWXwwrQod6UxZqk5n0YyspDTp98CkUNw18Xiu6A0ziqdBViy9YTan5fDAWGmN3dPuz+0oPwWjkzgy8aQTp70vgCglCNW456m5uEoGv8DmCY7G1aZErNv1SozYONGPUi177DxV/Q/MdLaQbl/j6lGCOpj6g6yHI27DNT6PRxTMJoTtlsE9LmknkNKepvr6Quf90TACn4b4yFsOBbsLVtfDVecBARPqFur1YueuX2T6PEF+BKC+JgWJEvP7mCUHMlRqKDokjezUvKYbjZJ7X5IXTss6PmM4jIheOOyABcLXExOLbmKphJGgzGx3OvIMRZOmx651Ql7ih8vfZbjyzOeq70nzaOhFhIyXvKUcc6lddGs02ZlMuuM4g+ZxiKMPvV42Ak3LoPA61oDxY2RRd1DStEsM15TOJT9TLj03FW824rtAPq737VlY44+QV91LD6MNt2Z3Ljwyi1s40I8wH5nAV5f+FngF2CT+1VUh2GrRq9wXlxlnUt7/hO65bphOf+oINohe/FjaBKDMPB52QYVcEANepbgXfm5NHds6hLzo0vpMygI2kNAHt0u3MCk5W5/mch31NWgYw5dv1cjkXvtpxWgUfe3nE0Ls3hniD+TEGuw5w7h1ODti7SFlcqBW6ZXGjbw3JtAnk7nrIAVY5or7Vb7k1Z+tVLTcR7fWheN7ukHKIylKa//EVz01V2iW6WJgsQEQq1rJGonPZQ+BIz7S104/hcWb7s6bQKHBqB5Jp2tb54PxYvxn7F1zNA++9dBJpnOH32jd1vDsxEOAOohwYNm2dS5rStmXx+z0TF/6R86qtcq45cuYWrwzYuphR3YPNFLaXPCnllYwCZRDCbgID9dxMPYhSjFoER5zMS+h/x3GvN6RTTyNdVSh0c+1aqVnRxk5FP0JZx/S04zbbYZ7PV49qB3XbnP7gds1JFQk2Ia7RVP4qEwTkqozwKz52mAtBeFjwqC0cjHqZCK0/gDLmF6WT/aYwKmclmj/yzENHtSUR8uLkdzxWfGmvbLECnPfbzf7A8UW+4hjUpgDWmXlxPhI+k3b+GwkMHeHxpvLMqx4Kx+gQJf5pUOg/WsTt2MTud1iz8Qw5qCiLe9ju4OUCyems21JEqn3+LR6il6Qvy6KarLGKStDfNMpY3MB6w= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 238f27fe-ad6c-4544-cac5-08d9b8b61e20 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2021 12:44:18.0910 (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: pERmCvDLpEZNDwsAc9KWlts2HUMAQ8+Pvr1dp4Dy6nNfZE2YW+WVIuakWs6pV95CwcsMBY+En/4V9G9IYNuZLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4791 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10189 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112060078 X-Proofpoint-GUID: AEkSG1uJofawukMt_49DoOMnWjqV8Ot8 X-Proofpoint-ORIG-GUID: AEkSG1uJofawukMt_49DoOMnWjqV8Ot8 Received-SPF: pass client-ip=205.220.177.32; envelope-from=jonah.palmer@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier This new command shows the status of a VirtIODevice, including its corresponding vhost device's status (if active). Next patch will improve output by decoding feature bits, including vhost device's feature bits (backend, protocol, acked, and features). Also will decode status bits of a VirtIODevice. Signed-off-by: Jonah Palmer Acked-by: Markus Armbruster --- hw/virtio/virtio-stub.c | 5 ++ hw/virtio/virtio.c | 84 ++++++++++++++++++ qapi/virtio.json | 220 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 309 insertions(+) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index 05a81ed..0b432e8 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -12,3 +12,8 @@ VirtioInfoList *qmp_x_query_virtio(Error **errp) { return qmp_virtio_unsupported(errp); } + +VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 76a63a0..b8112ca 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3924,6 +3924,90 @@ VirtioInfoList *qmp_x_query_virtio(Error **errp) return list; } +static VirtIODevice *virtio_device_find(const char *path) +{ + VirtIODevice *vdev; + + QTAILQ_FOREACH(vdev, &virtio_list, next) { + DeviceState *dev = DEVICE(vdev); + + if (strcmp(dev->canonical_path, path) != 0) { + continue; + } + return vdev; + } + + return NULL; +} + +VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) +{ + VirtIODevice *vdev; + VirtioStatus *status; + + vdev = virtio_device_find(path); + if (vdev == NULL) { + error_setg(errp, "Path %s is not a VirtIODevice", path); + return NULL; + } + + status = g_new0(VirtioStatus, 1); + status->name = g_strdup(vdev->name); + status->device_id = vdev->device_id; + status->vhost_started = vdev->vhost_started; + status->guest_features = vdev->guest_features; + status->host_features = vdev->host_features; + status->backend_features = vdev->backend_features; + + switch (vdev->device_endian) { + case VIRTIO_DEVICE_ENDIAN_LITTLE: + status->device_endian = g_strdup("little"); + break; + case VIRTIO_DEVICE_ENDIAN_BIG: + status->device_endian = g_strdup("big"); + break; + default: + status->device_endian = g_strdup("unknown"); + break; + } + + status->num_vqs = virtio_get_num_queues(vdev); + status->status = vdev->status; + status->isr = vdev->isr; + status->queue_sel = vdev->queue_sel; + status->vm_running = vdev->vm_running; + status->broken = vdev->broken; + status->disabled = vdev->disabled; + status->use_started = vdev->use_started; + status->started = vdev->started; + status->start_on_kick = vdev->start_on_kick; + status->disable_legacy_check = vdev->disable_legacy_check; + status->bus_name = g_strdup(vdev->bus_name); + status->use_guest_notifier_mask = vdev->use_guest_notifier_mask; + status->has_vhost_dev = vdev->vhost_started; + + if (vdev->vhost_started) { + VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); + struct vhost_dev *hdev = vdc->get_vhost(vdev); + + status->vhost_dev = g_new0(VhostStatus, 1); + status->vhost_dev->n_mem_sections = hdev->n_mem_sections; + status->vhost_dev->n_tmp_sections = hdev->n_tmp_sections; + status->vhost_dev->nvqs = hdev->nvqs; + status->vhost_dev->vq_index = hdev->vq_index; + status->vhost_dev->features = hdev->features; + status->vhost_dev->acked_features = hdev->acked_features; + status->vhost_dev->backend_features = hdev->backend_features; + status->vhost_dev->protocol_features = hdev->protocol_features; + status->vhost_dev->max_queues = hdev->max_queues; + status->vhost_dev->backend_cap = hdev->backend_cap; + status->vhost_dev->log_enabled = hdev->log_enabled; + status->vhost_dev->log_size = hdev->log_size; + } + + return status; +} + static const TypeInfo virtio_device_info = { .name = TYPE_VIRTIO_DEVICE, .parent = TYPE_DEVICE, diff --git a/qapi/virtio.json b/qapi/virtio.json index 5372cde..235b8f3 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -66,3 +66,223 @@ { 'command': 'x-query-virtio', 'returns': [ 'VirtioInfo' ], 'features': [ 'unstable' ] } + +## +# @VhostStatus: +# +# Information about a vhost device. This information will only be +# displayed if the vhost device is active. +# +# @n-mem-sections: vhost_dev n_mem_sections +# +# @n-tmp-sections: vhost_dev n_tmp_sections +# +# @nvqs: vhost_dev nvqs (number of virtqueues being used) +# +# @vq-index: vhost_dev vq_index +# +# @features: vhost_dev features +# +# @acked-features: vhost_dev acked_features +# +# @backend-features: vhost_dev backend_features +# +# @protocol-features: vhost_dev protocol_features +# +# @max-queues: vhost_dev max_queues +# +# @backend-cap: vhost_dev backend_cap +# +# @log-enabled: vhost_dev log_enabled flag +# +# @log-size: vhost_dev log_size +# +# Since: 7.0 +# +## + +{ 'struct': 'VhostStatus', + 'data': { 'n-mem-sections': 'int', + 'n-tmp-sections': 'int', + 'nvqs': 'uint32', + 'vq-index': 'int', + 'features': 'uint64', + 'acked-features': 'uint64', + 'backend-features': 'uint64', + 'protocol-features': 'uint64', + 'max-queues': 'uint64', + 'backend-cap': 'uint64', + 'log-enabled': 'bool', + 'log-size': 'uint64' } } + +## +# @VirtioStatus: +# +# Full status of the virtio device with most VirtIODevice members. +# Also includes the full status of the corresponding vhost device +# if the vhost device is active. +# +# @name: VirtIODevice name +# +# @device-id: VirtIODevice ID +# +# @vhost-started: VirtIODevice vhost_started flag +# +# @guest-features: VirtIODevice guest_features +# +# @host-features: VirtIODevice host_features +# +# @backend-features: VirtIODevice backend_features +# +# @device-endian: VirtIODevice device_endian +# +# @num-vqs: VirtIODevice virtqueue count. This is the number of active +# virtqueues being used by the VirtIODevice. +# +# @status: VirtIODevice configuration status (VirtioDeviceStatus) +# +# @isr: VirtIODevice ISR +# +# @queue-sel: VirtIODevice queue_sel +# +# @vm-running: VirtIODevice vm_running flag +# +# @broken: VirtIODevice broken flag +# +# @disabled: VirtIODevice disabled flag +# +# @use-started: VirtIODevice use_started flag +# +# @started: VirtIODevice started flag +# +# @start-on-kick: VirtIODevice start_on_kick flag +# +# @disable-legacy-check: VirtIODevice disabled_legacy_check flag +# +# @bus-name: VirtIODevice bus_name +# +# @use-guest-notifier-mask: VirtIODevice use_guest_notifier_mask flag +# +# @vhost-dev: Corresponding vhost device info for a given VirtIODevice +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtioStatus', + 'data': { 'name': 'str', + 'device-id': 'uint16', + 'vhost-started': 'bool', + 'device-endian': 'str', + 'guest-features': 'uint64', + 'host-features': 'uint64', + 'backend-features': 'uint64', + 'num-vqs': 'int', + 'status': 'uint8', + 'isr': 'uint8', + 'queue-sel': 'uint16', + 'vm-running': 'bool', + 'broken': 'bool', + 'disabled': 'bool', + 'use-started': 'bool', + 'started': 'bool', + 'start-on-kick': 'bool', + 'disable-legacy-check': 'bool', + 'bus-name': 'str', + 'use-guest-notifier-mask': 'bool', + '*vhost-dev': 'VhostStatus' } } + +## +# @x-query-virtio-status: +# +# Poll for a comprehensive status of a given virtio device +# +# @path: Canonical QOM path of the VirtIODevice +# +# Features: +# @unstable: This command is meant for debugging +# +# Returns: VirtioStatus of the virtio device +# +# Since: 7.0 +# +# Examples: +# +# 1. Poll for the status of virtio-crypto (no vhost-crypto active) +# +# -> { "execute": "x-query-virtio-status", +# "arguments": { "path": "/machine/peripheral/crypto0/virtio-backend" } +# } +# <- { "return": { +# "device-endian": "little", +# "bus-name": "", +# "disable-legacy-check": false, +# "name": "virtio-crypto", +# "started": true, +# "device-id": 20, +# "backend-features": 0, +# "start-on-kick": false, +# "isr": 1, +# "broken": false, +# "status": 15, +# "num-vqs": 2, +# "guest-features": 5100273664, +# "host-features": 6325010432, +# "use-guest-notifier-mask": true, +# "vm-running": true, +# "queue-sel": 1, +# "disabled": false, +# "vhost-started": false, +# "use-started": true +# } +# } +# +# 2. Poll for the status of virtio-net (vhost-net is active) +# +# -> { "execute": "x-query-virtio-status", +# "arguments": { "path": "/machine/peripheral-anon/device[1]/virtio-backend" } +# } +# <- { "return": { +# "device-endian": "little", +# "bus-name": "", +# "disabled-legacy-check": false, +# "name": "virtio-net", +# "started": true, +# "device-id": 1, +# "vhost-dev": { +# "n-tmp-sections": 4, +# "n-mem-sections": 4, +# "max-queues": 1, +# "backend-cap": 2, +# "log-size": 0, +# "backend-features": 0, +# "nvqs": 2, +# "protocol-features": 0, +# "vq-index": 0, +# "log-enabled": false, +# "acked-features": 5100306432, +# "features": 13908344832 +# }, +# "backend-features": 6337593319, +# "start-on-kick": false, +# "isr": 1, +# "broken": false, +# "status": 15, +# "num-vqs": 3, +# "guest-features": 5111807911, +# "host-features": 6337593319, +# "use-guest-notifier-mask": true, +# "vm-running": true, +# "queue-sel": 2, +# "disabled": false, +# "vhost-started": true, +# "use-started": true +# } +# } +# +## + +{ 'command': 'x-query-virtio-status', + 'data': { 'path': 'str' }, + 'returns': 'VirtioStatus', + 'features': [ 'unstable' ] } From patchwork Mon Dec 6 12:43:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 12658279 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96AE8C433EF for ; Mon, 6 Dec 2021 12:56:21 +0000 (UTC) Received: from localhost ([::1]:51774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muDXY-0006Ji-LJ for qemu-devel@archiver.kernel.org; Mon, 06 Dec 2021 07:56:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDMm-0000no-9z; Mon, 06 Dec 2021 07:45:12 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:41966) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDMU-00020J-2G; Mon, 06 Dec 2021 07:44:57 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6C5As1023240; Mon, 6 Dec 2021 12:44:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=8qInwgMpf+UzuHXr3i/0XZ+VnDb+8vdGwmlMTuzqRh8=; b=hJCK7KwgLMja5Glkgwdw2eQN5WHZARdRMDECQ4vDARD47gqgpqRx4qHnffBl+m0YxYf2 RjqmMR+ApvnC6afmmgRuKFLqHGKPp344/CHIE80nfoB2lq59GlIaoJlZuMqEW8NoxZs1 XUe0BkfEjmFEXP++y09Rr+QQAT4r/rgERopb9MODcHEHj2YjdrGa55rNfBP7zpaa4x1p kjZCX6DKS7YV2XcTK7XubajloBQ47hncKhS8ZxZjsbNsFfPrXZ1S/ebI5Vt60IWeVBz7 7ZlgJfX1OM5mtgiQYRQBRB0KkXbl7fgBp6TdmUjFQQg9H3DC6vZlu7yE02ArVsnbD1b3 ZA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3csbbqj2pb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Dec 2021 12:44:24 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B6Cf9oa139484; Mon, 6 Dec 2021 12:44:23 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2102.outbound.protection.outlook.com [104.47.70.102]) by aserp3030.oracle.com with ESMTP id 3csc4rqj89-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Dec 2021 12:44:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mk0QLBG8HzqOZzwppVJ840BWmsaq28NKJFNTdNtWJMZRS/EKXI+1P7cAF0Px8l3RIjoadcI/+NRHpp6XKxnFIh4QPw8K17EgFxB6JL8+LiInTKvV/guPUqeK//wxJ78JzooJ0Y3sl3yOpQ6OfLM6LeTyl7LP0KWdmhAwRX5/UZutog1Yv9DCETbBRG7AHsJYqfnWNsxgziggYlvOhwWRc/JCbmWy+XjsxZaZYRArZdA1HsJzCEtntD7rSGRr2v8o6weK6ODQTBqxGXy3BA+zAP+KDwGJNdnbN9CNwKRoW3RbyjRXoF5PQMHLxWoeZPDw8Qs9NPHxuQgzrEbkujEPcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8qInwgMpf+UzuHXr3i/0XZ+VnDb+8vdGwmlMTuzqRh8=; b=mSfUk3+DWJRPVCIFQpOw95DBZjVEsPS6bPqrwR7izSJHrtf+pbIUQFghgEKnd18Y2gAZo5wc2E/UPIiVkAOrx+SoELXvGCeSRZ1AwBLx1YqXPJXHqSY86Ct+YW9r+7RrXSOKtbEQRS2pH4ZzkBTZwp3YDPZY+pDH1qY/dg74/LoF1JvO8Q+42QbOi9Dp7NKzNfNsTlWqEPAKYCNr7nk/h1UDLZSuWgmpC6nsqcGlE/WlMMuymAA4NP7fH8SXLrzsZ9d12FSMIQ9HHJyJcB6VpDV3nVZmGdOABbp0RdaNQk3TYIEC5xpkGBCk7huPTxcizbDV1feky+kcVagdno8/9w== 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=8qInwgMpf+UzuHXr3i/0XZ+VnDb+8vdGwmlMTuzqRh8=; b=dZjVucvwkhMTkgfOK9fqYkFeud1hXGGhxiEcnH5Z2kDy9Womu6ZA16HlWC4gCcCFG/NWVtsRvZrPP3ytiUC7y7zRi4MFr5PAGIiTBUycSkHFEpWI7uM4YYcQvJJRQlwrgX+WEqODQvzs/8PgltoPyJK3QT6NMz9zFqMBq/05i2w= Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB4791.namprd10.prod.outlook.com (2603:10b6:510:3a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.20; Mon, 6 Dec 2021 12:44:21 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%5]) with mapi id 15.20.4755.022; Mon, 6 Dec 2021 12:44:21 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v10 5/8] qmp: decode feature & status bits in virtio-status Date: Mon, 6 Dec 2021 07:43:23 -0500 Message-Id: <1638794606-19631-6-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1638794606-19631-1-git-send-email-jonah.palmer@oracle.com> References: <1638794606-19631-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SA9P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::35) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 Received: from jonpalme-lnx.us.oracle.com (209.17.40.42) by SA9P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21 via Frontend Transport; Mon, 6 Dec 2021 12:44:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 814803de-874a-4c6f-e035-08d9b8b61fc2 X-MS-TrafficTypeDiagnostic: PH0PR10MB4791:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CMMxMM83e6ecq6hg5XDRXPL7mfVy0CmC97brO8P22cdwaeJr5Ai40isfXZ+Lh8+72qchZVWd8t+pU0GS1d2m43jjVkq6fmwk1TW7KWeNeAOXGMd6SQrHCK2B1b+NR3Vh/Ux6o15eopYkD6lz4Jt0c8cbHv1jryvwNHo26WMcUac5rctmO5jl1rv+bUSF3W38MjKgKhwLCBUaTaoQXR5BmA/i6hf75q7QUg6/UkjqndaessB8wSL1EVx5JeuIhUm5Lt1avEoQdmxCMs1sra0mJmw1vxAoFdjelIklylz8Ci6C73bCtQvba9NmYdrl3pR7dAgy5qTpbsf0AOVLwjIVdxEzLA5u/nNKoS40YSmfmZJXgptHESmenR2jovcli4ur5tA5fmYboCAEyT3OOcFJLpsz369rZ1y9uB1gJLsdtlU/M0WSA7INL/4+13T8qbk7bO54ZYAEhkQYZzRL/M0tUqRTdcuuuoJBXB/qqGzabePoGv1oMvbHUXvrZ9x3h5xLqleeLHkr+FeJO9yg5ZHl77ik99YaAtsP6gTE/edBEHe9VdNQx2CVW0RSAy3nJvAHkVonnb8EEbyJI+Z7ayvdGERdSvWKO7Ijb1jnYIdqPX9xtJ0HQ58BEF8679gDRmqrhIYwMoFeXwsoVrtmoy7qBpBH29YCAwaxz5gti48pJf1116vH+0+44R9aMdJtRvf0 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)(956004)(66556008)(52116002)(186003)(8936002)(38350700002)(508600001)(6486002)(2616005)(83380400001)(7696005)(36756003)(6916009)(86362001)(38100700002)(30864003)(66476007)(5660300002)(26005)(316002)(66946007)(4326008)(6666004)(7416002)(8676002)(44832011)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ic3SXbxz0YbQP8jXBMXHxV8+XHEkUEr4LZf5gdnqy9wCOBQwzUMud0E2XP2khAnG3LBQ4nKcpaxXD6QcTKCPwQfDGqubaMf1NW1jw04TlImS7jO9Qs6UczkgIBUO8xQfy8KB6RLRcfh5RyTSAtUsAJ8kcXhXNikznlZbJkM0x4Z0tJaOAYat6RPLo9x6EZn65tqchjx+IkutquRZ79pikBk0XsZHUkkybVuUDvUDv6HrwR+ZeTrFTp47b/P/fuejSZ1CpPCF3R0sL3uBUC8g65tTCLi52iEtnmp1K+VYaGX4RqyWf+x5r+ruQveqDed3yTuoTSpuZgMXBXUQTDIew2rfJ/kzS2lNySmLxXK5v2xSnWvPWgtjBMJ/bNnXA7pkcbVUrFysdvE/Rzqq5Y7twB0czpwpE5jR9RiKOCOflwgVkLhlVxWkMTfeoarpS3gB/WORQWC61nng3g1Te3bc+obueqOx1oshB9Mc8k3Z/Xcf4M3TDb+uzO+yNCmhtUMcfRVBOBBDZF5AYmv0P3dfkg5ZzEh/0t8tlDUMrKM/A466y4cvq1R/Q8ZQ2/zDo/qiXoEzL/lhMMXpOBxemlRUdFzmfUOVIW4vCzazF01JXCAaIcmcHoHsIczwRfi/od8mQiDgX3uMzixkcy69NKCsZE9Y1+9uDNDqm9JcW/2VGNI35i3lQoj2mXECqUPoU2dy7Z7GzhS4KywiiCONeLUyuVB1cZ9rDRBeGESasIkUn2Vyg5oUhrRsxPl9cy3oCw8PN+hoZ92L2//uHeGQjnqfuhx8duIO2U83rVPSTdXnCStZoIZBlWfzD+fKSKjs5umhgCM80OSqi6U9fBDxSA6p/sOPaoNeed7j1D3Q4A0W16ZqsT2zJ+FTvHS5QP7/W63Btx24jEbwEU4AgFx6BTWmwkoekMBPbceoquqV1j+iwyU9+YAZb5iTGkc/13bmJZCoC8nzZN6IjMTIXUu3cAN+dUJHxsltl2aN/byFNqrJZT0d7xs2aDK08x1JcG4ER+mZ2Tm9JF3wOiXgpL2UtvxPv+/1zLguL2qnsJIABO39qDto6eY52rNKGSzjib50/k/vN84cxYbrWOnkCCqWgI/VYWVSI5SlaNLf/RIGWIMxGoKxpalm5xTnPPgpmSPdcsUmiiXow3siEYur9qV68VN5yk1u8N2IGuVmfRfoDEso8v1Bpu4mwb/2XZJ002/IC9XC9QFRqJ/83L8LntR08DvvpSL239j0hdPOevaJBaDtKfHTPMB3wvmOG8TFEJ/EnrE+kraxHkC3BcQTFZa22jtMUgTcAcNIEF4qRHFDcOAbloWNpy/6Fzy+k5pb3VNBT3YJdeFG+QnaS9S6abPCifKcwj3uq/n0MFwadg898BGfpBfknYhNo6Ioghgv2yF1JGPLy2tRNLJXhsTvT9Tz6KPXarQCiXQIjaNsiIhMblbXskZ2CsZflWhRhZdASiWdQx50ZDqgPSZDOL43PZb1OyABToioENUfsUjxYgMbbFHCYCPsi05hIFxJkCuUkUYudQtr06SgCF8FTK3+tfpg2RwsiXC7S6pk8swFN8ix8ynE63tBjLBDxPjhwyaJTIUiEDAuATbMKNAxcsPg1hxh8uEZq993dx+QZpsU+lJ/th8R9zg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 814803de-874a-4c6f-e035-08d9b8b61fc2 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2021 12:44:20.8917 (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: Mf3smiAqwX/z5GDH1dMuzzNA98NqBBzh2VoVb7R264bzCUFdeGjaoDbQVo5lcM8NmNjn3TwCQ2XLOGQOQPYoLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4791 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10189 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112060078 X-Proofpoint-GUID: 6XNYL4viVDidqBCyGHMck3Tc8dO5iUE9 X-Proofpoint-ORIG-GUID: 6XNYL4viVDidqBCyGHMck3Tc8dO5iUE9 Received-SPF: pass client-ip=205.220.177.32; envelope-from=jonah.palmer@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier Display feature names instead of bitmaps for host, guest, and backend for VirtIODevices. Display status names instead of bitmaps for VirtIODevices. Display feature names instead of bitmaps for backend, protocol, acked, and features (hdev->features) for vhost devices. Decode features according to device ID. Decode statuses according to configuration status bitmap (config_status_map). Decode vhost user protocol features according to vhost user protocol bitmap (vhost_user_protocol_map). Transport features are on the first line. Undecoded bits (if any) are stored in a separate field. Signed-off-by: Jonah Palmer --- hw/block/virtio-blk.c | 29 +++++ hw/char/virtio-serial-bus.c | 11 ++ hw/display/virtio-gpu-base.c | 18 ++- hw/input/virtio-input.c | 10 ++ hw/net/virtio-net.c | 47 +++++++ hw/scsi/virtio-scsi.c | 17 +++ hw/virtio/vhost-user-fs.c | 10 ++ hw/virtio/vhost-vsock-common.c | 10 ++ hw/virtio/virtio-balloon.c | 14 ++ hw/virtio/virtio-crypto.c | 10 ++ hw/virtio/virtio-iommu.c | 14 ++ hw/virtio/virtio-mem.c | 11 ++ hw/virtio/virtio.c | 286 +++++++++++++++++++++++++++++++++++++++-- include/hw/virtio/vhost.h | 3 + include/hw/virtio/virtio.h | 18 +++ qapi/virtio.json | 156 +++++++++++++++++++--- 16 files changed, 635 insertions(+), 29 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 505e574..d550f077 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/iov.h" #include "qemu/module.h" #include "qemu/error-report.h" @@ -32,10 +33,38 @@ #include "hw/virtio/virtio-bus.h" #include "migration/qemu-file-types.h" #include "hw/virtio/virtio-access.h" +#include "standard-headers/linux/vhost_types.h" /* Config size before the discard support (hide associated config fields) */ #define VIRTIO_BLK_CFG_SIZE offsetof(struct virtio_blk_config, \ max_discard_sectors) + +qmp_virtio_feature_map_t blk_map[] = { +#define FEATURE_ENTRY(name) \ + { VIRTIO_BLK_F_##name, #name } + FEATURE_ENTRY(SIZE_MAX), + FEATURE_ENTRY(SEG_MAX), + FEATURE_ENTRY(GEOMETRY), + FEATURE_ENTRY(RO), + FEATURE_ENTRY(BLK_SIZE), + FEATURE_ENTRY(TOPOLOGY), + FEATURE_ENTRY(MQ), + FEATURE_ENTRY(DISCARD), + FEATURE_ENTRY(WRITE_ZEROES), +#ifndef VIRTIO_BLK_NO_LEGACY + FEATURE_ENTRY(BARRIER), + FEATURE_ENTRY(SCSI), + FEATURE_ENTRY(FLUSH), + FEATURE_ENTRY(CONFIG_WCE), +#endif /* !VIRTIO_BLK_NO_LEGACY */ +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; + /* * Starting from the discard feature, we can use this array to properly * set the config size depending on the features enabled. diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 9f19fd0..9de2575 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/iov.h" #include "qemu/main-loop.h" #include "qemu/module.h" @@ -32,6 +33,16 @@ #include "hw/virtio/virtio-serial.h" #include "hw/virtio/virtio-access.h" +qmp_virtio_feature_map_t serial_map[] = { +#define FEATURE_ENTRY(name) \ + { VIRTIO_CONSOLE_F_##name, #name } + FEATURE_ENTRY(SIZE), + FEATURE_ENTRY(MULTIPORT), + FEATURE_ENTRY(EMERG_WRITE), +#undef FEATURE_ENTRY + { -1, "" } +}; + static struct VirtIOSerialDevices { QLIST_HEAD(, VirtIOSerial) devices; } vserdevices; diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 5411a7b..f6b2373 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -12,13 +12,29 @@ */ #include "qemu/osdep.h" - +#include "standard-headers/linux/vhost_types.h" #include "hw/virtio/virtio-gpu.h" #include "migration/blocker.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/error-report.h" #include "trace.h" +qmp_virtio_feature_map_t gpu_map[] = { +#define FEATURE_ENTRY(name) \ + { VIRTIO_GPU_F_##name, #name } + FEATURE_ENTRY(VIRGL), + FEATURE_ENTRY(EDID), + FEATURE_ENTRY(RESOURCE_UUID), + FEATURE_ENTRY(RESOURCE_BLOB), +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; + void virtio_gpu_base_reset(VirtIOGPUBase *g) { diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c index 5b5398b..fe0ed6d 100644 --- a/hw/input/virtio-input.c +++ b/hw/input/virtio-input.c @@ -6,6 +6,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/iov.h" #include "qemu/module.h" #include "trace.h" @@ -14,10 +15,19 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-input.h" +#include "standard-headers/linux/vhost_types.h" #include "standard-headers/linux/input.h" #define VIRTIO_INPUT_VM_VERSION 1 +qmp_virtio_feature_map_t input_map[] = { +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; + /* ----------------------------------------------------------------- */ void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 2449b9c..b4a0ab8 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -35,9 +35,11 @@ #include "hw/qdev-properties.h" #include "qapi/qapi-types-migration.h" #include "qapi/qapi-events-migration.h" +#include "qapi/qapi-visit-virtio.h" #include "hw/virtio/virtio-access.h" #include "migration/misc.h" #include "standard-headers/linux/ethtool.h" +#include "standard-headers/linux/vhost_types.h" #include "sysemu/sysemu.h" #include "trace.h" #include "monitor/qdev.h" @@ -89,6 +91,51 @@ VIRTIO_NET_RSS_HASH_TYPE_TCP_EX | \ VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) +qmp_virtio_feature_map_t net_map[] = { +#define FEATURE_ENTRY(name) \ + { VIRTIO_NET_F_##name, #name } + FEATURE_ENTRY(CSUM), + FEATURE_ENTRY(GUEST_CSUM), + FEATURE_ENTRY(CTRL_GUEST_OFFLOADS), + FEATURE_ENTRY(MTU), + FEATURE_ENTRY(MAC), + FEATURE_ENTRY(GUEST_TSO4), + FEATURE_ENTRY(GUEST_TSO6), + FEATURE_ENTRY(GUEST_ECN), + FEATURE_ENTRY(GUEST_UFO), + FEATURE_ENTRY(HOST_TSO4), + FEATURE_ENTRY(HOST_TSO6), + FEATURE_ENTRY(HOST_ECN), + FEATURE_ENTRY(HOST_UFO), + FEATURE_ENTRY(MRG_RXBUF), + FEATURE_ENTRY(STATUS), + FEATURE_ENTRY(CTRL_VQ), + FEATURE_ENTRY(CTRL_RX), + FEATURE_ENTRY(CTRL_VLAN), + FEATURE_ENTRY(CTRL_RX_EXTRA), + FEATURE_ENTRY(GUEST_ANNOUNCE), + FEATURE_ENTRY(MQ), + FEATURE_ENTRY(CTRL_MAC_ADDR), + FEATURE_ENTRY(HASH_REPORT), + FEATURE_ENTRY(RSS), + FEATURE_ENTRY(RSC_EXT), + FEATURE_ENTRY(STANDBY), + FEATURE_ENTRY(SPEED_DUPLEX), +#ifndef VIRTIO_NET_NO_LEGACY + FEATURE_ENTRY(GSO), +#endif /* VIRTIO_NET_NO_LEGACY */ +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_NET_F_##name, #name } + FEATURE_ENTRY(VIRTIO_NET_HDR), +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; + static const VirtIOFeature feature_sizes[] = { {.flags = 1ULL << VIRTIO_NET_F_MAC, .end = endof(struct virtio_net_config, mac)}, diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index ce71939..caa3be8 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -15,7 +15,9 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "standard-headers/linux/virtio_ids.h" +#include "standard-headers/linux/vhost_types.h" #include "hw/virtio/virtio-scsi.h" #include "migration/qemu-file-types.h" #include "qemu/error-report.h" @@ -29,6 +31,21 @@ #include "hw/virtio/virtio-access.h" #include "trace.h" +qmp_virtio_feature_map_t scsi_map[] = { +#define FEATURE_ENTRY(name) \ + { VIRTIO_SCSI_F_##name, #name } + FEATURE_ENTRY(INOUT), + FEATURE_ENTRY(HOTPLUG), + FEATURE_ENTRY(CHANGE), + FEATURE_ENTRY(T10_PI), +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; + static inline int virtio_scsi_get_lun(uint8_t *lun) { return ((lun[2] << 8) | lun[3]) & 0x3FFF; diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index e513e4f..096cc07 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -15,6 +15,7 @@ #include #include "standard-headers/linux/virtio_fs.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" #include "hw/virtio/virtio-bus.h" @@ -23,6 +24,15 @@ #include "hw/virtio/vhost-user-fs.h" #include "monitor/monitor.h" #include "sysemu/sysemu.h" +#include "standard-headers/linux/vhost_types.h" + +qmp_virtio_feature_map_t fs_map[] = { +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; static const int user_feature_bits[] = { VIRTIO_F_VERSION_1, diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 416daf8..047ebb7 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -11,12 +11,22 @@ #include "qemu/osdep.h" #include "standard-headers/linux/virtio_vsock.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "hw/virtio/virtio-access.h" #include "qemu/error-report.h" #include "hw/qdev-properties.h" #include "hw/virtio/vhost-vsock.h" #include "qemu/iov.h" #include "monitor/monitor.h" +#include "standard-headers/linux/vhost_types.h" + +qmp_virtio_feature_map_t vsock_map[] = { +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; const int feature_bits[] = { VIRTIO_VSOCK_F_SEQPACKET, diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 236542f..6705314 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -27,6 +27,7 @@ #include "qapi/error.h" #include "qapi/qapi-events-machine.h" #include "qapi/visitor.h" +#include "qapi/qapi-visit-virtio.h" #include "trace.h" #include "qemu/error-report.h" #include "migration/misc.h" @@ -37,6 +38,19 @@ #define BALLOON_PAGE_SIZE (1 << VIRTIO_BALLOON_PFN_SHIFT) +qmp_virtio_feature_map_t balloon_map[] = { +#define FEATURE_ENTRY(name) \ + { VIRTIO_BALLOON_F_##name, #name } + FEATURE_ENTRY(MUST_TELL_HOST), + FEATURE_ENTRY(STATS_VQ), + FEATURE_ENTRY(DEFLATE_ON_OOM), + FEATURE_ENTRY(FREE_PAGE_HINT), + FEATURE_ENTRY(PAGE_POISON), + FEATURE_ENTRY(REPORTING), +#undef FEATURE_ENTRY + { -1, "" } +}; + typedef struct PartiallyBalloonedPage { ram_addr_t base_gpa; unsigned long *bitmap; diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 7d63b8c..b938bd8 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -16,6 +16,7 @@ #include "qemu/main-loop.h" #include "qemu/module.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/error-report.h" #include "hw/virtio/virtio.h" @@ -23,10 +24,19 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-access.h" #include "standard-headers/linux/virtio_ids.h" +#include "standard-headers/linux/vhost_types.h" #include "sysemu/cryptodev-vhost.h" #define VIRTIO_CRYPTO_VM_VERSION 1 +qmp_virtio_feature_map_t crypto_map[] = { +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; + /* * Transfer virtqueue index to crypto queue index. * The control virtqueue is after the data virtqueues diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 92c5eb7..13c3a13 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -25,6 +25,7 @@ #include "hw/virtio/virtio.h" #include "sysemu/kvm.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/error-report.h" #include "trace.h" @@ -40,6 +41,19 @@ #define VIOMMU_DEFAULT_QUEUE_SIZE 256 #define VIOMMU_PROBE_SIZE 512 +qmp_virtio_feature_map_t iommu_map[] = { +#define FEATURE_ENTRY(name) \ + { VIRTIO_IOMMU_F_##name, #name } + FEATURE_ENTRY(INPUT_RANGE), + FEATURE_ENTRY(DOMAIN_RANGE), + FEATURE_ENTRY(MAP_UNMAP), + FEATURE_ENTRY(BYPASS), + FEATURE_ENTRY(PROBE), + FEATURE_ENTRY(MMIO), +#undef FEATURE_ENTRY + { -1, "" } +}; + typedef struct VirtIOIOMMUDomain { uint32_t id; GTree *mappings; diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index e217520..e619d7d 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -25,6 +25,7 @@ #include "hw/virtio/virtio-mem.h" #include "qapi/error.h" #include "qapi/visitor.h" +#include "qapi/qapi-visit-virtio.h" #include "exec/ram_addr.h" #include "migration/misc.h" #include "hw/boards.h" @@ -32,6 +33,16 @@ #include CONFIG_DEVICES #include "trace.h" +qmp_virtio_feature_map_t mem_map[] = { +#define FEATURE_ENTRY(name) \ + { VIRTIO_MEM_F_##name, #name } +#ifndef CONFIG_ACPI + FEATURE_ENTRY(ACPI_PXM), +#endif /* CONFIG_ACPI */ +#undef FEATURE_ENTRY + { -1, "" } +}; + /* * Let's not allow blocks smaller than 1 MiB, for example, to keep the tracking * bitmap small. diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index b8112ca..b4b2af8 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -30,11 +30,100 @@ #include "sysemu/dma.h" #include "sysemu/runstate.h" #include "standard-headers/linux/virtio_ids.h" +#include "standard-headers/linux/vhost_types.h" +#include CONFIG_DEVICES /* QAPI list of realized VirtIODevices */ static QTAILQ_HEAD(, VirtIODevice) virtio_list; /* + * Maximum size of virtio device config space + */ +#define VHOST_USER_MAX_CONFIG_SIZE 256 + +enum VhostUserProtocolFeature { + VHOST_USER_PROTOCOL_F_MQ = 0, + VHOST_USER_PROTOCOL_F_LOG_SHMFD = 1, + VHOST_USER_PROTOCOL_F_RARP = 2, + VHOST_USER_PROTOCOL_F_REPLY_ACK = 3, + VHOST_USER_PROTOCOL_F_NET_MTU = 4, + VHOST_USER_PROTOCOL_F_SLAVE_REQ = 5, + VHOST_USER_PROTOCOL_F_CROSS_ENDIAN = 6, + VHOST_USER_PROTOCOL_F_CRYPTO_SESSION = 7, + VHOST_USER_PROTOCOL_F_PAGEFAULT = 8, + VHOST_USER_PROTOCOL_F_CONFIG = 9, + VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD = 10, + VHOST_USER_PROTOCOL_F_HOST_NOTIFIER = 11, + VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD = 12, + VHOST_USER_PROTOCOL_F_RESET_DEVICE = 13, + VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS = 14, + VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS = 15, + VHOST_USER_PROTOCOL_F_MAX +}; + +static qmp_virtio_feature_map_t transport_map[] = { +#define FEATURE_ENTRY(name) \ + { VIRTIO_F_##name, #name } +#ifndef VIRTIO_CONFIG_NO_LEGACY + FEATURE_ENTRY(NOTIFY_ON_EMPTY), + FEATURE_ENTRY(ANY_LAYOUT), +#endif /* VIRTIO_CONFIG_NO_LEGACY */ + FEATURE_ENTRY(VERSION_1), + FEATURE_ENTRY(IOMMU_PLATFORM), + FEATURE_ENTRY(RING_PACKED), + FEATURE_ENTRY(ORDER_PLATFORM), + FEATURE_ENTRY(SR_IOV), +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VIRTIO_RING_F_##name, #name } + FEATURE_ENTRY(INDIRECT_DESC), + FEATURE_ENTRY(EVENT_IDX), +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_USER_F_##name, #name } + FEATURE_ENTRY(PROTOCOL_FEATURES), +#undef FEATURE_ENTRY + { -1, "" } +}; + +static qmp_virtio_feature_map_t vhost_user_protocol_map[] = { +#define FEATURE_ENTRY(name) \ + { VHOST_USER_PROTOCOL_F_##name, #name } + FEATURE_ENTRY(MQ), + FEATURE_ENTRY(LOG_SHMFD), + FEATURE_ENTRY(RARP), + FEATURE_ENTRY(REPLY_ACK), + FEATURE_ENTRY(NET_MTU), + FEATURE_ENTRY(SLAVE_REQ), + FEATURE_ENTRY(CROSS_ENDIAN), + FEATURE_ENTRY(CRYPTO_SESSION), + FEATURE_ENTRY(PAGEFAULT), + FEATURE_ENTRY(CONFIG), + FEATURE_ENTRY(SLAVE_SEND_FD), + FEATURE_ENTRY(HOST_NOTIFIER), + FEATURE_ENTRY(INFLIGHT_SHMFD), + FEATURE_ENTRY(RESET_DEVICE), + FEATURE_ENTRY(INBAND_NOTIFICATIONS), + FEATURE_ENTRY(CONFIGURE_MEM_SLOTS), +#undef FEATURE_ENTRY + { -1, "" } +}; + +/* virtio device configuration statuses */ +static qmp_virtio_feature_map_t config_status_map[] = { +#define STATUS_ENTRY(name) \ + { VIRTIO_CONFIG_S_##name, #name } + STATUS_ENTRY(DRIVER_OK), + STATUS_ENTRY(FEATURES_OK), + STATUS_ENTRY(DRIVER), + STATUS_ENTRY(NEEDS_RESET), + STATUS_ENTRY(FAILED), + STATUS_ENTRY(ACKNOWLEDGE), +#undef STATUS_ENTRY + { -1, "" } +}; + +/* * The alignment to use between consumer and producer parts of vring. * x86 pagesize again. This is the default, used by transports like PCI * which don't provide a means for the guest to tell the host the alignment. @@ -3940,6 +4029,180 @@ static VirtIODevice *virtio_device_find(const char *path) return NULL; } +#define CONVERT_FEATURES(type, map, is_status, bitmap) \ + ({ \ + type *list = NULL; \ + type *node; \ + for (i = 0; map[i].virtio_bit != -1; i++) { \ + if (is_status) { \ + bit = map[i].virtio_bit; \ + } \ + else { \ + bit = 1ULL << map[i].virtio_bit; \ + } \ + if ((bitmap & bit) == 0) { \ + continue; \ + } \ + node = g_new0(type, 1); \ + node->value = g_strdup(map[i].feature_name); \ + node->next = list; \ + list = node; \ + bitmap ^= bit; \ + } \ + list; \ + }) + +static VirtioDeviceStatus *qmp_decode_status(uint8_t bitmap) +{ + VirtioDeviceStatus *status; + uint8_t bit; + int i; + + status = g_new0(VirtioDeviceStatus, 1); + status->statuses = CONVERT_FEATURES(strList, config_status_map, 1, bitmap); + status->has_unknown_statuses = bitmap != 0; + if (status->has_unknown_statuses) { + status->unknown_statuses = bitmap; + } + + return status; +} + +static VhostDeviceProtocols *qmp_decode_protocols(uint64_t bitmap) +{ + VhostDeviceProtocols *vhu_protocols; + uint64_t bit; + int i; + + vhu_protocols = g_new0(VhostDeviceProtocols, 1); + vhu_protocols->protocols = + CONVERT_FEATURES(strList, + vhost_user_protocol_map, 0, bitmap); + vhu_protocols->has_unknown_protocols = bitmap != 0; + if (vhu_protocols->has_unknown_protocols) { + vhu_protocols->unknown_protocols = bitmap; + } + + return vhu_protocols; +} + +static VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id, + uint64_t bitmap) +{ + VirtioDeviceFeatures *features; + uint64_t bit; + int i; + + features = g_new0(VirtioDeviceFeatures, 1); + features->has_dev_features = true; + + /* transport features */ + features->transports = CONVERT_FEATURES(strList, transport_map, 0, bitmap); + + /* device features */ + switch (device_id) { +#ifdef CONFIG_VIRTIO_SERIAL + case VIRTIO_ID_CONSOLE: + features->dev_features = + CONVERT_FEATURES(strList, serial_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_BLK + case VIRTIO_ID_BLOCK: + features->dev_features = + CONVERT_FEATURES(strList, blk_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_GPU + case VIRTIO_ID_GPU: + features->dev_features = + CONVERT_FEATURES(strList, gpu_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_NET + case VIRTIO_ID_NET: + features->dev_features = + CONVERT_FEATURES(strList, net_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_SCSI + case VIRTIO_ID_SCSI: + features->dev_features = + CONVERT_FEATURES(strList, scsi_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_BALLOON + case VIRTIO_ID_BALLOON: + features->dev_features = + CONVERT_FEATURES(strList, balloon_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_IOMMU + case VIRTIO_ID_IOMMU: + features->dev_features = + CONVERT_FEATURES(strList, iommu_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_INPUT + case VIRTIO_ID_INPUT: + features->dev_features = + CONVERT_FEATURES(strList, input_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VHOST_USER_FS + case VIRTIO_ID_FS: + features->dev_features = + CONVERT_FEATURES(strList, fs_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VHOST_VSOCK + case VIRTIO_ID_VSOCK: + features->dev_features = + CONVERT_FEATURES(strList, vsock_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_CRYPTO + case VIRTIO_ID_CRYPTO: + features->dev_features = + CONVERT_FEATURES(strList, crypto_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_MEM + case VIRTIO_ID_MEM: + features->dev_features = + CONVERT_FEATURES(strList, mem_map, 0, bitmap); + break; +#endif + /* No features */ + case VIRTIO_ID_9P: + case VIRTIO_ID_PMEM: + case VIRTIO_ID_RNG: + case VIRTIO_ID_IOMEM: + case VIRTIO_ID_RPMSG: + case VIRTIO_ID_CLOCK: + case VIRTIO_ID_MAC80211_WLAN: + case VIRTIO_ID_MAC80211_HWSIM: + case VIRTIO_ID_RPROC_SERIAL: + case VIRTIO_ID_MEMORY_BALLOON: + case VIRTIO_ID_CAIF: + case VIRTIO_ID_SIGNAL_DIST: + case VIRTIO_ID_PSTORE: + case VIRTIO_ID_SOUND: + case VIRTIO_ID_BT: + case VIRTIO_ID_I2C_ADAPTER: + break; + default: + g_assert_not_reached(); + } + + features->has_unknown_dev_features = bitmap != 0; + if (features->has_unknown_dev_features) { + features->unknown_dev_features = bitmap; + } + + return features; +} + VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) { VirtIODevice *vdev; @@ -3955,9 +4218,12 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) status->name = g_strdup(vdev->name); status->device_id = vdev->device_id; status->vhost_started = vdev->vhost_started; - status->guest_features = vdev->guest_features; - status->host_features = vdev->host_features; - status->backend_features = vdev->backend_features; + status->guest_features = qmp_decode_features(vdev->device_id, + vdev->guest_features); + status->host_features = qmp_decode_features(vdev->device_id, + vdev->host_features); + status->backend_features = qmp_decode_features(vdev->device_id, + vdev->backend_features); switch (vdev->device_endian) { case VIRTIO_DEVICE_ENDIAN_LITTLE: @@ -3972,7 +4238,7 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) } status->num_vqs = virtio_get_num_queues(vdev); - status->status = vdev->status; + status->status = qmp_decode_status(vdev->status); status->isr = vdev->isr; status->queue_sel = vdev->queue_sel; status->vm_running = vdev->vm_running; @@ -3995,10 +4261,14 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) status->vhost_dev->n_tmp_sections = hdev->n_tmp_sections; status->vhost_dev->nvqs = hdev->nvqs; status->vhost_dev->vq_index = hdev->vq_index; - status->vhost_dev->features = hdev->features; - status->vhost_dev->acked_features = hdev->acked_features; - status->vhost_dev->backend_features = hdev->backend_features; - status->vhost_dev->protocol_features = hdev->protocol_features; + status->vhost_dev->features = + qmp_decode_features(vdev->device_id, hdev->features); + status->vhost_dev->acked_features = + qmp_decode_features(vdev->device_id, hdev->acked_features); + status->vhost_dev->backend_features = + qmp_decode_features(vdev->device_id, hdev->backend_features); + status->vhost_dev->protocol_features = + qmp_decode_protocols(hdev->protocol_features); status->vhost_dev->max_queues = hdev->max_queues; status->vhost_dev->backend_cap = hdev->backend_cap; status->vhost_dev->log_enabled = hdev->log_enabled; diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 58a73e7..4aaa21f 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -5,6 +5,9 @@ #include "hw/virtio/virtio.h" #include "exec/memory.h" +#define VHOST_F_DEVICE_IOTLB 63 +#define VHOST_USER_F_PROTOCOL_FEATURES 30 + /* Generic structures common for any vhost based device. */ struct vhost_inflight { diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 3b4eb85..6ed8861 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -71,6 +71,24 @@ typedef struct VirtQueueElement #define TYPE_VIRTIO_DEVICE "virtio-device" OBJECT_DECLARE_TYPE(VirtIODevice, VirtioDeviceClass, VIRTIO_DEVICE) +typedef struct { + int virtio_bit; + const char *feature_name; +} qmp_virtio_feature_map_t; + +extern qmp_virtio_feature_map_t serial_map[]; +extern qmp_virtio_feature_map_t blk_map[]; +extern qmp_virtio_feature_map_t gpu_map[]; +extern qmp_virtio_feature_map_t net_map[]; +extern qmp_virtio_feature_map_t scsi_map[]; +extern qmp_virtio_feature_map_t balloon_map[]; +extern qmp_virtio_feature_map_t iommu_map[]; +extern qmp_virtio_feature_map_t input_map[]; +extern qmp_virtio_feature_map_t fs_map[]; +extern qmp_virtio_feature_map_t vsock_map[]; +extern qmp_virtio_feature_map_t crypto_map[]; +extern qmp_virtio_feature_map_t mem_map[]; + enum virtio_device_endian { VIRTIO_DEVICE_ENDIAN_UNKNOWN, VIRTIO_DEVICE_ENDIAN_LITTLE, diff --git a/qapi/virtio.json b/qapi/virtio.json index 235b8f3..7ef1f95 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -106,10 +106,10 @@ 'n-tmp-sections': 'int', 'nvqs': 'uint32', 'vq-index': 'int', - 'features': 'uint64', - 'acked-features': 'uint64', - 'backend-features': 'uint64', - 'protocol-features': 'uint64', + 'features': 'VirtioDeviceFeatures', + 'acked-features': 'VirtioDeviceFeatures', + 'backend-features': 'VirtioDeviceFeatures', + 'protocol-features': 'VhostDeviceProtocols', 'max-queues': 'uint64', 'backend-cap': 'uint64', 'log-enabled': 'bool', @@ -174,11 +174,11 @@ 'device-id': 'uint16', 'vhost-started': 'bool', 'device-endian': 'str', - 'guest-features': 'uint64', - 'host-features': 'uint64', - 'backend-features': 'uint64', + 'guest-features': 'VirtioDeviceFeatures', + 'host-features': 'VirtioDeviceFeatures', + 'backend-features': 'VirtioDeviceFeatures', 'num-vqs': 'int', - 'status': 'uint8', + 'status': 'VirtioDeviceStatus', 'isr': 'uint8', 'queue-sel': 'uint16', 'vm-running': 'bool', @@ -220,14 +220,28 @@ # "name": "virtio-crypto", # "started": true, # "device-id": 20, -# "backend-features": 0, +# "backend-features": { +# "transports": [], +# "dev-features": [] +# }, # "start-on-kick": false, # "isr": 1, # "broken": false, -# "status": 15, +# "status": { +# "statuses": ["ACKNOWLEDGE", "DRIVER", "FEATURES_OK", +# "DRIVER_OK"] +# }, # "num-vqs": 2, -# "guest-features": 5100273664, -# "host-features": 6325010432, +# "guest-features": { +# "transports": ["EVENT_IDX", "INDIRECT_DESC", "VERSION_1"], +# "dev-features": [] +# }, +# "host-features": { +# "transports": ["PROTOCOL_FEATURES", "EVENT_IDX", +# "INDIRECT_DESC", "VERSION_1", "ANY_LAYOUT", +# "NOTIFY_ON_EMPTY"], +# "dev-features": [] +# }, # "use-guest-notifier-mask": true, # "vm-running": true, # "queue-sel": 1, @@ -255,22 +269,65 @@ # "max-queues": 1, # "backend-cap": 2, # "log-size": 0, -# "backend-features": 0, +# "backend-features": { +# "transports": [], +# "dev-features": [] +# }, # "nvqs": 2, -# "protocol-features": 0, +# "protocol-features": { +# "protocols": [] +# }, # "vq-index": 0, # "log-enabled": false, -# "acked-features": 5100306432, -# "features": 13908344832 +# "acked-features": { +# "transports": ["EVENT_IDX", "INDIRECT_DESC", "VERSION_1", +# "ANY_LAYOUT", "NOTIFY_ON_EMPTY"], +# "dev-features": ["MRG_RXBUF"] +# }, +# "features": { +# "transports": ["EVENT_IDX", "INDIRECT_DESC", +# "IOMMU_PLATFORM", "VERSION_1", "ANY_LAYOUT", +# "NOTIFY_ON_EMPTY"], +# "dev-features": ["LOG_ALL", "MRG_RXBUF"] +# } +# }, +# "backend-features": { +# "transports": ["PROTOCOL_FEATURES", "EVENT_IDX", "INDIRECT_DESC", +# "VERSION_1", "ANY_LAYOUT", "NOTIFY_ON_EMPTY"], +# "dev-features": ["GSO", "CTRL_MAC_ADDR", "GUEST_ANNOUNCE", "CTRL_RX_EXTRA", +# "CTRL_VLAN", "CTRL_RX", "CTRL_VQ", "STATUS", "MRG_RXBUF", +# "HOST_UFO", "HOST_ECN", "HOST_TSO6", "HOST_TSO4", +# "GUEST_UFO", "GUEST_ECN", "GUEST_TSO6", "GUEST_TSO4", +# "MAC", "CTRL_GUEST_OFFLOADS", "GUEST_CSUM", "CSUM"] # }, -# "backend-features": 6337593319, # "start-on-kick": false, # "isr": 1, # "broken": false, -# "status": 15, +# "status": { +# "statuses": ["ACKNOWLEDGE", "DRIVER", "FEATURES_OK", "DRIVER_OK"] +# }, # "num-vqs": 3, -# "guest-features": 5111807911, -# "host-features": 6337593319, +# "guest-features": { +# "transports": ["EVENT_IDX", "INDIRECT_DESC", "VERSION_1"], +# "dev-features": ["CTRL_MAC_ADDR", "GUEST_ANNOUNCE", "CTRL_VLAN", +# "CTRL_RX", "CTRL_VQ", "STATUS", "MRG_RXBUF", +# "HOST_UFO", "HOST_ECN", "HOST_TSO6", +# "HOST_TSO4", "GUEST_UFO", "GUEST_ECN", +# "GUEST_TSO6", "GUEST_TSO4", "MAC", +# "CTRL_GUEST_OFFLOADS", "GUEST_CSUM", "CSUM"] +# }, +# "host-features": { +# "transports": ["PROTOCOL_FEATURES", "EVENT_IDX", +# "INDIRECT_DESC", "VERSION_1", "ANY_LAYOUT", +# "NOTIFY_ON_EMPTY"], +# "dev-features": ["GSO", "CTRL_MAC_ADDR", "GUEST_ANNOUNCE", +# "CTRL_RX_EXTRA", "CTRL_VLAN", "CTRL_RX", +# "CTRL_VQ", "STATUS", "MRG_RXBUF", "HOST_UFO", +# "HOST_ECN", "HOST_TSO4", "HOST_TSO4", +# "GUEST_UFO", "GUEST_ECN", "GUEST_TSO6", +# "GUEST_TSO4", "MAC", "CTRL_GUEST_OFFLOADS", +# "GUEST_CSUM", "CSUM"] +# }, # "use-guest-notifier-mask": true, # "vm-running": true, # "queue-sel": 2, @@ -286,3 +343,62 @@ 'data': { 'path': 'str' }, 'returns': 'VirtioStatus', 'features': [ 'unstable' ] } + +## +# @VirtioDeviceStatus: +# +# A structure defined to list the configuration statuses of a virtio +# device +# +# @statuses: List of decoded configuration statuses of the virtio +# device +# +# @unknown-statuses: Virtio device statuses bitmap that have not been decoded +# +# Since: 7.0 +## + +{ 'struct': 'VirtioDeviceStatus', + 'data': { 'statuses': [ 'str' ], + '*unknown-statuses': 'uint8' } } + +## +# @VhostDeviceProtocols: +# +# A structure defined to list the vhost user protocol features of a +# Vhost User device +# +# @protocols: List of decoded vhost user protocol features of a vhost +# user device +# +# @unknown-protocols: Vhost user device protocol features bitmap that +# have not been decoded +# +# Since: 7.0 +## + +{ 'struct': 'VhostDeviceProtocols', + 'data': { 'protocols': [ 'str' ], + '*unknown-protocols': 'uint64' } } + +## +# @VirtioDeviceFeatures: +# +# The common fields that apply to most Virtio devices. Some devices +# may not have their own device-specific features (e.g. virtio-rng). +# +# @transports: List of transport features of the virtio device +# +# @dev-features: List of device-specific features (if the device has +# unique features) +# +# @unknown-dev-features: Virtio device features bitmap that have not +# been decoded +# +# Since: 7.0 +## + +{ 'struct': 'VirtioDeviceFeatures', + 'data': { 'transports': [ 'str' ], + '*dev-features': [ 'str' ], + '*unknown-dev-features': 'uint64' } } From patchwork Mon Dec 6 12:43:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 12658267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F1FC8C433EF for ; Mon, 6 Dec 2021 12:50:14 +0000 (UTC) Received: from localhost ([::1]:36164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muDRd-0003uR-Jl for qemu-devel@archiver.kernel.org; Mon, 06 Dec 2021 07:50:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDMm-0000nq-BP; Mon, 06 Dec 2021 07:45:12 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:48876) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDMX-0002Fx-E7; Mon, 06 Dec 2021 07:45:03 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6C5As3023240; Mon, 6 Dec 2021 12:44:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=vpDDHdD9kYc7wKoffkPNE5S+j6a2NnQoQxim/rS3xag=; b=Yq1Za2dVm2EgHI4JZYcLi5ltTLpkNBc7CIxIkrlpSU2lx2/0UBK4LelXCpoocf4FETQT 5xJCGl9Yi8NF5tW3Q2vDrEU4D31SsdjM+XDpsP1O5/2pzP1XFjnNb/tnxIeBjwyeoBDm 0yAKKm+2mRaCl7ZOtqpgjJNk1aXa/cuS95NGEwjWieZimgb2Ck2tw1D/Be/Ue/0q71gv SVe6M3j1kzmieEBhECSmSMc+u9rq1jFjiH7FxVaUdb74yaVtB3M9BBfFBqN4HQmMg+0n a7ORl8q4zsOLOfBzhDDPAoRhvnLk97urTngD64j80jk5WArKLpa6Cc9q26jA4GZHwL22 OA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3csbbqj2pf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Dec 2021 12:44:27 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B6Cec6t084125; Mon, 6 Dec 2021 12:44:26 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by userp3020.oracle.com with ESMTP id 3cr1skys5s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Dec 2021 12:44:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fveAxBoEfBF/2IrdOpIbko387L/zm7Ruq0GxzbcJth5L8FmC43GtsXWyKc5HmqZJc/W4x3Vfrd/R486OJwXgSfTFCN/z4hj9DJ8HRcFux/DhFVktAFbiTa1EprQcXcWpewEtXhIOa57ueN0Hb5Y/Bds7O5wM4cpqBy16bu4Qd0R/11HQfViE9EKdj65jvb/x/WBKgDLVoy2zTI3cuK1IdYOeO2+E0Y/l4N4HUbICWlz3U6YJmsd1feFjkOqbl8+Y5raoG4Vx18cNSV6wRi58Ldg0dgOWWKBUi9DtWgDtOrr+oe94CI+f3ikgxlUSygEwwIL29MiOrpAhGuqOA29/fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vpDDHdD9kYc7wKoffkPNE5S+j6a2NnQoQxim/rS3xag=; b=jqgf5s+13V9q1/WIKdJxynmVL4FJ/FN9IBWj8WKCZiOzmBf0YAnPLohbJ3oRGIlaP4wwIERAee3oHD8ZUIU50v0bL7JAaV/9cvLhmklolCw39ikdzT/BePUsZ54Zd5PnIkexMdzY4R8UGS+5b/5HeClfg5gCWSPFPCTFzmNB6aXCywXAEjh8Y3dD5nolyBFwy4NE63ZiUCv2fbsaDf6VeIMmyoC1xtF6zQs/1B4xF3k1lkKIzx2dJ+gXFudJ4bXdc5i2xglUu82YHMDdJzE8VseAoWZMtpf12xADTFvYMkcy3GeP/BfTqt4RMVkL5Zt4j1oeGlM7TpcUe96WCdsyXQ== 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=vpDDHdD9kYc7wKoffkPNE5S+j6a2NnQoQxim/rS3xag=; b=ADnpviBn2cCG8L2KYlpPYZ55Tmf5gb5M8tHUQfTS69zxEo6x+eXZMKDErDrL3migw5tQNAE1cWMavll6cs3y0Ve+G20W1yOvjFN1VTeWT3DEevArkhOOMz5ZpL1dOLBIMvhhm0BvMHUtPBwD1aUP9h7JOAqhvvQq+zHy3gSRUdg= Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB4791.namprd10.prod.outlook.com (2603:10b6:510:3a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.20; Mon, 6 Dec 2021 12:44:23 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%5]) with mapi id 15.20.4755.022; Mon, 6 Dec 2021 12:44:23 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v10 6/8] qmp: add QMP commands for virtio/vhost queue-status Date: Mon, 6 Dec 2021 07:43:24 -0500 Message-Id: <1638794606-19631-7-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1638794606-19631-1-git-send-email-jonah.palmer@oracle.com> References: <1638794606-19631-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SA9P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::35) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 Received: from jonpalme-lnx.us.oracle.com (209.17.40.42) by SA9P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21 via Frontend Transport; Mon, 6 Dec 2021 12:44:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 67f98584-d095-4880-9efe-08d9b8b62179 X-MS-TrafficTypeDiagnostic: PH0PR10MB4791:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:221; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pftRQD2AE1kQHaPkI8fLD7+osnwScbqrGepkqZ8CyVcNWMY1LY/9FQ0pTGNJT3mcensrcJJPhAPJnuvz13UdlPO+kntXcyJIQtZVg5Q9ye8U63Cyoifvsg/R/5TPWDLua8AKVgAT703bL6qJO0z3nCPZDtlSMGZbYyJ3BGjqsaeeMhg7iqtEIrGWutXrAin6nJa1qJHXN/VHxVMpw2rYL/Apx86YYZw3DzunFYm1BCfriG++jK7+nKbo528LqzR3OTSn3XHeyRu0NxDM5JjGxMl97zYmO/ZdVP3Y6upmfiQCBOR5zMq7VdURfTwxziItSxfYnmdSAcOjNPl4ZCO7p3nYCpJNpnY3Ti36r+9e8qfKaK6BHnT8jaIsAFkCYG8ZzVZ4q4LtixA7bpO4dER9uJhIR6qr20cvo9YRsxK7LOHUxwf4QZYLrdmd+hBETgBD6ayU4xl9ktJmDEbnJM3Wv2XlwvM8+j0V5KSfH0vctkNmM7l9jFNx2C0jtfBgvgMhmoekZez20owljRoqZEH6574uaAZR6wAS1zxFaUVnwNTJCA46UpWYm9PcJ2hoIkIfjrx9CrLk4heKqHTwEv2aWlVUvDUtpDZsfsDTa/jnREJWlgcyxOr+QCmsJF9430AwlZlrdLOOT3e/PdHKYhNK/FxwGAVDZbstwiebD0ERn3dTqdgaCPHhgEZo3kjtg88V 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)(956004)(66556008)(52116002)(186003)(8936002)(38350700002)(508600001)(6486002)(2616005)(7696005)(36756003)(6916009)(86362001)(38100700002)(30864003)(66476007)(5660300002)(26005)(316002)(66946007)(4326008)(7416002)(8676002)(44832011)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AdBm0C6yD2EwfjuTD5nAO7UoWqO48wjEB/fYZVgJV8Hzxo0FO14Z01EkYX2SFDROUKY+aifFFtTxY9E8RTzKEUcFzzNoM8t9UnpKvXToXnqNG8bzLGAl0FVVu+4Csv/L4KQToJ9kjjvzlcgKSl+8DA0LLSdx3E2M/ZGOE3qSfemBVxzUfHHwqaQI4C1+mbDC1zKj0I6ob5QqI9MpAJzNgGoPMdSkeDwQJARvZOgDcXm3MD1C9OIySAKM/rekDyKKV4R2xcqFhhfTBE6ykh0hKvG2ydf2B6QvYtOMUW1WRDdSgIOwYVy32qCAks42WBjs+S22B2a6EsiKebJL4JUZDDohuf7tDW62M8xyTQBMGpIN1IDA3utblRmhds3eZwNnO4j7rzLrJE3235LeMlRmkrxfSCBIn6nsJlhMFXjcU4fLouMwkowaYsOa36QyT6fCjWMIQSE1f+HxmuFbYStow04kZn7jZKKWlXNEChUhfitKwqL4re6++BdP/KTTqSyuC4JgCh0Zw6WgrLqddbYz5WjztN52hYa5mX21snUxnd1wIGLHnCX3hb16UrjPOyIOLOZjdW+S21yJDvi5g5ZYLv8BI56FfOw2FcOSKtHyt2+Wkap3LkgxFttLrs2QVrBeA9oS/g6S+S029LMRlr5ynGNMoe9ZpG12AD06IInBVdvKsMZ04vTloz5mSItKIc3MEpx9FQNQ7Axxat7oDH5ZW3CkEQi9z6Ko71r8Gx4kQF6Qm0kWfpiluX4Cj203i8D5Sq+zeHYX2TM6Bbh4LxEbjevxQpzDv/m9L2yZBdosQs+9L8w9I8Doq06labsh+EtKdckDTPirSKDZaYipsZq7zVmLSrcCTmWvFzeGw+a5sSKIRKzcd1BGoV65RruChkhp8NhAFyS2vkKhRvsEo5cFra9MhwgXXqBt+OD4bx0zJubu3iJsymixSR8Obeci4DQ5m1X0PyEt+iAoNHAUmhAbcp8FZOdEI+6XbzqPfnRzvx/VAg9ul4nM4gWYP7ZRyOty5u315hEbPTWk7FceDoQsVE/zN1rL7i9CmjY2p55QAlbMdISjuAELdeGHKdgyJUPUzpMyc7N2i04oj44lJPNw+ZkQCbJE6Wf4o6kayXZQ11bh4j6FQ7BPxbCgGrlSz8Chg7jI+ugqVQqmRYeWZysL3QukEC5o9uTpKOtrlaHNDornrAdLJ2kv2qejF54FJNDD9HtGqQfW+EMGKAnqNkd1aglk0otNUi7lBJVEaRlE15gcTf+9sTvRlpRxVf5zJ3ekTK/gi63uNEBUiTcsrRKr7pd08jMvSF7qC92wFj8EOxK9k27EThyf4gXiLSfotWo+BoQ4WfG6Rh9s75VxQ0Xm4e0DvZE2EN3IQ3OyYsA2h5Ykw56stjy1SAKAFXwmv6jt2qmzWEWq9bcva3X6LcTTpYDLZ9SjU+b1YINZrKf/w3S23ZJhjHk2+sYTyc896BxsDS17tevWvhA/yA7JVeRPMMqxFK/rP8l1e02WJQafcPHc2ekCmLgKGgrYxSrSlqJThNp732jNsqISXg6E8imA7hHCt34G4ly21eSqO9dyqQV2wrOCotPdMXoxjpzOaoOcOZ47++NCuU+nBRKzs83lvMz4wdWgdhmsI+Ir3Z+aU9Q= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67f98584-d095-4880-9efe-08d9b8b62179 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2021 12:44:23.6555 (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: vWMbWw3gI1Zci/Yq7oqejmPB9rnlpmJb5pMuVqyyQIcD1/uZSNk1gkbcnyoI4egzcJBJbNgl+37p5QUBAopRIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4791 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10189 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112060078 X-Proofpoint-GUID: CqVsEvFyB8dF6_XzlzNUy_sztwZ6AaB2 X-Proofpoint-ORIG-GUID: CqVsEvFyB8dF6_XzlzNUy_sztwZ6AaB2 Received-SPF: pass client-ip=205.220.177.32; envelope-from=jonah.palmer@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier These new commands show the internal status of a VirtIODevice's VirtQueue and a vhost device's vhost_virtqueue (if active). Signed-off-by: Jonah Palmer Acked-by: Markus Armbruster --- hw/virtio/virtio-stub.c | 14 +++ hw/virtio/virtio.c | 103 ++++++++++++++++++++ qapi/virtio.json | 252 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 369 insertions(+) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index 0b432e8..13e5f93 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -17,3 +17,17 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) { return qmp_virtio_unsupported(errp); } + +VirtVhostQueueStatus *qmp_x_query_virtio_vhost_queue_status(const char *path, + uint16_t queue, + Error **errp) +{ + return qmp_virtio_unsupported(errp); +} + +VirtQueueStatus *qmp_x_query_virtio_queue_status(const char *path, + uint16_t queue, + Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index b4b2af8..459bfb2 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -4278,6 +4278,109 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) return status; } +VirtVhostQueueStatus *qmp_x_query_virtio_vhost_queue_status(const char *path, + uint16_t queue, + Error **errp) +{ + VirtIODevice *vdev; + VirtVhostQueueStatus *status; + + vdev = virtio_device_find(path); + if (vdev == NULL) { + error_setg(errp, "Path %s is not a VirtIODevice", path); + return NULL; + } + + if (!vdev->vhost_started) { + error_setg(errp, "Error: vhost device has not started yet"); + return NULL; + } + + VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); + struct vhost_dev *hdev = vdc->get_vhost(vdev); + + if (queue < hdev->vq_index || queue >= hdev->vq_index + hdev->nvqs) { + error_setg(errp, "Invalid vhost virtqueue number %d", queue); + return NULL; + } + + status = g_new0(VirtVhostQueueStatus, 1); + status->name = g_strdup(vdev->name); + status->kick = hdev->vqs[queue].kick; + status->call = hdev->vqs[queue].call; + status->desc = (uint64_t)(unsigned long)hdev->vqs[queue].desc; + status->avail = (uint64_t)(unsigned long)hdev->vqs[queue].avail; + status->used = (uint64_t)(unsigned long)hdev->vqs[queue].used; + status->num = hdev->vqs[queue].num; + status->desc_phys = hdev->vqs[queue].desc_phys; + status->desc_size = hdev->vqs[queue].desc_size; + status->avail_phys = hdev->vqs[queue].avail_phys; + status->avail_size = hdev->vqs[queue].avail_size; + status->used_phys = hdev->vqs[queue].used_phys; + status->used_size = hdev->vqs[queue].used_size; + + return status; +} + +VirtQueueStatus *qmp_x_query_virtio_queue_status(const char *path, + uint16_t queue, + Error **errp) +{ + VirtIODevice *vdev; + VirtQueueStatus *status; + + vdev = virtio_device_find(path); + if (vdev == NULL) { + error_setg(errp, "Path %s is not a VirtIODevice", path); + return NULL; + } + + if (queue >= VIRTIO_QUEUE_MAX || !virtio_queue_get_num(vdev, queue)) { + error_setg(errp, "Invalid virtqueue number %d", queue); + return NULL; + } + + status = g_new0(VirtQueueStatus, 1); + status->name = g_strdup(vdev->name); + status->queue_index = vdev->vq[queue].queue_index; + status->inuse = vdev->vq[queue].inuse; + status->vring_num = vdev->vq[queue].vring.num; + status->vring_num_default = vdev->vq[queue].vring.num_default; + status->vring_align = vdev->vq[queue].vring.align; + status->vring_desc = vdev->vq[queue].vring.desc; + status->vring_avail = vdev->vq[queue].vring.avail; + status->vring_used = vdev->vq[queue].vring.used; + status->used_idx = vdev->vq[queue].used_idx; + status->signalled_used = vdev->vq[queue].signalled_used; + status->signalled_used_valid = vdev->vq[queue].signalled_used_valid; + + if (vdev->vhost_started) { + VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); + struct vhost_dev *hdev = vdc->get_vhost(vdev); + + /* check if vq index exists for vhost as well */ + if (queue >= hdev->vq_index && queue < hdev->vq_index + hdev->nvqs) { + status->has_last_avail_idx = true; + + int vhost_vq_index = + hdev->vhost_ops->vhost_get_vq_index(hdev, queue); + struct vhost_vring_state state = { + .index = vhost_vq_index, + }; + + status->last_avail_idx = + hdev->vhost_ops->vhost_get_vring_base(hdev, &state); + } + } else { + status->has_shadow_avail_idx = true; + status->has_last_avail_idx = true; + status->last_avail_idx = vdev->vq[queue].last_avail_idx; + status->shadow_avail_idx = vdev->vq[queue].shadow_avail_idx; + } + + return status; +} + static const TypeInfo virtio_device_info = { .name = TYPE_VIRTIO_DEVICE, .parent = TYPE_DEVICE, diff --git a/qapi/virtio.json b/qapi/virtio.json index 7ef1f95..56e56d2 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -402,3 +402,255 @@ 'data': { 'transports': [ 'str' ], '*dev-features': [ 'str' ], '*unknown-dev-features': 'uint64' } } + +## +# @VirtQueueStatus: +# +# Information of a VirtIODevice VirtQueue, including most members of +# the VirtQueue data structure. +# +# @name: Name of the VirtIODevice that uses this VirtQueue +# +# @queue-index: VirtQueue queue_index +# +# @inuse: VirtQueue inuse +# +# @vring-num: VirtQueue vring.num +# +# @vring-num-default: VirtQueue vring.num_default +# +# @vring-align: VirtQueue vring.align +# +# @vring-desc: VirtQueue vring.desc (descriptor area) +# +# @vring-avail: VirtQueue vring.avail (driver area) +# +# @vring-used: VirtQueue vring.used (device area) +# +# @last-avail-idx: VirtQueue last_avail_idx or return of vhost_dev +# vhost_get_vring_base (if vhost active) +# +# @shadow-avail-idx: VirtQueue shadow_avail_idx +# +# @used-idx: VirtQueue used_idx +# +# @signalled-used: VirtQueue signalled_used +# +# @signalled-used-valid: VirtQueue signalled_used_valid flag +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtQueueStatus', + 'data': { 'name': 'str', + 'queue-index': 'uint16', + 'inuse': 'uint32', + 'vring-num': 'uint32', + 'vring-num-default': 'uint32', + 'vring-align': 'uint32', + 'vring-desc': 'uint64', + 'vring-avail': 'uint64', + 'vring-used': 'uint64', + '*last-avail-idx': 'uint16', + '*shadow-avail-idx': 'uint16', + 'used-idx': 'uint16', + 'signalled-used': 'uint16', + 'signalled-used-valid': 'bool' } } + +## +# @x-query-virtio-queue-status: +# +# Return the status of a given VirtIODevice's VirtQueue +# +# @path: VirtIODevice canonical QOM path +# +# @queue: VirtQueue index to examine +# +# Features: +# @unstable: This command is meant for debugging +# +# Returns: VirtQueueStatus of the VirtQueue +# +# Notes: last_avail_idx will not be displayed in the case where +# the selected VirtIODevice has a running vhost device and +# the VirtIODevice VirtQueue index (queue) does not exist for +# the corresponding vhost device vhost_virtqueue. Also, +# shadow_avail_idx will not be displayed in the case where +# the selected VirtIODevice has a running vhost device. +# +# Since: 7.0 +# +# Examples: +# +# 1. Get VirtQueueStatus for virtio-vsock (vhost-vsock running) +# +# -> { "execute": "x-query-virtio-queue-status", +# "arguments": { "path": "/machine/peripheral/vsock0/virtio-backend", +# "queue": 1 } +# } +# <- { "return": { +# "signalled-used": 0, +# "inuse": 0, +# "vring-align": 4096, +# "vring-desc": 5217370112, +# "signalled-used-valid": false, +# "vring-num-default": 128, +# "vring-avail": 5217372160, +# "queue-index": 1, +# "last-avail-idx": 0, +# "vring-used": 5217372480, +# "used-idx": 0, +# "name": "vhost-vsock", +# "vring-num": 128 } +# } +# +# 2. Get VirtQueueStatus for virtio-serial (no vhost) +# +# -> { "execute": "x-query-virtio-queue-status", +# "arguments": { "path": "/machine/peripheral-anon/device[0]/virtio-backend", +# "queue": 20 } +# } +# <- { "return": { +# "signalled-used": 0, +# "inuse": 0, +# "vring-align": 4096, +# "vring-desc": 5182074880, +# "signalled-used-valid": false, +# "vring-num-default": 128, +# "vring-avail": 5182076928, +# "queue-index": 20, +# "last-avail-idx": 0, +# "vring-used": 5182077248, +# "used-idx": 0, +# "name": "virtio-serial", +# "shadow-avail-idx": 0, +# "vring-num": 128 } +# } +# +## + +{ 'command': 'x-query-virtio-queue-status', + 'data': { 'path': 'str', 'queue': 'uint16' }, + 'returns': 'VirtQueueStatus', + 'features': [ 'unstable' ] } + +## +# @VirtVhostQueueStatus: +# +# Information of a vhost device's vhost_virtqueue, including most +# members of the vhost_dev vhost_virtqueue data structure. +# +# @name: Name of the VirtIODevice that uses this vhost_virtqueue +# +# @kick: vhost_virtqueue kick +# +# @call: vhost_virtqueue call +# +# @desc: vhost_virtqueue desc +# +# @avail: vhost_virtqueue avail +# +# @used: vhost_virtqueue used +# +# @num: vhost_virtqueue num +# +# @desc-phys: vhost_virtqueue desc_phys (descriptor area phys. addr.) +# +# @desc-size: vhost_virtqueue desc_size +# +# @avail-phys: vhost_virtqueue avail_phys (driver area phys. addr.) +# +# @avail-size: vhost_virtqueue avail_size +# +# @used-phys: vhost_virtqueue used_phys (device area phys. addr.) +# +# @used-size: vhost_virtqueue used_size +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtVhostQueueStatus', + 'data': { 'name': 'str', + 'kick': 'int', + 'call': 'int', + 'desc': 'uint64', + 'avail': 'uint64', + 'used': 'uint64', + 'num': 'int', + 'desc-phys': 'uint64', + 'desc-size': 'uint32', + 'avail-phys': 'uint64', + 'avail-size': 'uint32', + 'used-phys': 'uint64', + 'used-size': 'uint32' } } + +## +# @x-query-virtio-vhost-queue-status: +# +# Return information of a given vhost device's vhost_virtqueue +# +# @path: VirtIODevice canonical QOM path +# +# @queue: vhost_virtqueue index to examine +# +# Features: +# @unstable: This command ism eant for debugging +# +# Returns: VirtVhostQueueStatus of the vhost_virtqueue +# +# Since: 7.0 +# +# Examples: +# +# 1. Get vhost_virtqueue status for vhost-crypto +# +# -> { "execute": "x-query-virtio-vhost-queue-status", +# "arguments": { "path": "/machine/peripheral/crypto0/virtio-backend", +# "queue": 0 } +# } +# <- { "return": { +# "avail-phys": 5216124928, +# "used-phys": 5216127040, +# "avail-size": 2054, +# "desc-size": 16384, +# "used-size": 8198, +# "desc": 140141447430144, +# "num": 1024, +# "name": "virtio-crypto", +# "call": 0, +# "avail": 140141447446528, +# "desc-phys": 5216108544, +# "used": 140141447448640, +# "kick": 0 } +# } +# +# 2. Get vhost_virtqueue status for vhost-vsock +# +# -> { "execute": "x-query-virtio-vhost-queue-status", +# "arguments": { "path": "/machine/peripheral/vsock0/virtio-backend", +# "queue": 0 } +# } +# <- { "return": { +# "avail-phys": 5182261248, +# "used-phys": 5182261568, +# "avail-size": 262, +# "desc-size": 2048, +# "used-size": 1030, +# "desc": 140141413580800, +# "num": 128, +# "name": "vhost-vsock", +# "call": 0, +# "avail": 140141413582848, +# "desc-phys": 5182259200, +# "used": 140141413583168, +# "kick": 0 } +# } +# +## + +{ 'command': 'x-query-virtio-vhost-queue-status', + 'data': { 'path': 'str', 'queue': 'uint16' }, + 'returns': 'VirtVhostQueueStatus', + 'features': [ 'unstable' ] } From patchwork Mon Dec 6 12:43:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 12658303 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67125C433EF for ; Mon, 6 Dec 2021 13:04:00 +0000 (UTC) Received: from localhost ([::1]:39200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muDex-0000WF-1g for qemu-devel@archiver.kernel.org; Mon, 06 Dec 2021 08:03:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDMS-0000fM-Mk; Mon, 06 Dec 2021 07:44:55 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:48654) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDMQ-0001zs-2q; Mon, 06 Dec 2021 07:44:52 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6BLavi030765; Mon, 6 Dec 2021 12:44:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=TGzmnAnKkXhOXkdrt1fwW5UteTxwbdHdKbxjc9UFR18=; b=Q1m2d1nxQ+RmUQUIiZ1G4QL4HRKC7PAFINGP9dCOYcPJD2xE3G4XnelW9PrKNawO0yBJ 9T2seFWbyVjWydKjuFKzDnAYz3Q0N9sRTs0V6vbRyMYUzItMlRuczMRQn4ioVfPE6FtJ iFoqyi3XS4ohWVm4oPWMU9kvqYYAe3Lys0LRPAXjgpI9Y5/XqYNfNYHO8PWfKdUZZ5WX 388pK+laxhujqV9k7Hoy3leczAnnoBeuWMp0qV2qllemi7NsAj8noeQvFSVVuZLGeFLW Lb7zVl+V32HjoN9fF70l09Y4adbqiVw5+4XevKQBQvcJqThhPE227Ark6dvXzHO2/l23 Dw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3cscwc9s63-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Dec 2021 12:44:30 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B6Cec5e084177; Mon, 6 Dec 2021 12:44:29 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by userp3020.oracle.com with ESMTP id 3cr1skys6j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Dec 2021 12:44:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cONV4t9gZ18rDns7wrGZio4L6VEd7PLxgFd++DWK5/v+mA1WcTjrgTWkSNT6OX4g+GAi5f8vvQSvb9x7HJPeJp038Wi+wEDu/l+Y6oXx8EADZVXTJc9LGpKn1l61Rrjjgwuhn8V6oGeAMrCMeSeUz/tY0qwFPOtY+6HGFVj9nwIgPbfsm0ezoJ3H/HZBWDVwO3cyo4olwcdO+XqB6C2ta7Zy7+wC8UaUlrv48xTJ78ge/CJVePWyh3Yr6dkv8upJ7pEbHYMfE2WQ2/kjVZYq4F1MmGITuyFauOcL9yhrO3v+Cyi4ORW6TlTDJ/8oGgEwmXoo5VbsYlWoYFmsUi16Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TGzmnAnKkXhOXkdrt1fwW5UteTxwbdHdKbxjc9UFR18=; b=ANhVVsuk7IeSKIexrjo1oUgRvLey8wJxi0iJl2GV+7nRh0knY1wrIZosn49J8YmWC77InHEWqiJNVnBg/Kcbi8ygqPymnNxr615zo5bFdaZwNM9X5cEAMh/GLnMDndMhGTDruGJgdZICVDiTtzXLUyHvWEiZ9OXAPQ2f1Rm3j/hZrYk+/mgrRgMYAjdswT3e/oBj3F0dZgrAX7esBn7FpxJu14jSiAmUnnWwKs7nUIO1y7kPq/gB0EHhCmNoKUDev7T5CB4nzi2bvM3rMwxqYMgbfDimhLrzcGBOp3VuCnSWbLMhHwHuqoYoSnfkFgDg/4AnR5YGt5/sn2KRfKwloQ== 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=TGzmnAnKkXhOXkdrt1fwW5UteTxwbdHdKbxjc9UFR18=; b=eDqnkQO02ZPJffXpqFGF59OAjriihh2v03WvXjDj3l69HE+3qC8ydTdexrlK0JGEFVIMaC4qgYP5AucIHO5TGFIILlo4Z1WqeWw4MQK98BgHy1UTLZTetwKfYyIRL0BkMGrsIt20CuWq65dOnIq0JtKzKNXdcsOfeIHGcqqUThU= Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB4791.namprd10.prod.outlook.com (2603:10b6:510:3a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.20; Mon, 6 Dec 2021 12:44:26 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%5]) with mapi id 15.20.4755.022; Mon, 6 Dec 2021 12:44:26 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v10 7/8] qmp: add QMP command x-query-virtio-queue-element Date: Mon, 6 Dec 2021 07:43:25 -0500 Message-Id: <1638794606-19631-8-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1638794606-19631-1-git-send-email-jonah.palmer@oracle.com> References: <1638794606-19631-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SA9P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::35) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 Received: from jonpalme-lnx.us.oracle.com (209.17.40.42) by SA9P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21 via Frontend Transport; Mon, 6 Dec 2021 12:44:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e9e892fd-3e80-4670-d47c-08d9b8b62311 X-MS-TrafficTypeDiagnostic: PH0PR10MB4791:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1850; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PnAJrfBMsV9TpuskXfXCP7tZgDnr3O9ECSC0tW8maXh3BV9TOx3T6Dmzjk/QWPjYKQAqSkeLMrLMJyhusfbjq7SuMWgze1+9+1oILrgzhnjk9Xj09trp5rgS20kGrosoWuVY0CAo4rrU9d6WGFnK5F4rq5EYmlqdF3dfzRijUIFguyO80vDDfXsDz9ywjfC/iL3L6m+XlwpK4eS/HQV1ZEb1sRCywliUcqnsbF4kQXyq77mfhiFwh2FGF6bXJ4aisuwYJBcyZ0/mmr5ASbkrnbgt5xYsdUmxITWItyhJ66RIqVd+VuLbiEYr7aTYpYha3hNz52BfPlC+nKUCEx0uowQQgr0syrosfXQS/y7HnynzUffHR34JWWdn1JjGe2MQu5a8JthvcuGzfe2BQdAHBrkwtzM2ml5Yysbe7sPqTJ7RTidruhUM/DNsXD6RXBUOvZa1I1fOPhuSX2g0vuly60s8BJ9s8e4tYBA7MHBPSlPEw5wncw+jBaKdUhq3RuUCp+DzWHPDkfZBBR5VOvGrDldaSCpwmVywD+Xhn726uCefIlJcap9FGYa3mPfJWo1yAkccfMQy/UBX142RVdH53anVvSoKPLwHs/fnSaE+gOjnqrOvkTK5xIs12+fh28g/IqW9HS71JCvl9gvzm2FDxpoqY05XHbzkwQTwIpw/OzvKRYfY5v7Kyo0scFzdr3iW 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)(956004)(66556008)(52116002)(186003)(8936002)(38350700002)(508600001)(6486002)(2616005)(83380400001)(7696005)(36756003)(6916009)(86362001)(38100700002)(66476007)(5660300002)(26005)(316002)(66946007)(4326008)(7416002)(8676002)(44832011)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8IEE9iAbPJ7+LkTu/I2pBf91khOz6nc+TTRBXG11xkhRfEiUCSE3wer6IBUmjSQYMTX1Yy1KlPRpnOK0o38ZAODLxVB1qScpu+9CM43b/4RjvRi7IEJCIFzCi1PXLscxaJwKBGZNtCCvr32dzsKQj5oQq5Ggpr6zWFqrS7/ea4hLMcVAaUqe3D3SOp2d7u5imQIH+sXoKaA7CR0wOyvNeSlDlAy61q00b+W02HA9ku9cvX7Xam7oTFra7TMh/SXDytUvJ2vf3LDcFKxefnAPoiI0mi6ff3IeN6xEEO21jkyHJ1R3C2kxE3KjTibd7vrdBShZq9YsSbgfryohOzLhSxT2OVZipO5KuUS806O0v9h8QGC98lN6Zkd38XyIFPalve/047Is/x6o+PvuUoe/96kfscQVbJVgGhvGtGGwfMwIkF9+4cNCI52XwAvNdX4FvWmSFYSQ/7tQqy4DNEiL6r+MeqR/o7NBLLnunca/1KbJ++auIO3AwrZkeTWRdtTvJ+k8tmICWnr+6VW8Q5wSVPWwg1ltxfYM3XIowm95vJmaotfn2z1ZAj8sMBfInx/DCsmecHAAGyvDNU6p4tHRsI2Qocp/NKtC0LRSgK+q316EVN8SatFqRFdCSbDlY4oE3XuJVbn7Gz+MyaDJEegnFkEDWUPIK9QFVsfMX4OoQuX2IpGUqypY7IIuPSfY/pOPF8+OErbXiJj3+1mO30HGB/RTwSEbWVcbyqve+R1t4W1jggZjDOgv5SqiRbDg0Oe1EE4bXH3eecTffmmBbS/SAm2oEWirGB91mhhDJ/YbSJnvd0nRnZsuqqgiFkAJ0pyZxt2lKeedLclZ5zrElwozihRoOWrfqWZDcANmznycLFJeVcv4bhPsIpxlhYc5E66nhdG60ucd6woSmf4xTOE22gLvut5H7hqLTK4tFhgSGVe1gBvHDCHvHht3Ivq5cm5pl5bQ7HsgAgZ44TWtPeRjxvp0tRbwF2KZsjhhx2ns00JWI9l3p18aCLW73dy9grQGzIOtWpSWpmIcxz48pUDgxANX5jLKtND7iuOvNfY2Cfy3rDia9BifDlFDbhFC0nhPARpVctcdUeKClzJIneOW7MJRQCF4ZVrgZep3/xlqZ9E8NrSBZo+94R1mFNVlUShxBcwe6hlw3vil7VqsL/CrC7UiDPadz8ehKknWet0ukJTbVgE/sVAQV8+jJt6fjIpRoGVh6swo+BNofLWtp6NOWWlftTEmhA5cQKZbVOxXs0v7TwUzaTQngTKYLgmNMkqJLPV6PJtmTEDP/z7calxT0pP/L95MQsI1+7pg1/qFmAvwIsjUCjR0+5sBGQok7oV690qJZgjoRX6o5QecexcQo6fK2n8+hY35zRhOUvcCXtbU3d3ReI7Gv+5eXm8nx7sOtDoxVnrzC7UHd5ImpK0qeerqUdbWplfdl4iaaP1Id45Tnsdzy8z4fpPzC0S2VHx/5axUh+C3UA7yPWczAkSIbxWa/ptLOJ9cr0sv3AL/womEwEfKJZEaYrTC/WI33tfM2Z6nepoWu/+V4htqMlAeCvxxWsCJzBpD6KKG1q3xK6OH3E/ptuBUAGFZaxbRwacXjd7ZerzXubqCye19FxQSFuMvtc2HDt6vYhAhFl/KRgo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9e892fd-3e80-4670-d47c-08d9b8b62311 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2021 12:44:26.3198 (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: h6+kzIw/3KCYIQw4L94Ue/+shYTk1bGXrzxrmIhaUTznW2n6pc0zUXF/3ooFtIDQ3ryDBwtOgl131zbjxkeRoQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4791 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10189 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112060078 X-Proofpoint-ORIG-GUID: YJX6uFXwUwppDUyMed24PCYY1lTca9YH X-Proofpoint-GUID: YJX6uFXwUwppDUyMed24PCYY1lTca9YH Received-SPF: pass client-ip=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier This new command shows the information of a VirtQueue element. Signed-off-by: Jonah Palmer Acked-by: Markus Armbruster --- hw/virtio/virtio-stub.c | 9 +++ hw/virtio/virtio.c | 154 ++++++++++++++++++++++++++++++++++++++++ qapi/virtio.json | 183 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 346 insertions(+) diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index 13e5f93..7ddb22c 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -31,3 +31,12 @@ VirtQueueStatus *qmp_x_query_virtio_queue_status(const char *path, { return qmp_virtio_unsupported(errp); } + +VirtioQueueElement *qmp_x_query_virtio_queue_element(const char *path, + uint16_t queue, + bool has_index, + uint16_t index, + Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 459bfb2..8c6cc27 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -475,6 +475,19 @@ static inline void vring_used_write(VirtQueue *vq, VRingUsedElem *uelem, address_space_cache_invalidate(&caches->used, pa, sizeof(VRingUsedElem)); } +/* Called within rcu_read_lock(). */ +static inline uint16_t vring_used_flags(VirtQueue *vq) +{ + VRingMemoryRegionCaches *caches = vring_get_region_caches(vq); + hwaddr pa = offsetof(VRingUsed, flags); + + if (!caches) { + return 0; + } + + return virtio_lduw_phys_cached(vq->vdev, &caches->used, pa); +} + /* Called within rcu_read_lock(). */ static uint16_t vring_used_idx(VirtQueue *vq) { @@ -4381,6 +4394,147 @@ VirtQueueStatus *qmp_x_query_virtio_queue_status(const char *path, return status; } +static strList *qmp_decode_vring_desc_flags(uint16_t flags) +{ + strList *list = NULL; + strList *node; + int i; + + struct { + uint16_t flag; + const char *value; + } map[] = { + { VRING_DESC_F_NEXT, "next" }, + { VRING_DESC_F_WRITE, "write" }, + { VRING_DESC_F_INDIRECT, "indirect" }, + { 1 << VRING_PACKED_DESC_F_AVAIL, "avail" }, + { 1 << VRING_PACKED_DESC_F_USED, "used" }, + { 0, "" } + }; + + for (i = 0; map[i].flag; i++) { + if ((map[i].flag & flags) == 0) { + continue; + } + node = g_malloc0(sizeof(strList)); + node->value = g_strdup(map[i].value); + node->next = list; + list = node; + } + + return list; +} + +VirtioQueueElement *qmp_x_query_virtio_queue_element(const char *path, + uint16_t queue, + bool has_index, + uint16_t index, + Error **errp) +{ + VirtIODevice *vdev; + VirtQueue *vq; + VirtioQueueElement *element = NULL; + + vdev = virtio_device_find(path); + if (vdev == NULL) { + error_setg(errp, "Path %s is not a VirtIO device", path); + return NULL; + } + + if (queue >= VIRTIO_QUEUE_MAX || !virtio_queue_get_num(vdev, queue)) { + error_setg(errp, "Invalid virtqueue number %d", queue); + return NULL; + } + vq = &vdev->vq[queue]; + + if (virtio_vdev_has_feature(vdev, VIRTIO_F_RING_PACKED)) { + error_setg(errp, "Packed ring not supported"); + return NULL; + } else { + unsigned int head, i, max; + VRingMemoryRegionCaches *caches; + MemoryRegionCache indirect_desc_cache = MEMORY_REGION_CACHE_INVALID; + MemoryRegionCache *desc_cache; + VRingDesc desc; + VirtioRingDescList *list = NULL; + VirtioRingDescList *node; + int rc; int ndescs; + + RCU_READ_LOCK_GUARD(); + + max = vq->vring.num; + + if (!has_index) { + head = vring_avail_ring(vq, vq->last_avail_idx % vq->vring.num); + } else { + head = vring_avail_ring(vq, index % vq->vring.num); + } + i = head; + + caches = vring_get_region_caches(vq); + if (!caches) { + error_setg(errp, "Region caches not initialized"); + return NULL; + } + if (caches->desc.len < max * sizeof(VRingDesc)) { + error_setg(errp, "Cannot map descriptor ring"); + return NULL; + } + + desc_cache = &caches->desc; + vring_split_desc_read(vdev, &desc, desc_cache, i); + if (desc.flags & VRING_DESC_F_INDIRECT) { + int64_t len; + len = address_space_cache_init(&indirect_desc_cache, vdev->dma_as, + desc.addr, desc.len, false); + desc_cache = &indirect_desc_cache; + if (len < desc.len) { + error_setg(errp, "Cannot map indirect buffer"); + goto done; + } + + max = desc.len / sizeof(VRingDesc); + i = 0; + vring_split_desc_read(vdev, &desc, desc_cache, i); + } + + element = g_new0(VirtioQueueElement, 1); + element->avail = g_new0(VirtioRingAvail, 1); + element->used = g_new0(VirtioRingUsed, 1); + element->name = g_strdup(vdev->name); + element->index = head; + element->avail->flags = vring_avail_flags(vq); + element->avail->idx = vring_avail_idx(vq); + element->avail->ring = head; + element->used->flags = vring_used_flags(vq); + element->used->idx = vring_used_idx(vq); + ndescs = 0; + + do { + /* A buggy driver may produce an infinite loop */ + if (ndescs >= max) { + break; + } + node = g_new0(VirtioRingDescList, 1); + node->value = g_new0(VirtioRingDesc, 1); + node->value->addr = desc.addr; + node->value->len = desc.len; + node->value->flags = qmp_decode_vring_desc_flags(desc.flags); + node->next = list; + list = node; + + ndescs++; + rc = virtqueue_split_read_next_desc(vdev, &desc, desc_cache, + max, &i); + } while (rc == VIRTQUEUE_READ_DESC_MORE); + element->descs = list; +done: + address_space_cache_destroy(&indirect_desc_cache); + } + + return element; +} + static const TypeInfo virtio_device_info = { .name = TYPE_VIRTIO_DEVICE, .parent = TYPE_DEVICE, diff --git a/qapi/virtio.json b/qapi/virtio.json index 56e56d2..2984e48 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -654,3 +654,186 @@ 'data': { 'path': 'str', 'queue': 'uint16' }, 'returns': 'VirtVhostQueueStatus', 'features': [ 'unstable' ] } + +## +# @VirtioRingDesc: +# +# Information regarding the vring descriptor area +# +# @addr: Guest physical address of the descriptor area +# +# @len: Length of the descriptor area +# +# @flags: List of descriptor flags +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtioRingDesc', + 'data': { 'addr': 'uint64', + 'len': 'uint32', + 'flags': [ 'str' ] } } + +## +# @VirtioRingAvail: +# +# Information regarding the avail vring (a.k.a. driver area) +# +# @flags: VRingAvail flags +# +# @idx: VRingAvail index +# +# @ring: VRingAvail ring[] entry at provided index +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtioRingAvail', + 'data': { 'flags': 'uint16', + 'idx': 'uint16', + 'ring': 'uint16' } } + +## +# @VirtioRingUsed: +# +# Information regarding the used vring (a.k.a. device area) +# +# @flags: VRingUsed flags +# +# @idx: VRingUsed index +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtioRingUsed', + 'data': { 'flags': 'uint16', + 'idx': 'uint16' } } + +## +# @VirtioQueueElement: +# +# Information regarding a VirtQueue's VirtQueueElement including +# descriptor, driver, and device areas +# +# @name: Name of the VirtIODevice that uses this VirtQueue +# +# @index: Index of the element in the queue +# +# @descs: List of descriptors (VirtioRingDesc) +# +# @avail: VRingAvail info +# +# @used: VRingUsed info +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtioQueueElement', + 'data': { 'name': 'str', + 'index': 'uint32', + 'descs': [ 'VirtioRingDesc' ], + 'avail': 'VirtioRingAvail', + 'used': 'VirtioRingUsed' } } + +## +# @x-query-virtio-queue-element: +# +# Return the information about a VirtQueue's VirtQueueElement. By +# default it looks at the head of the queue (if no index is given) +# +# @path: VirtIODevice canonical QOM path +# +# @queue: VirtQueue index to examine +# +# @index: Index of the element in the queue +# +# Features: +# @unstable: This command is meant for debugging +# +# Returns: VirtioQueueElement information +# +# Since: 7.0 +# +# Examples: +# +# 1. Introspect on virtio-net's VirtQueue 0 at index 5 +# +# -> { "execute": "x-query-virtio-queue-element", +# "arguments": { "path": "/machine/peripheral-anon/device[1]/virtio-backend", +# "queue": 0, +# "index": 5 } +# } +# <- { "return": { +# "index": 5, +# "name": "virtio-net", +# "descs": [ +# { "flags": ["write"], "len": 1536, "addr": 5257305600 } +# ], +# "avail": { +# "idx": 256, +# "flags": 0, +# "ring": 5 +# }, +# "used": { +# "idx": 13, +# "flags": 0 +# }, +# } +# +# 2. Introspect on virtio-crypto's VirtQueue 1 at head +# +# -> { "execute": "x-query-virtio-queue-element", +# "arguments": { "path": "/machine/peripheral/crypto0/virtio-backend", +# "queue": 1 } +# } +# <- { "return": { +# "index": 0, +# "name": "virtio-crypto", +# "descs": [ +# { "flags": [], "len": 0, "addr": 8080268923184214134 } +# ], +# "avail": { +# "idx": 280, +# "flags": 0, +# "ring": 0 +# }, +# "used": { +# "idx": 280, +# "flags": 0 +# } +# } +# +# 3. Introspect on virtio-scsi's VirtQueue 2 at head +# +# -> { "execute": "x-query-virtio-queue-element", +# "arguments": { "path": "/machine/peripheral-anon/device[2]/virtio-backend", +# "queue": 2 } +# } +# <- { "return": { +# "index": 19, +# "name": "virtio-scsi", +# "descs": [ +# { "flags": ["used", "indirect", "write"], "len": 4099327944, +# "addr": 12055409292258155293 } +# ], +# "avail": { +# "idx": 1147, +# "flags": 0, +# "ring": 19 +# }, +# "used": { +# "idx": 280, +# "flags": 0 +# } +# } +# +## + +{ 'command': 'x-query-virtio-queue-element', + 'data': { 'path': 'str', 'queue': 'uint16', '*index': 'uint16' }, + 'returns': 'VirtioQueueElement', + 'features': [ 'unstable' ] } From patchwork Mon Dec 6 12:43:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonah Palmer X-Patchwork-Id: 12658277 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 09B4BC433EF for ; Mon, 6 Dec 2021 12:55:21 +0000 (UTC) Received: from localhost ([::1]:47998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muDWa-0003kF-1x for qemu-devel@archiver.kernel.org; Mon, 06 Dec 2021 07:55:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDNK-00019q-O5; Mon, 06 Dec 2021 07:45:54 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:13320) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDNI-0002Qv-17; Mon, 06 Dec 2021 07:45:46 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6C5As5023240; Mon, 6 Dec 2021 12:44:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=wW2M8EryMzwsbBUEZ8pWsFlGDVw4odxooyXIWmKzeH4=; b=b2X+4kT6eoVwuGQqepvxZ5o49O6VwJH14rjerpYyXFAzgjW13l9n7jCYEbeAcc0RDxlg u/RreGUl33FNlDxhePpMRrMsk1M73Tdk4Z09tsE4v0PNVMMkLXQFB4piF+euTN43XT5s V+SAQ3VQztx0fUr8pbOUnf7J2WWDiW011byPT4foqY3BAy7O5GHAczfhzf5q9fGzodrN 1O5qi17gCt5xF7NyV9inkRwIk6vYNodcb3pO/45lINDQcGjITL7RKM0BwR6CCgUaETcL FMxEQdAEhzwsAxEfng9yWGlpA+CXA1mqNjsKy6WkJBPCp8lLDl7NofVKLsF0B4PsYlf2 VA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3csbbqj2pn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Dec 2021 12:44:32 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B6Cf9F9139474; Mon, 6 Dec 2021 12:44:31 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2040.outbound.protection.outlook.com [104.47.66.40]) by aserp3030.oracle.com with ESMTP id 3csc4rqjca-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Dec 2021 12:44:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T4LjTjhpCjXTVlhwlaK0xYXVDTaFaztdkooRz4HTOOMYalXOpRZChYVmo4avEwuXGX/DwTWhosyDxZ7IO61lga+JjogTdXg/DlAFWbjJrRy7tYHTzMdGcnlz5Z1pU6KUGtLpH5qfD3wMxipNwAalu8yhc1cEddnFHzssx47gzJk9enoWuKjy0QQoLonP9N0aqhXOJkk7E+1C5Tm+H9KZPZ3cuB2lXNdmb5yZm1y8sKeg1I0qYisJ0x4R+z3QsJcK2DYJHmj3vdhGuYZy7by9m8u4Xz3dYDYS3u/c0raK49Ketx5e4ZWLdy7XA9dDhsv6q3kzqY/oa1lBER79MxYLmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wW2M8EryMzwsbBUEZ8pWsFlGDVw4odxooyXIWmKzeH4=; b=FfybhPQTZPp9G1IaHbIOruf6+D1ICxSTjolL5v/VSbii7NH+fZQWP45OIL8tT9rRZ5+xL80PFVUrsjrt54NVUF+vWeW6hIztiZ4zxJZH3v+jW5tdEt82YQM0SOgfPZL363JIzXCpGv0LypZU7Jm5iOHnZbo2SVJXsUfEeBeqG4BCM6as30DAygt6H7UzdEhtXuj3DXb4LjjrVoq+vk9w4FAA9bNPDZTZiBxlNaZBH+saRQpTOEhpHhFWiM9uUWk0wGJ/la4US1Y/2CTuR0nczFFmewWdmwgMDnqb+Kt/+DsPu7/5736ZbkKvBgRYGrNVHUCxG2fw9ui0ppj4RMSbDw== 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=wW2M8EryMzwsbBUEZ8pWsFlGDVw4odxooyXIWmKzeH4=; b=Y3YIof/lo9GhFUefmyTZy1NyJdbC0tV+gwcPe60F/el+CNkXGOskEKcYzrBZSa8qisAlymgb2v1LverkI3i4WBEkygRtHWpWhSydbPWjzmkol7bfOXhiEXn/AUyG4crLUjxlVcfHqGtgn8evDcnOHG12ZEfu/ythzsBnWWRMtUk= Received: from PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) by PH0PR10MB4791.namprd10.prod.outlook.com (2603:10b6:510:3a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.20; Mon, 6 Dec 2021 12:44:29 +0000 Received: from PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517]) by PH0PR10MB4664.namprd10.prod.outlook.com ([fe80::3446:f4ea:c037:4517%5]) with mapi id 15.20.4755.022; Mon, 6 Dec 2021 12:44:29 +0000 From: Jonah Palmer To: qemu-devel@nongnu.org Subject: [PATCH v10 8/8] hmp: add virtio commands Date: Mon, 6 Dec 2021 07:43:26 -0500 Message-Id: <1638794606-19631-9-git-send-email-jonah.palmer@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1638794606-19631-1-git-send-email-jonah.palmer@oracle.com> References: <1638794606-19631-1-git-send-email-jonah.palmer@oracle.com> X-ClientProxiedBy: SA9P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::35) To PH0PR10MB4664.namprd10.prod.outlook.com (2603:10b6:510:41::11) MIME-Version: 1.0 Received: from jonpalme-lnx.us.oracle.com (209.17.40.42) by SA9P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21 via Frontend Transport; Mon, 6 Dec 2021 12:44:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a0af787e-d908-44dd-069f-08d9b8b624a5 X-MS-TrafficTypeDiagnostic: PH0PR10MB4791:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:120; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6U7xc5C62z667454agcoFNXXy02v/37fha6IGuW6Yx0X7DPO8J0CZFCd/33oNqgRChzi4ms8Ryc8bI1c7xUP6ri9d7CV1Thk3OLMGu/AbhglARkm9S86v440NNjeY2sffo0rzCz9bn7kfPLgdQMmkKcWw5Bmc7xwKfbDBHVnFx0VsXSnAvjQ+1jme2gxvZRT3QftVfSdltHXovSVATErCpgtpZ3h82IGPTmikWuyBAAi+7VRqXW5uJLx5QVbyMLEazA8p8UVRbZYPK6J4zf3M4zqSmdyoV/vE2vxeMwNAWhpnOvAuNtkGYXaUzyllv17sLBX9yutvEAO3UivhmMKqCf9FpuPrtus7CEzSWmD6eljV+3dAjFX/IpJ+V6ET4erHck0ujtP9ibcdjZ5VyFGVx2yxrz+lL+sTD57s8PhomR//ygzWyE1aJWbdwXQ90+Odgz9+x4rccKfb4BTB1S6JyW+oeIyYB5PpL3a84ZFu0QIRnKiq++US73/L5HhKKoWBhSjGj7irOtkglu3FyUwmoFYvM0qD7xmjt486XMYOttfwtcjKPRgb7zAraFm4LhxHUo+6S+k3R/cX5vmcQQzG9fi0bvU80d5caBYyDC/scYW/c0y5RJHSuMqFkoNKwu2oDrH8t6u4mXmeJM7oIFRmy7g+yYI89dqo7ZjOEuW9AXgAnBlCDUJ2EmM+4K1xXMzMrpHlvsispFAHmCrvWis7w== 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)(956004)(66556008)(52116002)(186003)(8936002)(38350700002)(508600001)(6486002)(2616005)(83380400001)(7696005)(36756003)(6916009)(86362001)(38100700002)(30864003)(66476007)(5660300002)(26005)(316002)(66946007)(4326008)(7416002)(8676002)(44832011)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yW8uDV/IiKtJymEgw4HQ5PGznamRP/Shnd3/SyDJj5upZumWyPbcrBW1nAYmlkKwUvl52O/nPEKmrYGWq0NFDjVVSFcGfFCDnaDK+DUO5b/zMY8z1k7jGLIoCHpPGDSTpniMezx+PrSW6j0Dco0nJYNZzCm6MeSQ+1Iet6Mj8jy5bWWrrv/zxatXkw5sl2LAFlTc2+JJkyQrR8LVDJZKaxaDL+95xnDntrAIQC07qemA/ERYHMDfqR3ijeXP+EAK8xHfKANd0/CSz3XpasyPOZDQ8hgLrusynIr9PQ8z0Vljkw0NbW7u4kWoIY3uimcBMcHpRr07+tLKp1zmixuG3nInqz6+7P//m2fBnzIqbKIPUMElb/lRa4UyBmkOzzNPvQiGSyTJeGtYDs48rjrvhqleGy1FIA7wx+isBTt+gTmGYaPs5eMOFtXnhSafGU1bzRsUIUzrfT6xkY5UL0N5mb5lbRSeaOv0R/towrh65wmvpocz6y9hye2ZVnYqRNJxHLZiEt9Ki+uSGhvTIQ5gMWW7R0NTjeJyFs8IOhsQqfebxREXiImhQz+AhSqwo+bIIUmpTxAQz0ctFNzMpaDjhUckSOTWhGaqh00+KBDrVMR5yk8xDzx8pkwEjx0T1dD0ta1Q2eHUNWd0dn6Yryg9fujPRJAF9wZQfA0t/g6aV7WDpNJslPxaV4P0KtTQZWMYVqAp/+14RlDPCQ7Yf7Q28qUyBXBn7kT6SZ9SBI7y3WTFdHH/gJqLEfD114+gBMdOa016Rpb24YraSo6P2gdvrmBXkyIPp3HHAog3PGIm4+jf4hTXmU1V0v4j9YfM3o/TQNoqKy+crEMuIM+a7QW9xKNUZXp8MlDRLg1/Il0ihICmUHROpqiBHYDhB0fBubS5o55bUPf0uJmwyVp52utdCHUB4nFmTY4470WCU2TmQ9sXtjKpBXpm7DjKzbr8K0s5EwY81CFQ9A3uMo88YZbURt3z3+Ded1kMWmiIsZIirhwMsydkVIivHNTOH4tVfO3pSzXv4NxBCwvv68qDiuLGZI/NCItVYRROuiI2yb+hRDhCUl/qjkSWGn1/uG9uCxtb05wv82HSBL2krgeJpX/BOeqKISP4RBYcs936ALSrLsRxmVag+km1Nxr4VkpASvMV21NusJpG8jUhVzZrm2LI9M18uixbGhs4YyTSWEVlyek7xphWa9/sOAwroNWQH4jYU4zQM4JJuv+T9ZpEiEFmFEFoXwW4eIR+gsEJ8RW8dGsGr05JiLlIHuVNgrgGsf+h3YEVFHw24bu+SUtxo32hwqBJhIQmQM2zCMnxpWuAK8e6/zIiX9CySa5HXA0g1Dwmh4klbu5fLzKsDWfaBQlhu3aEphNmKBSuIx+eniguF9bEspa6gHF5UH8m86RVMxQlSKi9Dvl8PXdkr5DH+2W97irFiMh+rtlFrrtsYF0OytSC+yHrLrsKqk1r1D8iv0qmM3s6HA833ySmcodpzX62t24f+4CjN30y7GC8AVgYT0QyOumPJ2lKrUi4o5zMLXPf2e5k5Kub2cIf6lnhaymJe0f/fJrhJh3Z1Txi8cDh5kEpmacxWvSy44LAnD3fbQhSb8DDsjbT5pO6PK8mXkRi1j9ZEhx64OaSYij8CuUIFEc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0af787e-d908-44dd-069f-08d9b8b624a5 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB4664.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2021 12:44:28.9771 (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: CQgrmKNGGk8x/X0TJdBzpHasw7lczVRgv1A4kJ0qS672E2mV1lykEtE2WqYb1dkK4r+REiBDOeq5urAR/dM1XQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4791 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10189 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112060078 X-Proofpoint-GUID: qyuWs-hHVEHo6z-hOiNJ6FfEtAmVsL__ X-Proofpoint-ORIG-GUID: qyuWs-hHVEHo6z-hOiNJ6FfEtAmVsL__ Received-SPF: pass client-ip=205.220.177.32; envelope-from=jonah.palmer@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, qemu_oss@crudebyte.com, kraxel@redhat.com, si-wei.liu@oracle.com, joao.m.martins@oracle.com, eblake@redhat.com, qemu-block@nongnu.org, david@redhat.com, armbru@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, lvivier@redhat.com, thuth@redhat.com, michael.roth@amd.com, groug@kaod.org, dgilbert@redhat.com, eric.auger@redhat.com, stefanha@redhat.com, boris.ostrovsky@oracle.com, kwolf@redhat.com, mathieu.poirier@linaro.org, raphael.norwitz@nutanix.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier This patch implements the HMP versions of the virtio QMP commands. Signed-off-by: Jonah Palmer --- hmp-commands-info.hx | 70 ++++++++++++ include/monitor/hmp.h | 5 + monitor/hmp-cmds.c | 311 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 386 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 407a1da..e49d852 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -877,3 +877,73 @@ SRST ``info sgx`` Show intel SGX information. ERST + + { + .name = "virtio", + .args_type = "", + .params = "", + .help = "List all available virtio devices", + .cmd = hmp_virtio_query, + .flags = "p", + }, + +SRST + ``info virtio`` + List all available virtio devices +ERST + + { + .name = "virtio-status", + .args_type = "path:s", + .params = "path", + .help = "Display status of a given virtio device", + .cmd = hmp_virtio_status, + .flags = "p", + }, + +SRST + ``info virtio-status`` *path* + Display status of a given virtio device +ERST + + { + .name = "virtio-queue-status", + .args_type = "path:s,queue:i", + .params = "path queue", + .help = "Display status of a given virtio queue", + .cmd = hmp_virtio_queue_status, + .flags = "p", + }, + +SRST + ``info virtio-queue-status`` *path* *queue* + Display status of a given virtio queue +ERST + + { + .name = "virtio-vhost-queue-status", + .args_type = "path:s,queue:i", + .params = "path queue", + .help = "Display status of a given vhost queue", + .cmd = hmp_vhost_queue_status, + .flags = "p", + }, + +SRST + ``info virtio-vhost-queue-status`` *path* *queue* + Display status of a given vhost queue +ERST + + { + .name = "virtio-queue-element", + .args_type = "path:s,queue:i,index:i?", + .params = "path queue [index]", + .help = "Display element of a given virtio queue", + .cmd = hmp_virtio_queue_element, + .flags = "p", + }, + +SRST + ``info virtio-queue-element`` *path* *queue* [*index*] + Display element of a given virtio queue +ERST diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 96d0148..47446d8 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -95,6 +95,11 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict); void hmp_qom_get(Monitor *mon, const QDict *qdict); void hmp_qom_set(Monitor *mon, const QDict *qdict); void hmp_info_qom_tree(Monitor *mon, const QDict *dict); +void hmp_virtio_query(Monitor *mon, const QDict *qdict); +void hmp_virtio_status(Monitor *mon, const QDict *qdict); +void hmp_virtio_queue_status(Monitor *mon, const QDict *qdict); +void hmp_vhost_queue_status(Monitor *mon, const QDict *qdict); +void hmp_virtio_queue_element(Monitor *mon, const QDict *qdict); void object_add_completion(ReadLineState *rs, int nb_args, const char *str); void object_del_completion(ReadLineState *rs, int nb_args, const char *str); void device_add_completion(ReadLineState *rs, int nb_args, const char *str); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 9c91bf9..7092653 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -42,6 +42,8 @@ #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-tpm.h" #include "qapi/qapi-commands-ui.h" +#include "qapi/qapi-commands-virtio.h" +#include "qapi/qapi-visit-virtio.h" #include "qapi/qapi-visit-net.h" #include "qapi/qapi-visit-migration.h" #include "qapi/qmp/qdict.h" @@ -2165,3 +2167,312 @@ void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict) } hmp_handle_error(mon, err); } + +static void hmp_virtio_dump_protocols(Monitor *mon, + VhostDeviceProtocols *pcol) +{ + strList *pcol_list = pcol->protocols; + while (pcol_list) { + monitor_printf(mon, "%s", pcol_list->value); + pcol_list = pcol_list->next; + if (pcol_list != NULL) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, "\n"); + if (pcol->has_unknown_protocols) { + monitor_printf(mon, " unknown-protocols(0x%016"PRIx64")\n", + pcol->unknown_protocols); + } +} + +static void hmp_virtio_dump_status(Monitor *mon, + VirtioDeviceStatus *status) +{ + strList *status_list = status->statuses; + while (status_list) { + monitor_printf(mon, "%s", status_list->value); + status_list = status_list->next; + if (status_list != NULL) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, "\n"); + if (status->has_unknown_statuses) { + monitor_printf(mon, " unknown-statuses(0x%016"PRIx32")\n", + status->unknown_statuses); + } +} + +static void hmp_virtio_dump_features(Monitor *mon, + VirtioDeviceFeatures *features) +{ + strList *transport_list = features->transports; + while (transport_list) { + monitor_printf(mon, "%s", transport_list->value); + transport_list = transport_list->next; + if (transport_list != NULL) { + monitor_printf(mon, ", "); + } + } + + monitor_printf(mon, "\n"); + strList *list = features->dev_features; + if (list) { + monitor_printf(mon, " "); + while (list) { + monitor_printf(mon, "%s", list->value); + list = list->next; + if (list != NULL) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, "\n"); + } + + if (features->has_unknown_dev_features) { + monitor_printf(mon, " unknown-features(0x%016"PRIx64")\n", + features->unknown_dev_features); + } +} + +void hmp_virtio_query(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + VirtioInfoList *list = qmp_x_query_virtio(&err); + VirtioInfoList *node; + + if (err != NULL) { + hmp_handle_error(mon, err); + return; + } + + if (list == NULL) { + monitor_printf(mon, "No VirtIO devices\n"); + return; + } + + node = list; + while (node) { + monitor_printf(mon, "%s [%s]\n", node->value->path, + node->value->name); + node = node->next; + } + qapi_free_VirtioInfoList(list); +} + +void hmp_virtio_status(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + const char *path = qdict_get_try_str(qdict, "path"); + VirtioStatus *s = qmp_x_query_virtio_status(path, &err); + + if (err != NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " device_name: %s %s\n", + s->name, s->has_vhost_dev ? "(vhost)" : ""); + monitor_printf(mon, " device_id: %d\n", s->device_id); + monitor_printf(mon, " vhost_started: %s\n", + s->vhost_started ? "true" : "false"); + monitor_printf(mon, " bus_name: %s\n", s->bus_name); + monitor_printf(mon, " broken: %s\n", + s->broken ? "true" : "false"); + monitor_printf(mon, " disabled: %s\n", + s->disabled ? "true" : "false"); + monitor_printf(mon, " disable_legacy_check: %s\n", + s->disable_legacy_check ? "true" : "false"); + monitor_printf(mon, " started: %s\n", + s->started ? "true" : "false"); + monitor_printf(mon, " use_started: %s\n", + s->use_started ? "true" : "false"); + monitor_printf(mon, " start_on_kick: %s\n", + s->start_on_kick ? "true" : "false"); + monitor_printf(mon, " use_guest_notifier_mask: %s\n", + s->use_guest_notifier_mask ? "true" : "false"); + monitor_printf(mon, " vm_running: %s\n", + s->vm_running ? "true" : "false"); + monitor_printf(mon, " num_vqs: %ld\n", s->num_vqs); + monitor_printf(mon, " queue_sel: %d\n", + s->queue_sel); + monitor_printf(mon, " isr: %d\n", s->isr); + monitor_printf(mon, " endianness: %s\n", + s->device_endian); + monitor_printf(mon, " status: "); + hmp_virtio_dump_status(mon, s->status); + monitor_printf(mon, " Guest features: "); + hmp_virtio_dump_features(mon, s->guest_features); + monitor_printf(mon, " Host features: "); + hmp_virtio_dump_features(mon, s->host_features); + monitor_printf(mon, " Backend features: "); + hmp_virtio_dump_features(mon, s->backend_features); + + if (s->has_vhost_dev) { + monitor_printf(mon, " VHost:\n"); + monitor_printf(mon, " nvqs: %d\n", + s->vhost_dev->nvqs); + monitor_printf(mon, " vq_index: %ld\n", + s->vhost_dev->vq_index); + monitor_printf(mon, " max_queues: %lu\n", + s->vhost_dev->max_queues); + monitor_printf(mon, " n_mem_sections: %ld\n", + s->vhost_dev->n_mem_sections); + monitor_printf(mon, " n_tmp_sections: %ld\n", + s->vhost_dev->n_tmp_sections); + monitor_printf(mon, " backend_cap: %lu\n", + s->vhost_dev->backend_cap); + monitor_printf(mon, " log_enabled: %s\n", + s->vhost_dev->log_enabled ? "true" : "false"); + monitor_printf(mon, " log_size: %lu\n", + s->vhost_dev->log_size); + monitor_printf(mon, " Features: "); + hmp_virtio_dump_features(mon, s->vhost_dev->features); + monitor_printf(mon, " Acked features: "); + hmp_virtio_dump_features(mon, s->vhost_dev->acked_features); + monitor_printf(mon, " Backend features: "); + hmp_virtio_dump_features(mon, s->vhost_dev->backend_features); + monitor_printf(mon, " Protocol features: "); + hmp_virtio_dump_protocols(mon, s->vhost_dev->protocol_features); + } + + qapi_free_VirtioStatus(s); +} + +void hmp_vhost_queue_status(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + const char *path = qdict_get_try_str(qdict, "path"); + int queue = qdict_get_int(qdict, "queue"); + VirtVhostQueueStatus *s = + qmp_x_query_virtio_vhost_queue_status(path, queue, &err); + + if (err != NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " device_name: %s (vhost)\n", + s->name); + monitor_printf(mon, " kick: %ld\n", s->kick); + monitor_printf(mon, " call: %ld\n", s->call); + monitor_printf(mon, " VRing:\n"); + monitor_printf(mon, " num: %ld\n", s->num); + monitor_printf(mon, " desc: 0x%016"PRIx64"\n", s->desc); + monitor_printf(mon, " desc_phys: 0x%016"PRIx64"\n", + s->desc_phys); + monitor_printf(mon, " desc_size: %"PRId32"\n", s->desc_size); + monitor_printf(mon, " avail: 0x%016"PRIx64"\n", s->avail); + monitor_printf(mon, " avail_phys: 0x%016"PRIx64"\n", + s->avail_phys); + monitor_printf(mon, " avail_size: %"PRId32"\n", s->avail_size); + monitor_printf(mon, " used: 0x%016"PRIx64"\n", s->used); + monitor_printf(mon, " used_phys: 0x%016"PRIx64"\n", + s->used_phys); + monitor_printf(mon, " used_size: %"PRId32"\n", s->used_size); + + qapi_free_VirtVhostQueueStatus(s); +} + +void hmp_virtio_queue_status(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + const char *path = qdict_get_try_str(qdict, "path"); + int queue = qdict_get_int(qdict, "queue"); + VirtQueueStatus *s = qmp_x_query_virtio_queue_status(path, queue, &err); + + if (err != NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " device_name: %s\n", s->name); + monitor_printf(mon, " queue_index: %d\n", s->queue_index); + monitor_printf(mon, " inuse: %d\n", s->inuse); + monitor_printf(mon, " used_idx: %d\n", s->used_idx); + monitor_printf(mon, " signalled_used: %d\n", + s->signalled_used); + monitor_printf(mon, " signalled_used_valid: %s\n", + s->signalled_used_valid ? "true" : "false"); + if (s->has_last_avail_idx) { + monitor_printf(mon, " last_avail_idx: %d\n", + s->last_avail_idx); + } + if (s->has_shadow_avail_idx) { + monitor_printf(mon, " shadow_avail_idx: %d\n", + s->shadow_avail_idx); + } + monitor_printf(mon, " VRing:\n"); + monitor_printf(mon, " num: %"PRId32"\n", s->vring_num); + monitor_printf(mon, " num_default: %"PRId32"\n", + s->vring_num_default); + monitor_printf(mon, " align: %"PRId32"\n", + s->vring_align); + monitor_printf(mon, " desc: 0x%016"PRIx64"\n", + s->vring_desc); + monitor_printf(mon, " avail: 0x%016"PRIx64"\n", + s->vring_avail); + monitor_printf(mon, " used: 0x%016"PRIx64"\n", + s->vring_used); + + qapi_free_VirtQueueStatus(s); +} + +void hmp_virtio_queue_element(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + const char *path = qdict_get_try_str(qdict, "path"); + int queue = qdict_get_int(qdict, "queue"); + int index = qdict_get_try_int(qdict, "index", -1); + VirtioQueueElement *e; + VirtioRingDescList *list; + + e = qmp_x_query_virtio_queue_element(path, queue, index != -1, + index, &err); + if (err != NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " device_name: %s\n", e->name); + monitor_printf(mon, " index: %d\n", e->index); + monitor_printf(mon, " desc:\n"); + monitor_printf(mon, " descs: "); + + list = e->descs; + while (list) { + monitor_printf(mon, "addr 0x%"PRIx64" len %d", list->value->addr, + list->value->len); + if (list->value->flags) { + strList *flag = list->value->flags; + monitor_printf(mon, " ("); + while (flag) { + monitor_printf(mon, "%s", flag->value); + flag = flag->next; + if (flag) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, ")"); + } + list = list->next; + if (list) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, "\n"); + monitor_printf(mon, " avail:\n"); + monitor_printf(mon, " flags: %d\n", e->avail->flags); + monitor_printf(mon, " idx: %d\n", e->avail->idx); + monitor_printf(mon, " ring: %d\n", e->avail->ring); + monitor_printf(mon, " used:\n"); + monitor_printf(mon, " flags: %d\n", e->used->flags); + monitor_printf(mon, " idx: %d\n", e->used->idx); + + qapi_free_VirtioQueueElement(e); +}