[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v6 6/6] hmp: add virtio commands

From: Jonah Palmer
Subject: Re: [PATCH v6 6/6] hmp: add virtio commands
Date: Mon, 26 Jul 2021 05:38:20 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

On 7/22/21 5:18 AM, Jason Wang wrote:

在 2021/7/21 下午5:11, Jonah Palmer 写道:

On 7/13/21 10:40 PM, Jason Wang wrote:

在 2021/7/12 下午6:35, Jonah Palmer 写道:
+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_debug_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_type:          %s\n",
+                   VirtioType_str(s->device_type));
+    monitor_printf(mon, "  index:                %d\n", s->queue_index);
+    monitor_printf(mon, "  inuse:                %d\n", s->inuse);
+    monitor_printf(mon, "  last_avail_idx:       %d (%"PRId64" %% %"PRId64")\n", +                   s->last_avail_idx, s->last_avail_idx % s->vring_num,
+                   s->vring_num);
+    monitor_printf(mon, "  shadow_avail_idx:     %d (%"PRId64" %% %"PRId64")\n", +                   s->shadow_avail_idx, s->shadow_avail_idx % s->vring_num,
+                   s->vring_num);
+    monitor_printf(mon, "  used_idx:             %d (%"PRId64" %% %"PRId64")\n", +                   s->used_idx, s->used_idx % s->vring_num, s->vring_num);

The modular information is not the case of packed ring where the queue size does not have to be a power of 2.
Doesn't modulo work for any integer, regardless if it's a power of 2 or not? Could you clarify this for me?

For packed ring, the index doesn't increase freely, it's always small than the virtqueue size.

So showing the modulo arithmetic seems useless since the device or driver doesn't use modulo for calculating the real offset.


I see, got it. Thank you for the explanation.

I should be able to easily determine a packed or split ring via. virtio_vdev_has_feature(vq->vdev, VIRTIO_F_RING_PACKED).


Thank you,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]