qemu-devel
[Top][All Lists]
Advanced

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

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


From: Jason Wang
Subject: Re: [PATCH v6 6/6] hmp: add virtio commands
Date: Thu, 22 Jul 2021 17:18:58 +0800
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.12.0


在 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.

Thanks



Thank you,




reply via email to

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