From: Thomas Huth <thuth@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Jonah Palmer" <jonah.palmer@oracle.com>,
qemu-devel@nongnu.org, armbru@redhat.com
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,
arei.gonglei@huawei.com, marcandre.lureau@redhat.com,
lvivier@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, "Daniel P. Berrangé" <berrange@redhat.com>
Subject: Re: [PATCH v15 2/6] qmp: add QMP command x-query-virtio-status
Date: Mon, 5 May 2025 08:30:42 +0200 [thread overview]
Message-ID: <41eff78d-db42-4391-a243-ec40e2356627@redhat.com> (raw)
In-Reply-To: <7de79c4d-57f2-4103-a22e-748cfbe08974@linaro.org>
On 02/05/2025 00.09, Philippe Mathieu-Daudé wrote:
> Hello,
>
> (patch merged as commit 90c066cd682).
>
> On 11/8/22 14:24, Jonah Palmer wrote:
>> From: Laurent Vivier <lvivier@redhat.com>
>>
>> This new command shows the status of a VirtIODevice, including
>> its corresponding vhost device's status (if active).
>>
>> Next patch will improve output by decoding feature bits, including
>> vhost device's feature bits (backend, protocol, acked, and features).
>> Also will decode status bits of a VirtIODevice.
>>
>> [Jonah: From patch v12; added a check to @virtio_device_find to ensure
>> synchronicity between @virtio_list and the devices in the QOM
>> composition tree.]
>>
>> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
>> Signed-off-by: Jonah Palmer <jonah.palmer@oracle.com>
>> ---
>> hw/virtio/virtio-stub.c | 5 +
>> hw/virtio/virtio.c | 104 +++++++++++++++++++
>> qapi/virtio.json | 222 ++++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 331 insertions(+)
>>
>> diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c
>> index 05a81edc92..0b432e8de7 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 bdfa82e9c0..3e0a484660 100644
>> --- a/hw/virtio/virtio.c
>> +++ b/hw/virtio/virtio.c
>> @@ -3939,6 +3939,110 @@ 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;
>> + }
>> +
>> + Error *err = NULL;
>> + QObject *obj = qmp_qom_get(dev->canonical_path, "realized", &err);
>> + if (err == NULL) {
>> + GString *is_realized = qobject_to_json_pretty(obj, true);
>> + /* virtio device is NOT realized, remove it from list */
>> + if (!strncmp(is_realized->str, "false", 4)) {
>> + g_string_free(is_realized, true);
>> + qobject_unref(obj);
>> + QTAILQ_REMOVE(&virtio_list, vdev, next);
>> + return NULL;
>> + }
>> + g_string_free(is_realized, true);
>> + } else {
>> + /* virtio device doesn't exist in QOM tree */
>> + QTAILQ_REMOVE(&virtio_list, vdev, next);
>> + qobject_unref(obj);
>> + return NULL;
>> + }
>> + /* device exists in QOM tree & is realized */
>> + qobject_unref(obj);
>> + return vdev;
>> + }
>> + return NULL;
>> +}
>> +
>> +VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp)
>> +{
>> + VirtIODevice *vdev;
>> + VirtioStatus *status;
>> +
>> + vdev = 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 03896e423f..c86b3bc635 100644
>> --- a/qapi/virtio.json
>> +++ b/qapi/virtio.json
>> @@ -66,3 +66,225 @@
>> { 'command': 'x-query-virtio',
>> 'returns': [ 'VirtioInfo' ],
>> 'features': [ 'unstable' ] }
>
> When a structure is only used by an unstable command, is it considered
> unstable too? IOW is it OK to modify it?
IMHO yes. If there is no other user of the struct, why should it considered
to be stable if the only command that uses it is unstable?
Thomas
next prev parent reply other threads:[~2025-05-05 6:31 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-11 12:24 [PATCH v15 0/6] hmp,qmp: Add commands to introspect virtio devices Jonah Palmer
2022-08-11 12:24 ` [PATCH v15 1/6] qmp: add QMP command x-query-virtio Jonah Palmer
2022-11-30 16:16 ` Philippe Mathieu-Daudé
2022-12-02 12:23 ` Jonah Palmer
2022-12-02 14:17 ` Philippe Mathieu-Daudé
2022-12-02 15:21 ` Markus Armbruster
2022-12-07 8:47 ` Jonah Palmer
2022-12-07 13:22 ` Markus Armbruster
2022-12-09 8:54 ` Jonah Palmer
2025-05-01 22:15 ` Philippe Mathieu-Daudé
2022-08-11 12:24 ` [PATCH v15 2/6] qmp: add QMP command x-query-virtio-status Jonah Palmer
2025-05-01 22:09 ` Philippe Mathieu-Daudé
2025-05-05 6:30 ` Thomas Huth [this message]
2025-05-05 7:29 ` Laurent Vivier
2025-05-08 7:51 ` Markus Armbruster
2025-05-08 10:44 ` Philippe Mathieu-Daudé
2022-08-11 12:24 ` [PATCH v15 3/6] qmp: decode feature & status bits in virtio-status Jonah Palmer
2022-08-11 12:24 ` [PATCH v15 4/6] qmp: add QMP commands for virtio/vhost queue-status Jonah Palmer
2022-08-11 12:24 ` [PATCH v15 5/6] qmp: add QMP command x-query-virtio-queue-element Jonah Palmer
2022-08-11 12:24 ` [PATCH v15 6/6] hmp: add virtio commands Jonah Palmer
2022-09-27 8:36 ` [PATCH v15 0/6] hmp,qmp: Add commands to introspect virtio devices Jonah Palmer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=41eff78d-db42-4391-a243-ec40e2356627@redhat.com \
--to=thuth@redhat.com \
--cc=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=boris.ostrovsky@oracle.com \
--cc=david@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=eric.auger@redhat.com \
--cc=groug@kaod.org \
--cc=joao.m.martins@oracle.com \
--cc=jonah.palmer@oracle.com \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=lvivier@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mathieu.poirier@linaro.org \
--cc=michael.roth@amd.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu_oss@crudebyte.com \
--cc=raphael.norwitz@nutanix.com \
--cc=si-wei.liu@oracle.com \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).