From: Jason Wang <jasowang@redhat.com>
To: Jonah Palmer <jonah.palmer@oracle.com>, qemu-devel@nongnu.org
Cc: fam@euphon.net, kwolf@redhat.com, thuth@redhat.com,
qemu-block@nongnu.org, mst@redhat.com, michael.roth@amd.com,
david@redhat.com, armbru@redhat.com, amit@kernel.org,
dgilbert@redhat.com, eric.auger@redhat.com,
dmitrii.stepanov@cloud.ionos.com, kraxel@redhat.com,
stefanha@redhat.com, pbonzini@redhat.com, si-wei.liu@oracle.com,
marcandre.lureau@redhat.com, joao.m.martins@oracle.com,
mreitz@redhat.com, laurent@vivier.eu
Subject: Re: [PATCH v6 4/6] qmp: add QMP command x-debug-virtio-queue-status
Date: Wed, 14 Jul 2021 10:37:12 +0800 [thread overview]
Message-ID: <b0c11f6c-31dd-121d-ab27-e83e5afa8596@redhat.com> (raw)
In-Reply-To: <1626086137-16292-5-git-send-email-jonah.palmer@oracle.com>
在 2021/7/12 下午6:35, Jonah Palmer 写道:
> From: Laurent Vivier <lvivier@redhat.com>
>
> This new command shows internal status of a VirtQueue.
> (vrings and indexes).
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> Signed-off-by: Jonah Palmer <jonah.palmer@oracle.com>
> ---
> hw/virtio/virtio-stub.c | 6 +++
> hw/virtio/virtio.c | 37 ++++++++++++++++++
> qapi/virtio.json | 102 ++++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 145 insertions(+)
>
> [Jonah: Added 'device-type' field to VirtQueueStatus and
> qmp command x-debug-virtio-queue-status.]
>
> diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c
> index ddb592f..3c1bf17 100644
> --- a/hw/virtio/virtio-stub.c
> +++ b/hw/virtio/virtio-stub.c
> @@ -17,3 +17,9 @@ VirtioStatus *qmp_x_debug_virtio_status(const char* path, Error **errp)
> {
> return qmp_virtio_unsupported(errp);
> }
> +
> +VirtQueueStatus *qmp_x_debug_virtio_queue_status(const char *path,
> + uint16_t queue, Error **errp)
> +{
> + return qmp_virtio_unsupported(errp);
> +}
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 81a0ee8..ccd4371 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -3935,6 +3935,43 @@ static VirtIODevice *virtio_device_find(const char *path)
> return NULL;
> }
>
> +VirtQueueStatus *qmp_x_debug_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 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;
> + }
> +
> + status = g_new0(VirtQueueStatus, 1);
> + status->device_type = qapi_enum_parse(&VirtioType_lookup, vdev->name,
> + VIRTIO_TYPE_UNKNOWN, NULL);
> + 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->last_avail_idx = vdev->vq[queue].last_avail_idx;
As mentioned in previous versions. We need add vhost support otherwise
the value here is wrong.
> + status->shadow_avail_idx = vdev->vq[queue].shadow_avail_idx;
The shadow index is something that is implementation specific e.g in the
case of vhost it's kind of meaningless.
Thanks
> + 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;
> +
> + return status;
> +}
> +
> #define CONVERT_FEATURES(type, map) \
> ({ \
> type *list = NULL; \
> diff --git a/qapi/virtio.json b/qapi/virtio.json
> index 78873cd..7007e0c 100644
> --- a/qapi/virtio.json
> +++ b/qapi/virtio.json
> @@ -406,3 +406,105 @@
> 'data': { 'path': 'str' },
> 'returns': 'VirtioStatus'
> }
> +
> +##
> +# @VirtQueueStatus:
> +#
> +# Status of a VirtQueue
> +#
> +# @device-type: VirtIO device type
> +#
> +# @queue-index: VirtQueue queue_index
> +#
> +# @inuse: VirtQueue inuse
> +#
> +# @vring-num: VirtQueue vring.num
> +#
> +# @vring-num-default: VirtQueue vring.num_default
> +#
> +# @vring-align: VirtQueue vring.align
> +#
> +# @vring-desc: VirtQueue vring.desc
> +#
> +# @vring-avail: VirtQueue vring.avail
> +#
> +# @vring-used: VirtQueue vring.used
> +#
> +# @last-avail-idx: VirtQueue last_avail_idx
> +#
> +# @shadow-avail-idx: VirtQueue shadow_avail_idx
> +#
> +# @used-idx: VirtQueue used_idx
> +#
> +# @signalled-used: VirtQueue signalled_used
> +#
> +# @signalled-used-valid: VirtQueue signalled_used_valid
> +#
> +# Since: 6.1
> +#
> +##
> +
> +{ 'struct': 'VirtQueueStatus',
> + 'data': {
> + 'device-type': 'VirtioType',
> + 'queue-index': 'uint16',
> + 'inuse': 'uint32',
> + 'vring-num': 'int',
> + 'vring-num-default': 'int',
> + 'vring-align': 'int',
> + 'vring-desc': 'uint64',
> + 'vring-avail': 'uint64',
> + 'vring-used': 'uint64',
> + 'last-avail-idx': 'uint16',
> + 'shadow-avail-idx': 'uint16',
> + 'used-idx': 'uint16',
> + 'signalled-used': 'uint16',
> + 'signalled-used-valid': 'uint16'
> + }
> +}
> +
> +##
> +# @x-debug-virtio-queue-status:
> +#
> +# Return the status of a given VirtQueue
> +#
> +# @path: QOBject path of the VirtIODevice
> +#
> +# @queue: queue number to examine
> +#
> +# Returns: Status of the VirtQueue
> +#
> +# Since: 6.1
> +#
> +# Example:
> +#
> +# -> { "execute": "x-debug-virtio-queue-status",
> +# "arguments": {
> +# "path": "/machine/peripheral-anon/device[3]/virtio-backend",
> +# "queue": 0
> +# }
> +# }
> +# <- { "return": {
> +# "signalled-used": 373,
> +# "inuse": 0,
> +# "vring-align": 4096,
> +# "vring-desc": 864411648,
> +# "signalled-used-valid": 0,
> +# "vring-num-default": 256,
> +# "vring-avail": 864415744,
> +# "queue-index": 0,
> +# "last-avail-idx": 373,
> +# "vring-used": 864416320,
> +# "used-idx": 373,
> +# "device-type": "virtio-net",
> +# "shadow-avail-idx": 619,
> +# "vring-num": 256
> +# }
> +# }
> +#
> +##
> +
> +{ 'command': 'x-debug-virtio-queue-status',
> + 'data': { 'path': 'str', 'queue': 'uint16' },
> + 'returns': 'VirtQueueStatus'
> +}
next prev parent reply other threads:[~2021-07-14 2:39 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-12 10:35 [PATCH v6 0/6] hmp, qmp: Add some commands to introspect virtio devices Jonah Palmer
2021-07-12 10:35 ` [PATCH v6 1/6] qmp: add QMP command x-debug-query-virtio Jonah Palmer
2021-08-07 12:35 ` Markus Armbruster
2021-08-10 6:36 ` Jonah Palmer
2021-08-23 13:27 ` Markus Armbruster
2021-08-26 6:18 ` Jonah Palmer
2021-09-01 11:15 ` Markus Armbruster
2021-07-12 10:35 ` [PATCH v6 2/6] qmp: add QMP command x-debug-virtio-status Jonah Palmer
2021-08-07 12:42 ` Markus Armbruster
2021-08-10 6:50 ` Jonah Palmer
2021-09-03 8:26 ` Michael S. Tsirkin
2021-07-12 10:35 ` [PATCH v6 3/6] qmp: decode feature bits in virtio-status Jonah Palmer
2021-07-12 10:35 ` [PATCH v6 4/6] qmp: add QMP command x-debug-virtio-queue-status Jonah Palmer
2021-07-14 2:37 ` Jason Wang [this message]
2021-07-21 8:59 ` Jonah Palmer
2021-07-22 9:22 ` Jason Wang
2021-07-26 9:33 ` Jonah Palmer
2021-08-26 6:25 ` Jonah Palmer
2021-08-27 3:11 ` Jason Wang
2021-08-07 12:45 ` Markus Armbruster
2021-08-10 7:25 ` Jonah Palmer
2021-07-12 10:35 ` [PATCH v6 5/6] qmp: add QMP command x-debug-virtio-queue-element Jonah Palmer
2021-07-12 10:35 ` [PATCH v6 6/6] hmp: add virtio commands Jonah Palmer
2021-07-14 2:40 ` Jason Wang
2021-07-21 9:11 ` Jonah Palmer
2021-07-22 9:18 ` Jason Wang
2021-07-26 9:38 ` Jonah Palmer
2021-07-13 15:25 ` [PATCH v6 0/6] hmp,qmp: Add some commands to introspect virtio devices Michael S. Tsirkin
2021-07-14 2:42 ` [PATCH v6 0/6] hmp, qmp: " Jason Wang
2021-07-21 8:53 ` Jonah Palmer
2021-07-22 9:16 ` Jason Wang
2021-07-26 9:11 ` 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=b0c11f6c-31dd-121d-ab27-e83e5afa8596@redhat.com \
--to=jasowang@redhat.com \
--cc=amit@kernel.org \
--cc=armbru@redhat.com \
--cc=david@redhat.com \
--cc=dgilbert@redhat.com \
--cc=dmitrii.stepanov@cloud.ionos.com \
--cc=eric.auger@redhat.com \
--cc=fam@euphon.net \
--cc=joao.m.martins@oracle.com \
--cc=jonah.palmer@oracle.com \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=laurent@vivier.eu \
--cc=marcandre.lureau@redhat.com \
--cc=michael.roth@amd.com \
--cc=mreitz@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=si-wei.liu@oracle.com \
--cc=stefanha@redhat.com \
--cc=thuth@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).