Skip to contentSkip to conversation

Adjust the output of x-query-virtio-status

PATCH Superseded Hyman Huang 2 participants 5 messages Dec 28, 2023 – Jan 3, 2024

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Adjust the output of x-query-virtio-status

This patchset is derived from the series:
https://lore.kernel.org/qemu-devel/[email protected]/
Please go to the link to see more background information.

The following points are what we have done in the patchset:
1. Take the policy of adding human-readable output just in HMP.
2. For the HMP output, display the human-readable information and drop the unknown bits in practice.
3. For the QMP output, remove the descriptive strings and only display bits encoded as numbers.

Please review, thanks,
Yong

Hyman Huang (2):
qapi/virtio: Keep feature and status bits in the QMP output
hmp: Drop unknown feature and status bits

 hw/virtio/virtio-hmp-cmds.c |  38 ++++---
 hw/virtio/virtio-qmp.c      |  23 ++---
 qapi/virtio.json            | 192 ++++--------------------------------
 3 files changed, 45 insertions(+), 208 deletions(-)
Signature · 1 line
2.39.1
#1 lore raw

PATCH 1/2 qapi/virtio: Keep feature and status bits in the QMP output

Maintain the feature and status bits in the x-query-virtio-status output and, as usual, add human-readable output only in HMP.

Applications may find it useful to compare features and status information directly. An upper application, for example, could use the QMP command x-query-virtio-status to retrieve vhost-user net device features and the "ovs-vsctl list interface" command to retrieve interface features (in number format) in order to verify the correctness of the virtio negotiation between guest, QEMU, and OVS-DPDK. The application could then compare the two features directly, without the need for additional feature encoding.

---
 hw/virtio/virtio-hmp-cmds.c |  25 +++--
 hw/virtio/virtio-qmp.c      |  23 ++---
 qapi/virtio.json            | 192 ++++--------------------------------
 3 files changed, 45 insertions(+), 195 deletions(-)
hw/virtio/virtio-hmp-cmds.c +17 -8
index 477c97dea2..721c630ab0 100644
@@ -6,6 +6,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "virtio-qmp.h"
 #include "monitor/hmp.h"
 #include "monitor/monitor.h"
 #include "qapi/qapi-commands-virtio.h"
@@ -145,13 +146,17 @@ void hmp_virtio_status(Monitor *mon, const QDict *qdict)
     monitor_printf(mon, "  endianness:              %s\n",
                    s->device_endian);
     monitor_printf(mon, "  status:\n");
-    hmp_virtio_dump_status(mon, s->status);
+    hmp_virtio_dump_status(mon,
+        qmp_decode_status(s->status));
     monitor_printf(mon, "  Guest features:\n");
-    hmp_virtio_dump_features(mon, s->guest_features);
+    hmp_virtio_dump_features(mon,
+        qmp_decode_features(s->device_id, s->guest_features));
     monitor_printf(mon, "  Host features:\n");
-    hmp_virtio_dump_features(mon, s->host_features);
+    hmp_virtio_dump_features(mon,
+        qmp_decode_features(s->device_id, s->host_features));
     monitor_printf(mon, "  Backend features:\n");
-    hmp_virtio_dump_features(mon, s->backend_features);
+    hmp_virtio_dump_features(mon,
+        qmp_decode_features(s->device_id, s->backend_features));
 
     if (s->vhost_dev) {
         monitor_printf(mon, "  VHost:\n");
@@ -172,13 +177,17 @@ void hmp_virtio_status(Monitor *mon, const QDict *qdict)
         monitor_printf(mon, "    log_size:       %"PRId64"\n",
                        s->vhost_dev->log_size);
         monitor_printf(mon, "    Features:\n");
-        hmp_virtio_dump_features(mon, s->vhost_dev->features);
+        hmp_virtio_dump_features(mon,
+            qmp_decode_features(s->device_id, s->vhost_dev->features));
         monitor_printf(mon, "    Acked features:\n");
-        hmp_virtio_dump_features(mon, s->vhost_dev->acked_features);
+        hmp_virtio_dump_features(mon,
+            qmp_decode_features(s->device_id, s->vhost_dev->acked_features));
         monitor_printf(mon, "    Backend features:\n");
-        hmp_virtio_dump_features(mon, s->vhost_dev->backend_features);
+        hmp_virtio_dump_features(mon,
+            qmp_decode_features(s->device_id, s->vhost_dev->backend_features));
         monitor_printf(mon, "    Protocol features:\n");
-        hmp_virtio_dump_protocols(mon, s->vhost_dev->protocol_features);
+        hmp_virtio_dump_protocols(mon,
+            qmp_decode_protocols(s->vhost_dev->protocol_features));
     }
 
     qapi_free_VirtioStatus(s);
hw/virtio/virtio-qmp.c +8 -15
index 1dd96ed20f..1660c17653 100644
@@ -733,12 +733,9 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp)
     status->name = g_strdup(vdev->name);
     status->device_id = vdev->device_id;
     status->vhost_started = vdev->vhost_started;
-    status->guest_features = qmp_decode_features(vdev->device_id,
-                                                 vdev->guest_features);
-    status->host_features = qmp_decode_features(vdev->device_id,
-                                                vdev->host_features);
-    status->backend_features = qmp_decode_features(vdev->device_id,
-                                                   vdev->backend_features);
+    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:
@@ -753,7 +750,7 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp)
     }
 
     status->num_vqs = virtio_get_num_queues(vdev);
-    status->status = qmp_decode_status(vdev->status);
+    status->status = vdev->status;
     status->isr = vdev->isr;
     status->queue_sel = vdev->queue_sel;
     status->vm_running = vdev->vm_running;
@@ -775,14 +772,10 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp)
         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 =
-            qmp_decode_features(vdev->device_id, hdev->features);
-        status->vhost_dev->acked_features =
-            qmp_decode_features(vdev->device_id, hdev->acked_features);
-        status->vhost_dev->backend_features =
-            qmp_decode_features(vdev->device_id, hdev->backend_features);
-        status->vhost_dev->protocol_features =
-            qmp_decode_protocols(hdev->protocol_features);
+        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;
qapi/virtio.json +20 -172

229 lines not on this page · raw message

Signature · 1 line
2.39.1
#2 lore raw

Re: [PATCH 1/2] qapi/virtio: Keep feature and status bits in the QMP output

Hi,

Quoted 32 lines · Hyman Huang

Maintain the feature and status bits in the x-query-virtio-status output and, as usual, add human-readable output only in HMP.

Applications may find it useful to compare features and status information directly. An upper application, for example, could use the QMP command x-query-virtio-status to retrieve vhost-user net device features and the "ovs-vsctl list interface" command to retrieve interface features (in number format) in order to verify the correctness of the virtio negotiation between guest, QEMU, and OVS-DPDK. The application could then compare the two features directly, without the need for additional feature encoding.

---
  hw/virtio/virtio-hmp-cmds.c |  25 +++--
  hw/virtio/virtio-qmp.c      |  23 ++---
  qapi/virtio.json            | 192 ++++--------------------------------
  3 files changed, 45 insertions(+), 195 deletions(-)
hw/virtio/virtio-hmp-cmds.c +1 -0
index 477c97dea2..721c630ab0 100644
@@ -6,6 +6,7 @@
   */
 
  #include "qemu/osdep.h"
+#include "virtio-qmp.h"
  #include "monitor/hmp.h"
  #include "monitor/monitor.h"
  #include "qapi/qapi-commands-virtio.h"

hw/virtio/virtio-hmp-cmds.c void hmp_virtio_status(Monitor *mon, const QDict *qdict) · line 150

Quoted 6 lines
hw/virtio/virtio-hmp-cmds.c +2 -1
@@ -145,13 +146,17 @@ void hmp_virtio_status(Monitor *mon, const QDict *qdict)
      monitor_printf(mon, "  endianness:              %s\n",
                     s->device_endian);
      monitor_printf(mon, "  status:\n");
-    hmp_virtio_dump_status(mon, s->status);
+    hmp_virtio_dump_status(mon,
+        qmp_decode_status(s->status));

Why not let the callee do this call?

Quoted 16 lines
hw/virtio/virtio-hmp-cmds.c +6 -3
      monitor_printf(mon, "  Guest features:\n");
-    hmp_virtio_dump_features(mon, s->guest_features);
+    hmp_virtio_dump_features(mon,
+        qmp_decode_features(s->device_id, s->guest_features));
      monitor_printf(mon, "  Host features:\n");
-    hmp_virtio_dump_features(mon, s->host_features);
+    hmp_virtio_dump_features(mon,
+        qmp_decode_features(s->device_id, s->host_features));
      monitor_printf(mon, "  Backend features:\n");
-    hmp_virtio_dump_features(mon, s->backend_features);
+    hmp_virtio_dump_features(mon,
+        qmp_decode_features(s->device_id, s->backend_features));
 
      if (s->vhost_dev) {
          monitor_printf(mon, "  VHost:\n");

hw/virtio/virtio-hmp-cmds.c void hmp_virtio_status(Monitor *mon, const QDict *qdict) · line 181

Quoted 6 lines
hw/virtio/virtio-hmp-cmds.c +2 -1
@@ -172,13 +177,17 @@ void hmp_virtio_status(Monitor *mon, const QDict *qdict)
          monitor_printf(mon, "    log_size:       %"PRId64"\n",
                         s->vhost_dev->log_size);
          monitor_printf(mon, "    Features:\n");
-        hmp_virtio_dump_features(mon, s->vhost_dev->features);
+        hmp_virtio_dump_features(mon,
+            qmp_decode_features(s->device_id, s->vhost_dev->features));

Ditto.

Quoted 13 lines
hw/virtio/virtio-hmp-cmds.c +6 -3
          monitor_printf(mon, "    Acked features:\n");
-        hmp_virtio_dump_features(mon, s->vhost_dev->acked_features);
+        hmp_virtio_dump_features(mon,
+            qmp_decode_features(s->device_id, s->vhost_dev->acked_features));
          monitor_printf(mon, "    Backend features:\n");
-        hmp_virtio_dump_features(mon, s->vhost_dev->backend_features);
+        hmp_virtio_dump_features(mon,
+            qmp_decode_features(s->device_id, s->vhost_dev->backend_features));
          monitor_printf(mon, "    Protocol features:\n");
-        hmp_virtio_dump_protocols(mon, s->vhost_dev->protocol_features);
+        hmp_virtio_dump_protocols(mon,
+            qmp_decode_protocols(s->vhost_dev->protocol_features));
      }
author
#3 lore raw

Re: [PATCH 1/2] qapi/virtio: Keep feature and status bits in the QMP output

Thanks, I'll fix that in the next version.

Quoted 88 lines · Philippe Mathieu-Daudé

Hi,

hw/virtio/virtio-hmp-cmds.c void hmp_virtio_status(Monitor *mon, const QDict

Quoted 32 lines · Hyman Huang

Maintain the feature and status bits in the x-query-virtio-status output and, as usual, add human-readable output only in HMP.

Applications may find it useful to compare features and status information directly. An upper application, for example, could use the QMP command x-query-virtio-status to retrieve vhost-user net device features and the "ovs-vsctl list interface" command to retrieve interface features (in number format) in order to verify the correctness of the virtio negotiation between guest, QEMU, and OVS-DPDK. The application could then compare the two features directly, without the need for additional feature encoding.

---
  hw/virtio/virtio-hmp-cmds.c |  25 +++--
  hw/virtio/virtio-qmp.c      |  23 ++---
  qapi/virtio.json            | 192 ++++--------------------------------
  3 files changed, 45 insertions(+), 195 deletions(-)
hw/virtio/virtio-hmp-cmds.c +1 -0
index 477c97dea2..721c630ab0 100644
@@ -6,6 +6,7 @@
   */
 
  #include "qemu/osdep.h"
+#include "virtio-qmp.h"
  #include "monitor/hmp.h"
  #include "monitor/monitor.h"
  #include "qapi/qapi-commands-virtio.h"
@@ -145,13 +146,17 @@ void hmp_virtio_status(Monitor *mon, const QDict

*qdict)

hw/virtio/virtio-hmp-cmds.c void hmp_virtio_status(Monitor *mon, const QDict *qdict) · line 150

Quoted 6 lines
hw/virtio/virtio-hmp-cmds.c +2 -1
      monitor_printf(mon, "  endianness:              %s\n",
                     s->device_endian);
      monitor_printf(mon, "  status:\n");
-    hmp_virtio_dump_status(mon, s->status);
+    hmp_virtio_dump_status(mon,
+        qmp_decode_status(s->status));

Why not let the callee do this call?

hw/virtio/virtio-hmp-cmds.c void hmp_virtio_status(Monitor *mon, const QDict

Quoted 16 lines
hw/virtio/virtio-hmp-cmds.c +6 -3
      monitor_printf(mon, "  Guest features:\n");
-    hmp_virtio_dump_features(mon, s->guest_features);
+    hmp_virtio_dump_features(mon,
+        qmp_decode_features(s->device_id, s->guest_features));
      monitor_printf(mon, "  Host features:\n");
-    hmp_virtio_dump_features(mon, s->host_features);
+    hmp_virtio_dump_features(mon,
+        qmp_decode_features(s->device_id, s->host_features));
      monitor_printf(mon, "  Backend features:\n");
-    hmp_virtio_dump_features(mon, s->backend_features);
+    hmp_virtio_dump_features(mon,
+        qmp_decode_features(s->device_id, s->backend_features));
 
      if (s->vhost_dev) {
          monitor_printf(mon, "  VHost:\n");
@@ -172,13 +177,17 @@ void hmp_virtio_status(Monitor *mon, const QDict

*qdict)

hw/virtio/virtio-hmp-cmds.c void hmp_virtio_status(Monitor *mon, const QDict *qdict) · line 181

Quoted 6 lines
hw/virtio/virtio-hmp-cmds.c +2 -1
          monitor_printf(mon, "    log_size:       %"PRId64"\n",
                         s->vhost_dev->log_size);
          monitor_printf(mon, "    Features:\n");
-        hmp_virtio_dump_features(mon, s->vhost_dev->features);
+        hmp_virtio_dump_features(mon,
+            qmp_decode_features(s->device_id, s->vhost_dev->features));

Ditto.

hw/virtio/virtio-hmp-cmds.c void hmp_virtio_status(Monitor *mon, const QDict *qdict)

Quoted 4 lines
hw/virtio/virtio-hmp-cmds.c +2 -1
          monitor_printf(mon, "    Acked features:\n");
-        hmp_virtio_dump_features(mon, s->vhost_dev->acked_features);
+        hmp_virtio_dump_features(mon,
+            qmp_decode_features(s->device_id,

s->vhost_dev->acked_features));

hw/virtio/virtio-hmp-cmds.c void hmp_virtio_status(Monitor *mon, const QDict *qdict)

Quoted 4 lines
hw/virtio/virtio-hmp-cmds.c +2 -1
          monitor_printf(mon, "    Backend features:\n");
-        hmp_virtio_dump_features(mon, s->vhost_dev->backend_features);
+        hmp_virtio_dump_features(mon,
+            qmp_decode_features(s->device_id,

s->vhost_dev->backend_features));

Quoted 5 lines
hw/virtio/virtio-hmp-cmds.c +2 -1
          monitor_printf(mon, "    Protocol features:\n");
-        hmp_virtio_dump_protocols(mon, s->vhost_dev->protocol_features);
+        hmp_virtio_dump_protocols(mon,
+            qmp_decode_protocols(s->vhost_dev->protocol_features));
      }
Signature · 1 line
Best regards
#4 lore raw

PATCH 2/2 hmp: Drop unknown feature and status bits

In reply to Hyman Huang

The QMP command "x-query-virtio-status" outputs the full feature and status bit information, so there is no need to maintain it in the HMP output; drop it.

---
 hw/virtio/virtio-hmp-cmds.c | 13 -------------
 1 file changed, 13 deletions(-)
hw/virtio/virtio-hmp-cmds.c +0 -13
index 721c630ab0..f9a7384604 100644
@@ -25,10 +25,6 @@ static void hmp_virtio_dump_protocols(Monitor *mon,
         }
     }
     monitor_printf(mon, "\n");
-    if (pcol->has_unknown_protocols) {
-        monitor_printf(mon, "  unknown-protocols(0x%016"PRIx64")\n",
-                       pcol->unknown_protocols);
-    }
 }
 
 static void hmp_virtio_dump_status(Monitor *mon,
@@ -43,10 +39,6 @@ static void hmp_virtio_dump_status(Monitor *mon,
         }
     }
     monitor_printf(mon, "\n");
-    if (status->has_unknown_statuses) {
-        monitor_printf(mon, "  unknown-statuses(0x%016"PRIx32")\n",
-                       status->unknown_statuses);
-    }
 }
 
 static void hmp_virtio_dump_features(Monitor *mon,
@@ -73,11 +65,6 @@ static void hmp_virtio_dump_features(Monitor *mon,
         }
         monitor_printf(mon, "\n");
     }
-
-    if (features->has_unknown_dev_features) {
-        monitor_printf(mon, "  unknown-features(0x%016"PRIx64")\n",
-                       features->unknown_dev_features);
-    }
 }
 
 void hmp_virtio_query(Monitor *mon, const QDict *qdict)
Signature · 1 line
2.39.1