Skip to contentSkip to conversation

virtio: clarify VirtioPCIDeviceTypeInfo usage

PATCH Superseded Stefan Hajnoczi 3 participants 3 messages Apr 24, 2019 – Apr 25, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio: clarify VirtioPCIDeviceTypeInfo usage

How to use .base_name, .generic_name, .transitional_name, and .non_transitional_name can be confusing.

Existing devices have .generic_name but its behavior is somewhat magic.

Devices added to new versions of the VIRTIO specification should forego transitional mode completely and always operate in non-transitional mode because there are no existing drivers for them that require backwards compatibility.

This patch adds comments that hopefully make it easier for developers to decide how to fill out VirtioPCIDeviceTypeInfo.

---
 hw/virtio/virtio-pci.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
hw/virtio/virtio-pci.h +6 -1
index 18581854ca..debdee28b3 100644
@@ -209,7 +209,9 @@ typedef struct VirtioPCIDeviceTypeInfo {
      * 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.
+     * The only type implemented by QEMU 3.1 and older.  This type is less
+     * explicit than the transitional and non-transitional device types.  Its
+     * behavior can be affected by machine type compat properties.
      */
     const char *generic_name;
     /*
@@ -222,6 +224,9 @@ typedef struct VirtioPCIDeviceTypeInfo {
      * The non-transitional device type.  Optional.
      *
      * Implements INTERFACE_CONVENTIONAL_PCI_DEVICE only.
+     *
+     * New virtio device types should only define this and base_name, thereby
+     * allowing only non-transitional mode.
      */
     const char *non_transitional_name;
 
Signature · 1 line
2.20.1
#1 lore raw
Quoted 23 lines · Stefan Hajnoczi

How to use .base_name, .generic_name, .transitional_name, and .non_transitional_name can be confusing.

Existing devices have .generic_name but its behavior is somewhat magic.

Devices added to new versions of the VIRTIO specification should forego transitional mode completely and always operate in non-transitional mode because there are no existing drivers for them that require backwards compatibility.

This patch adds comments that hopefully make it easier for developers to decide how to fill out VirtioPCIDeviceTypeInfo.

---
 hw/virtio/virtio-pci.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
hw/virtio/virtio-pci.h +0 -0
index 18581854ca..debdee28b3 100644

hw/virtio/virtio-pci.h typedef struct VirtioPCIDeviceTypeInfo { · line 214

Quoted 7 lines
hw/virtio/virtio-pci.h +3 -1
@@ -209,7 +209,9 @@ typedef struct VirtioPCIDeviceTypeInfo {
      * 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.
+     * The only type implemented by QEMU 3.1 and older.  This type is less
+     * explicit than the transitional and non-transitional device types.  Its
+     * behavior can be affected by machine type compat properties.

I'm not sure what you mean here. All types can be affected by machine type compat properties when necessary, don't they?

Quoted 16 lines
hw/virtio/virtio-pci.h +3 -0
      */
     const char *generic_name;
     /*
@@ -222,6 +224,9 @@ typedef struct VirtioPCIDeviceTypeInfo {
      * The non-transitional device type.  Optional.
      *
      * Implements INTERFACE_CONVENTIONAL_PCI_DEVICE only.
+     *
+     * New virtio device types should only define this and base_name, thereby
+     * allowing only non-transitional mode.
      */
     const char *non_transitional_name;
 
Signature · 1 line
2.20.1
Signature · 1 line
Eduardo
#2 lore raw
Quoted 19 lines · Eduardo Habkost
Quoted 18 lines · Stefan Hajnoczi

How to use .base_name, .generic_name, .transitional_name, and .non_transitional_name can be confusing.

Existing devices have .generic_name but its behavior is somewhat magic.

Devices added to new versions of the VIRTIO specification should forego transitional mode completely and always operate in non-transitional mode because there are no existing drivers for them that require backwards compatibility.

This patch adds comments that hopefully make it easier for developers to decide how to fill out VirtioPCIDeviceTypeInfo.

---
 hw/virtio/virtio-pci.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
Quoted 15 lines

hw/virtio/virtio-pci.h typedef struct VirtioPCIDeviceTypeInfo { · line 214

Quoted 12 lines
hw/virtio/virtio-pci.h +3 -1
index 18581854ca..debdee28b3 100644
@@ -209,7 +209,9 @@ typedef struct VirtioPCIDeviceTypeInfo {
      * 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.
+     * The only type implemented by QEMU 3.1 and older.  This type is less
+     * explicit than the transitional and non-transitional device types.  Its
+     * behavior can be affected by machine type compat properties.

I'm not sure what you mean here. All types can be affected by machine type compat properties when necessary, don't they?

That's true. I didn't realize that the compat properties are applied after instance_init().

Will fix in v2.