Skip to contentSkip to conversation

compat: Use explicit type names on HW_COMPAT_2_6

PATCH In review Eduardo Habkost 4 participants 15 messages Jan 4, 2019 – Jan 7, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 compat: Use explicit type names on HW_COMPAT_2_6

The virtio-pci entries in HW_COMPAT_2_6 had an implicit
assumption: that all virtio-pci subclasses support the disable-legacy and disable-modern options.

That assumption was broken by commit f6e501a28ef9 ("virtio:
Provide version-specific variants of virtio PCI devices"). This caused QEMU to crash if using the new -non-transitional or -transitional device types:

  $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
    -device virtio-net-pci-non-transitional
  Unexpected error in object_property_find() at qom/object.c:1092:
  qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
  global virtio-pci.disable-modern=on: Property '.disable-modern' not found
  Aborted (core dumped)

Replace the virtio-pci.disable-legacy=off and virtio-pci.disable-modern=on entries on HW_COMPAT_2_6 with explicit entries for each generic virtio device type.

The full list of generic virtio device types was extracted by just grepping for ".generic_name". Note that we don't need to worry about listing new virtio-pci devices in HW_COMPAT_2_6 in the future, because new devices won't require QEMU 2.6 compatibility.

This makes the compat entries annoyingly verbose, but is simpler than the alternative of making the virtio-pci type inheritance rules even more complex.

---

---
 include/hw/compat.h | 140 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 138 insertions(+), 2 deletions(-)
include/hw/compat.h +138 -2
index 3ca85b037c..fbb6c1138a 100644
@@ -163,11 +163,147 @@
         .property = "format_transport_address",\
         .value    = "off",\
     },{\
-        .driver   = "virtio-pci",\
+        .driver   = "vhost-scsi-pci",\
         .property = "disable-modern",\
         .value    = "on",\
     },{\
-        .driver   = "virtio-pci",\
+        .driver   = "vhost-scsi-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "vhost-user-blk-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "vhost-user-blk-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "vhost-user-scsi-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "vhost-user-scsi-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "vhost-vsock-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "vhost-vsock-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-9p-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-9p-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-balloon-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-balloon-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-blk-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-blk-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-crypto-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-crypto-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-gpu-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-gpu-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-input-host-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-input-host-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-keyboard-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-keyboard-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-mouse-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-mouse-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-rng-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-rng-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-scsi-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-scsi-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-serial-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-serial-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-tablet-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-tablet-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-vga",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-vga",\
         .property = "disable-legacy",\
         .value    = "off",\
     },
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
#1 lore raw
Quoted 20 lines · Eduardo Habkost

The virtio-pci entries in HW_COMPAT_2_6 had an implicit
assumption: that all virtio-pci subclasses support the disable-legacy and disable-modern options.

That assumption was broken by commit f6e501a28ef9 ("virtio:
Provide version-specific variants of virtio PCI devices"). This caused QEMU to crash if using the new -non-transitional or -transitional device types:

  $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
    -device virtio-net-pci-non-transitional
  Unexpected error in object_property_find() at qom/object.c:1092:
  qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
  global virtio-pci.disable-modern=on: Property '.disable-modern' not found
  Aborted (core dumped)

Replace the virtio-pci.disable-legacy=off and virtio-pci.disable-modern=on entries on HW_COMPAT_2_6 with explicit entries for each generic virtio device type.

Quoted 5 lines

The full list of generic virtio device types was extracted by just grepping for ".generic_name". Note that we don't need to worry about listing new virtio-pci devices in HW_COMPAT_2_6 in the future, because new devices won't require QEMU 2.6 compatibility.

I fully expect that e.g. packed ring support will need to affect all virtio devices too. And it's likely that we'll have some new virtio-pci transport features too.

Quoted 3 lines

This makes the compat entries annoyingly verbose, but is simpler than the alternative of making the virtio-pci type inheritance rules even more complex.

God forbid we forgot something, the only way to notice is to run a cross version migration with an old qemu.
I think we need to come up with something less verbose and fragile.

Quoted 163 lines

---

---
 include/hw/compat.h | 140 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 138 insertions(+), 2 deletions(-)
include/hw/compat.h +138 -2
index 3ca85b037c..fbb6c1138a 100644
@@ -163,11 +163,147 @@
         .property = "format_transport_address",\
         .value    = "off",\
     },{\
-        .driver   = "virtio-pci",\
+        .driver   = "vhost-scsi-pci",\
         .property = "disable-modern",\
         .value    = "on",\
     },{\
-        .driver   = "virtio-pci",\
+        .driver   = "vhost-scsi-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "vhost-user-blk-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "vhost-user-blk-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "vhost-user-scsi-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "vhost-user-scsi-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "vhost-vsock-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "vhost-vsock-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-9p-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-9p-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-balloon-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-balloon-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-blk-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-blk-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-crypto-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-crypto-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-gpu-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-gpu-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-input-host-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-input-host-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-keyboard-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-keyboard-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-mouse-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-mouse-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-rng-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-rng-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-scsi-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-scsi-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-serial-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-serial-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-tablet-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-tablet-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-vga",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-vga",\
         .property = "disable-legacy",\
         .value    = "off",\
     },
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
#2 lore raw
Quoted 27 lines · On Thu, 3 Jan 2019 23:23:45 -0500 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 20 lines · Eduardo Habkost

The virtio-pci entries in HW_COMPAT_2_6 had an implicit
assumption: that all virtio-pci subclasses support the disable-legacy and disable-modern options.

That assumption was broken by commit f6e501a28ef9 ("virtio:
Provide version-specific variants of virtio PCI devices"). This caused QEMU to crash if using the new -non-transitional or -transitional device types:

  $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
    -device virtio-net-pci-non-transitional
  Unexpected error in object_property_find() at qom/object.c:1092:
  qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
  global virtio-pci.disable-modern=on: Property '.disable-modern' not found
  Aborted (core dumped)

Replace the virtio-pci.disable-legacy=off and virtio-pci.disable-modern=on entries on HW_COMPAT_2_6 with explicit entries for each generic virtio device type.

Quoted 5 lines

The full list of generic virtio device types was extracted by just grepping for ".generic_name". Note that we don't need to worry about listing new virtio-pci devices in HW_COMPAT_2_6 in the future, because new devices won't require QEMU 2.6 compatibility.

Quoted 3 lines

I fully expect that e.g. packed ring support will need to affect all virtio devices too. And it's likely that we'll have some new virtio-pci transport features too.

Yes, but as this post-dates the introduction of the version-specific devices, it will all go into the base class and therefore not be problematic.

Quoted 8 lines
Quoted 4 lines

This makes the compat entries annoyingly verbose, but is simpler than the alternative of making the virtio-pci type inheritance rules even more complex.

God forbid we forgot something, the only way to notice is to run a cross version migration with an old qemu.
I think we need to come up with something less verbose and fragile.

I'd rather prefer to do this change now, so that we don't need to drag around some complicated infrastructure forever.

As Eduardo said, we don't need to care about new devices, so this grep-based approach sounds like it would catch everything.

Quoted 8 lines
Quoted 8 lines

---

---
 include/hw/compat.h | 140 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 138 insertions(+), 2 deletions(-)
#3 lore raw
In reply to Michael S. Tsirkin
Quoted 31 lines · * Michael S. Tsirkin ([email protected]) wrote:
Quoted 20 lines · Eduardo Habkost

The virtio-pci entries in HW_COMPAT_2_6 had an implicit
assumption: that all virtio-pci subclasses support the disable-legacy and disable-modern options.

That assumption was broken by commit f6e501a28ef9 ("virtio:
Provide version-specific variants of virtio PCI devices"). This caused QEMU to crash if using the new -non-transitional or -transitional device types:

  $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
    -device virtio-net-pci-non-transitional
  Unexpected error in object_property_find() at qom/object.c:1092:
  qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
  global virtio-pci.disable-modern=on: Property '.disable-modern' not found
  Aborted (core dumped)

Replace the virtio-pci.disable-legacy=off and virtio-pci.disable-modern=on entries on HW_COMPAT_2_6 with explicit entries for each generic virtio device type.

Quoted 5 lines

The full list of generic virtio device types was extracted by just grepping for ".generic_name". Note that we don't need to worry about listing new virtio-pci devices in HW_COMPAT_2_6 in the future, because new devices won't require QEMU 2.6 compatibility.

I fully expect that e.g. packed ring support will need to affect all virtio devices too. And it's likely that we'll have some new virtio-pci transport features too.

Quoted 7 lines
Quoted 3 lines

This makes the compat entries annoyingly verbose, but is simpler than the alternative of making the virtio-pci type inheritance rules even more complex.

God forbid we forgot something, the only way to notice is to run a cross version migration with an old qemu.
I think we need to come up with something less verbose and fragile.

I guess we could use a script like tests/acceptance/virtio_version.py to do a check?

As for something less verbose, I guess something is doable with a few macros (more complex but less verbose); or I guess you could add these properties to the other devices but just refuse to operate when they were set the wrong way.

Dave

Quoted 156 lines
Quoted 156 lines

---

---
 include/hw/compat.h | 140 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 138 insertions(+), 2 deletions(-)
include/hw/compat.h +135 -2
index 3ca85b037c..fbb6c1138a 100644
@@ -163,11 +163,147 @@
         .property = "format_transport_address",\
         .value    = "off",\
     },{\
-        .driver   = "virtio-pci",\
+        .driver   = "vhost-scsi-pci",\
         .property = "disable-modern",\
         .value    = "on",\
     },{\
-        .driver   = "virtio-pci",\
+        .driver   = "vhost-scsi-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "vhost-user-blk-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "vhost-user-blk-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "vhost-user-scsi-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "vhost-user-scsi-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "vhost-vsock-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "vhost-vsock-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-9p-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-9p-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-balloon-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-balloon-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-blk-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-blk-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-crypto-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-crypto-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-gpu-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-gpu-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-input-host-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-input-host-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-keyboard-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-keyboard-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-mouse-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-mouse-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-rng-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-rng-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-scsi-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-scsi-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-serial-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-serial-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-tablet-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-tablet-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-vga",\
+        .property = "disable-modern",\
Quoted 8 lines
Quoted 8 lines
include/hw/compat.h +3 -0
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-vga",\
         .property = "disable-legacy",\
         .value    = "off",\
     },
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#4 lore raw
Quoted 36 lines · Dr. David Alan Gilbert
Quoted 35 lines · * Michael S. Tsirkin ([email protected]) wrote:
Quoted 20 lines · Eduardo Habkost

The virtio-pci entries in HW_COMPAT_2_6 had an implicit
assumption: that all virtio-pci subclasses support the disable-legacy and disable-modern options.

That assumption was broken by commit f6e501a28ef9 ("virtio:
Provide version-specific variants of virtio PCI devices"). This caused QEMU to crash if using the new -non-transitional or -transitional device types:

  $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
    -device virtio-net-pci-non-transitional
  Unexpected error in object_property_find() at qom/object.c:1092:
  qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
  global virtio-pci.disable-modern=on: Property '.disable-modern' not found
  Aborted (core dumped)

Replace the virtio-pci.disable-legacy=off and virtio-pci.disable-modern=on entries on HW_COMPAT_2_6 with explicit entries for each generic virtio device type.

Quoted 5 lines

The full list of generic virtio device types was extracted by just grepping for ".generic_name". Note that we don't need to worry about listing new virtio-pci devices in HW_COMPAT_2_6 in the future, because new devices won't require QEMU 2.6 compatibility.

I fully expect that e.g. packed ring support will need to affect all virtio devices too. And it's likely that we'll have some new virtio-pci transport features too.

Quoted 3 lines

This makes the compat entries annoyingly verbose, but is simpler than the alternative of making the virtio-pci type inheritance rules even more complex.

Quoted 6 lines
Quoted 3 lines

God forbid we forgot something, the only way to notice is to run a cross version migration with an old qemu.
I think we need to come up with something less verbose and fragile.

I guess we could use a script like tests/acceptance/virtio_version.py to do a check?

That's a good idea. On test code we can try additional tricks to detect the hybrid virtio devices without increasing the complexity of QEMU code. I'll give it a try.

Quoted 5 lines

As for something less verbose, I guess something is doable with a few macros (more complex but less verbose); or I guess you could add these properties to the other devices but just refuse to operate when they were set the wrong way.

Adding the properties to all virtio-pci devices is the kind of complexity I would like to avoid. If we need to define rules for when disable-modern/disable-legacy is set to unexpected values, we'll have to maintain the code that implement those rules forever.

Signature · 1 line
Eduardo
#5 lore raw
Quoted 41 lines · Eduardo Habkost
Quoted 40 lines · Dr. David Alan Gilbert
Quoted 38 lines · * Michael S. Tsirkin ([email protected]) wrote:
Quoted 20 lines · Eduardo Habkost

The virtio-pci entries in HW_COMPAT_2_6 had an implicit
assumption: that all virtio-pci subclasses support the disable-legacy and disable-modern options.

That assumption was broken by commit f6e501a28ef9 ("virtio:
Provide version-specific variants of virtio PCI devices"). This caused QEMU to crash if using the new -non-transitional or -transitional device types:

  $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
    -device virtio-net-pci-non-transitional
  Unexpected error in object_property_find() at qom/object.c:1092:
  qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
  global virtio-pci.disable-modern=on: Property '.disable-modern' not found
  Aborted (core dumped)

Replace the virtio-pci.disable-legacy=off and virtio-pci.disable-modern=on entries on HW_COMPAT_2_6 with explicit entries for each generic virtio device type.

Quoted 5 lines

The full list of generic virtio device types was extracted by just grepping for ".generic_name". Note that we don't need to worry about listing new virtio-pci devices in HW_COMPAT_2_6 in the future, because new devices won't require QEMU 2.6 compatibility.

I fully expect that e.g. packed ring support will need to affect all virtio devices too. And it's likely that we'll have some new virtio-pci transport features too.

Quoted 3 lines

This makes the compat entries annoyingly verbose, but is simpler than the alternative of making the virtio-pci type inheritance rules even more complex.

God forbid we forgot something, the only way to notice is to run a cross version migration with an old qemu.
I think we need to come up with something less verbose and fragile.

Quoted 6 lines
Quoted 2 lines

I guess we could use a script like tests/acceptance/virtio_version.py to do a check?

That's a good idea. On test code we can try additional tricks to detect the hybrid virtio devices without increasing the complexity of QEMU code. I'll give it a try.

I did it but I'm not happy with the result: many of the virtio devices can't be tested without extra arguments. Some of them (like vhost-*) require extra privileges on the host that might be unavailable.

Anyway, while writing this I noticed another issue: many of the virtio devices in QEMU 2.6 were already modern-only!

Setting disable-modern=off on modern-only devices like virtio-vga or virtio-tablet-pci doesn't make sense. This means setting virtio-pci.disable-modern=off on HW_COMPAT_2_6 was incorrect even before the -non-transitional and -transitional device types were introduced.

---

tests/acceptance/virtio_version.py +42 -0
index ce990250d8..9157a1b173 100644
@@ -55,6 +55,18 @@ 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)]
 
+def is_hybrid_dev(vm, devtype):
+    props = [p['name'] for p in vm.command('device-list-properties',
+                                           typename=devtype)]
+    return 'disable-legacy' in props
+
+def get_all_hybrid_devs(vm):
+    """Return list of all hybrid virtio device types (the ones that can be
+    configured using the disable-legacy & disable-modern properties)"""
+    alldevs = [d['name'] for d in vm.command('qom-list-types',
+                                             implements='virtio-pci')]
+    return [d for d in alldevs if is_hybrid_dev(vm, d)]
+
 class VirtioVersionCheck(Test):
     """
     Check if virtio-version-specific device types result in the
@@ -174,3 +186,33 @@ class VirtioVersionCheck(Test):
         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)
+
+    def get_all_hybrid_devs(self):
+        with QEMUMachine(self.qemu_bin) as vm:
+            vm.set_machine('none')
+            vm.add_args('-S')
+            vm.launch()
+            return get_all_hybrid_devs(vm)
+
+    def check_legacy_compat(self, qemu_devtype):
+        # these device types can't be run with extra arguments, so we can't
+        # test them directly:
+        if qemu_devtype in ('virtio-input-host-pci', 'virtio-blk-pci',
+                            'virtio-crypto-pci', 'virtio-9p-pci',
+                            'vhost-vsock-pci', 'vhost-scsi-pci',
+                            'vhost-user-blk-pci', 'vhost-user-scsi-pci'):
+               return
+
+        # Force legacy mode:
+        dev_legacy, _ = self.run_device(qemu_devtype,
+                                        'disable-modern=on,disable-legacy=off',
+                                        machine='pc-i440fx-2.6')
+
+        # No options: default to legacy on <= 2.6 machine-types:
+        no_opts_pc, _ = self.run_device(qemu_devtype, machine='pc-i440fx-2.6')
+        self.assertEqual(dev_legacy, no_opts_pc)
+
+    def test_legacy_compat(self):
+        devs = self.get_all_hybrid_devs()
+        for d in devs:
+            self.check_legacy_compat(d)
Signature · 1 line
Eduardo
#6 lore raw
Quoted 54 lines · Eduardo Habkost
Quoted 41 lines · Eduardo Habkost
Quoted 40 lines · Dr. David Alan Gilbert
Quoted 38 lines · * Michael S. Tsirkin ([email protected]) wrote:
Quoted 20 lines · Eduardo Habkost

The virtio-pci entries in HW_COMPAT_2_6 had an implicit
assumption: that all virtio-pci subclasses support the disable-legacy and disable-modern options.

That assumption was broken by commit f6e501a28ef9 ("virtio:
Provide version-specific variants of virtio PCI devices"). This caused QEMU to crash if using the new -non-transitional or -transitional device types:

  $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
    -device virtio-net-pci-non-transitional
  Unexpected error in object_property_find() at qom/object.c:1092:
  qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
  global virtio-pci.disable-modern=on: Property '.disable-modern' not found
  Aborted (core dumped)

Replace the virtio-pci.disable-legacy=off and virtio-pci.disable-modern=on entries on HW_COMPAT_2_6 with explicit entries for each generic virtio device type.

Quoted 5 lines

The full list of generic virtio device types was extracted by just grepping for ".generic_name". Note that we don't need to worry about listing new virtio-pci devices in HW_COMPAT_2_6 in the future, because new devices won't require QEMU 2.6 compatibility.

I fully expect that e.g. packed ring support will need to affect all virtio devices too. And it's likely that we'll have some new virtio-pci transport features too.

Quoted 3 lines

This makes the compat entries annoyingly verbose, but is simpler than the alternative of making the virtio-pci type inheritance rules even more complex.

God forbid we forgot something, the only way to notice is to run a cross version migration with an old qemu.
I think we need to come up with something less verbose and fragile.

Quoted 6 lines
Quoted 2 lines

I guess we could use a script like tests/acceptance/virtio_version.py to do a check?

That's a good idea. On test code we can try additional tricks to detect the hybrid virtio devices without increasing the complexity of QEMU code. I'll give it a try.

I did it but I'm not happy with the result: many of the virtio devices can't be tested without extra arguments. Some of them (like vhost-*) require extra privileges on the host that might be unavailable.

Quoted 8 lines

Anyway, while writing this I noticed another issue: many of the virtio devices in QEMU 2.6 were already modern-only!

Setting disable-modern=off on modern-only devices like virtio-vga or virtio-tablet-pci doesn't make sense. This means setting virtio-pci.disable-modern=off on HW_COMPAT_2_6 was incorrect even before the -non-transitional and -transitional device types were introduced.

It did create an opportunity to create non working devices.

Whether that's incorrect as such I'm not sure.

Quoted 61 lines

---

tests/acceptance/virtio_version.py +42 -0
index ce990250d8..9157a1b173 100644
@@ -55,6 +55,18 @@ 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)]
 
+def is_hybrid_dev(vm, devtype):
+    props = [p['name'] for p in vm.command('device-list-properties',
+                                           typename=devtype)]
+    return 'disable-legacy' in props
+
+def get_all_hybrid_devs(vm):
+    """Return list of all hybrid virtio device types (the ones that can be
+    configured using the disable-legacy & disable-modern properties)"""
+    alldevs = [d['name'] for d in vm.command('qom-list-types',
+                                             implements='virtio-pci')]
+    return [d for d in alldevs if is_hybrid_dev(vm, d)]
+
 class VirtioVersionCheck(Test):
     """
     Check if virtio-version-specific device types result in the
@@ -174,3 +186,33 @@ class VirtioVersionCheck(Test):
         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)
+
+    def get_all_hybrid_devs(self):
+        with QEMUMachine(self.qemu_bin) as vm:
+            vm.set_machine('none')
+            vm.add_args('-S')
+            vm.launch()
+            return get_all_hybrid_devs(vm)
+
+    def check_legacy_compat(self, qemu_devtype):
+        # these device types can't be run with extra arguments, so we can't
+        # test them directly:
+        if qemu_devtype in ('virtio-input-host-pci', 'virtio-blk-pci',
+                            'virtio-crypto-pci', 'virtio-9p-pci',
+                            'vhost-vsock-pci', 'vhost-scsi-pci',
+                            'vhost-user-blk-pci', 'vhost-user-scsi-pci'):
+               return
+
+        # Force legacy mode:
+        dev_legacy, _ = self.run_device(qemu_devtype,
+                                        'disable-modern=on,disable-legacy=off',
+                                        machine='pc-i440fx-2.6')
+
+        # No options: default to legacy on <= 2.6 machine-types:
+        no_opts_pc, _ = self.run_device(qemu_devtype, machine='pc-i440fx-2.6')
+        self.assertEqual(dev_legacy, no_opts_pc)
+
+    def test_legacy_compat(self):
+        devs = self.get_all_hybrid_devs()
+        for d in devs:
+            self.check_legacy_compat(d)
Signature · 2 lines
-- 
Eduardo
#7 lore raw
Quoted 65 lines · Michael S. Tsirkin
Quoted 54 lines · Eduardo Habkost
Quoted 41 lines · Eduardo Habkost
Quoted 40 lines · Dr. David Alan Gilbert
Quoted 38 lines · * Michael S. Tsirkin ([email protected]) wrote:
Quoted 20 lines · Eduardo Habkost

The virtio-pci entries in HW_COMPAT_2_6 had an implicit
assumption: that all virtio-pci subclasses support the disable-legacy and disable-modern options.

That assumption was broken by commit f6e501a28ef9 ("virtio:
Provide version-specific variants of virtio PCI devices"). This caused QEMU to crash if using the new -non-transitional or -transitional device types:

  $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
    -device virtio-net-pci-non-transitional
  Unexpected error in object_property_find() at qom/object.c:1092:
  qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
  global virtio-pci.disable-modern=on: Property '.disable-modern' not found
  Aborted (core dumped)

Replace the virtio-pci.disable-legacy=off and virtio-pci.disable-modern=on entries on HW_COMPAT_2_6 with explicit entries for each generic virtio device type.

Quoted 5 lines

The full list of generic virtio device types was extracted by just grepping for ".generic_name". Note that we don't need to worry about listing new virtio-pci devices in HW_COMPAT_2_6 in the future, because new devices won't require QEMU 2.6 compatibility.

I fully expect that e.g. packed ring support will need to affect all virtio devices too. And it's likely that we'll have some new virtio-pci transport features too.

Quoted 3 lines

This makes the compat entries annoyingly verbose, but is simpler than the alternative of making the virtio-pci type inheritance rules even more complex.

God forbid we forgot something, the only way to notice is to run a cross version migration with an old qemu.
I think we need to come up with something less verbose and fragile.

Quoted 6 lines
Quoted 2 lines

I guess we could use a script like tests/acceptance/virtio_version.py to do a check?

That's a good idea. On test code we can try additional tricks to detect the hybrid virtio devices without increasing the complexity of QEMU code. I'll give it a try.

I did it but I'm not happy with the result: many of the virtio devices can't be tested without extra arguments. Some of them (like vhost-*) require extra privileges on the host that might be unavailable.

Quoted 8 lines

Anyway, while writing this I noticed another issue: many of the virtio devices in QEMU 2.6 were already modern-only!

Setting disable-modern=off on modern-only devices like virtio-vga or virtio-tablet-pci doesn't make sense. This means setting virtio-pci.disable-modern=off on HW_COMPAT_2_6 was incorrect even before the -non-transitional and -transitional device types were introduced.

Quoted 3 lines

It did create an opportunity to create non working devices.

Whether that's incorrect as such I'm not sure.

This is not just creating the opportunity for an user to disable-modern=on. HW_COMPAT_2_6 is actually setting disable-modern=on on virtio-vga and other modern-only devices. Sounds like a mistake to me.

Luckily those modern-only devices silently ignore the disable-modern/disable-legacy properties, but this might change in the future.

Signature · 1 line
Eduardo
#8 lore raw
Quoted 70 lines · Eduardo Habkost
Quoted 65 lines · Michael S. Tsirkin
Quoted 54 lines · Eduardo Habkost
Quoted 41 lines · Eduardo Habkost
Quoted 40 lines · Dr. David Alan Gilbert
Quoted 38 lines · * Michael S. Tsirkin ([email protected]) wrote:
Quoted 20 lines · Eduardo Habkost

The virtio-pci entries in HW_COMPAT_2_6 had an implicit
assumption: that all virtio-pci subclasses support the disable-legacy and disable-modern options.

That assumption was broken by commit f6e501a28ef9 ("virtio:
Provide version-specific variants of virtio PCI devices"). This caused QEMU to crash if using the new -non-transitional or -transitional device types:

  $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
    -device virtio-net-pci-non-transitional
  Unexpected error in object_property_find() at qom/object.c:1092:
  qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
  global virtio-pci.disable-modern=on: Property '.disable-modern' not found
  Aborted (core dumped)

Replace the virtio-pci.disable-legacy=off and virtio-pci.disable-modern=on entries on HW_COMPAT_2_6 with explicit entries for each generic virtio device type.

Quoted 5 lines

The full list of generic virtio device types was extracted by just grepping for ".generic_name". Note that we don't need to worry about listing new virtio-pci devices in HW_COMPAT_2_6 in the future, because new devices won't require QEMU 2.6 compatibility.

I fully expect that e.g. packed ring support will need to affect all virtio devices too. And it's likely that we'll have some new virtio-pci transport features too.

Quoted 3 lines

This makes the compat entries annoyingly verbose, but is simpler than the alternative of making the virtio-pci type inheritance rules even more complex.

God forbid we forgot something, the only way to notice is to run a cross version migration with an old qemu.
I think we need to come up with something less verbose and fragile.

Quoted 6 lines
Quoted 2 lines

I guess we could use a script like tests/acceptance/virtio_version.py to do a check?

That's a good idea. On test code we can try additional tricks to detect the hybrid virtio devices without increasing the complexity of QEMU code. I'll give it a try.

I did it but I'm not happy with the result: many of the virtio devices can't be tested without extra arguments. Some of them (like vhost-*) require extra privileges on the host that might be unavailable.

Quoted 8 lines

Anyway, while writing this I noticed another issue: many of the virtio devices in QEMU 2.6 were already modern-only!

Setting disable-modern=off on modern-only devices like virtio-vga or virtio-tablet-pci doesn't make sense. This means setting virtio-pci.disable-modern=off on HW_COMPAT_2_6 was incorrect even before the -non-transitional and -transitional device types were introduced.

Quoted 3 lines

It did create an opportunity to create non working devices.

Whether that's incorrect as such I'm not sure.

Quoted 8 lines

This is not just creating the opportunity for an user to disable-modern=on. HW_COMPAT_2_6 is actually setting disable-modern=on on virtio-vga and other modern-only devices. Sounds like a mistake to me.

Luckily those modern-only devices silently ignore the disable-modern/disable-legacy properties, but this might change in the future.

Worry about it then?

Signature · 1 line
MST
#9 lore raw
Quoted 76 lines · Michael S. Tsirkin
Quoted 75 lines · Eduardo Habkost
Quoted 65 lines · Michael S. Tsirkin
Quoted 54 lines · Eduardo Habkost
Quoted 41 lines · Eduardo Habkost
Quoted 40 lines · Dr. David Alan Gilbert
Quoted 38 lines · * Michael S. Tsirkin ([email protected]) wrote:
Quoted 20 lines · Eduardo Habkost

The virtio-pci entries in HW_COMPAT_2_6 had an implicit
assumption: that all virtio-pci subclasses support the disable-legacy and disable-modern options.

That assumption was broken by commit f6e501a28ef9 ("virtio:
Provide version-specific variants of virtio PCI devices"). This caused QEMU to crash if using the new -non-transitional or -transitional device types:

  $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
    -device virtio-net-pci-non-transitional
  Unexpected error in object_property_find() at qom/object.c:1092:
  qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
  global virtio-pci.disable-modern=on: Property '.disable-modern' not found
  Aborted (core dumped)

Replace the virtio-pci.disable-legacy=off and virtio-pci.disable-modern=on entries on HW_COMPAT_2_6 with explicit entries for each generic virtio device type.

Quoted 5 lines

The full list of generic virtio device types was extracted by just grepping for ".generic_name". Note that we don't need to worry about listing new virtio-pci devices in HW_COMPAT_2_6 in the future, because new devices won't require QEMU 2.6 compatibility.

I fully expect that e.g. packed ring support will need to affect all virtio devices too. And it's likely that we'll have some new virtio-pci transport features too.

Quoted 3 lines

This makes the compat entries annoyingly verbose, but is simpler than the alternative of making the virtio-pci type inheritance rules even more complex.

God forbid we forgot something, the only way to notice is to run a cross version migration with an old qemu.
I think we need to come up with something less verbose and fragile.

Quoted 6 lines
Quoted 2 lines

I guess we could use a script like tests/acceptance/virtio_version.py to do a check?

That's a good idea. On test code we can try additional tricks to detect the hybrid virtio devices without increasing the complexity of QEMU code. I'll give it a try.

I did it but I'm not happy with the result: many of the virtio devices can't be tested without extra arguments. Some of them (like vhost-*) require extra privileges on the host that might be unavailable.

Quoted 8 lines

Anyway, while writing this I noticed another issue: many of the virtio devices in QEMU 2.6 were already modern-only!

Setting disable-modern=off on modern-only devices like virtio-vga or virtio-tablet-pci doesn't make sense. This means setting virtio-pci.disable-modern=off on HW_COMPAT_2_6 was incorrect even before the -non-transitional and -transitional device types were introduced.

Quoted 3 lines

It did create an opportunity to create non working devices.

Whether that's incorrect as such I'm not sure.

This is not just creating the opportunity for an user to disable-modern=on. HW_COMPAT_2_6 is actually setting disable-modern=on on virtio-vga and other modern-only devices. Sounds like a mistake to me.

Quoted 5 lines
Quoted 3 lines

Luckily those modern-only devices silently ignore the disable-modern/disable-legacy properties, but this might change in the future.

Worry about it then?

Right, we don't need to worry about it today. But if a solution to the crash reported by Thomas will make the problem go away, that's even better.

Signature · 1 line
Eduardo
#10 lore raw
Quoted 28 lines · On Fri, 4 Jan 2019 20:00:50 -0200 Eduardo Habkost <[email protected]> wrote:
Quoted 27 lines · Michael S. Tsirkin
Quoted 25 lines · Eduardo Habkost
Quoted 12 lines · Michael S. Tsirkin
Quoted 8 lines · Eduardo Habkost

Anyway, while writing this I noticed another issue: many of the virtio devices in QEMU 2.6 were already modern-only!

Setting disable-modern=off on modern-only devices like virtio-vga or virtio-tablet-pci doesn't make sense. This means setting virtio-pci.disable-modern=off on HW_COMPAT_2_6 was incorrect even before the -non-transitional and -transitional device types were introduced.

Quoted 3 lines

It did create an opportunity to create non working devices.

Whether that's incorrect as such I'm not sure.

This is not just creating the opportunity for an user to disable-modern=on. HW_COMPAT_2_6 is actually setting disable-modern=on on virtio-vga and other modern-only devices. Sounds like a mistake to me.

Luckily those modern-only devices silently ignore the disable-modern/disable-legacy properties, but this might change in the future.

Quoted 5 lines
Quoted 1 line

Worry about it then?

Right, we don't need to worry about it today. But if a solution to the crash reported by Thomas will make the problem go away, that's even better.

It seems your patch with the modern-only devices removed from the list would achieve that?

#11 lore raw
Quoted 31 lines · Cornelia Huck
Quoted 28 lines · On Fri, 4 Jan 2019 20:00:50 -0200 Eduardo Habkost <[email protected]> wrote:
Quoted 27 lines · Michael S. Tsirkin
Quoted 25 lines · Eduardo Habkost
Quoted 12 lines · Michael S. Tsirkin
Quoted 8 lines · Eduardo Habkost

Anyway, while writing this I noticed another issue: many of the virtio devices in QEMU 2.6 were already modern-only!

Setting disable-modern=off on modern-only devices like virtio-vga or virtio-tablet-pci doesn't make sense. This means setting virtio-pci.disable-modern=off on HW_COMPAT_2_6 was incorrect even before the -non-transitional and -transitional device types were introduced.

Quoted 3 lines

It did create an opportunity to create non working devices.

Whether that's incorrect as such I'm not sure.

This is not just creating the opportunity for an user to disable-modern=on. HW_COMPAT_2_6 is actually setting disable-modern=on on virtio-vga and other modern-only devices. Sounds like a mistake to me.

Luckily those modern-only devices silently ignore the disable-modern/disable-legacy properties, but this might change in the future.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Worry about it then?

Right, we don't need to worry about it today. But if a solution to the crash reported by Thomas will make the problem go away, that's even better.

It seems your patch with the modern-only devices removed from the list would achieve that?

I think so. But I think I'll do the removal of modern-only devices from the list in a separate patch, just to be safe.

Signature · 1 line
Eduardo
#12 lore raw
In reply to Michael S. Tsirkin
Quoted 27 lines · Michael S. Tsirkin
Quoted 20 lines · Eduardo Habkost

The virtio-pci entries in HW_COMPAT_2_6 had an implicit
assumption: that all virtio-pci subclasses support the disable-legacy and disable-modern options.

That assumption was broken by commit f6e501a28ef9 ("virtio:
Provide version-specific variants of virtio PCI devices"). This caused QEMU to crash if using the new -non-transitional or -transitional device types:

  $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
    -device virtio-net-pci-non-transitional
  Unexpected error in object_property_find() at qom/object.c:1092:
  qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
  global virtio-pci.disable-modern=on: Property '.disable-modern' not found
  Aborted (core dumped)

Replace the virtio-pci.disable-legacy=off and virtio-pci.disable-modern=on entries on HW_COMPAT_2_6 with explicit entries for each generic virtio device type.

Quoted 5 lines

The full list of generic virtio device types was extracted by just grepping for ".generic_name". Note that we don't need to worry about listing new virtio-pci devices in HW_COMPAT_2_6 in the future, because new devices won't require QEMU 2.6 compatibility.

Quoted 3 lines

I fully expect that e.g. packed ring support will need to affect all virtio devices too. And it's likely that we'll have some new virtio-pci transport features too.

If you need to affect all virtio devices, you can still use .driver="virtio-pci" on compat_props. This is just about the disable-legacy and disable-modern properties.

Quoted 8 lines
Quoted 4 lines

This makes the compat entries annoyingly verbose, but is simpler than the alternative of making the virtio-pci type inheritance rules even more complex.

God forbid we forgot something, the only way to notice is to run a cross version migration with an old qemu.
I think we need to come up with something less verbose and fragile.

Both approaches can break if we forget something or do something wrong. I don't think this one is more fragile than the others.

The difference is that this one lets us list the device types once on compat_props and never think about it again. The others would require us to worry forever about subtle interactions between the disable-modern/disable-legacy properties and QOM inheritance.

Quoted 165 lines
Quoted 165 lines

---

---
 include/hw/compat.h | 140 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 138 insertions(+), 2 deletions(-)
include/hw/compat.h +138 -2
index 3ca85b037c..fbb6c1138a 100644
@@ -163,11 +163,147 @@
         .property = "format_transport_address",\
         .value    = "off",\
     },{\
-        .driver   = "virtio-pci",\
+        .driver   = "vhost-scsi-pci",\
         .property = "disable-modern",\
         .value    = "on",\
     },{\
-        .driver   = "virtio-pci",\
+        .driver   = "vhost-scsi-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "vhost-user-blk-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "vhost-user-blk-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "vhost-user-scsi-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "vhost-user-scsi-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "vhost-vsock-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "vhost-vsock-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-9p-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-9p-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-balloon-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-balloon-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-blk-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-blk-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-crypto-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-crypto-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-gpu-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-gpu-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-input-host-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-input-host-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-keyboard-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-keyboard-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-mouse-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-mouse-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-rng-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-rng-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-scsi-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-scsi-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-serial-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-serial-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-tablet-pci",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-tablet-pci",\
+        .property = "disable-legacy",\
+        .value    = "off",\
+    },{\
+        .driver   = "virtio-vga",\
+        .property = "disable-modern",\
+        .value    = "on",\
+    },{\
+        .driver   = "virtio-vga",\
         .property = "disable-legacy",\
         .value    = "off",\
     },
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
Signature · 1 line
Eduardo
Reviewed-by on v1 1/1
#13 lore raw
In reply to Eduardo Habkost
Quoted 20 lines · On Fri, 4 Jan 2019 01:22:26 -0200 Eduardo Habkost <[email protected]> wrote:

The virtio-pci entries in HW_COMPAT_2_6 had an implicit
assumption: that all virtio-pci subclasses support the disable-legacy and disable-modern options.

That assumption was broken by commit f6e501a28ef9 ("virtio:
Provide version-specific variants of virtio PCI devices"). This caused QEMU to crash if using the new -non-transitional or -transitional device types:

  $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
    -device virtio-net-pci-non-transitional
  Unexpected error in object_property_find() at qom/object.c:1092:
  qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
  global virtio-pci.disable-modern=on: Property '.disable-modern' not found
  Aborted (core dumped)

Replace the virtio-pci.disable-legacy=off and virtio-pci.disable-modern=on entries on HW_COMPAT_2_6 with explicit entries for each generic virtio device type.

Quoted 5 lines

The full list of generic virtio device types was extracted by just grepping for ".generic_name". Note that we don't need to worry about listing new virtio-pci devices in HW_COMPAT_2_6 in the future, because new devices won't require QEMU 2.6 compatibility.

Some of these will not be relevant for 2.6 compat, but better safe than sorry :)

Quoted 4 lines

This makes the compat entries annoyingly verbose, but is simpler than the alternative of making the virtio-pci type inheritance rules even more complex.

Maybe also write out explicitly:

Fixes f6e501a28ef9 ("virtio: Provide version-specific variants of virtio PCI devices")
Quoted 7 lines

---

---
 include/hw/compat.h | 140 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 138 insertions(+), 2 deletions(-)
#14 lore raw
Quoted 23 lines · Cornelia Huck
Quoted 20 lines · On Fri, 4 Jan 2019 01:22:26 -0200 Eduardo Habkost <[email protected]> wrote:

The virtio-pci entries in HW_COMPAT_2_6 had an implicit
assumption: that all virtio-pci subclasses support the disable-legacy and disable-modern options.

That assumption was broken by commit f6e501a28ef9 ("virtio:
Provide version-specific variants of virtio PCI devices"). This caused QEMU to crash if using the new -non-transitional or -transitional device types:

  $ qemu-system-x86_64 -machine pc-i440fx-2.6 \
    -device virtio-net-pci-non-transitional
  Unexpected error in object_property_find() at qom/object.c:1092:
  qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
  global virtio-pci.disable-modern=on: Property '.disable-modern' not found
  Aborted (core dumped)

Replace the virtio-pci.disable-legacy=off and virtio-pci.disable-modern=on entries on HW_COMPAT_2_6 with explicit entries for each generic virtio device type.

Quoted 8 lines
Quoted 5 lines

The full list of generic virtio device types was extracted by just grepping for ".generic_name". Note that we don't need to worry about listing new virtio-pci devices in HW_COMPAT_2_6 in the future, because new devices won't require QEMU 2.6 compatibility.

Some of these will not be relevant for 2.6 compat, but better safe than sorry :)

Yes. My first version was based on grepping the v2.6.0 tree, but then I decided to be safer and grep for ".generic_name" on qemu.git master. Just in case somebody is using a v2.7+ device type with 2.6 machine-types.

Quoted 9 lines
Quoted 5 lines

This makes the compat entries annoyingly verbose, but is simpler than the alternative of making the virtio-pci type inheritance rules even more complex.

Maybe also write out explicitly:

Fixes f6e501a28ef9 ("virtio: Provide version-specific variants of virtio PCI devices")

Yes, I forgot to do it. Thanks no noting!

Quoted 10 lines
Quoted 8 lines

---

---
 include/hw/compat.h | 140 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 138 insertions(+), 2 deletions(-)
Signature · 1 line
Eduardo