qemu-devel
[Top][All Lists]
Advanced

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

Re: [RFC v5 1/6] qmp: add QMP command x-debug-query-virtio


From: Dr. David Alan Gilbert
Subject: Re: [RFC v5 1/6] qmp: add QMP command x-debug-query-virtio
Date: Wed, 2 Jun 2021 12:28:58 +0100
User-agent: Mutt/2.0.7 (2021-05-04)

* Jonah Palmer (jonah.palmer@oracle.com) wrote:
> 
> On 3/24/21 2:31 PM, Dr. David Alan Gilbert wrote:
> > * Jonah Palmer (jonah.palmer@oracle.com) wrote:
> > > From: Laurent Vivier <lvivier@redhat.com>
> > > 
> > <snip>
> > 
> > > --- /dev/null
> > > +++ b/qapi/virtio.json
> > > @@ -0,0 +1,68 @@
> > > +##
> > > +# = Virtio devices
> > > +##
> > > +
> > > +##
> > > +# @VirtioType:
> > > +#
> > > +# An enumeration of Virtio device types.
> > > +#
> > > +# Since: 6.0
> > > +##
> > > +{ 'enum': 'VirtioType',
> > > +  'data': [ 'unknown', 'virtio-9p', 'virtio-blk', 'virtio-serial',
> > > +            'virtio-gpu', 'virtio-input', 'virtio-net', 'virtio-scsi',
> > > +            'vhost-user-fs', 'vhost-vsock', 'virtio-balloon', 
> > > 'virtio-crypto',
> > > +            'virtio-iommu', 'virtio-pmem', 'virtio-rng' ]
> > Can we make this be a complete list that's in the same order as 
> > include/standard-headers/linux/virtio_ids.h
> > then if we add a few asserts somewhere to make sure we don't screwup, we
> > don't need to do any translation.
> > 
> > Dave
> 
> Hi Dave. Just so I understand correctly, you would like me to add all of the 
> entries in the given order?
> E.g. including 'virtio-rpmsg', ..., 'virtio-mac80211-wlan', etc.? Or just the 
> supported virtio types in
> the order as it's shown in virtio_ids.h?
>
> Many of these devices may not be supported for introspection.

Make that list all of the types, and keep it in the same order as the
header with the same gaps (including one at the start); so that that the QAPI 
generated enum values
for 'VirtioType' match the virtio_ids constants; that way you never have
to convert between the qapi number and the header number.
(Whenever we do a convert, sooner or later we screwup the convert and
end up with numbers that don't match!)

As you say, only some have support for introspection; so you just need
to check for support rather than doing a mapping.

Dave

> Jonah
> 
> > 
> > > +}
> > > +
> > > +##
> > > +# @VirtioInfo:
> > > +#
> > > +# Information about a given VirtIODevice
> > > +#
> > > +# @path: VirtIO device canonical path.
> > > +#
> > > +# @type: VirtIO device type.
> > > +#
> > > +# Since: 6.0
> > > +#
> > > +##
> > > +{ 'struct': 'VirtioInfo',
> > > +  'data': {
> > > +    'path': 'str',
> > > +    'type': 'VirtioType'
> > > +  }
> > > +}
> > > +
> > > +##
> > > +# @x-debug-query-virtio:
> > > +#
> > > +# Return the list of all VirtIO devices
> > > +#
> > > +# Returns: list of @VirtioInfo
> > > +#
> > > +# Since: 6.0
> > > +#
> > > +# Example:
> > > +#
> > > +# -> { "execute": "x-debug-query-virtio" }
> > > +# <- { "return": [
> > > +#        {
> > > +#            "path": "/machine/peripheral-anon/device[3]/virtio-backend",
> > > +#            "type": "virtio-net"
> > > +#        },
> > > +#        {
> > > +#            "path": "/machine/peripheral-anon/device[1]/virtio-backend",
> > > +#            "type": "virtio-serial"
> > > +#        },
> > > +#        {
> > > +#            "path": "/machine/peripheral-anon/device[0]/virtio-backend",
> > > +#            "type": "virtio-blk"
> > > +#        }
> > > +#      ]
> > > +#    }
> > > +#
> > > +##
> > > +
> > > +{ 'command': 'x-debug-query-virtio', 'returns': ['VirtioInfo'] }
> > > diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c
> > > index 1c7186e..8f0ae20 100644
> > > --- a/tests/qtest/qmp-cmd-test.c
> > > +++ b/tests/qtest/qmp-cmd-test.c
> > > @@ -95,6 +95,7 @@ static bool query_is_ignored(const char *cmd)
> > >           "query-gic-capabilities", /* arm */
> > >           /* Success depends on target-specific build configuration: */
> > >           "query-pci",              /* CONFIG_PCI */
> > > +        "x-debug-query-virtio",   /* CONFIG_VIRTIO */
> > >           /* Success depends on launching SEV guest */
> > >           "query-sev-launch-measure",
> > >           /* Success depends on Host or Hypervisor SEV support */
> > > -- 
> > > 1.8.3.1
> > > 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK




reply via email to

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