virtio: introduce `info virtio' hmp command
v4 cover virtio: introduce `info virtio' hmp command
v4:
* Implement `query-virtio' QMP
* Split the work into QMP and HMP parts
v3: http://lists.nongnu.org/archive/html/qemu-devel/2017-09/msg07565.html
v2: http://lists.nongnu.org/archive/html/qemu-devel/2017-09/msg07527.html
v1: http://lists.nongnu.org/archive/html/qemu-devel/2017-09/msg07247.html
Jan Dakinevich (2):
virtio: introduce `query-virtio' QMP command
virtio: add `info virtio' HMP command
hmp-commands-info.hx | 14 ++++++ hmp.c | 79 ++++++++++++++++++++++++++++++++++ hmp.h | 1 + hw/block/virtio-blk.c | 21 +++++++++ hw/char/virtio-serial-bus.c | 15 +++++++ hw/display/virtio-gpu.c | 13 ++++++ hw/net/virtio-net.c | 35 +++++++++++++++ hw/scsi/virtio-scsi.c | 16 +++++++ hw/virtio/Makefile.objs | 2 + hw/virtio/virtio-balloon.c | 15 +++++++ hw/virtio/virtio-stub.c | 9 ++++ hw/virtio/virtio.c | 101 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio.h | 2 + qapi-schema.json | 1 + qapi/virtio.json | 94 +++++++++++++++++++++++++++++++++++++++++ 15 files changed, 418 insertions(+) create mode 100644 hw/virtio/virtio-stub.c create mode 100644 qapi/virtio.json
Signature · 1 line
2.1.4
PATCH v4 1/2 virtio: introduce `query-virtio' QMP command
The command is intended for gathering virtio information such as status, feature bits, negotiation status. It is convenient and useful for debug purpose.
The commands returns generic virtio information for virtio such as common feature names and status bits names and information for all attached to current machine devices.
To retrieve names of device-specific features `get_feature_name' callback in VirtioDeviceClass also was introduced.
--- hw/block/virtio-blk.c | 21 +++++++++ hw/char/virtio-serial-bus.c | 15 +++++++ hw/display/virtio-gpu.c | 13 ++++++ hw/net/virtio-net.c | 35 +++++++++++++++ hw/scsi/virtio-scsi.c | 16 +++++++ hw/virtio/Makefile.objs | 2 + hw/virtio/virtio-balloon.c | 15 +++++++ hw/virtio/virtio-stub.c | 9 ++++ hw/virtio/virtio.c | 101 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio.h | 2 + qapi-schema.json | 1 + qapi/virtio.json | 94 +++++++++++++++++++++++++++++++++++++++++ 12 files changed, 324 insertions(+) create mode 100644 hw/virtio/virtio-stub.c create mode 100644 qapi/virtio.json
hw/block/virtio-blk.c +21 -0
@@ -1017,6 +1017,26 @@ static Property virtio_blk_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static const char *virtio_blk_get_feature_name (VirtIODevice *vdev, +unsigned feature) +{ +static const char *names[] = { + [VIRTIO_BLK_F_BARRIER ] ="barrier" , + [VIRTIO_BLK_F_SIZE_MAX ] ="size_max" , + [VIRTIO_BLK_F_SEG_MAX ] ="seg_max" , + [VIRTIO_BLK_F_RO ] ="ro" , + [VIRTIO_BLK_F_BLK_SIZE ] ="blk_size" , + [VIRTIO_BLK_F_SCSI ] ="scsi" , + [VIRTIO_BLK_F_TOPOLOGY ] ="topology" , + [VIRTIO_BLK_F_FLUSH ] ="flush" , + [VIRTIO_BLK_F_MQ ] ="mq" , + }; +if (feature >=ARRAY_SIZE (names)) { +return NULL ; + } +return names[feature]; +} +static void virtio_blk_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -1030,6 +1050,7 @@ static void virtio_blk_class_init(ObjectClass *klass, void *data) vdc->get_config = virtio_blk_update_config; vdc->set_config = virtio_blk_set_config; vdc->get_features = virtio_blk_get_features; + vdc->get_feature_name = virtio_blk_get_feature_name; vdc->set_status = virtio_blk_set_status; vdc->reset = virtio_blk_reset; vdc->save = virtio_blk_save_device;
hw/char/virtio-serial-bus.c +15 -0
@@ -1156,6 +1156,20 @@ static Property virtio_serial_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static const char *virtio_serial_get_feature_name (VirtIODevice *vdev, +unsigned feature) +{ +static const char *names[] = { + [VIRTIO_CONSOLE_F_SIZE ] ="size" , + [VIRTIO_CONSOLE_F_MULTIPORT ] ="multiport" , + [VIRTIO_CONSOLE_F_EMERG_WRITE ] ="emerg_write" , + }; +if (feature >=ARRAY_SIZE (names)) { +return NULL ; + } +return names[feature]; +} +static void virtio_serial_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -1170,6 +1184,7 @@ static void virtio_serial_class_init(ObjectClass *klass, void *data) vdc->realize = virtio_serial_device_realize; vdc->unrealize = virtio_serial_device_unrealize; vdc->get_features = get_features; + vdc->get_feature_name = virtio_serial_get_feature_name; vdc->get_config = get_config; vdc->set_config = set_config; vdc->set_status = set_status;
hw/display/virtio-gpu.c +13 -0
@@ -1307,6 +1307,18 @@ static Property virtio_gpu_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static const char *virtio_gpu_get_feature_name (VirtIODevice *vdev, +unsigned feature) +{ +static const char *names[] = { + [VIRTIO_GPU_F_VIRGL ] ="virgl" , + }; +if (feature >=ARRAY_SIZE (names)) { +return NULL ; + } +return names[feature]; +} +static void virtio_gpu_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -1317,6 +1329,7 @@ static void virtio_gpu_class_init(ObjectClass *klass, void *data) vdc->get_config = virtio_gpu_get_config; vdc->set_config = virtio_gpu_set_config; vdc->get_features = virtio_gpu_get_features; + vdc->get_feature_name = virtio_gpu_get_feature_name; vdc->set_features = virtio_gpu_set_features; vdc->reset = virtio_gpu_reset;
hw/net/virtio-net.c +35 -0
@@ -2154,6 +2154,40 @@ static Property virtio_net_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static const char *virtio_net_get_feature_name (VirtIODevice *vdev, +unsigned feature) +{ +static const char *names[] = { + [VIRTIO_NET_F_CSUM ] ="csum" , + [VIRTIO_NET_F_GUEST_CSUM ] ="guest_csum" , + [VIRTIO_NET_F_CTRL_GUEST_OFFLOADS ] ="ctrl_guest_offloads" , + [VIRTIO_NET_F_MTU ] ="mtu" , + [VIRTIO_NET_F_MAC ] ="mac" , + [VIRTIO_NET_F_GSO ] ="gso" , + [VIRTIO_NET_F_GUEST_TSO4 ] ="guest_tso4" , + [VIRTIO_NET_F_GUEST_TSO6 ] ="guest_tso6" , + [VIRTIO_NET_F_GUEST_ECN ] ="guest_ecn" , + [VIRTIO_NET_F_GUEST_UFO ] ="guest_ufo" , + [VIRTIO_NET_F_HOST_TSO4 ] ="host_tso4" , + [VIRTIO_NET_F_HOST_TSO6 ] ="host_tso6" , + [VIRTIO_NET_F_HOST_ECN ] ="host_ecn" , + [VIRTIO_NET_F_HOST_UFO ] ="host_ufo" , + [VIRTIO_NET_F_MRG_RXBUF ] ="mrg_rxbuf" , + [VIRTIO_NET_F_STATUS ] ="status" , + [VIRTIO_NET_F_CTRL_VQ ] ="ctrl_vq" , + [VIRTIO_NET_F_CTRL_RX ] ="ctrl_rx" , + [VIRTIO_NET_F_CTRL_VLAN ] ="ctrl_vlan" , + [VIRTIO_NET_F_CTRL_RX_EXTRA ] ="ctrl_rx_extra" , + [VIRTIO_NET_F_GUEST_ANNOUNCE ] ="guest_announce" , + [VIRTIO_NET_F_MQ ] ="mq" , + [VIRTIO_NET_F_CTRL_MAC_ADDR ] ="ctrl_mac_addr" , + }; +if (feature >=ARRAY_SIZE (names)) { +return NULL ; + } +return names[feature]; +} +static void virtio_net_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -2169,6 +2203,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data) vdc->get_features = virtio_net_get_features; vdc->set_features = virtio_net_set_features; vdc->bad_features = virtio_net_bad_features; + vdc->get_feature_name = virtio_net_get_feature_name; vdc->reset = virtio_net_reset; vdc->set_status = virtio_net_set_status; vdc->guest_notifier_mask = virtio_net_guest_notifier_mask;
hw/scsi/virtio-scsi.c +16 -0
@@ -942,6 +942,21 @@ static const VMStateDescription vmstate_virtio_scsi = { }, }; +static const char *virtio_scsi_get_feature_name (VirtIODevice *vdev, +unsigned feature) +{ +static const char *names[] = { + [VIRTIO_SCSI_F_INOUT ] ="inout" , + [VIRTIO_SCSI_F_HOTPLUG ] ="hotplug" , + [VIRTIO_SCSI_F_CHANGE ] ="change" , + [VIRTIO_SCSI_F_T10_PI ] ="t10_pi" , + }; +if (feature >=ARRAY_SIZE (names)) { +return NULL ; + } +return names[feature]; +} +static void virtio_scsi_common_class_init (ObjectClass *klass,void *data) {VirtioDeviceClass *vdc =VIRTIO_DEVICE_CLASS (klass);
@@ -964,6 +979,7 @@ static void virtio_scsi_class_init(ObjectClass *klass, void *data) vdc->unrealize = virtio_scsi_device_unrealize; vdc->set_config = virtio_scsi_set_config; vdc->get_features = virtio_scsi_get_features; + vdc->get_feature_name = virtio_scsi_get_feature_name; vdc->reset = virtio_scsi_reset; vdc->start_ioeventfd = virtio_scsi_dataplane_start; vdc->stop_ioeventfd = virtio_scsi_dataplane_stop;
hw/virtio/Makefile.objs +2 -0
@@ -9,6 +9,8 @@ obj-$(CONFIG_LINUX) += vhost.o vhost-backend.o vhost-user.o obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock.o obj-y += virtio-crypto.o obj-$(CONFIG_VIRTIO_PCI) += virtio-crypto-pci.o +else +obj-y += virtio-stub.o endif common-obj-$(call lnot,$(CONFIG_LINUX)) += vhost-stub.o
hw/virtio/virtio-balloon.c +15 -0
@@ -509,6 +509,20 @@ static Property virtio_balloon_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static const char *virtio_balloon_get_feature_name (VirtIODevice *vdev, +unsigned feature) +{ +static const char *names[] = { + [VIRTIO_BALLOON_F_MUST_TELL_HOST ] ="must_tell_host" , + [VIRTIO_BALLOON_F_STATS_VQ ] ="stats_vq" , + [VIRTIO_BALLOON_F_DEFLATE_ON_OOM ] ="deflate_on_oom" , + }; +if (feature >=ARRAY_SIZE (names)) { +return NULL ; + } +return names[feature]; +} +static void virtio_balloon_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -523,6 +537,7 @@ static void virtio_balloon_class_init(ObjectClass *klass, void *data) vdc->get_config = virtio_balloon_get_config; vdc->set_config = virtio_balloon_set_config; vdc->get_features = virtio_balloon_get_features; + vdc->get_feature_name = virtio_balloon_get_feature_name; vdc->set_status = virtio_balloon_set_status; vdc->vmsd = &vmstate_virtio_balloon_device; }
hw/virtio/virtio-stub.c new file +9 -0
@@ -0,0 +1,9 @@ +#include "qemu/osdep.h" +#include "qmp-commands.h" +#include "qapi/qmp/qerror.h" + +VirtioInfo *qmp_query_virtio (Error **errp) +{ +error_setg (errp,QERR_UNSUPPORTED ); +return NULL ; +}
hw/virtio/virtio.c +101 -0
113 lines not on this page · raw message
include/hw/virtio/virtio.h +2 -0
@@ -141,6 +141,8 @@ typedef struct VirtioDeviceClass {void (*save)(VirtIODevice *vdev,QEMUFile *f);int (*load)(VirtIODevice *vdev,QEMUFile *f,int version_id);const VMStateDescription *vmsd; +/* Get the name of device specific feature */ +const char *(*get_feature_name)(VirtIODevice *vdev,unsigned feature); } VirtioDeviceClass; void virtio_instance_init_common(Object *proxy_obj, void *data,
qapi-schema.json +1 -0
@@ -92,6 +92,7 @@ { 'include': 'qapi/transaction.json' } { 'include': 'qapi/trace.json' } { 'include': 'qapi/introspect.json' } +{ 'include': 'qapi/virtio.json' } ## # = Miscellanea
qapi/virtio.json new file +94 -0
94 lines not on this page · raw message
Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH v4 1/2] virtio: introduce `query-virtio' QMP command
Quoted 13 lines · Jan Dakinevich
The command is intended for gathering virtio information such as status, feature bits, negotiation status. It is convenient and useful for debug purpose.
The commands returns generic virtio information for virtio such as common feature names and status bits names and information for all attached to current machine devices.
To retrieve names of device-specific features `get_feature_name' callback in VirtioDeviceClass also was introduced.
Cc Denis V. Lunev <[email protected]>Signed-off-by Jan Dakinevich <[email protected]>
Quoted 16 lines
--- hw/block/virtio-blk.c | 21 +++++++++ hw/char/virtio-serial-bus.c | 15 +++++++ hw/display/virtio-gpu.c | 13 ++++++ hw/net/virtio-net.c | 35 +++++++++++++++ hw/scsi/virtio-scsi.c | 16 +++++++ hw/virtio/Makefile.objs | 2 + hw/virtio/virtio-balloon.c | 15 +++++++ hw/virtio/virtio-stub.c | 9 ++++ hw/virtio/virtio.c | 101 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio.h | 2 + qapi-schema.json | 1 + qapi/virtio.json | 94 +++++++++++++++++++++++++++++++++++++++++ 12 files changed, 324 insertions(+) create mode 100644 hw/virtio/virtio-stub.c create mode 100644 qapi/virtio.json
This creates a new .json file, but does not touch MAINTAINERS. Our idea in splitting the .json files was to make it easier for each sub-file that needs a specific maintainer in addition to the overall *.json line for QAPI maintainers, so this may deserve a MAINTAINERS entry.
Quoted 17 lines
+++
b/qapi/virtio.jsonqapi/virtio.json new file +15
-0@@ -0,0 +1,94 @@ +# -*- Mode: Python -*- +# + +## +# = Virtio devices +## + +{ 'include': 'common.json' } + +## +# @VirtioInfoBit: +# +# Named virtio bit +# +# @bit: bit number
qapi/virtio.json line 25
Quoted 10 lines
qapi/virtio.json new file +10
-0+# +# @name: bit name +# +# Since: 2.11.0 +# +## +{ + 'struct': 'VirtioInfoBit', + 'data': { + 'bit': 'uint64',
Why is this a 64-bit value? Are the values 0-63, or are they 1, 2, 4, 8, ...? The documentation on 'bit number' is rather sparse.
qapi/virtio.json line 26
Quoted 1 line
qapi/virtio.json new file +1
-0+ 'name': 'str'
Wouldn't an enum type be better than an open-ended string?
qapi/virtio.json line 35
Quoted 9 lines
qapi/virtio.json new file +9
-0+ } +} + +## +# @VirtioInfoDevice: +# +# Information about specific virtio device +# +# @qom_path: QOM path of the device
Please make this 'qom-path' - new interfaces should prefer '-' over '_'.
Quoted 10 lines
qapi/virtio.json new file +10
-0+# +# @feature-names: names of device-specific features +# +# @host-features: bitmask of features, provided by devices +# +# @guest-features: bitmask of features, acknowledged by guest +# +# @status: virtio device status bitmask +# +# Since: 2.11.0
qapi/virtio.json line 55
Quoted 10 lines
qapi/virtio.json new file +10
-0+# +## +{ + 'struct': 'VirtioInfoDevice', + 'data': { + 'qom_path': 'str', + 'feature-names': ['VirtioInfoBit'], + 'host-features': 'uint64', + 'guest-features': 'uint64', + 'status': 'uint64'
I'm wondering if this is the best representation (where the caller has to parse the integer and then lookup in feature-names what each bit of the integer represents). But I'm not sure I have anything better off the top of my head.
Quoted 11 lines
qapi/virtio.json new file +11
-0+ } +} + +## +# @VirtioInfo: +# +# Information about virtio devices +# +# @feature-names: names of common virtio features +# +# @status-names: names of bits which represents virtio device status
qapi/virtio.json line 76
Quoted 10 lines
qapi/virtio.json new file +10
-0+# +# @devices: list of per-device virtio information +# +# Since: 2.11.0 +# +## +{ + 'struct': 'VirtioInfo', + 'data': { + 'feature-names': ['VirtioInfoBit'],
Why is feature-names listed at two different nestings of the return value?
Quoted 19 lines
qapi/virtio.json new file +18
-0+ 'status-names': ['VirtioInfoBit'], + 'devices': ['VirtioInfoDevice'] + } +} + + +## +# @query-virtio: +# +# Returns generic and per-device virtio information +# +# Since: 2.11.0 +# +## +{ + 'command': 'query-virtio', + 'returns': 'VirtioInfo' +}
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH v4 1/2] virtio: introduce `query-virtio' QMP command
Quoted 31 lines · Eric Blake
Quoted 13 lines · Jan Dakinevich
The command is intended for gathering virtio information such as status, feature bits, negotiation status. It is convenient and useful for debug purpose.
The commands returns generic virtio information for virtio such as common feature names and status bits names and information for all attached to current machine devices.
To retrieve names of device-specific features `get_feature_name' callback in VirtioDeviceClass also was introduced.
Cc Denis V. Lunev <[email protected]>Signed-off-by Jan Dakinevich <[email protected]>Quoted 16 lines
--- hw/block/virtio-blk.c | 21 +++++++++ hw/char/virtio-serial-bus.c | 15 +++++++ hw/display/virtio-gpu.c | 13 ++++++ hw/net/virtio-net.c | 35 +++++++++++++++ hw/scsi/virtio-scsi.c | 16 +++++++ hw/virtio/Makefile.objs | 2 + hw/virtio/virtio-balloon.c | 15 +++++++ hw/virtio/virtio-stub.c | 9 ++++ hw/virtio/virtio.c | 101 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio.h | 2 + qapi-schema.json | 1 + qapi/virtio.json | 94 +++++++++++++++++++++++++++++++++++++++++ 12 files changed, 324 insertions(+) create mode 100644 hw/virtio/virtio-stub.c create mode 100644 qapi/virtio.json
Quoted 5 lines
This creates a new .json file, but does not touch
MAINTAINERS. Our idea in splitting the .json files was to make it easier for each sub-file that needs a specific maintainer in addition to the overall *.json line for QAPI maintainers, so this may deserve aMAINTAINERSentry.
Ok.
Quoted 22 lines
Quoted 22 lines
+++
b/qapi/virtio.jsonqapi/virtio.json new file +20
-0@@ -0,0 +1,94 @@ +# -*- Mode: Python -*- +# + +## +# = Virtio devices +## + +{ 'include': 'common.json' } + +## +# @VirtioInfoBit: +# +# Named virtio bit +# +# @bit: bit number +# +# @name: bit name +# +# Since: 2.11.0 +#
Quoted 8 lines
qapi/virtio.json line 25
Quoted 5 lines
qapi/virtio.json new file +5
-0+## +{ + 'struct': 'VirtioInfoBit', + 'data': { + 'bit': 'uint64',Why is this a 64-bit value? Are the values 0-63, or are they 1, 2, 4, 8, ...? The documentation on 'bit number' is rather sparse.
I would prefer `uint' here, but I don't see generic unsigned type (may be, I am mistaken). I could use uint8 here, though.
Quoted 5 lines
qapi/virtio.json line 26
Quoted 2 lines
qapi/virtio.json new file +1
-0+ 'name': 'str'Wouldn't an enum type be better than an open-ended string?
Bit names are not known here, they are obtained from virtio device implementations.
Quoted 11 lines
qapi/virtio.json line 35
Quoted 9 lines
qapi/virtio.json new file +9
-0+ } +} + +## +# @VirtioInfoDevice: +# +# Information about specific virtio device +# +# @qom_path: QOM path of the devicePlease make this 'qom-path' - new interfaces should prefer '-' over '_'.
Ok.
Quoted 17 lines
Quoted 17 lines
qapi/virtio.json new file +17
-0+# +# @feature-names: names of device-specific features +# +# @host-features: bitmask of features, provided by devices +# +# @guest-features: bitmask of features, acknowledged by guest +# +# @status: virtio device status bitmask +# +# Since: 2.11.0 +# +## +{ + 'struct': 'VirtioInfoDevice', + 'data': { + 'qom_path': 'str', + 'feature-names': ['VirtioInfoBit'],
Quoted 9 lines
qapi/virtio.json line 55
Quoted 3 lines
qapi/virtio.json new file +3
-0+ 'host-features': 'uint64', + 'guest-features': 'uint64', + 'status': 'uint64'I'm wondering if this is the best representation (where the caller has to parse the integer and then lookup in feature-names what each bit of the integer represents). But I'm not sure I have anything better off the top of my head.
Consider it as way to tell caller about names of supported features.
Quoted 15 lines
Quoted 15 lines
qapi/virtio.json new file +15
-0+ } +} + +## +# @VirtioInfo: +# +# Information about virtio devices +# +# @feature-names: names of common virtio features +# +# @status-names: names of bits which represents virtio device status +# +# @devices: list of per-device virtio information +# +# Since: 2.11.0
Quoted 9 lines
qapi/virtio.json line 76
Quoted 6 lines
qapi/virtio.json new file +6
-0+# +## +{ + 'struct': 'VirtioInfo', + 'data': { + 'feature-names': ['VirtioInfoBit'],Why is feature-names listed at two different nestings of the return value?
These are different feature names. First names are common and predefined for all devices. Second names are device-specific.
Quoted 20 lines
Quoted 19 lines
qapi/virtio.json new file +18
-0+ 'status-names': ['VirtioInfoBit'], + 'devices': ['VirtioInfoDevice'] + } +} + + +## +# @query-virtio: +# +# Returns generic and per-device virtio information +# +# Since: 2.11.0 +# +## +{ + 'command': 'query-virtio', + 'returns': 'VirtioInfo' +}
Signature · 2 lines
Best regards Jan Dakinevich
Re: [Qemu-devel] [PATCH v4 1/2] virtio: introduce `query-virtio' QMP command
Quoted 153 lines · * Jan Dakinevich ([email protected]) wrote:
Quoted 31 lines · Eric Blake
Quoted 13 lines · Jan Dakinevich
The command is intended for gathering virtio information such as status, feature bits, negotiation status. It is convenient and useful for debug purpose.
The commands returns generic virtio information for virtio such as common feature names and status bits names and information for all attached to current machine devices.
To retrieve names of device-specific features `get_feature_name' callback in VirtioDeviceClass also was introduced.
Cc Denis V. Lunev <[email protected]>Signed-off-by Jan Dakinevich <[email protected]>Quoted 16 lines
--- hw/block/virtio-blk.c | 21 +++++++++ hw/char/virtio-serial-bus.c | 15 +++++++ hw/display/virtio-gpu.c | 13 ++++++ hw/net/virtio-net.c | 35 +++++++++++++++ hw/scsi/virtio-scsi.c | 16 +++++++ hw/virtio/Makefile.objs | 2 + hw/virtio/virtio-balloon.c | 15 +++++++ hw/virtio/virtio-stub.c | 9 ++++ hw/virtio/virtio.c | 101 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio.h | 2 + qapi-schema.json | 1 + qapi/virtio.json | 94 +++++++++++++++++++++++++++++++++++++++++ 12 files changed, 324 insertions(+) create mode 100644 hw/virtio/virtio-stub.c create mode 100644 qapi/virtio.jsonQuoted 5 lines
This creates a new .json file, but does not touch
MAINTAINERS. Our idea in splitting the .json files was to make it easier for each sub-file that needs a specific maintainer in addition to the overall *.json line for QAPI maintainers, so this may deserve aMAINTAINERSentry.Ok.
Quoted 22 lines
Quoted 22 lines
+++
b/qapi/virtio.jsonqapi/virtio.json new file +20
-0@@ -0,0 +1,94 @@ +# -*- Mode: Python -*- +# + +## +# = Virtio devices +## + +{ 'include': 'common.json' } + +## +# @VirtioInfoBit: +# +# Named virtio bit +# +# @bit: bit number +# +# @name: bit name +# +# Since: 2.11.0 +#Quoted 8 lines
qapi/virtio.json line 25
Quoted 5 lines
qapi/virtio.json new file +5
-0+## +{ + 'struct': 'VirtioInfoBit', + 'data': { + 'bit': 'uint64',Why is this a 64-bit value? Are the values 0-63, or are they 1, 2, 4, 8, ...? The documentation on 'bit number' is rather sparse.
I would prefer `uint' here, but I don't see generic unsigned type (may be, I am mistaken). I could use uint8 here, though.
Quoted 5 lines
qapi/virtio.json line 26
Quoted 2 lines
qapi/virtio.json new file +1
-0+ 'name': 'str'Wouldn't an enum type be better than an open-ended string?
Bit names are not known here, they are obtained from virtio device implementations.
Quoted 11 lines
qapi/virtio.json line 35
Quoted 9 lines
qapi/virtio.json new file +9
-0+ } +} + +## +# @VirtioInfoDevice: +# +# Information about specific virtio device +# +# @qom_path: QOM path of the devicePlease make this 'qom-path' - new interfaces should prefer '-' over '_'.
Ok.
Quoted 17 lines
Quoted 17 lines
qapi/virtio.json new file +17
-0+# +# @feature-names: names of device-specific features +# +# @host-features: bitmask of features, provided by devices +# +# @guest-features: bitmask of features, acknowledged by guest +# +# @status: virtio device status bitmask +# +# Since: 2.11.0 +# +## +{ + 'struct': 'VirtioInfoDevice', + 'data': { + 'qom_path': 'str', + 'feature-names': ['VirtioInfoBit'],Quoted 9 lines
qapi/virtio.json line 55
Quoted 3 lines
qapi/virtio.json new file +3
-0+ 'host-features': 'uint64', + 'guest-features': 'uint64', + 'status': 'uint64'I'm wondering if this is the best representation (where the caller has to parse the integer and then lookup in feature-names what each bit of the integer represents). But I'm not sure I have anything better off the top of my head.
Consider it as way to tell caller about names of supported features.
Quoted 15 lines
Quoted 15 lines
qapi/virtio.json new file +15
-0+ } +} + +## +# @VirtioInfo: +# +# Information about virtio devices +# +# @feature-names: names of common virtio features +# +# @status-names: names of bits which represents virtio device status +# +# @devices: list of per-device virtio information +# +# Since: 2.11.0Quoted 9 lines
qapi/virtio.json line 76
Quoted 6 lines
qapi/virtio.json new file +6
-0+# +## +{ + 'struct': 'VirtioInfo', + 'data': { + 'feature-names': ['VirtioInfoBit'],Why is feature-names listed at two different nestings of the return value?
Quoted 2 lines
These are different feature names. First names are common and predefined for all devices. Second names are device-specific.
If you can turn these into enums (union'd enums?) then you might be able to get rid of a lot of your array filling/naming conversion boilerplate. (Not sure if it's worth it, but it's worth looking).
Dave
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
qapi/virtio.json new file +12
-0+ 'status-names': ['VirtioInfoBit'], + 'devices': ['VirtioInfoDevice'] + } +} + + +## +# @query-virtio: +# +# Returns generic and per-device virtio information +# +# Since: 2.11.0
Quoted 12 lines
Quoted 8 lines
Quoted 7 lines
qapi/virtio.json new file +6
-0+# +## +{ + 'command': 'query-virtio', + 'returns': 'VirtioInfo' +}Signature · 2 lines
Best regards Jan Dakinevich
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH v4 1/2] virtio: introduce `query-virtio' QMP command
Quoted 154 lines · Dr. David Alan Gilbert
Quoted 153 lines · * Jan Dakinevich ([email protected]) wrote:
Quoted 31 lines · Eric Blake
Quoted 13 lines · Jan Dakinevich
The command is intended for gathering virtio information such as status, feature bits, negotiation status. It is convenient and useful for debug purpose.
The commands returns generic virtio information for virtio such as common feature names and status bits names and information for all attached to current machine devices.
To retrieve names of device-specific features `get_feature_name' callback in VirtioDeviceClass also was introduced.
Cc Denis V. Lunev <[email protected]>Signed-off-by Jan Dakinevich <[email protected]>Quoted 16 lines
--- hw/block/virtio-blk.c | 21 +++++++++ hw/char/virtio-serial-bus.c | 15 +++++++ hw/display/virtio-gpu.c | 13 ++++++ hw/net/virtio-net.c | 35 +++++++++++++++ hw/scsi/virtio-scsi.c | 16 +++++++ hw/virtio/Makefile.objs | 2 + hw/virtio/virtio-balloon.c | 15 +++++++ hw/virtio/virtio-stub.c | 9 ++++ hw/virtio/virtio.c | 101 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio.h | 2 + qapi-schema.json | 1 + qapi/virtio.json | 94 +++++++++++++++++++++++++++++++++++++++++ 12 files changed, 324 insertions(+) create mode 100644 hw/virtio/virtio-stub.c create mode 100644 qapi/virtio.jsonQuoted 5 lines
This creates a new .json file, but does not touch
MAINTAINERS. Our idea in splitting the .json files was to make it easier for each sub-file that needs a specific maintainer in addition to the overall *.json line for QAPI maintainers, so this may deserve aMAINTAINERSentry.Ok.
Quoted 22 lines
Quoted 22 lines
+++
b/qapi/virtio.jsonqapi/virtio.json new file +20
-0@@ -0,0 +1,94 @@ +# -*- Mode: Python -*- +# + +## +# = Virtio devices +## + +{ 'include': 'common.json' } + +## +# @VirtioInfoBit: +# +# Named virtio bit +# +# @bit: bit number +# +# @name: bit name +# +# Since: 2.11.0 +#Quoted 8 lines
qapi/virtio.json line 25
Quoted 5 lines
qapi/virtio.json new file +5
-0+## +{ + 'struct': 'VirtioInfoBit', + 'data': { + 'bit': 'uint64',Why is this a 64-bit value? Are the values 0-63, or are they 1, 2, 4, 8, ...? The documentation on 'bit number' is rather sparse.
I would prefer `uint' here, but I don't see generic unsigned type (may be, I am mistaken). I could use uint8 here, though.
Quoted 5 lines
qapi/virtio.json line 26
Quoted 2 lines
qapi/virtio.json new file +1
-0+ 'name': 'str'Wouldn't an enum type be better than an open-ended string?
Bit names are not known here, they are obtained from virtio device implementations.
Quoted 11 lines
qapi/virtio.json line 35
Quoted 9 lines
qapi/virtio.json new file +9
-0+ } +} + +## +# @VirtioInfoDevice: +# +# Information about specific virtio device +# +# @qom_path: QOM path of the devicePlease make this 'qom-path' - new interfaces should prefer '-' over '_'.
Ok.
Quoted 17 lines
Quoted 17 lines
qapi/virtio.json new file +17
-0+# +# @feature-names: names of device-specific features +# +# @host-features: bitmask of features, provided by devices +# +# @guest-features: bitmask of features, acknowledged by guest +# +# @status: virtio device status bitmask +# +# Since: 2.11.0 +# +## +{ + 'struct': 'VirtioInfoDevice', + 'data': { + 'qom_path': 'str', + 'feature-names': ['VirtioInfoBit'],Quoted 9 lines
qapi/virtio.json line 55
Quoted 3 lines
qapi/virtio.json new file +3
-0+ 'host-features': 'uint64', + 'guest-features': 'uint64', + 'status': 'uint64'I'm wondering if this is the best representation (where the caller has to parse the integer and then lookup in feature-names what each bit of the integer represents). But I'm not sure I have anything better off the top of my head.
Consider it as way to tell caller about names of supported features.
Quoted 24 lines
Quoted 11 lines
qapi/virtio.json new file +11
-0+ } +} + +## +# @VirtioInfo: +# +# Information about virtio devices +# +# @feature-names: names of common virtio features +# +# @status-names: names of bits which represents virtio device statusqapi/virtio.json line 76
Quoted 10 lines
qapi/virtio.json new file +10
-0+# +# @devices: list of per-device virtio information +# +# Since: 2.11.0 +# +## +{ + 'struct': 'VirtioInfo', + 'data': { + 'feature-names': ['VirtioInfoBit'],Why is feature-names listed at two different nestings of the return value?
Quoted 7 lines
Quoted 2 lines
These are different feature names. First names are common and predefined for all devices. Second names are device-specific.
If you can turn these into enums (union'd enums?) then you might be able to get rid of a lot of your array filling/naming conversion boilerplate. (Not sure if it's worth it, but it's worth looking).
I would be happy to drop this boilerplate, but how enum could help here? To respond my requirement it should be something like set, not enum. Even so, having set, I would have been needed to declare mapping between names in set type and bit numbers within feature bitmask.
Quoted 29 lines
Dave
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
qapi/virtio.json new file +12
-0+ 'status-names': ['VirtioInfoBit'], + 'devices': ['VirtioInfoDevice'] + } +} + + +## +# @query-virtio: +# +# Returns generic and per-device virtio information +# +# Since: 2.11.0Quoted 12 lines
Quoted 8 lines
Quoted 7 lines
qapi/virtio.json new file +6
-0+# +## +{ + 'command': 'query-virtio', + 'returns': 'VirtioInfo' +}Signature · 2 lines
Best regards Jan Dakinevich--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Signature · 2 lines
Best regards Jan Dakinevich
Re: [Qemu-devel] [PATCH v4 1/2] virtio: introduce `query-virtio' QMP command
Quoted 16 lines · Jan Dakinevich
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
qapi/virtio.json line 76
Quoted 4 lines
qapi/virtio.json new file +4
-0+{ + 'struct': 'VirtioInfo', + 'data': { + 'feature-names': ['VirtioInfoBit'],Why is feature-names listed at two different nestings of the return value?
Quoted 7 lines
Quoted 2 lines
These are different feature names. First names are common and predefined for all devices. Second names are device-specific.
If you can turn these into enums (union'd enums?) then you might be able to get rid of a lot of your array filling/naming conversion boilerplate. (Not sure if it's worth it, but it's worth looking).
Quoted 4 lines
I would be happy to drop this boilerplate, but how enum could help here? To respond my requirement it should be something like set, not enum. Even so, having set, I would have been needed to declare mapping between names in set type and bit numbers within feature bitmask.
Instead of returning a bitmask ("mask":123) as well as an array naming those bits ([{"bit":1,"name":"bit1"},{"bit":2","name":"bit2"},{"bit":4,"name":"bit4},...]), you could omit the bit numbers and just return an array of named bits (["bit1", "bit2", "bit4"]). An enum lets you declare up front what named bits are supported (and code can introspect when new named bits are supported in newer qemu).
Perhaps it's easier to first take a step back, and show what the desired output might be like, and then we can figure out how to represent that output in QAPI.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH v4 1/2] virtio: introduce `query-virtio' QMP command
Quoted 23 lines · Eric Blake
Quoted 16 lines · Jan Dakinevich
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
qapi/virtio.json line 76
Quoted 4 lines
qapi/virtio.json new file +4
-0+{ + 'struct': 'VirtioInfo', + 'data': { + 'feature-names': ['VirtioInfoBit'],Why is feature-names listed at two different nestings of the return value?
Quoted 7 lines
Quoted 2 lines
These are different feature names. First names are common and predefined for all devices. Second names are device-specific.
If you can turn these into enums (union'd enums?) then you might be able to get rid of a lot of your array filling/naming conversion boilerplate. (Not sure if it's worth it, but it's worth looking).
Quoted 4 lines
I would be happy to drop this boilerplate, but how enum could help here? To respond my requirement it should be something like set, not enum. Even so, having set, I would have been needed to declare mapping between names in set type and bit numbers within feature bitmask.
Quoted 8 lines
Instead of returning a bitmask ("mask":123) as well as an array naming those bits ([{"bit":1,"name":"bit1"},{"bit":2","name":"bit2"},{"bit":4,"name":"bit4},...]), you could omit the bit numbers and just return an array of named bits (["bit1", "bit2", "bit4"]). An enum lets you declare up front what named bits are supported (and code can introspect when new named bits are supported in newer qemu).
But how can I declare in this notation that name "bit1" is owned by bit #1, name "bit2" is owned by bit #2, name "bit4" is owned by bit #4, and all other bits has no names.
Quoted 4 lines
Perhaps it's easier to first take a step back, and show what the desired output might be like, and then we can figure out how to represent that output in QAPI.
Yeah... I expect the following HMP output:
(qmue) info virtio
virtio-blk-device at 0000:00:07.0
status: 0x07 acknowledge,driver,driver_ok
host features: 0x0000000179000e54
guest features: 0x0000000030000e54
common features:
notify_on_empty
any_layout
indirect_desc acked
event_idx acked
version_1
specific features:
seg_max acked
blk_size acked
flush acked
topology acked
virtio-serial-device at 0000:00:08.0
status: 0x07 acknowledge,driver,driver_ok
host features: 0x0000000179000006
guest features: 0x0000000030000002 common features:
notify_on_empty
any_layout
indirect_desc acked
event_idx acked
version_1
specific features:
multiport acked
emerg_write
Signature · 2 lines
Best regards Jan Dakinevich
Re: [Qemu-devel] [PATCH v4 1/2] virtio: introduce `query-virtio' QMP command
In reply to Jan DakinevichQuoted 75 lines · Jan Dakinevich
Quoted 31 lines · Eric Blake
Quoted 13 lines · Jan Dakinevich
The command is intended for gathering virtio information such as status, feature bits, negotiation status. It is convenient and useful for debug purpose.
The commands returns generic virtio information for virtio such as common feature names and status bits names and information for all attached to current machine devices.
To retrieve names of device-specific features `get_feature_name' callback in VirtioDeviceClass also was introduced.
Cc Denis V. Lunev <[email protected]>Signed-off-by Jan Dakinevich <[email protected]>Quoted 16 lines
--- hw/block/virtio-blk.c | 21 +++++++++ hw/char/virtio-serial-bus.c | 15 +++++++ hw/display/virtio-gpu.c | 13 ++++++ hw/net/virtio-net.c | 35 +++++++++++++++ hw/scsi/virtio-scsi.c | 16 +++++++ hw/virtio/Makefile.objs | 2 + hw/virtio/virtio-balloon.c | 15 +++++++ hw/virtio/virtio-stub.c | 9 ++++ hw/virtio/virtio.c | 101 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio.h | 2 + qapi-schema.json | 1 + qapi/virtio.json | 94 +++++++++++++++++++++++++++++++++++++++++ 12 files changed, 324 insertions(+) create mode 100644 hw/virtio/virtio-stub.c create mode 100644 qapi/virtio.jsonQuoted 5 lines
This creates a new .json file, but does not touch
MAINTAINERS. Our idea in splitting the .json files was to make it easier for each sub-file that needs a specific maintainer in addition to the overall *.json line for QAPI maintainers, so this may deserve aMAINTAINERSentry.Ok.
Quoted 22 lines
Quoted 22 lines
+++
b/qapi/virtio.jsonqapi/virtio.json new file +20
-0@@ -0,0 +1,94 @@ +# -*- Mode: Python -*- +# + +## +# = Virtio devices +## + +{ 'include': 'common.json' } + +## +# @VirtioInfoBit: +# +# Named virtio bit +# +# @bit: bit number +# +# @name: bit name +# +# Since: 2.11.0 +#Quoted 8 lines
qapi/virtio.json line 25
Quoted 5 lines
qapi/virtio.json new file +5
-0+## +{ + 'struct': 'VirtioInfoBit', + 'data': { + 'bit': 'uint64',Why is this a 64-bit value? Are the values 0-63, or are they 1, 2, 4, 8, ...? The documentation on 'bit number' is rather sparse.
I would prefer `uint' here, but I don't see generic unsigned type (may be, I am mistaken). I could use uint8 here, though.
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
qapi/virtio.json line 26
Quoted 1 line
qapi/virtio.json new file +1
-0+ 'name': 'str'Wouldn't an enum type be better than an open-ended string?
Bit names are not known here, they are obtained from virtio device implementations.
What exactly uses these bits?
Why do these uses justify pass-through? By pass-through, I mean the messenger (QEMU) merely passes them along, without understanding them. Defeats introspection.
Quoted 41 lines
Quoted 11 lines
qapi/virtio.json line 35
Quoted 9 lines
qapi/virtio.json new file +9
-0+ } +} + +## +# @VirtioInfoDevice: +# +# Information about specific virtio device +# +# @qom_path: QOM path of the devicePlease make this 'qom-path' - new interfaces should prefer '-' over '_'.
Ok.
Quoted 17 lines
Quoted 17 lines
qapi/virtio.json new file +17
-0+# +# @feature-names: names of device-specific features +# +# @host-features: bitmask of features, provided by devices +# +# @guest-features: bitmask of features, acknowledged by guest +# +# @status: virtio device status bitmask +# +# Since: 2.11.0 +# +## +{ + 'struct': 'VirtioInfoDevice', + 'data': { + 'qom_path': 'str', + 'feature-names': ['VirtioInfoBit'],Quoted 9 lines
qapi/virtio.json line 55
Quoted 3 lines
qapi/virtio.json new file +3
-0+ 'host-features': 'uint64', + 'guest-features': 'uint64', + 'status': 'uint64'I'm wondering if this is the best representation (where the caller has to parse the integer and then lookup in feature-names what each bit of the integer represents). But I'm not sure I have anything better off the top of my head.
Quoted 1 line
Consider it as way to tell caller about names of supported features.
"Unsigned integer interpreted as combination of well-known bit-valued symbols" is a fine C interface, but a pretty horrid QMP interface. What's wrong with doing a set the straightforward way as "array of enum"?
Quoted 48 lines
Quoted 15 lines
Quoted 15 lines
qapi/virtio.json new file +15
-0+ } +} + +## +# @VirtioInfo: +# +# Information about virtio devices +# +# @feature-names: names of common virtio features +# +# @status-names: names of bits which represents virtio device status +# +# @devices: list of per-device virtio information +# +# Since: 2.11.0Quoted 9 lines
qapi/virtio.json line 76
Quoted 6 lines
qapi/virtio.json new file +6
-0+# +## +{ + 'struct': 'VirtioInfo', + 'data': { + 'feature-names': ['VirtioInfoBit'],Why is feature-names listed at two different nestings of the return value?
These are different feature names. First names are common and predefined for all devices. Second names are device-specific.
Quoted 20 lines
Quoted 19 lines
qapi/virtio.json new file +18
-0+ 'status-names': ['VirtioInfoBit'], + 'devices': ['VirtioInfoDevice'] + } +} + + +## +# @query-virtio: +# +# Returns generic and per-device virtio information +# +# Since: 2.11.0 +# +## +{ + 'command': 'query-virtio', + 'returns': 'VirtioInfo' +}
Re: [Qemu-devel] [PATCH v4 1/2] virtio: introduce `query-virtio' QMP command
Quoted 82 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 80 lines · Jan Dakinevich
Quoted 31 lines · Eric Blake
Quoted 13 lines · Jan Dakinevich
The command is intended for gathering virtio information such as status, feature bits, negotiation status. It is convenient and useful for debug purpose.
The commands returns generic virtio information for virtio such as common feature names and status bits names and information for all attached to current machine devices.
To retrieve names of device-specific features `get_feature_name' callback in VirtioDeviceClass also was introduced.
Cc Denis V. Lunev <[email protected]>Signed-off-by Jan Dakinevich <[email protected]>Quoted 16 lines
--- hw/block/virtio-blk.c | 21 +++++++++ hw/char/virtio-serial-bus.c | 15 +++++++ hw/display/virtio-gpu.c | 13 ++++++ hw/net/virtio-net.c | 35 +++++++++++++++ hw/scsi/virtio-scsi.c | 16 +++++++ hw/virtio/Makefile.objs | 2 + hw/virtio/virtio-balloon.c | 15 +++++++ hw/virtio/virtio-stub.c | 9 ++++ hw/virtio/virtio.c | 101 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio.h | 2 + qapi-schema.json | 1 + qapi/virtio.json | 94 +++++++++++++++++++++++++++++++++++++++++ 12 files changed, 324 insertions(+) create mode 100644 hw/virtio/virtio-stub.c create mode 100644 qapi/virtio.jsonQuoted 5 lines
This creates a new .json file, but does not touch
MAINTAINERS. Our idea in splitting the .json files was to make it easier for each sub-file that needs a specific maintainer in addition to the overall *.json line for QAPI maintainers, so this may deserve aMAINTAINERSentry.Ok.
Quoted 22 lines
Quoted 22 lines
+++
b/qapi/virtio.jsonqapi/virtio.json new file +20
-0@@ -0,0 +1,94 @@ +# -*- Mode: Python -*- +# + +## +# = Virtio devices +## + +{ 'include': 'common.json' } + +## +# @VirtioInfoBit: +# +# Named virtio bit +# +# @bit: bit number +# +# @name: bit name +# +# Since: 2.11.0 +#Quoted 8 lines
qapi/virtio.json line 25
Quoted 5 lines
qapi/virtio.json new file +5
-0+## +{ + 'struct': 'VirtioInfoBit', + 'data': { + 'bit': 'uint64',Why is this a 64-bit value? Are the values 0-63, or are they 1, 2, 4, 8, ...? The documentation on 'bit number' is rather sparse.
I would prefer `uint' here, but I don't see generic unsigned type (may be, I am mistaken). I could use uint8 here, though.
Quoted 5 lines
qapi/virtio.json line 26
Quoted 2 lines
qapi/virtio.json new file +1
-0+ 'name': 'str'Wouldn't an enum type be better than an open-ended string?
Quoted 8 lines
Quoted 2 lines
Bit names are not known here, they are obtained from virtio device implementations.
What exactly uses these bits?
Why do these uses justify pass-through? By pass-through, I mean the messenger (QEMU) merely passes them along, without understanding them. Defeats introspection.
It should be noted originally it was HMP - this was just a debug command and it's only getting the need to be introspectable because people insisted it had a QMP version.
I think the intent is to print all flags, even ones we dont yet understand.
Dave
Quoted 41 lines
Quoted 41 lines
Quoted 11 lines
qapi/virtio.json line 35
Quoted 9 lines
qapi/virtio.json new file +9
-0+ } +} + +## +# @VirtioInfoDevice: +# +# Information about specific virtio device +# +# @qom_path: QOM path of the devicePlease make this 'qom-path' - new interfaces should prefer '-' over '_'.
Ok.
Quoted 26 lines
Quoted 10 lines
qapi/virtio.json new file +10
-0+# +# @feature-names: names of device-specific features +# +# @host-features: bitmask of features, provided by devices +# +# @guest-features: bitmask of features, acknowledged by guest +# +# @status: virtio device status bitmask +# +# Since: 2.11.0qapi/virtio.json line 55
Quoted 10 lines
qapi/virtio.json new file +10
-0+# +## +{ + 'struct': 'VirtioInfoDevice', + 'data': { + 'qom_path': 'str', + 'feature-names': ['VirtioInfoBit'], + 'host-features': 'uint64', + 'guest-features': 'uint64', + 'status': 'uint64'I'm wondering if this is the best representation (where the caller has to parse the integer and then lookup in feature-names what each bit of the integer represents). But I'm not sure I have anything better off the top of my head.
Quoted 55 lines
Quoted 1 line
Consider it as way to tell caller about names of supported features.
"Unsigned integer interpreted as combination of well-known bit-valued symbols" is a fine C interface, but a pretty horrid QMP interface. What's wrong with doing a set the straightforward way as "array of enum"?
Quoted 48 lines
Quoted 15 lines
Quoted 15 lines
qapi/virtio.json new file +15
-0+ } +} + +## +# @VirtioInfo: +# +# Information about virtio devices +# +# @feature-names: names of common virtio features +# +# @status-names: names of bits which represents virtio device status +# +# @devices: list of per-device virtio information +# +# Since: 2.11.0Quoted 9 lines
qapi/virtio.json line 76
Quoted 6 lines
qapi/virtio.json new file +6
-0+# +## +{ + 'struct': 'VirtioInfo', + 'data': { + 'feature-names': ['VirtioInfoBit'],Why is feature-names listed at two different nestings of the return value?
These are different feature names. First names are common and predefined for all devices. Second names are device-specific.
Quoted 20 lines
Quoted 19 lines
qapi/virtio.json new file +18
-0+ 'status-names': ['VirtioInfoBit'], + 'devices': ['VirtioInfoDevice'] + } +} + + +## +# @query-virtio: +# +# Returns generic and per-device virtio information +# +# Since: 2.11.0 +# +## +{ + 'command': 'query-virtio', + 'returns': 'VirtioInfo' +}
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH v4 2/2 virtio: add `info virtio' HMP command
In reply to Jan DakinevichThe command prints data from `query-virtio' QMP in human-readable format.
--- hmp-commands-info.hx | 14 ++++++++++ hmp.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++ hmp.h | 1 + 3 files changed, 94 insertions(+)
hmp-commands-info.hx +14 -0
@@ -868,6 +868,20 @@ ETEXI }, STEXI +@item info virtio +@findex virtio +Display guest and host fetures for all virtio devices. +ETEXI + + { + .name = "virtio", + .args_type = "", + .params = "", + .help = "show virtio info", + .cmd = hmp_info_virtio, + }, + +STEXI @end table ETEXI
hmp.c +79 -0
88 lines not on this page · raw message
hmp.h +1 -0
@@ -146,5 +146,6 @@ void hmp_info_ramblock(Monitor *mon, const QDict *qdict);void hmp_hotpluggable_cpus (Monitor *mon,const QDict *qdict);void hmp_info_vm_generation_id (Monitor *mon,const QDict *qdict);void hmp_info_memory_size_summary (Monitor *mon,const QDict *qdict); +void hmp_info_virtio (Monitor *mon,const QDict *qdict);#endif
Signature · 1 line
2.1.4