From nobody Sun May 5 14:34:15 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1686321493; cv=none; d=zohomail.com; s=zohoarc; b=ZN9zlcTkT1MbQhEsCyLppCFxmcR3UmlneC8CApCglZ2ARgYrdjpe45qkgJR4nRnYBNQYpF1jFkeO1H4VqKNJIDRPQw8hyzt0pefs1dOmJuv+pYPG6C/QnL0TIzLx6ttwuO9uXvkX18ulCmVXIx/MqcMC0duiNBeeBG1lIT0HIgk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686321493; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hjtSKzz7O6A6lV+1ELfYKO6t/rtB8xNG5bvjFTu6Fgo=; b=KL3+5yRDT6fCwwyHaj2RRNkiGVFDJlJojR1+LLmQ+T9uu1E1ul+HacS6zdZShIuDJS/feDlvRGCaOzmeQF5ikl+wZNrxF94T7iazAksQt50hesgZejBNGC6BwxuGOdYTJqDhKwy3EtCipNJHw51mGcfhAQ2KUZPJ2aAQ2+BsZNg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1686321493222308.2359096198211; Fri, 9 Jun 2023 07:38:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7c2z-00070p-U5; Fri, 09 Jun 2023 09:20:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7c2y-00070N-8O for qemu-devel@nongnu.org; Fri, 09 Jun 2023 09:20:56 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7c2w-0000TC-81 for qemu-devel@nongnu.org; Fri, 09 Jun 2023 09:20:55 -0400 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3598aPYc014732; Fri, 9 Jun 2023 13:20:48 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3r2a6ppk3t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 09 Jun 2023 13:20:48 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 359DFlBY015682; Fri, 9 Jun 2023 13:20:47 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r2a6pdh9s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 09 Jun 2023 13:20:47 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 359DK5Y9035303; Fri, 9 Jun 2023 13:20:46 GMT Received: from jonah-ol8.us.oracle.com (dhcp-10-39-219-26.vpn.oracle.com [10.39.219.26]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3r2a6pdh62-2; Fri, 09 Jun 2023 13:20:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2023-03-30; bh=hjtSKzz7O6A6lV+1ELfYKO6t/rtB8xNG5bvjFTu6Fgo=; b=Ra8FzzvLkQfYjKPukF/zU7gnbNerLmVh1HMifJUWReRk0wYhATu4FHryTK6fs3L73wxG SXEZEY0rD8x0pKnnwlyqjmGEpRZKgcY5AL1ys70lONZUkbRS4HbmWtDWeaWr8jGeZZfn VEwglRyP0uysJeMdFeC+lE8tXUhCGWKPxvKKgI1nbZ4QCBOtu4uQa0pTFbhTvw7J+6Pv FhnAbVwuRqHDlu8zNqhsbmyhqY5SQ6oIpfUwbwUNp7tptwNd+M9JOJUb7QG8ClhX5jSr BucD15vkszvF6MMGHbDAqZE5mlEGqMou+kmy8pfB4FoX32LEZSSnEGk0r0Xj/KmjZc2s Yw== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: philmd@linaro.org, laurent@vivier.eu, mst@redhat.com, boris.ostrovsky@oracle.com, alex.bennee@linaro.org, viresh.kumar@linaro.org, armbru@redhat.com, pbonzini@redhat.com, berrange@redhat.com, eduardo@habkost.net Subject: [PATCH v2 1/2] qmp: remove virtio_list, search QOM tree instead Date: Fri, 9 Jun 2023 09:20:39 -0400 Message-Id: <20230609132040.2180710-2-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230609132040.2180710-1-jonah.palmer@oracle.com> References: <20230609132040.2180710-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-09_09,2023-06-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 suspectscore=0 bulkscore=0 spamscore=0 mlxlogscore=948 adultscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306090113 X-Proofpoint-ORIG-GUID: E78P75EXr7JqbhHiPIUS3BZlup1XivXf X-Proofpoint-GUID: E78P75EXr7JqbhHiPIUS3BZlup1XivXf Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=jonah.palmer@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1686321494417100005 Content-Type: text/plain; charset="utf-8" The virtio_list duplicates information about virtio devices that already exist in the QOM composition tree. Instead of creating this list of realized virtio devices, search the QOM composition tree instead. This patch modifies the QMP command qmp_x_query_virtio to instead search the partial paths of '/machine/peripheral/' & '/machine/peripheral-anon/' in the QOM composition tree for virtio devices. A device is found to be a valid virtio device if (1) its canonical path is of 'TYPE_VIRTIO_DEVICE' and (2) the device has been realized. [Jonah: In the previous commit I had written that a device is found to be a valid virtio device if (1) it has a canonical path ending with 'virtio-backend'. The code now determines if it's a virtio device by appending 'virtio-backend' (if needed) to a given canonical path and then checking that path to see if the device is of type 'TYPE_VIRTIO_DEVICE'. The patch also instead now checks to make sure it's a virtio device before attempting to check whether the device is realized or not.] Signed-off-by: Jonah Palmer --- hw/virtio/virtio-qmp.c | 128 ++++++++++++++++++++++++++--------------- hw/virtio/virtio-qmp.h | 8 +-- hw/virtio/virtio.c | 6 -- 3 files changed, 82 insertions(+), 60 deletions(-) diff --git a/hw/virtio/virtio-qmp.c b/hw/virtio/virtio-qmp.c index b5e1835299..e936cc8ce5 100644 --- a/hw/virtio/virtio-qmp.c +++ b/hw/virtio/virtio-qmp.c @@ -668,67 +668,101 @@ VirtioDeviceFeatures *qmp_decode_features(uint16_t d= evice_id, uint64_t bitmap) VirtioInfoList *qmp_x_query_virtio(Error **errp) { VirtioInfoList *list =3D NULL; - VirtioInfo *node; - VirtIODevice *vdev; =20 - QTAILQ_FOREACH(vdev, &virtio_list, next) { - DeviceState *dev =3D DEVICE(vdev); - Error *err =3D NULL; - QObject *obj =3D qmp_qom_get(dev->canonical_path, "realized", &err= ); - - if (err =3D=3D NULL) { - GString *is_realized =3D qobject_to_json_pretty(obj, true); - /* virtio device is NOT realized, remove it from list */ - if (!strncmp(is_realized->str, "false", 4)) { - QTAILQ_REMOVE(&virtio_list, vdev, next); - } else { - node =3D g_new(VirtioInfo, 1); - node->path =3D g_strdup(dev->canonical_path); - node->name =3D g_strdup(vdev->name); - QAPI_LIST_PREPEND(list, node); + /* Query the QOM composition tree for virtio devices */ + qmp_set_virtio_device_list("/machine/peripheral/", &list); + qmp_set_virtio_device_list("/machine/peripheral-anon/", &list); + if (list =3D=3D NULL) { + error_setg(errp, "No virtio devices found"); + return NULL; + } + return list; +} + +/* qmp_set_virtio_device_list: + * @ppath: An incomplete peripheral path to search from. + * @list: A list of realized virtio devices. + * Searches a given incomplete peripheral path (e.g. '/machine/peripheral/' + * or '/machine/peripheral-anon/') for realized virtio devices and adds th= em + * to a given list of virtio devices. + */ +void qmp_set_virtio_device_list(const char *ppath, VirtioInfoList **list) +{ + ObjectPropertyInfoList *plist; + VirtioInfoList *node; + Error *err =3D NULL; + + /* Search an incomplete path for virtio devices */ + plist =3D qmp_qom_list(ppath, &err); + if (err =3D=3D NULL) { + ObjectPropertyInfoList *start =3D plist; + while (plist !=3D NULL) { + ObjectPropertyInfo *value =3D plist->value; + GString *path =3D g_string_new(ppath); + g_string_append(path, value->name); + g_string_append(path, "/virtio-backend"); + + /* Determine if full path is a realized virtio device */ + VirtIODevice *vdev =3D qmp_find_virtio_device(path->str); + if (vdev !=3D NULL) { + node =3D g_new0(VirtioInfoList, 1); + node->value =3D g_new(VirtioInfo, 1); + node->value->path =3D g_strdup(path->str); + node->value->name =3D g_strdup(vdev->name); + QAPI_LIST_PREPEND(*list, node->value); } - g_string_free(is_realized, true); + g_string_free(path, true); + plist =3D plist->next; } - qobject_unref(obj); + qapi_free_ObjectPropertyInfoList(start); } - - return list; } =20 VirtIODevice *qmp_find_virtio_device(const char *path) { - VirtIODevice *vdev; - - QTAILQ_FOREACH(vdev, &virtio_list, next) { - DeviceState *dev =3D DEVICE(vdev); - - if (strcmp(dev->canonical_path, path) !=3D 0) { - continue; + Error *err =3D NULL; + char *basename; + + /* Append 'virtio-backend' to path if needed */ + basename =3D g_path_get_basename(path); + if (strcmp(basename, "virtio-backend")) { + GString *temp =3D g_string_new(path); + char *last =3D strrchr(path, '/'); + if (g_strcmp0(last, "/")) { + g_string_append(temp, "/virtio-backend"); + } else { + g_string_append(temp, "virtio-backend"); } + path =3D g_strdup(temp->str); + g_string_free(temp, true); + } =20 - Error *err =3D NULL; - QObject *obj =3D qmp_qom_get(dev->canonical_path, "realized", &err= ); - if (err =3D=3D NULL) { - GString *is_realized =3D qobject_to_json_pretty(obj, true); - /* virtio device is NOT realized, remove it from list */ - if (!strncmp(is_realized->str, "false", 4)) { - g_string_free(is_realized, true); - qobject_unref(obj); - QTAILQ_REMOVE(&virtio_list, vdev, next); - return NULL; - } + /* Verify the canonical path is a virtio device */ + Object *obj =3D object_resolve_path(path, NULL); + if (!obj || !object_dynamic_cast(obj, TYPE_VIRTIO_DEVICE)) { + object_unref(obj); + return NULL; + } + + /* Verify the virtio device is realized */ + QObject *qobj =3D qmp_qom_get(path, "realized", &err); + if (err =3D=3D NULL) { + GString *is_realized =3D qobject_to_json_pretty(qobj, true); + if (!strncmp(is_realized->str, "false", 4)) { g_string_free(is_realized, true); - } else { - /* virtio device doesn't exist in QOM tree */ - QTAILQ_REMOVE(&virtio_list, vdev, next); - qobject_unref(obj); + qobject_unref(qobj); return NULL; } - /* device exists in QOM tree & is realized */ - qobject_unref(obj); - return vdev; + g_string_free(is_realized, true); + } else { + qobject_unref(qobj); + return NULL; } - return NULL; + qobject_unref(qobj); + + /* Get VirtIODevice object */ + VirtIODevice *vdev =3D VIRTIO_DEVICE(obj); + return vdev; } =20 VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) diff --git a/hw/virtio/virtio-qmp.h b/hw/virtio/virtio-qmp.h index 8af5f5e65a..4b2b7875b4 100644 --- a/hw/virtio/virtio-qmp.h +++ b/hw/virtio/virtio-qmp.h @@ -15,13 +15,7 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/vhost.h" =20 -#include "qemu/queue.h" - -typedef QTAILQ_HEAD(QmpVirtIODeviceList, VirtIODevice) QmpVirtIODeviceList; - -/* QAPI list of realized VirtIODevices */ -extern QmpVirtIODeviceList virtio_list; - +void qmp_set_virtio_device_list(const char *ppath, VirtioInfoList **list); VirtIODevice *qmp_find_virtio_device(const char *path); VirtioDeviceStatus *qmp_decode_status(uint8_t bitmap); VhostDeviceProtocols *qmp_decode_protocols(uint64_t bitmap); diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 295a603e58..83c5db3d26 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -45,8 +45,6 @@ #include "standard-headers/linux/virtio_mem.h" #include "standard-headers/linux/virtio_vsock.h" =20 -QmpVirtIODeviceList virtio_list; - /* * Maximum size of virtio device config space */ @@ -3616,7 +3614,6 @@ static void virtio_device_realize(DeviceState *dev, E= rror **errp) vdev->listener.commit =3D virtio_memory_listener_commit; vdev->listener.name =3D "virtio"; memory_listener_register(&vdev->listener, vdev->dma_as); - QTAILQ_INSERT_TAIL(&virtio_list, vdev, next); } =20 static void virtio_device_unrealize(DeviceState *dev) @@ -3631,7 +3628,6 @@ static void virtio_device_unrealize(DeviceState *dev) vdc->unrealize(dev); } =20 - QTAILQ_REMOVE(&virtio_list, vdev, next); g_free(vdev->bus_name); vdev->bus_name =3D NULL; } @@ -3805,8 +3801,6 @@ static void virtio_device_class_init(ObjectClass *kla= ss, void *data) vdc->stop_ioeventfd =3D virtio_device_stop_ioeventfd_impl; =20 vdc->legacy_features |=3D VIRTIO_LEGACY_FEATURES; - - QTAILQ_INIT(&virtio_list); } =20 bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev) --=20 2.39.3 From nobody Sun May 5 14:34:15 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1686321484; cv=none; d=zohomail.com; s=zohoarc; b=hNMCwA21kDY2WKnIiYcsQ0b2+NW+hpcSfdrMmubOXXZoA7foZUeG56/7wggAr3t+WfTq8oyYKSHZnlwLt54X91DQHHZNY/aIPpR+aT5VHIJXG7Mk+SpBYriYBGpFKbP1gcIlLGKDpTUg/DKj+OTWNj/UCcSUxt3VAjiZCS1HUVw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686321484; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pRXS0BcpRehLbDUJyCMToWY2XLYbJiIzTEj6CAUITaU=; b=OwahjzbLZAgl2YKkB/YsjYFbKsEubnv/lP4jNmXqFe36u4TT+vQoE3nWWN3gTBHMRKP2HbDsuvZuIbCJmEkLr0OkTGJUPkmhTKp4ODPnWkMBAZ4T6oprZGR4TYwLGpz5QUunyEZNaPVcc09SypZq0+Q4IQ2UNiKjkpqoexFIj2w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1686321484138464.71079097024995; Fri, 9 Jun 2023 07:38:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7c31-000710-Sp; Fri, 09 Jun 2023 09:20:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7c2z-00070l-Ld for qemu-devel@nongnu.org; Fri, 09 Jun 2023 09:20:57 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7c2w-0000TI-87 for qemu-devel@nongnu.org; Fri, 09 Jun 2023 09:20:57 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3598fxVY019336; Fri, 9 Jun 2023 13:20:50 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3r2a6refxt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 09 Jun 2023 13:20:50 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 359DBA99015974; Fri, 9 Jun 2023 13:20:49 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r2a6pdhbr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 09 Jun 2023 13:20:48 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 359DK5YB035303; Fri, 9 Jun 2023 13:20:48 GMT Received: from jonah-ol8.us.oracle.com (dhcp-10-39-219-26.vpn.oracle.com [10.39.219.26]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3r2a6pdh62-3; Fri, 09 Jun 2023 13:20:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2023-03-30; bh=pRXS0BcpRehLbDUJyCMToWY2XLYbJiIzTEj6CAUITaU=; b=4NLi9AtGtXAIr5yOPBKICrssxKRP9bMivA58MfoJBnWMuTMYpKZt5abtpsuBSfw1LbfR fwqE5yMqD+j41V91B4NFf2Krp2s5GEMUiqAJNY/xpExlQf0mF0DZrzFb/4U2RDzvKdCP HnW6P7xRkmjyi1huuoieeX+0/jyqyztiFHLWccdUqeGPXRFhEqG+8XrRGuOEWr9bH+R9 U9nro8NmJ4tqkrZfIyEUiYSzgC+33tvaekbNKJr5pSieTij0dmNuhXts7vZMGRRkcdCj MRkchC3MRSiIOMbFei5y24XTshvxaPBcohZ+qMlafSnYoA05N4iOJFx99/mwGVTo+y1J qg== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: philmd@linaro.org, laurent@vivier.eu, mst@redhat.com, boris.ostrovsky@oracle.com, alex.bennee@linaro.org, viresh.kumar@linaro.org, armbru@redhat.com, pbonzini@redhat.com, berrange@redhat.com, eduardo@habkost.net Subject: [PATCH v2 2/2] qmp: update virtio feature maps, vhost-user-gpio instrospection Date: Fri, 9 Jun 2023 09:20:40 -0400 Message-Id: <20230609132040.2180710-3-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230609132040.2180710-1-jonah.palmer@oracle.com> References: <20230609132040.2180710-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-09_09,2023-06-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 suspectscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306090113 X-Proofpoint-ORIG-GUID: kLF_8rod1E32o3Sgp_1zuENfIQnOFzv9 X-Proofpoint-GUID: kLF_8rod1E32o3Sgp_1zuENfIQnOFzv9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=jonah.palmer@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1686321484839100040 Content-Type: text/plain; charset="utf-8" Add new virtio transport feature to transport feature map: - VIRTIO_F_RING_RESET Add new vhost-user protocol feature to vhost-user protocol feature map and enumeration: - VHOST_USER_PROTOCOL_F_STATUS Add new virtio device features for several virtio devices to their respective feature mappings: virtio-blk: - VIRTIO_BLK_F_SECURE_ERASE virtio-net: - VIRTIO_NET_F_NOTF_COAL - VIRTIO_NET_F_GUEST_USO4 - VIRTIO_NET_F_GUEST_USO6 - VIRTIO_NET_F_HOST_USO virtio/vhost-user-gpio: - VIRTIO_GPIO_F_IRQ - VHOST_F_LOG_ALL - VHOST_USER_F_PROTOCOL_FEATURES virtio-bt: - VIRTIO_BT_F_VND_HCI - VIRTIO_BT_F_MSFT_EXT - VIRTIO_BT_F_AOSP_EXT - VIRTIO_BT_F_CONFIG_V2 virtio-scmi: - VIRTIO_SCMI_F_P2A_CHANNELS - VIRTIO_SCMI_F_SHARED_MEMORY Add support for introspection on vhost-user-gpio devices. Signed-off-by: Jonah Palmer --- hw/virtio/vhost-user-gpio.c | 7 ++++ hw/virtio/virtio-qmp.c | 79 +++++++++++++++++++++++++++++++++++-- 2 files changed, 83 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c index d6927b610a..e88ca5370f 100644 --- a/hw/virtio/vhost-user-gpio.c +++ b/hw/virtio/vhost-user-gpio.c @@ -205,6 +205,12 @@ static void vu_gpio_guest_notifier_mask(VirtIODevice *= vdev, int idx, bool mask) vhost_virtqueue_mask(&gpio->vhost_dev, vdev, idx, mask); } =20 +static struct vhost_dev *vu_gpio_get_vhost(VirtIODevice *vdev) +{ + VHostUserGPIO *gpio =3D VHOST_USER_GPIO(vdev); + return &gpio->vhost_dev; +} + static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserGPIO *gpio) { virtio_delete_queue(gpio->command_vq); @@ -413,6 +419,7 @@ static void vu_gpio_class_init(ObjectClass *klass, void= *data) vdc->get_config =3D vu_gpio_get_config; vdc->set_status =3D vu_gpio_set_status; vdc->guest_notifier_mask =3D vu_gpio_guest_notifier_mask; + vdc->get_vhost =3D vu_gpio_get_vhost; } =20 static const TypeInfo vu_gpio_info =3D { diff --git a/hw/virtio/virtio-qmp.c b/hw/virtio/virtio-qmp.c index e936cc8ce5..140c420d87 100644 --- a/hw/virtio/virtio-qmp.c +++ b/hw/virtio/virtio-qmp.c @@ -53,6 +53,7 @@ enum VhostUserProtocolFeature { VHOST_USER_PROTOCOL_F_RESET_DEVICE =3D 13, VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS =3D 14, VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS =3D 15, + VHOST_USER_PROTOCOL_F_STATUS =3D 16, VHOST_USER_PROTOCOL_F_MAX }; =20 @@ -79,6 +80,8 @@ static const qmp_virtio_feature_map_t virtio_transport_ma= p[] =3D { "VIRTIO_F_ORDER_PLATFORM: Memory accesses ordered by platform"= ), FEATURE_ENTRY(VIRTIO_F_SR_IOV, \ "VIRTIO_F_SR_IOV: Device supports single root I/O virtualizati= on"), + FEATURE_ENTRY(VIRTIO_F_RING_RESET, \ + "VIRTIO_F_RING_RESET: Driver can reset individual VQs"), /* Virtio ring transport features */ FEATURE_ENTRY(VIRTIO_RING_F_INDIRECT_DESC, \ "VIRTIO_RING_F_INDIRECT_DESC: Indirect descriptors supported"), @@ -134,6 +137,9 @@ static const qmp_virtio_feature_map_t vhost_user_protoc= ol_map[] =3D { FEATURE_ENTRY(VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS, \ "VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS: Configuration for " "memory slots supported"), + FEATURE_ENTRY(VHOST_USER_PROTOCOL_F_STATUS, \ + "VHOST_USER_PROTOCOL_F_STATUS: Querying and notifying back-end= " + "device statuses supported"), { -1, "" } }; =20 @@ -176,6 +182,8 @@ static const qmp_virtio_feature_map_t virtio_blk_featur= e_map[] =3D { "VIRTIO_BLK_F_DISCARD: Discard command supported"), FEATURE_ENTRY(VIRTIO_BLK_F_WRITE_ZEROES, \ "VIRTIO_BLK_F_WRITE_ZEROES: Write zeroes command supported"), + FEATURE_ENTRY(VIRTIO_BLK_F_SECURE_ERASE, \ + "VIRTIO_BLK_F_SECURE_ERASE: Secure erase supported"), FEATURE_ENTRY(VIRTIO_BLK_F_ZONED, \ "VIRTIO_BLK_F_ZONED: Zoned block devices"), #ifndef VIRTIO_BLK_NO_LEGACY @@ -299,6 +307,14 @@ static const qmp_virtio_feature_map_t virtio_net_featu= re_map[] =3D { FEATURE_ENTRY(VIRTIO_NET_F_CTRL_MAC_ADDR, \ "VIRTIO_NET_F_CTRL_MAC_ADDR: MAC address set through control " "channel"), + FEATURE_ENTRY(VIRTIO_NET_F_NOTF_COAL, \ + "VIRTIO_NET_F_NOTF_COAL: Device supports coalescing notificati= ons"), + FEATURE_ENTRY(VIRTIO_NET_F_GUEST_USO4, \ + "VIRTIO_NET_F_GUEST_USO4: Driver can receive USOv4"), + FEATURE_ENTRY(VIRTIO_NET_F_GUEST_USO6, \ + "VIRTIO_NET_F_GUEST_USO4: Driver can receive USOv6"), + FEATURE_ENTRY(VIRTIO_NET_F_HOST_USO, \ + "VIRTIO_NET_F_HOST_USO: Device can receive USO"), FEATURE_ENTRY(VIRTIO_NET_F_HASH_REPORT, \ "VIRTIO_NET_F_HASH_REPORT: Hash reporting supported"), FEATURE_ENTRY(VIRTIO_NET_F_RSS, \ @@ -469,6 +485,48 @@ static const qmp_virtio_feature_map_t virtio_rng_featu= re_map[] =3D { }; #endif =20 +/* virtio/vhost-gpio features mapping */ +#ifdef CONFIG_VIRTIO_GPIO +static const qmp_virtio_feature_map_t virtio_gpio_feature_map[] =3D { + FEATURE_ENTRY(VIRTIO_GPIO_F_IRQ, \ + "VIRTIO_GPIO_F_IRQ: Device supports interrupts on GPIO lines"), + FEATURE_ENTRY(VHOST_F_LOG_ALL, \ + "VHOST_F_LOG_ALL: Logging write descriptors supported"), + FEATURE_ENTRY(VHOST_USER_F_PROTOCOL_FEATURES, \ + "VHOST_USER_F_PROTOCOL_FEATURES: Vhost-user protocol features " + "negotiation supported"), + { -1, "" } +}; +#endif + +/* virtio-bluetooth features mapping */ +#ifdef CONFIG_VIRTIO_BT +static const qmp_virtio_feature_map_t virtio_bt_feature_map[] =3D { + FEATURE_ENTRY(VIRTIO_BT_F_VND_HCI, \ + "VIRTIO_BT_F_VND_HCI: Vendor command supported"), + FEATURE_ENTRY(VIRTIO_BT_F_MSFT_EXT, \ + "VIRTIO_BT_F_MSFT_EXT: MSFT vendor supported"), + FEATURE_ENTRY(VIRTIO_BT_F_AOSP_EXT, \ + "VIRTIO_BT_F_AOSP_EXT: AOSP vendor supported"), + FEATURE_ENTRY(VIRTIO_BT_F_CONFIG_V2, \ + "VIRTIO_BT_F_CONFIG_V2: Using v2 configuration"), + { -1, "" } +}; +#endif + +/* virtio-scmi features mapping */ +#ifdef CONFIG_VIRTIO_SCMI +static const qmp_virtio_feature_map_t virtio_scmi_feature_map[] =3D { + FEATURE_ENTRY(VIRTIO_SCMI_F_P2A_CHANNELS, \ + "VIRTIO_SCMI_F_P2A_CHANNELS: SCMI notifications or delayed " + "responses implemented"), + FEATURE_ENTRY(VIRTIO_SCMI_F_SHARED_MEMORY, \ + "VIRTIO_SCMI_F_SHARED_MEMORY: SCMI shared memory region statis= tics " + "implemented"), + { -1, "" } +}; +#endif + #define CONVERT_FEATURES(type, map, is_status, bitmap) \ ({ \ type *list =3D NULL; \ @@ -625,6 +683,24 @@ VirtioDeviceFeatures *qmp_decode_features(uint16_t dev= ice_id, uint64_t bitmap) features->dev_features =3D CONVERT_FEATURES(strList, virtio_rng_feature_map, 0, bitmap); break; +#endif +#ifdef CONFIG_VIRTIO_GPIO + case VIRTIO_ID_GPIO: + features->dev_features =3D + CONVERT_FEATURES(strList, virtio_gpio_feature_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_BT + case VIRTIO_ID_BT: + features->dev_features =3D + CONVERT_FEATURES(strList, virtio_bt_feature_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_SCMI + case VIRTIO_ID_SCMI: + features->dev_features =3D + CONVERT_FEATURES(strList, virtio_scmi_feature_map, 0, bitmap); + break; #endif /* No features */ case VIRTIO_ID_9P: @@ -640,18 +716,15 @@ VirtioDeviceFeatures *qmp_decode_features(uint16_t de= vice_id, uint64_t bitmap) case VIRTIO_ID_SIGNAL_DIST: case VIRTIO_ID_PSTORE: case VIRTIO_ID_SOUND: - case VIRTIO_ID_BT: case VIRTIO_ID_RPMB: case VIRTIO_ID_VIDEO_ENCODER: case VIRTIO_ID_VIDEO_DECODER: - case VIRTIO_ID_SCMI: case VIRTIO_ID_NITRO_SEC_MOD: case VIRTIO_ID_WATCHDOG: case VIRTIO_ID_CAN: case VIRTIO_ID_DMABUF: case VIRTIO_ID_PARAM_SERV: case VIRTIO_ID_AUDIO_POLICY: - case VIRTIO_ID_GPIO: break; default: g_assert_not_reached(); --=20 2.39.3