[RFC,2/2] virtio: show features acked by guest in 'info qtree' dump
diff mbox

Message ID 1462960324-4655-3-git-send-email-den@openvz.org
State New
Headers show

Commit Message

Denis V. Lunev May 11, 2016, 9:52 a.m. UTC
It is very convinient and useful for debug purpose to expose the set of
features negotiated with guest. The patch exports those features via
read-only bit properties.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Michael S. Tsirkin <mst@redhat.com>
CC: Eric Blake <eblake@redhat.com>
---
 hw/net/virtio-net.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

Comments

Michael S. Tsirkin May 11, 2016, 5:24 p.m. UTC | #1
On Wed, May 11, 2016 at 12:52:04PM +0300, Denis V. Lunev wrote:
> It is very convinient and useful for debug purpose to expose the set of
> features negotiated with guest. The patch exports those features via
> read-only bit properties.
> 
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Michael S. Tsirkin <mst@redhat.com>
> CC: Eric Blake <eblake@redhat.com>

Fine but can we avoid the code duplication, using some macro?
Same name and it are nearly always used with both
host and guest features.

> ---
>  hw/net/virtio-net.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 5798f87..cb9ce9c 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -1904,6 +1904,50 @@ static Property virtio_net_properties[] = {
>      DEFINE_PROP_BIT("ctrl_guest_offloads", VirtIONet, host_features,
>                      VIRTIO_NET_F_CTRL_GUEST_OFFLOADS, true),
>      DEFINE_PROP_BIT("mq", VirtIONet, host_features, VIRTIO_NET_F_MQ, false),
> +
> +    DEFINE_PROP_RO_BIT64("csum_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_CSUM),
> +    DEFINE_PROP_RO_BIT64("guest_csum_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_GUEST_CSUM),
> +    DEFINE_PROP_RO_BIT64("gso_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_GSO),
> +    DEFINE_PROP_RO_BIT64("guest_tso4_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_GUEST_TSO4),
> +    DEFINE_PROP_RO_BIT64("guest_tso6_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_GUEST_TSO6),
> +    DEFINE_PROP_RO_BIT64("guest_ecn_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_GUEST_ECN),
> +    DEFINE_PROP_RO_BIT64("guest_ufo_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_GUEST_UFO),
> +    DEFINE_PROP_RO_BIT64("guest_announce_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_GUEST_ANNOUNCE),
> +    DEFINE_PROP_RO_BIT64("host_tso4_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_HOST_TSO4),
> +    DEFINE_PROP_RO_BIT64("host_tso6_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_HOST_TSO6),
> +    DEFINE_PROP_RO_BIT64("host_ecn_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_HOST_ECN),
> +    DEFINE_PROP_RO_BIT64("host_ufo_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_HOST_UFO),
> +    DEFINE_PROP_RO_BIT64("mrg_rxbuf_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_MRG_RXBUF),
> +    DEFINE_PROP_RO_BIT64("status_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_STATUS),
> +    DEFINE_PROP_RO_BIT64("ctrl_vq_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_CTRL_VQ),
> +    DEFINE_PROP_RO_BIT64("ctrl_rx_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_CTRL_RX),
> +    DEFINE_PROP_RO_BIT64("ctrl_vlan_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_CTRL_VLAN),
> +    DEFINE_PROP_RO_BIT64("ctrl_rx_extra_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_CTRL_RX_EXTRA),
> +    DEFINE_PROP_RO_BIT64("ctrl_mac_addr_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_CTRL_MAC_ADDR),
> +    DEFINE_PROP_RO_BIT64("ctrl_guest_offloads_acked", VirtIODevice,
> +                         guest_features, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS),
> +    DEFINE_PROP_RO_BIT64("mq_acked", VirtIODevice, guest_features,
> +                         VIRTIO_NET_F_MQ),
> +
>      DEFINE_NIC_PROPERTIES(VirtIONet, nic_conf),
>      DEFINE_PROP_UINT32("x-txtimer", VirtIONet, net_conf.txtimer,
>                         TX_TIMER_INTERVAL),
> -- 
> 2.5.0

Patch
diff mbox

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 5798f87..cb9ce9c 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1904,6 +1904,50 @@  static Property virtio_net_properties[] = {
     DEFINE_PROP_BIT("ctrl_guest_offloads", VirtIONet, host_features,
                     VIRTIO_NET_F_CTRL_GUEST_OFFLOADS, true),
     DEFINE_PROP_BIT("mq", VirtIONet, host_features, VIRTIO_NET_F_MQ, false),
+
+    DEFINE_PROP_RO_BIT64("csum_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_CSUM),
+    DEFINE_PROP_RO_BIT64("guest_csum_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_GUEST_CSUM),
+    DEFINE_PROP_RO_BIT64("gso_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_GSO),
+    DEFINE_PROP_RO_BIT64("guest_tso4_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_GUEST_TSO4),
+    DEFINE_PROP_RO_BIT64("guest_tso6_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_GUEST_TSO6),
+    DEFINE_PROP_RO_BIT64("guest_ecn_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_GUEST_ECN),
+    DEFINE_PROP_RO_BIT64("guest_ufo_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_GUEST_UFO),
+    DEFINE_PROP_RO_BIT64("guest_announce_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_GUEST_ANNOUNCE),
+    DEFINE_PROP_RO_BIT64("host_tso4_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_HOST_TSO4),
+    DEFINE_PROP_RO_BIT64("host_tso6_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_HOST_TSO6),
+    DEFINE_PROP_RO_BIT64("host_ecn_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_HOST_ECN),
+    DEFINE_PROP_RO_BIT64("host_ufo_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_HOST_UFO),
+    DEFINE_PROP_RO_BIT64("mrg_rxbuf_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_MRG_RXBUF),
+    DEFINE_PROP_RO_BIT64("status_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_STATUS),
+    DEFINE_PROP_RO_BIT64("ctrl_vq_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_CTRL_VQ),
+    DEFINE_PROP_RO_BIT64("ctrl_rx_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_CTRL_RX),
+    DEFINE_PROP_RO_BIT64("ctrl_vlan_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_CTRL_VLAN),
+    DEFINE_PROP_RO_BIT64("ctrl_rx_extra_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_CTRL_RX_EXTRA),
+    DEFINE_PROP_RO_BIT64("ctrl_mac_addr_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_CTRL_MAC_ADDR),
+    DEFINE_PROP_RO_BIT64("ctrl_guest_offloads_acked", VirtIODevice,
+                         guest_features, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS),
+    DEFINE_PROP_RO_BIT64("mq_acked", VirtIODevice, guest_features,
+                         VIRTIO_NET_F_MQ),
+
     DEFINE_NIC_PROPERTIES(VirtIONet, nic_conf),
     DEFINE_PROP_UINT32("x-txtimer", VirtIONet, net_conf.txtimer,
                        TX_TIMER_INTERVAL),