virtio: Provide version-specific variants of virtio PCI devices
v3 cover virtio: Provide version-specific variants of virtio PCI devices
Existing modern-only device types are not being touched by v3, as they don't need separate variants. However, I plan to implement separate cleanups in the code that calls virtio_pci_force_virtio_1(), first, and then propose additional changes (e.g. deprecating disable-legacy and disable-modern in those device types).
Changes v2 -> v3:
* Split into two separate patches (type registration helper and introduction of new types)
* Rewrote virtio_pci_types_register() completely:
* Replaced magic generation of type names with explicit fields in VirtioPCIDeviceTypeInfo
* Removed modern_only field (not necessary anymore)
* Don't register a separate base type unless necessary
Changes v1 -> v2:
* Removed *-0.9 devices. Nobody will want to use them, if transitional devices work with legacy drivers
(Gerd Hoffmann, Michael S. Tsirkin)
* Drop virtio version from name: rename -1.0-transitional to -transitional (Michael S. Tsirkin)
* Renamed -1.0 to -non-transitional
* Don't add any extra variants to modern-only device types (they don't need it)
* Fix typo on TYPE_VIRTIO_INPUT_HOST_PCI (crash reported by Cornelia Huck)
* No need to change cast macros for modern-only devices
* Rename virtio_register_types() to virtio_pci_types_register()
Original patch description:
Many of the current virtio-*-pci device types actually represent 3 different types of devices:
* virtio 1.0 non-transitional devices
* virtio 1.0 transitional devices
* virtio 0.9 ("legacy device" in virtio 1.0 terminology)
That would be just an annoyance if it didn't break our device/bus compatibility QMP interfaces. With this multi-purpose device type, there's no way to tell management software that transitional devices and legacy devices require a Conventional PCI bus.
The multi-purpose device types would also prevent us from telling management software what's the PCI vendor/device ID for them, because their PCI IDs change at runtime depending on the bus where they were plugged.
This patch adds separate device types for each of those virtio device flavors:
* virtio-*-pci: the existing multi-purpose device types
* virtio-*-pci-transitional: virtio-1.0 device supporting legacy drivers
* virtio-*-pci-non-transitional: modern-only
Reference to previous discussion that originated this idea:
https://www.mail-archive.com/[email protected]/msg558389.html
Eduardo Habkost (2):
virtio: Helper for registering virtio device types
virtio: Provide version-specific variants of virtio PCI devices
hw/virtio/virtio-pci.h | 78 +++++++-- hw/display/virtio-gpu-pci.c | 7 +- hw/display/virtio-vga.c | 7 +- hw/virtio/virtio-crypto-pci.c | 7 +- hw/virtio/virtio-pci.c | 267 ++++++++++++++++++++++------- tests/acceptance/virtio_version.py | 177 +++++++++++++++++++ 6 files changed, 453 insertions(+), 90 deletions(-) create mode 100644 tests/acceptance/virtio_version.py
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
PATCH v3 1/2 virtio: Helper for registering virtio device types
Introduce a helper for registering different flavours of virtio devices. Convert code to use the helper, but keep only the existing generic types. Transitional and non-transitional device types will be added by another patch.
---
Changes v2 -> v3:
* Split into two separate patches (type registration helper and introduction of new types)
* Rewrote comments describing each flavour
* Rewrote virtio_pci_types_register() completely:
* Replaced magic generation of type names with explicit fields in VirtioPCIDeviceTypeInfo
* Removed modern_only field (won't be used anymore)
* Don't register a separate base type unless it's required by the caller
--- hw/virtio/virtio-pci.h | 54 ++++++++ hw/display/virtio-gpu-pci.c | 7 +- hw/display/virtio-vga.c | 7 +- hw/virtio/virtio-crypto-pci.c | 7 +- hw/virtio/virtio-pci.c | 231 ++++++++++++++++++++++++---------- 5 files changed, 228 insertions(+), 78 deletions(-)
hw/virtio/virtio-pci.h +54 -0
@@ -417,4 +417,58 @@ struct VirtIOCryptoPCI {/* Virtio ABI version, if we increment this, we break the guest driver. */ #define VIRTIO_PCI_ABI_VERSION 0 +/* Input for virtio_pci_types_register() */ +typedef struct VirtioPCIDeviceTypeInfo { +/* +* Common base class for the subclasses below. +* +* Required only if transitional_name or non_transitional_name is set. +* +* We need a separate base type instead of making all types +* inherit from generic_name for two reasons: +* 1) generic_name implements INTERFACE_PCIE_DEVICE, but +* transitional_name don't. +* 2) generic_name has the "disable-legacy" and "disable-modern" +* properties, transitional_name and non_transitional name don't. +*/ +const char *base_name; +/* +* Generic device type. Optional. +* +* Supports both transitional and non-transitional modes, +* using the disable-legacy and disable-modern properties. +* If disable-legacy=auto, (non-)transitional mode is selected +* depending on the bus where the device is plugged. +* +* Implements both INTERFACE_PCIE_DEVICE and INTERFACE_CONVENTIONAL_PCI_DEVICE, +* but PCI Express is supported only in non-transitional mode. +* +* The only type implemented by QEMU 3.1 and older. +*/ +const char *generic_name; +/* +* The non-transitional device type. Optional. +* +* Implements both INTERFACE_PCIE_DEVICE and INTERFACE_CONVENTIONAL_PCI_DEVICE. +*/ +const char *transitional_name; +/* +* The transitional device type. Optional. +* +* Implements INTERFACE_CONVENTIONAL_PCI_DEVICE only. +*/ +const char *non_transitional_name; + +/* Parent type. If NULL, TYPE_VIRTIO_PCI is used */ +const char *parent; + +/* Same as TypeInfo fields: */ +size_t instance_size; +void (*instance_init)(Object *obj); +void (*class_init)(ObjectClass *klass,void *data); +}VirtioPCIDeviceTypeInfo ; + +/* Register virtio-pci type(s). @t must be static. */ +void virtio_pci_types_register (const VirtioPCIDeviceTypeInfo *t); +#endif
hw/display/virtio-gpu-pci.c +3 -4
@@ -69,9 +69,8 @@ static void virtio_gpu_initfn(Object *obj) TYPE_VIRTIO_GPU); } -static const TypeInfo virtio_gpu_pci_info = { - .name =TYPE_VIRTIO_GPU_PCI , - .parent =TYPE_VIRTIO_PCI , +static const VirtioPCIDeviceTypeInfo virtio_gpu_pci_info = { + .generic_name =TYPE_VIRTIO_GPU_PCI , .instance_size =sizeof (VirtIOGPUPCI), .instance_init = virtio_gpu_initfn, .class_init = virtio_gpu_pci_class_init,
@@ -79,6 +78,6 @@ static const TypeInfo virtio_gpu_pci_info = {static void virtio_gpu_pci_register_types (void ) { -type_register_static (&virtio_gpu_pci_info); +virtio_pci_types_register (&virtio_gpu_pci_info); }type_init (virtio_gpu_pci_register_types)
hw/display/virtio-vga.c +3 -4
@@ -207,9 +207,8 @@ static void virtio_vga_inst_initfn(Object *obj) TYPE_VIRTIO_GPU); } -static TypeInfo virtio_vga_info = { - .name =TYPE_VIRTIO_VGA , - .parent =TYPE_VIRTIO_PCI , +static VirtioPCIDeviceTypeInfo virtio_vga_info = { + .generic_name =TYPE_VIRTIO_VGA , .instance_size =sizeof (struct VirtIOVGA ), .instance_init = virtio_vga_inst_initfn, .class_init = virtio_vga_class_init,
@@ -217,7 +216,7 @@ static TypeInfo virtio_vga_info = {static void virtio_vga_register_types (void ) { -type_register_static (&virtio_vga_info); +virtio_pci_types_register (&virtio_vga_info); }type_init (virtio_vga_register_types)
hw/virtio/virtio-crypto-pci.c +3 -4
@@ -64,9 +64,8 @@ static void virtio_crypto_initfn(Object *obj) TYPE_VIRTIO_CRYPTO); } -static const TypeInfo virtio_crypto_pci_info = { - .name =TYPE_VIRTIO_CRYPTO_PCI , - .parent =TYPE_VIRTIO_PCI , +static const VirtioPCIDeviceTypeInfo virtio_crypto_pci_info = { + .generic_name =TYPE_VIRTIO_CRYPTO_PCI , .instance_size =sizeof (VirtIOCryptoPCI), .instance_init = virtio_crypto_initfn, .class_init = virtio_crypto_pci_class_init,
@@ -74,6 +73,6 @@ static const TypeInfo virtio_crypto_pci_info = {static void virtio_crypto_pci_register_types (void ) { -type_register_static (&virtio_crypto_pci_info); +virtio_pci_types_register (&virtio_crypto_pci_info); }type_init (virtio_crypto_pci_register_types)
hw/virtio/virtio-pci.c +165 -66
354 lines not on this page · raw message
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
Re: [Qemu-devel] [PATCH for-4.0 v3 1/2] virtio: Helper for registering virtio device types
Quoted 35 lines · On Tue, 27 Nov 2018 00:49:58 -0200 Eduardo Habkost <[email protected]> wrote:
Introduce a helper for registering different flavours of virtio devices. Convert code to use the helper, but keep only the existing generic types. Transitional and non-transitional device types will be added by another patch.
Acked-by Andrea Bolognani <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>---
Changes v2 -> v3:
* Split into two separate patches (type registration helper and introduction of new types)
* Rewrote comments describing each flavour
* Rewrotevirtio_pci_types_register()completely:
* Replaced magic generation of type names with explicit fields in VirtioPCIDeviceTypeInfo
* Removedmodern_onlyfield (won't be used anymore)
* Don't register a separate base type unless it's required by the caller--- hw/virtio/virtio-pci.h | 54 ++++++++ hw/display/virtio-gpu-pci.c | 7 +- hw/display/virtio-vga.c | 7 +- hw/virtio/virtio-crypto-pci.c | 7 +- hw/virtio/virtio-pci.c | 231 ++++++++++++++++++++++++---------- 5 files changed, 228 insertions(+), 78 deletions(-)hw/virtio/virtio-pci.h +1
-0@@ -417,4 +417,58 @@ struct VirtIOCryptoPCI {/* Virtio ABI version, if we increment this, we break the guest driver. */ #define VIRTIO_PCI_ABI_VERSION 0 +/* Input for virtio_pci_types_register() */
hw/virtio/virtio-pci.h struct VirtIOCryptoPCI { · line 430
Quoted 10 lines
hw/virtio/virtio-pci.h +10
-0+typedef struct VirtioPCIDeviceTypeInfo { + /* + * Common base class for the subclasses below. + * + * Required only if transitional_name or non_transitional_name is set. + * + * We need a separate base type instead of making all types + * inherit from generic_name for two reasons: + * 1) generic_name implements INTERFACE_PCIE_DEVICE, but + * transitional_name don't.
s/don't/does not/
Quoted 10 lines
hw/virtio/virtio-pci.h +10
-0+* 2) generic_name has the "disable-legacy" and "disable-modern" +* properties, transitional_name and non_transitional name don't. +*/ +const char *base_name; +/* +* Generic device type. Optional. +* +* Supports both transitional and non-transitional modes, +* using the disable-legacy and disable-modern properties. +* If disable-legacy=auto, (non-)transitional mode is selected
hw/virtio/virtio-pci.h struct VirtIOCryptoPCI { · line 450
Quoted 10 lines
hw/virtio/virtio-pci.h +10
-0+* depending on the bus where the device is plugged. +* +* Implements both INTERFACE_PCIE_DEVICE and INTERFACE_CONVENTIONAL_PCI_DEVICE, +* but PCI Express is supported only in non-transitional mode. +* +* The only type implemented by QEMU 3.1 and older. +*/ +const char *generic_name; +/* +* The non-transitional device type. Optional.
That's transitional...
hw/virtio/virtio-pci.h struct VirtIOCryptoPCI { · line 456
Quoted 6 lines
hw/virtio/virtio-pci.h +6
-0+* +* Implements both INTERFACE_PCIE_DEVICE and INTERFACE_CONVENTIONAL_PCI_DEVICE. +*/ +const char *transitional_name; +/* +* The transitional device type. Optional.
...and that's non-transitional :)
hw/virtio/virtio-pci.h struct VirtIOCryptoPCI { · line 469
Quoted 13 lines
hw/virtio/virtio-pci.h +13
-0+* +* Implements INTERFACE_CONVENTIONAL_PCI_DEVICE only. +*/ +const char *non_transitional_name; + +/* Parent type. If NULL, TYPE_VIRTIO_PCI is used */ +const char *parent; + +/* Same as TypeInfo fields: */ +size_t instance_size; +void (*instance_init)(Object *obj); +void (*class_init)(ObjectClass *klass,void *data); +} VirtioPCIDeviceTypeInfo;
That's a bit of boilerplate, but the end result seems to be more greppable.
hw/virtio/virtio-pci.h struct VirtIOCryptoPCI { · line 474
Quoted 5 lines
hw/virtio/virtio-pci.h +4
-0+ +/* Register virtio-pci type(s). @t must be static. */ +void virtio_pci_types_register (const VirtioPCIDeviceTypeInfo *t); +#endif
(...)
Looks sane to me. With the typos fixed,
Re: [Qemu-devel] [PATCH for-4.0 v3 1/2] virtio: Helper for registering virtio device types
Quoted 37 lines · Cornelia Huck
Quoted 34 lines · On Tue, 27 Nov 2018 00:49:58 -0200 Eduardo Habkost <[email protected]> wrote:
Introduce a helper for registering different flavours of virtio devices. Convert code to use the helper, but keep only the existing generic types. Transitional and non-transitional device types will be added by another patch.
Acked-by Andrea Bolognani <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>---
Changes v2 -> v3:
* Split into two separate patches (type registration helper and introduction of new types)
* Rewrote comments describing each flavour
* Rewrotevirtio_pci_types_register()completely:
* Replaced magic generation of type names with explicit fields in VirtioPCIDeviceTypeInfo
* Removedmodern_onlyfield (won't be used anymore)
* Don't register a separate base type unless it's required by the caller--- hw/virtio/virtio-pci.h | 54 ++++++++ hw/display/virtio-gpu-pci.c | 7 +- hw/display/virtio-vga.c | 7 +- hw/virtio/virtio-crypto-pci.c | 7 +- hw/virtio/virtio-pci.c | 231 ++++++++++++++++++++++++---------- 5 files changed, 228 insertions(+), 78 deletions(-)hw/virtio/virtio-pci.h +0
-0@@ -417,4 +417,58 @@ struct VirtIOCryptoPCI {/* Virtio ABI version, if we increment this, we break the guest driver. */ #define VIRTIO_PCI_ABI_VERSION 0
Quoted 13 lines
hw/virtio/virtio-pci.h struct VirtIOCryptoPCI { · line 430
Quoted 11 lines
hw/virtio/virtio-pci.h +11
-0+/* Input for virtio_pci_types_register() */ +typedef struct VirtioPCIDeviceTypeInfo { + /* + * Common base class for the subclasses below. + * + * Required only if transitional_name or non_transitional_name is set. + * + * We need a separate base type instead of making all types + * inherit from generic_name for two reasons: + * 1) generic_name implements INTERFACE_PCIE_DEVICE, but + * transitional_name don't.s/don't/does not/
Fixed, thanks!
Quoted 22 lines
Quoted 11 lines
hw/virtio/virtio-pci.h +10
-0+* 2) generic_name has the "disable-legacy" and "disable-modern" +* properties, transitional_name and non_transitional name don't. +*/ +const char *base_name; +/* +* Generic device type. Optional. +* +* Supports both transitional and non-transitional modes, +* using the disable-legacy and disable-modern properties. +* If disable-legacy=auto, (non-)transitional mode is selected hw/virtio/virtio-pci.h struct VirtIOCryptoPCI { · line 450
Quoted 10 lines
hw/virtio/virtio-pci.h +10
-0+* depending on the bus where the device is plugged. +* +* Implements both INTERFACE_PCIE_DEVICE and INTERFACE_CONVENTIONAL_PCI_DEVICE, +* but PCI Express is supported only in non-transitional mode. +* +* The only type implemented by QEMU 3.1 and older. +*/ +const char *generic_name; +/* +* The non-transitional device type. Optional.
Quoted 1 line
That's transitional...
Oops. Fixed, thanks!
Quoted 9 lines
hw/virtio/virtio-pci.h struct VirtIOCryptoPCI { · line 456
Quoted 7 lines
hw/virtio/virtio-pci.h +6
-0+* +* Implements both INTERFACE_PCIE_DEVICE and INTERFACE_CONVENTIONAL_PCI_DEVICE. +*/ +const char *transitional_name; +/* +* The transitional device type. Optional. ...and that's non-transitional :)
Oops. Fixed, thanks!
Quoted 17 lines
Quoted 4 lines
hw/virtio/virtio-pci.h +3
-0+* +* Implements INTERFACE_CONVENTIONAL_PCI_DEVICE only. +*/ hw/virtio/virtio-pci.h struct VirtIOCryptoPCI { · line 469
Quoted 10 lines
hw/virtio/virtio-pci.h +10
-0+const char *non_transitional_name; + +/* Parent type. If NULL, TYPE_VIRTIO_PCI is used */ +const char *parent; + +/* Same as TypeInfo fields: */ +size_t instance_size; +void (*instance_init)(Object *obj); +void (*class_init)(ObjectClass *klass,void *data); +} VirtioPCIDeviceTypeInfo;That's a bit of boilerplate, but the end result seems to be more greppable.
Right. Also, only old devices that have transitional versions will need to use all fields. The modern-only devices now have less boilerplate (because parent is optional).
Quoted 9 lines
Quoted 6 lines
hw/virtio/virtio-pci.h +4
-0+ +/* Register virtio-pci type(s). @t must be static. */ +void virtio_pci_types_register (const VirtioPCIDeviceTypeInfo *t); +#endif (...)
Quoted 3 lines
Looks sane to me. With the typos fixed,
Reviewed-by Cornelia Huck <[email protected]>
Thanks!
Signature · 1 line
Eduardo
PATCH v3 2/2 virtio: Provide version-specific variants of virtio PCI devices
In reply to Eduardo HabkostMany of the current virtio-*-pci device types actually represent 3 different types of devices:
* virtio 1.0 non-transitional devices
* virtio 1.0 transitional devices
* virtio 0.9 ("legacy device" in virtio 1.0 terminology)
That would be just an annoyance if it didn't break our device/bus compatibility QMP interfaces. With these multi-purpose device types, there's no way to tell management software that transitional devices and legacy devices require a Conventional PCI bus.
The multi-purpose device types would also prevent us from telling management software what's the PCI vendor/device ID for them, because their PCI IDs change at runtime depending on the bus where they were plugged.
This patch adds separate device types for each of those virtio device flavors:
- virtio-*-pci: the existing multi-purpose device types
- Configurable using disable-legacy and disable-modern properties
- Legacy driver support is automatically enabled/disabled depending on the bus where it is plugged
- Supports Conventional PCI and PCI Express buses
(but Conventional PCI is incompatible with disable-legacy=off)
- Changes PCI vendor/device IDs at runtime
- virtio-*-pci-transitional: virtio-1.0 device supporting legacy drivers
- Supports Conventional PCI buses only, because
it has a PIO BAR
- virtio-*-pci-non-transitional: modern-only
- Supports both Conventional PCI and PCI Express buses
The existing TYPE_* macros for these types will point to an abstract base type, so existing casts in the code will keep working for all variants.
A simple test script (tests/acceptance/virtio_version.py) is included, to check if the new device types are equivalent to using the disable-legacy and disable-modern options.
---
Changes v2 -> v3:
* Split into two separate patches (type registration helper and introduction of new types)
* Include full type names as literals in the code instead of generating type names automatically
Changes v1 -> v2:
* Removed *-0.9 devices. Nobody will want to use them, if transitional devices work with legacy drivers
(Gerd Hoffmann, Michael S. Tsirkin)
* Drop virtio version from name: rename -1.0-transitional to -transitional (Michael S. Tsirkin)
* Renamed -1.0 to -non-transitional
* Don't add any extra variants to modern-only device types (they don't need it)
* Fix typo on TYPE_VIRTIO_INPUT_HOST_PCI (crash reported by Cornelia Huck)
* No need to change cast macros for modern-only devices
* Rename virtio_register_types() to virtio_pci_types_register()
--- hw/virtio/virtio-pci.h | 24 ++-- hw/virtio/virtio-pci.c | 60 ++++++++-- tests/acceptance/virtio_version.py | 177 +++++++++++++++++++++++++++++ 3 files changed, 237 insertions(+), 24 deletions(-) create mode 100644 tests/acceptance/virtio_version.py
hw/virtio/virtio-pci.h +12 -12
@@ -216,7 +216,7 @@ static inline void virtio_pci_disable_modern(VirtIOPCIProxy *proxy)/* * virtio-scsi-pci: This extends VirtioPCIProxy. */ -#define TYPE_VIRTIO_SCSI_PCI "virtio-scsi-pci" +#define TYPE_VIRTIO_SCSI_PCI "virtio-scsi-pci-base"#define VIRTIO_SCSI_PCI (obj) \ OBJECT_CHECK(VirtIOSCSIPCI, (obj), TYPE_VIRTIO_SCSI_PCI)
@@ -229,7 +229,7 @@ struct VirtIOSCSIPCI {/* * vhost-scsi-pci: This extends VirtioPCIProxy. */ -#define TYPE_VHOST_SCSI_PCI "vhost-scsi-pci" +#define TYPE_VHOST_SCSI_PCI "vhost-scsi-pci-base"#define VHOST_SCSI_PCI (obj) \ OBJECT_CHECK(VHostSCSIPCI, (obj), TYPE_VHOST_SCSI_PCI)
@@ -239,7 +239,7 @@ struct VHostSCSIPCI { };#endif -#define TYPE_VHOST_USER_SCSI_PCI "vhost-user-scsi-pci" +#define TYPE_VHOST_USER_SCSI_PCI "vhost-user-scsi-pci-base"#define VHOST_USER_SCSI_PCI (obj) \ OBJECT_CHECK(VHostUserSCSIPCI, (obj), TYPE_VHOST_USER_SCSI_PCI)
@@ -252,7 +252,7 @@ struct VHostUserSCSIPCI {/* * vhost-user-blk-pci: This extends VirtioPCIProxy. */ -#define TYPE_VHOST_USER_BLK_PCI "vhost-user-blk-pci" +#define TYPE_VHOST_USER_BLK_PCI "vhost-user-blk-pci-base"#define VHOST_USER_BLK_PCI (obj) \ OBJECT_CHECK(VHostUserBlkPCI, (obj), TYPE_VHOST_USER_BLK_PCI)
@@ -265,7 +265,7 @@ struct VHostUserBlkPCI {/* * virtio-blk-pci: This extends VirtioPCIProxy. */ -#define TYPE_VIRTIO_BLK_PCI "virtio-blk-pci" +#define TYPE_VIRTIO_BLK_PCI "virtio-blk-pci-base"#define VIRTIO_BLK_PCI (obj) \ OBJECT_CHECK(VirtIOBlkPCI, (obj), TYPE_VIRTIO_BLK_PCI)
@@ -277,7 +277,7 @@ struct VirtIOBlkPCI {/* * virtio-balloon-pci: This extends VirtioPCIProxy. */ -#define TYPE_VIRTIO_BALLOON_PCI "virtio-balloon-pci" +#define TYPE_VIRTIO_BALLOON_PCI "virtio-balloon-pci-base"#define VIRTIO_BALLOON_PCI (obj) \ OBJECT_CHECK(VirtIOBalloonPCI, (obj), TYPE_VIRTIO_BALLOON_PCI)
@@ -289,7 +289,7 @@ struct VirtIOBalloonPCI {/* * virtio-serial-pci: This extends VirtioPCIProxy. */ -#define TYPE_VIRTIO_SERIAL_PCI "virtio-serial-pci" +#define TYPE_VIRTIO_SERIAL_PCI "virtio-serial-pci-base"#define VIRTIO_SERIAL_PCI (obj) \ OBJECT_CHECK(VirtIOSerialPCI, (obj), TYPE_VIRTIO_SERIAL_PCI)
@@ -301,7 +301,7 @@ struct VirtIOSerialPCI {/* * virtio-net-pci: This extends VirtioPCIProxy. */ -#define TYPE_VIRTIO_NET_PCI "virtio-net-pci" +#define TYPE_VIRTIO_NET_PCI "virtio-net-pci-base"#define VIRTIO_NET_PCI (obj) \ OBJECT_CHECK(VirtIONetPCI, (obj), TYPE_VIRTIO_NET_PCI)
@@ -316,7 +316,7 @@ struct VirtIONetPCI {#ifdef CONFIG_VIRTFS -#define TYPE_VIRTIO_9P_PCI "virtio-9p-pci" +#define TYPE_VIRTIO_9P_PCI "virtio-9p-pci-base"#define VIRTIO_9P_PCI (obj) \ OBJECT_CHECK(V9fsPCIState, (obj), TYPE_VIRTIO_9P_PCI)
@@ -330,7 +330,7 @@ typedef struct V9fsPCIState {/* * virtio-rng-pci: This extends VirtioPCIProxy. */ -#define TYPE_VIRTIO_RNG_PCI "virtio-rng-pci" +#define TYPE_VIRTIO_RNG_PCI "virtio-rng-pci-base"#define VIRTIO_RNG_PCI (obj) \ OBJECT_CHECK(VirtIORngPCI, (obj), TYPE_VIRTIO_RNG_PCI)
@@ -365,7 +365,7 @@ struct VirtIOInputHIDPCI {#ifdef CONFIG_LINUX -#define TYPE_VIRTIO_INPUT_HOST_PCI "virtio-input-host-pci" +#define TYPE_VIRTIO_INPUT_HOST_PCI "virtio-input-host-pci-base"#define VIRTIO_INPUT_HOST_PCI (obj) \ OBJECT_CHECK(VirtIOInputHostPCI, (obj), TYPE_VIRTIO_INPUT_HOST_PCI)
@@ -392,7 +392,7 @@ struct VirtIOGPUPCI {/* * vhost-vsock-pci: This extends VirtioPCIProxy. */ -#define TYPE_VHOST_VSOCK_PCI "vhost-vsock-pci" +#define TYPE_VHOST_VSOCK_PCI "vhost-vsock-pci-base"#define VHOST_VSOCK_PCI (obj) \ OBJECT_CHECK(VHostVSockPCI, (obj), TYPE_VHOST_VSOCK_PCI)
hw/virtio/virtio-pci.c +48 -12
132 lines not on this page · raw message
tests/acceptance/virtio_version.py new file +177 -0
177 lines not on this page · raw message
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
Quoted 72 lines · On Tue, 27 Nov 2018 00:49:59 -0200 Eduardo Habkost <[email protected]> wrote:
Many of the current virtio-*-pci device types actually represent 3 different types of devices:
* virtio 1.0 non-transitional devices
* virtio 1.0 transitional devices
* virtio 0.9 ("legacy device" in virtio 1.0 terminology)That would be just an annoyance if it didn't break our device/bus compatibility QMP interfaces. With these multi-purpose device types, there's no way to tell management software that transitional devices and legacy devices require a Conventional PCI bus.
The multi-purpose device types would also prevent us from telling management software what's the PCI vendor/device ID for them, because their PCI IDs change at runtime depending on the bus where they were plugged.
This patch adds separate device types for each of those virtio device flavors:
- virtio-*-pci: the existing multi-purpose device types
- Configurable usingdisable-legacyanddisable-modernproperties
- Legacy driver support is automatically enabled/disabled depending on the bus where it is plugged
- Supports Conventional PCI and PCI Express buses
(but Conventional PCI is incompatible with disable-legacy=off)
- Changes PCI vendor/device IDs at runtime
- virtio-*-pci-transitional: virtio-1.0 device supporting legacy drivers
- Supports Conventional PCI buses only, because
it has a PIO BAR
- virtio-*-pci-non-transitional: modern-only
- Supports both Conventional PCI and PCI Express busesThe existing TYPE_* macros for these types will point to an abstract base type, so existing casts in the code will keep working for all variants.
A simple test script (
tests/acceptance/virtio_version.py) is included, to check if the new device types are equivalent to using thedisable-legacyanddisable-modernoptions.Acked-by Andrea Bolognani <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>---
Changes v2 -> v3:
* Split into two separate patches (type registration helper and introduction of new types)
* Include full type names as literals in the code instead of generating type names automaticallyChanges v1 -> v2:
* Removed *-0.9 devices. Nobody will want to use them, if transitional devices work with legacy drivers
(Gerd Hoffmann, Michael S. Tsirkin)
* Drop virtio version from name: rename -1.0-transitional to -transitional (Michael S. Tsirkin)
* Renamed -1.0 to -non-transitional
* Don't add any extra variants to modern-only device types (they don't need it)
* Fix typo onTYPE_VIRTIO_INPUT_HOST_PCI(crash reported by Cornelia Huck)
* No need to change cast macros for modern-only devices
* Renamevirtio_register_types()tovirtio_pci_types_register()--- hw/virtio/virtio-pci.h | 24 ++-- hw/virtio/virtio-pci.c | 60 ++++++++-- tests/acceptance/virtio_version.py | 177 +++++++++++++++++++++++++++++ 3 files changed, 237 insertions(+), 24 deletions(-) create mode 100644 tests/acceptance/virtio_version.py
(...)
Quoted 28 lines
tests/acceptance/virtio_version.py new file +22
-0@@ -0,0 +1,177 @@ +""" +Check compatibility of virtio device types +""" +# Copyright (c) 2018 Red Hat, Inc. +# +# Author: +# Eduardo Habkost <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 or +# later. See the COPYING file in the top-level directory. +import sys +import os + +sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "scripts")) +from qemu import QEMUMachine +from avocado_qemu import Test + +# Virtio Device IDs: +VIRTIO_NET = 1 +VIRTIO_BLOCK = 2 +VIRTIO_CONSOLE = 3 +VIRTIO_RNG = 4
tests/acceptance/virtio_version.py line 32
Quoted 10 lines
tests/acceptance/virtio_version.py new file +10
-0+VIRTIO_BALLOON = 5 +VIRTIO_RPMSG = 7 +VIRTIO_SCSI = 8 +VIRTIO_9P = 9 +VIRTIO_RPROC_SERIAL = 11 +VIRTIO_CAIF = 12 +VIRTIO_GPU = 16 +VIRTIO_INPUT = 18 +VIRTIO_VSOCK = 19 +VIRTIO_CRYPTO = 20
We may want to include additional device types when they are added; but I expect them to be modern-only, so I don't think we'd miss problems if they aren't covered here.
(...)
Review of the test case was more superficial; but have a
Hello, Eduardo.
Just some minor comments regarding the Python code.
Quoted 46 lines · Eduardo Habkost
Many of the current virtio-*-pci device types actually represent 3 different types of devices:
* virtio 1.0 non-transitional devices
* virtio 1.0 transitional devices
* virtio 0.9 ("legacy device" in virtio 1.0 terminology)That would be just an annoyance if it didn't break our device/bus compatibility QMP interfaces. With these multi-purpose device types, there's no way to tell management software that transitional devices and legacy devices require a Conventional PCI bus.
The multi-purpose device types would also prevent us from telling management software what's the PCI vendor/device ID for them, because their PCI IDs change at runtime depending on the bus where they were plugged.
This patch adds separate device types for each of those virtio device flavors:
- virtio-*-pci: the existing multi-purpose device types
- Configurable usingdisable-legacyanddisable-modernproperties
- Legacy driver support is automatically enabled/disabled depending on the bus where it is plugged
- Supports Conventional PCI and PCI Express buses
(but Conventional PCI is incompatible with disable-legacy=off)
- Changes PCI vendor/device IDs at runtime
- virtio-*-pci-transitional: virtio-1.0 device supporting legacy drivers
- Supports Conventional PCI buses only, because
it has a PIO BAR
- virtio-*-pci-non-transitional: modern-only
- Supports both Conventional PCI and PCI Express busesThe existing TYPE_* macros for these types will point to an abstract base type, so existing casts in the code will keep working for all variants.
A simple test script (
tests/acceptance/virtio_version.py) is included, to check if the new device types are equivalent to using thedisable-legacyanddisable-modernoptions.Acked-by Andrea Bolognani <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>---
[...]
Quoted 9 lines
--- hw/virtio/virtio-pci.h | 24 ++-- hw/virtio/virtio-pci.c | 60 ++++++++-- tests/acceptance/virtio_version.py | 177 +++++++++++++++++++++++++++++ 3 files changed, 237 insertions(+), 24 deletions(-) create mode 100644 tests/acceptance/virtio_version.pyhw/virtio/virtio-pci.h +0
-0
[...]
Quoted 50 lines
tests/acceptance/virtio_version.py new file +44
-0@@ -0,0 +1,177 @@ +""" +Check compatibility of virtio device types +""" +# Copyright (c) 2018 Red Hat, Inc. +# +# Author: +# Eduardo Habkost <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 or +# later. See the COPYING file in the top-level directory. +import sys +import os + +sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "scripts")) +from qemu import QEMUMachine +from avocado_qemu import Test + +# Virtio Device IDs: +VIRTIO_NET = 1 +VIRTIO_BLOCK = 2 +VIRTIO_CONSOLE = 3 +VIRTIO_RNG = 4 +VIRTIO_BALLOON = 5 +VIRTIO_RPMSG = 7 +VIRTIO_SCSI = 8 +VIRTIO_9P = 9 +VIRTIO_RPROC_SERIAL = 11 +VIRTIO_CAIF = 12 +VIRTIO_GPU = 16 +VIRTIO_INPUT = 18 +VIRTIO_VSOCK = 19 +VIRTIO_CRYPTO = 20 + +PCI_VENDOR_ID_REDHAT_QUMRANET = 0x1af4 + +# Device IDs for legacy/transitional devices: +PCI_LEGACY_DEVICE_IDS = { + VIRTIO_NET: 0x1000, + VIRTIO_BLOCK: 0x1001, + VIRTIO_BALLOON: 0x1002, + VIRTIO_CONSOLE: 0x1003, + VIRTIO_SCSI: 0x1004, + VIRTIO_RNG: 0x1005, + VIRTIO_9P: 0x1009,
tests/acceptance/virtio_version.py line 54
Quoted 10 lines
tests/acceptance/virtio_version.py new file +10
-0+ VIRTIO_VSOCK: 0x1012, +} + +def pci_modern_device_id(virtio_devid): + return virtio_devid + 0x1040 + +def devtype_implements(vm, devtype, implements): + return devtype in [d['name'] for d in vm.command('qom-list-types', implements=implements)] + +def get_interfaces(vm, devtype, interfaces=['pci-express-device', 'conventional-pci-device']):
Usually is not a good idea to use a mutable (in this case a list) default value as an argument:
def my_func(param=[1,2,3]):
param.append(666)
print(param)my_func()
[1, 2, 3, 666]my_func()
[1, 2, 3, 666, 666]my_func()
[1, 2, 3, 666, 666, 666]
Yes, you're not changing the value right now, but it's something we can not guarantee for the future when, for example, someone not Python experienced have to change this code.
Another way safer to write this function could be:
def get_interfaces(vm, devtype, interfaces=None):
if not interfaces:
interfaces = ['pci-express-device', 'conventional-pci-device']
return [i for i in interfaces if devtype_implements(vm, devtype, i)]
Quoted 21 lines
tests/acceptance/virtio_version.py new file +21
-0+ return [i for i in interfaces if devtype_implements(vm, devtype, i)] + +class VirtioVersionCheck(Test): + """ + Check if virtio-version-specific device types result in the + same device tree created by `disable-modern` and + `disable-legacy`. + + :avocado: enable + :avocado: tags=x86_64 + """ + + # just in case there are failures, show larger diff: + maxDiff = 4096 + + def run_device(self, devtype, opts=None, machine='pc'): + """ + Run QEMU with `-device DEVTYPE`, return device info from `query-pci` + """ + with QEMUMachine(self.qemu_bin) as vm: + vm.set_machine(machine)
tests/acceptance/virtio_version.py line 85
Quoted 10 lines
tests/acceptance/virtio_version.py new file +10
-0+ if opts: + devtype += ',' + opts + vm.add_args('-device', '%s,id=devfortest' % (devtype)) + vm.add_args('-S') + vm.launch() + + pcibuses = vm.command('query-pci') + alldevs = [dev for bus in pcibuses for dev in bus['devices']] + import pprint + pprint.pprint(alldevs)
I think it's an undesired print here, right?
Quoted 6 lines
tests/acceptance/virtio_version.py new file +6
-0+ devfortest = [dev for dev in alldevs + if dev['qdev_id'] == 'devfortest'] + return devfortest[0], get_interfaces(vm, devtype) + + + def assert_devids(self, dev, devid, non_transitional=False):
tests/acceptance/virtio_version.py line 101
Quoted 10 lines
tests/acceptance/virtio_version.py new file +10
-0+ self.assertEqual(dev['id']['vendor'], PCI_VENDOR_ID_REDHAT_QUMRANET) + self.assertEqual(dev['id']['device'], devid) + if non_transitional: + self.assertTrue(0x1040 <= dev['id']['device'] <= 0x107f) + self.assertGreaterEqual(dev['id']['subsystem'], 0x40) + + def check_all_variants(self, qemu_devtype, virtio_devid): + """Check if a virtio device type and its variants behave as expected""" + # Force modern mode: + dev_modern,_ = self.run_device(qemu_devtype,
s/dev_modern,_/dev_modern, _/ (blank space after comma. There are other cases bellow)
Quoted 79 lines
tests/acceptance/virtio_version.py new file +76
-0+ 'disable-modern=off,disable-legacy=on') + self.assert_devids(dev_modern, pci_modern_device_id(virtio_devid), + non_transitional=True) + + # <prefix>-non-transitional device types should be 100% equivalent to + # <prefix>,disable-modern=off,disable-legacy=on + dev_1_0,nt_ifaces = self.run_device('%s-non-transitional' % (qemu_devtype)) + self.assertEqual(dev_modern, dev_1_0) + + # Force transitional mode: + dev_trans,_ = self.run_device(qemu_devtype, + 'disable-modern=off,disable-legacy=off') + self.assert_devids(dev_trans, PCI_LEGACY_DEVICE_IDS[virtio_devid]) + + # Force legacy mode: + dev_legacy,_ = self.run_device(qemu_devtype, + 'disable-modern=on,disable-legacy=off') + self.assert_devids(dev_legacy, PCI_LEGACY_DEVICE_IDS[virtio_devid]) + + # No options: default to transitional on PC machine-type: + no_opts_pc,generic_ifaces = self.run_device(qemu_devtype) + self.assertEqual(dev_trans, no_opts_pc) + + #TODO: check if plugging on a PCI Express bus will make the + # device non-transitional + #no_opts_q35 = self.run_device(qemu_devtype, machine='q35') + #self.assertEqual(dev_modern, no_opts_q35) + + # <prefix>-transitional device types should be 100% equivalent to + # <prefix>,disable-modern=off,disable-legacy=off + dev_trans,trans_ifaces = self.run_device('%s-transitional' % (qemu_devtype)) + self.assertEqual(dev_trans, dev_trans) + + # ensure the interface information is correct: + self.assertIn('conventional-pci-device', generic_ifaces) + self.assertIn('pci-express-device', generic_ifaces) + + self.assertIn('conventional-pci-device', nt_ifaces) + self.assertIn('pci-express-device', nt_ifaces) + + self.assertIn('conventional-pci-device', trans_ifaces) + self.assertNotIn('pci-express-device', trans_ifaces) + + + def test_conventional_devs(self): + self.check_all_variants('virtio-net-pci', VIRTIO_NET) + # virtio-blk requires 'driver' parameter + #self.check_all_variants('virtio-blk-pci', VIRTIO_BLOCK) + self.check_all_variants('virtio-serial-pci', VIRTIO_CONSOLE) + self.check_all_variants('virtio-rng-pci', VIRTIO_RNG) + self.check_all_variants('virtio-balloon-pci', VIRTIO_BALLOON) + self.check_all_variants('virtio-scsi-pci', VIRTIO_SCSI) + # virtio-9p requires 'fsdev' parameter + #self.check_all_variants('virtio-9p-pci', VIRTIO_9P) + + def check_modern_only(self, qemu_devtype, virtio_devid): + """Check if a modern-only virtio device type behaves as expected""" + # Force modern mode: + dev_modern,_ = self.run_device(qemu_devtype, + 'disable-modern=off,disable-legacy=on') + self.assert_devids(dev_modern, pci_modern_device_id(virtio_devid), + non_transitional=True) + + # No options: should be modern anyway + dev_no_opts,ifaces = self.run_device(qemu_devtype) + self.assertEqual(dev_modern, dev_no_opts) + + self.assertIn('conventional-pci-device', ifaces) + self.assertIn('pci-express-device', ifaces) + + def test_modern_only_devs(self): + self.check_modern_only('virtio-vga', VIRTIO_GPU) + self.check_modern_only('virtio-gpu-pci', VIRTIO_GPU) + self.check_modern_only('virtio-mouse-pci', VIRTIO_INPUT) + self.check_modern_only('virtio-tablet-pci', VIRTIO_INPUT) + self.check_modern_only('virtio-keyboard-pci', VIRTIO_INPUT)Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
Thanks,
Signature · 3 lines
Caio Carrara Software Engineer, Virt Team - Red Hat [email protected]
Quoted 4 lines · Caio Carrara
Hello, Eduardo.
Just some minor comments regarding the Python code.
[...]
Quoted 19 lines
tests/acceptance/virtio_version.py line 54
Quoted 4 lines
tests/acceptance/virtio_version.py new file +4
-0+def devtype_implements(vm, devtype, implements): + return devtype in [d['name'] for d in vm.command('qom-list-types', implements=implements)] + +def get_interfaces(vm, devtype, interfaces=['pci-express-device', 'conventional-pci-device']):Usually is not a good idea to use a mutable (in this case a list) default value as an argument:
def
my_func(param=[1,2,3]):param.append(666) print(param)
my_func()
[1, 2, 3, 666]my_func()
[1, 2, 3, 666, 666]my_func()
[1, 2, 3, 666, 666, 666]
Quoted 3 lines
Yes, you're not changing the value right now, but it's something we can not guarantee for the future when, for example, someone not Python experienced have to change this code.
Oops, thanks for catching this!
Quoted 7 lines
Another way safer to write this function could be:
def
get_interfaces(vm, devtype, interfaces=None):
if not interfaces:
interfaces = ['pci-express-device', 'conventional-pci-device']
return [i for i in interfaces ifdevtype_implements(vm, devtype, i)]
Maybe I should just use a tuple, then?
def get_interfaces(vm, devtype, interfaces=('pci-express-device', 'conventional-pci-device')):
return [i for i in interfaces if devtype_implements(vm, devtype, i)]
but probably I can simply eliminate the parameter because nobody is using it:
def get_pci_interfaces(vm, devtype):
interfaces = ('pci-express-device', 'conventional-pci-device') return [i for i in interfaces if devtype_implements(vm, devtype, i)]
Quoted 26 lines
Quoted 26 lines
tests/acceptance/virtio_version.py new file +25
-0+ return [i for i in interfaces if devtype_implements(vm, devtype, i)] + +class VirtioVersionCheck(Test): + """ + Check if virtio-version-specific device types result in the + same device tree created by `disable-modern` and + `disable-legacy`. + + :avocado: enable + :avocado: tags=x86_64 + """ + + # just in case there are failures, show larger diff: + maxDiff = 4096 + + def run_device(self, devtype, opts=None, machine='pc'): + """ + Run QEMU with `-device DEVTYPE`, return device info from `query-pci` + """ + with QEMUMachine(self.qemu_bin) as vm: + vm.set_machine(machine) + if opts: + devtype += ',' + opts + vm.add_args('-device', '%s,id=devfortest' % (devtype)) + vm.add_args('-S')
Quoted 8 lines
tests/acceptance/virtio_version.py line 85
Quoted 6 lines
tests/acceptance/virtio_version.py new file +6
-0+ vm.launch() + + pcibuses = vm.command('query-pci') + alldevs = [dev for bus in pcibuses for dev in bus['devices']] + import pprint + pprint.pprint(alldevs)I think it's an undesired print here, right?
Oops! Yes, debugging leftover.
Quoted 12 lines
Quoted 12 lines
tests/acceptance/virtio_version.py new file +11
-0+ devfortest = [dev for dev in alldevs + if dev['qdev_id'] == 'devfortest'] + return devfortest[0], get_interfaces(vm, devtype) + + + def assert_devids(self, dev, devid, non_transitional=False): + self.assertEqual(dev['id']['vendor'], PCI_VENDOR_ID_REDHAT_QUMRANET) + self.assertEqual(dev['id']['device'], devid) + if non_transitional: + self.assertTrue(0x1040 <= dev['id']['device'] <= 0x107f) + self.assertGreaterEqual(dev['id']['subsystem'], 0x40)
Quoted 8 lines
tests/acceptance/virtio_version.py line 101
Quoted 5 lines
tests/acceptance/virtio_version.py new file +5
-0+ + def check_all_variants(self, qemu_devtype, virtio_devid): + """Check if a virtio device type and its variants behave as expected""" + # Force modern mode: + dev_modern,_ = self.run_device(qemu_devtype,s/dev_modern,_/dev_modern, _/ (blank space after comma. There are other cases bellow)
I will change it, thanks!
Quoted 4 lines
Quoted 4 lines
tests/acceptance/virtio_version.py new file +3
-0+ 'disable-modern=off,disable-legacy=on') + self.assert_devids(dev_modern, pci_modern_device_id(virtio_devid), + non_transitional=True)
[...]
Signature · 1 line
Eduardo
Quoted 32 lines · Eduardo Habkost
Quoted 4 lines · Caio Carrara
Hello, Eduardo.
Just some minor comments regarding the Python code.
[...]
Quoted 19 lines
tests/acceptance/virtio_version.py line 54
Quoted 4 lines
tests/acceptance/virtio_version.py new file +4
-0+def devtype_implements(vm, devtype, implements): + return devtype in [d['name'] for d in vm.command('qom-list-types', implements=implements)] + +def get_interfaces(vm, devtype, interfaces=['pci-express-device', 'conventional-pci-device']):Usually is not a good idea to use a mutable (in this case a list) default value as an argument:
def
my_func(param=[1,2,3]):param.append(666) print(param)
my_func()
[1, 2, 3, 666]my_func()
[1, 2, 3, 666, 666]my_func()
[1, 2, 3, 666, 666, 666]Quoted 3 lines
Yes, you're not changing the value right now, but it's something we can not guarantee for the future when, for example, someone not Python experienced have to change this code.
Oops, thanks for catching this!
Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Another way safer to write this function could be:
def
get_interfaces(vm, devtype, interfaces=None):
if not interfaces:
interfaces = ['pci-express-device', 'conventional-pci-device']
return [i for i in interfaces ifdevtype_implements(vm, devtype, i)]Maybe I should just use a tuple, then?
Yes. It should work as well.
Quoted 79 lines
def
get_interfaces(vm, devtype, interfaces=('pci-express-device', 'conventional-pci-device')):
return [i for i in interfaces ifdevtype_implements(vm, devtype, i)]but probably I can simply eliminate the parameter because nobody is using it:
def
get_pci_interfaces(vm, devtype):
interfaces = ('pci-express-device', 'conventional-pci-device') return [i for i in interfaces ifdevtype_implements(vm, devtype, i)]Quoted 26 lines
Quoted 26 lines
tests/acceptance/virtio_version.py new file +25
-0+ return [i for i in interfaces if devtype_implements(vm, devtype, i)] + +class VirtioVersionCheck(Test): + """ + Check if virtio-version-specific device types result in the + same device tree created by `disable-modern` and + `disable-legacy`. + + :avocado: enable + :avocado: tags=x86_64 + """ + + # just in case there are failures, show larger diff: + maxDiff = 4096 + + def run_device(self, devtype, opts=None, machine='pc'): + """ + Run QEMU with `-device DEVTYPE`, return device info from `query-pci` + """ + with QEMUMachine(self.qemu_bin) as vm: + vm.set_machine(machine) + if opts: + devtype += ',' + opts + vm.add_args('-device', '%s,id=devfortest' % (devtype)) + vm.add_args('-S')Quoted 8 lines
tests/acceptance/virtio_version.py line 85
Quoted 6 lines
tests/acceptance/virtio_version.py new file +6
-0+ vm.launch() + + pcibuses = vm.command('query-pci') + alldevs = [dev for bus in pcibuses for dev in bus['devices']] + import pprint + pprint.pprint(alldevs)I think it's an undesired print here, right?
Oops! Yes, debugging leftover.
Quoted 12 lines
Quoted 12 lines
tests/acceptance/virtio_version.py new file +11
-0+ devfortest = [dev for dev in alldevs + if dev['qdev_id'] == 'devfortest'] + return devfortest[0], get_interfaces(vm, devtype) + + + def assert_devids(self, dev, devid, non_transitional=False): + self.assertEqual(dev['id']['vendor'], PCI_VENDOR_ID_REDHAT_QUMRANET) + self.assertEqual(dev['id']['device'], devid) + if non_transitional: + self.assertTrue(0x1040 <= dev['id']['device'] <= 0x107f) + self.assertGreaterEqual(dev['id']['subsystem'], 0x40)Quoted 8 lines
tests/acceptance/virtio_version.py line 101
Quoted 5 lines
tests/acceptance/virtio_version.py new file +5
-0+ + def check_all_variants(self, qemu_devtype, virtio_devid): + """Check if a virtio device type and its variants behave as expected""" + # Force modern mode: + dev_modern,_ = self.run_device(qemu_devtype,s/dev_modern,_/dev_modern, _/ (blank space after comma. There are other cases bellow)
I will change it, thanks!
Quoted 4 lines
Quoted 4 lines
tests/acceptance/virtio_version.py new file +3
-0+ 'disable-modern=off,disable-legacy=on') + self.assert_devids(dev_modern, pci_modern_device_id(virtio_devid), + non_transitional=True)[...]
Signature · 1 line
Eduardo
Signature · 3 lines
Caio Carrara Software Engineer, Virt Team - Red Hat [email protected]
This series seems to have some coding style problems. See output below for more information:
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Subject: [libvirt] [PATCH for-4.0 v3 0/2] virtio: Provide version-specific variants of virtio PCI devices
Message-id: [email protected]
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
421d93d virtio: Provide version-specific variants of virtio PCI devices bef1223 virtio: Helper for registering virtio device types
=== OUTPUT BEGIN ===
Checking PATCH 1/2: virtio: Helper for registering virtio device types...
WARNING: line over 80 characters
#495: FILE: hw/virtio/virtio-pci.h:443:
+ * Implements both INTERFACE_PCIE_DEVICE and INTERFACE_CONVENTIONAL_PCI_DEVICE,
WARNING: line over 80 characters
#504: FILE: hw/virtio/virtio-pci.h:452:
+ * Implements both INTERFACE_PCIE_DEVICE and INTERFACE_CONVENTIONAL_PCI_DEVICE.
total: 0 errors, 2 warnings, 469 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 2/2: virtio: Provide version-specific variants of virtio PCI devices...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #315:
new file mode 100644
ERROR: line over 90 characters
#371: FILE: tests/acceptance/virtio_version.py:52:
+ return devtype in [d['name'] for d in vm.command('qom-list-types', implements=implements)]
ERROR: line over 90 characters
#373: FILE: tests/acceptance/virtio_version.py:54:
+def get_interfaces(vm, devtype, interfaces=['pci-express-device', 'conventional-pci-device']):
WARNING: line over 80 characters
#427: FILE: tests/acceptance/virtio_version.py:108:
+ dev_1_0,nt_ifaces = self.run_device('%s-non-transitional' % (qemu_devtype))
WARNING: line over 80 characters
#451: FILE: tests/acceptance/virtio_version.py:132:
+ dev_trans,trans_ifaces = self.run_device('%s-transitional' % (qemu_devtype))
total: 2 errors, 3 warnings, 405 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]