Skip to contentSkip to conversation

allow to deprecate objects and devices

PATCH Superseded Gerd Hoffmann 6 participants 11 messages May 28, 2024 – Jun 3, 2024 Arm/Amlogic Meson SoC support

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover allow to deprecate objects and devices

Put some infrastructure in place to allow tagging objects (including devices) as deprected. Use it to mark the ohci pci host adapter and the usb hub as deprecated.

Gerd Hoffmann (4):
qom: allow to mark objects (including devices) as deprecated.
usb: add config options for the hub and hid devices usb/ohci-pci: deprecate, don't build by default usb/hub: deprecate, don't build by default

 include/qom/object.h  |  1 +
 hw/usb/dev-hub.c      |  1 +
 hw/usb/hcd-ohci-pci.c |  1 +
 qom/qom-qmp-cmds.c    |  4 ++++
 system/qdev-monitor.c |  5 +++++
 hw/usb/Kconfig        | 10 +++++++++-
 hw/usb/meson.build    |  4 ++--
 qapi/qom.json         |  4 +++-
 8 files changed, 26 insertions(+), 4 deletions(-)
Signature · 1 line
2.45.1
#1 lore raw

PATCH 1/4 qom: allow to mark objects (including devices) as deprecated.

Add deprecation_note field (string) to ObjectClass.
Add deprecated bool to ObjectTypeInfo, report in 'qom-list-types'. Print the note when listing devices via '-device help'.

---
 include/qom/object.h  | 1 +
 qom/qom-qmp-cmds.c    | 4 ++++
 system/qdev-monitor.c | 5 +++++
 qapi/qom.json         | 4 +++-
 4 files changed, 13 insertions(+), 1 deletion(-)
include/qom/object.h +1 -0
index 13d3a655ddf9..6c682aa0135f 100644
@@ -136,6 +136,7 @@ struct ObjectClass
     ObjectUnparent *unparent;
 
     GHashTable *properties;
+    const char *deprecation_note;
 };
 
 /**
qom/qom-qmp-cmds.c +4 -0
index e91a2353472a..43de9c9ae141 100644
@@ -101,6 +101,10 @@ static void qom_list_types_tramp(ObjectClass *klass, void *data)
     if (parent) {
         info->parent = g_strdup(object_class_get_name(parent));
     }
+    if (klass->deprecation_note) {
+        info->has_deprecated = true;
+        info->deprecated = true;
+    }
 
     QAPI_LIST_PREPEND(*pret, info);
 }
system/qdev-monitor.c +5 -0
index 6af6ef7d667f..704be312e1a7 100644
@@ -144,6 +144,8 @@ static bool qdev_class_has_alias(DeviceClass *dc)
 
 static void qdev_print_devinfo(DeviceClass *dc)
 {
+    ObjectClass *klass = OBJECT_CLASS(dc);
+
     qemu_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc)));
     if (dc->bus_type) {
         qemu_printf(", bus %s", dc->bus_type);
@@ -157,6 +159,9 @@ static void qdev_print_devinfo(DeviceClass *dc)
     if (!dc->user_creatable) {
         qemu_printf(", no-user");
     }
+    if (klass->deprecation_note) {
+        qemu_printf(", deprecated \"%s\"", klass->deprecation_note);
+    }
     qemu_printf("\n");
 }
 
qapi/qom.json +3 -1
index 38dde6d785ac..bd062feabaf7 100644
@@ -163,10 +163,12 @@
 #
 # @parent: Name of parent type, if any (since 2.10)
 #
+# @deprecated: the type is deprecated (since 9.1)
+#
 # Since: 1.1
 ##
 { 'struct': 'ObjectTypeInfo',
-  'data': { 'name': 'str', '*abstract': 'bool', '*parent': 'str' } }
+  'data': { 'name': 'str', '*abstract': 'bool', '*parent': 'str', '*deprecated': 'bool' } }
 
 ##
 # @qom-list-types:
Signature · 1 line
2.45.1
#2 lore raw

Re: [PATCH 1/4] qom: allow to mark objects (including devices) as deprecated.

Quoted 11 lines · Gerd Hoffmann

Add deprecation_note field (string) to ObjectClass.
Add deprecated bool to ObjectTypeInfo, report in 'qom-list-types'. Print the note when listing devices via '-device help'.

---
 include/qom/object.h  | 1 +
 qom/qom-qmp-cmds.c    | 4 ++++
 system/qdev-monitor.c | 5 +++++
 qapi/qom.json         | 4 +++-
 4 files changed, 13 insertions(+), 1 deletion(-)

I think that object.c, object_init_with_type() should be printing a message on stderr when creating an instance of a deprecated object/device, since we do that with machine types and CPUs that are deprecated.

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#3 lore raw

PATCH 2/4 usb: add config options for the hub and hid devices

In reply to Gerd Hoffmann
---
 hw/usb/Kconfig     | 10 ++++++++++
 hw/usb/meson.build |  4 ++--
 2 files changed, 12 insertions(+), 2 deletions(-)
hw/usb/Kconfig +10 -0
index f569ed7eeaa1..84bc7fbe36cd 100644
@@ -65,6 +65,16 @@ config TUSB6010
     bool
     select USB_MUSB
 
+config USB_HUB
+    bool
+    default y
+    depends on USB
+
+config USB_HID
+    bool
+    default y
+    depends on USB
+
 config USB_TABLET_WACOM
     bool
     default y
hw/usb/meson.build +2 -2
index 23f7f7acb50b..d7de1003e3db 100644
@@ -35,8 +35,8 @@ system_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal-usb2-ctrl-
 system_ss.add(when: 'CONFIG_XLNX_USB_SUBSYS', if_true: files('xlnx-usb-subsystem.c'))
 
 # emulated usb devices
-system_ss.add(when: 'CONFIG_USB', if_true: files('dev-hub.c'))
-system_ss.add(when: 'CONFIG_USB', if_true: files('dev-hid.c'))
+system_ss.add(when: 'CONFIG_USB_HUB', if_true: files('dev-hub.c'))
+system_ss.add(when: 'CONFIG_USB_HID', if_true: files('dev-hid.c'))
 system_ss.add(when: 'CONFIG_USB_TABLET_WACOM', if_true: files('dev-wacom.c'))
 system_ss.add(when: 'CONFIG_USB_STORAGE_CORE', if_true: files('dev-storage.c'))
 system_ss.add(when: 'CONFIG_USB_STORAGE_BOT', if_true: files('dev-storage-bot.c'))
Signature · 1 line
2.45.1
#5 lore raw

PATCH 3/4 usb/ohci-pci: deprecate, don't build by default

In reply to Gerd Hoffmann

The xhci host adapter is the much better choice.

---
 hw/usb/hcd-ohci-pci.c | 1 +
 hw/usb/Kconfig        | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
hw/usb/hcd-ohci-pci.c +1 -0
index 33ed9b6f5a52..88de657def71 100644
@@ -143,6 +143,7 @@ static void ohci_pci_class_init(ObjectClass *klass, void *data)
     dc->hotpluggable = false;
     dc->vmsd = &vmstate_ohci;
     dc->reset = usb_ohci_reset_pci;
+    klass->deprecation_note = "use qemu-xhci instead";
 }
 
 static const TypeInfo ohci_pci_info = {
hw/usb/Kconfig +0 -1
index 84bc7fbe36cd..c4a6ea5a687f 100644
@@ -17,7 +17,6 @@ config USB_OHCI_SYSBUS
 
 config USB_OHCI_PCI
     bool
-    default y if PCI_DEVICES
     depends on PCI
     select USB_OHCI
 
Signature · 1 line
2.45.1
#6 lore raw

Re: [PATCH 3/4] usb/ohci-pci: deprecate, don't build by default

Quoted 25 lines · Gerd Hoffmann

The xhci host adapter is the much better choice.

---
  hw/usb/hcd-ohci-pci.c | 1 +
  hw/usb/Kconfig        | 1 -
  2 files changed, 1 insertion(+), 1 deletion(-)
hw/usb/hcd-ohci-pci.c +1 -0
index 33ed9b6f5a52..88de657def71 100644
@@ -143,6 +143,7 @@ static void ohci_pci_class_init(ObjectClass *klass, void *data)
      dc->hotpluggable = false;
      dc->vmsd = &vmstate_ohci;
      dc->reset = usb_ohci_reset_pci;
+    klass->deprecation_note = "use qemu-xhci instead";
  }
 
  static const TypeInfo ohci_pci_info = {
hw/usb/Kconfig +0 -0
index 84bc7fbe36cd..c4a6ea5a687f 100644

hw/usb/Kconfig config USB_OHCI_SYSBUS · line 21

Quoted 6 lines
hw/usb/Kconfig +0 -1
@@ -17,7 +17,6 @@ config USB_OHCI_SYSBUS
 
  config USB_OHCI_PCI
      bool
-    default y if PCI_DEVICES
      depends on PCI
      select USB_OHCI

Not sure whether we should disable it by default just because it is deprecated. We don't do that for any other devices as far as I know.

Anyway, you should add the device to docs/about/deprecated.rst to really mark it as deprecated, since that's our official list (AFAIK).

Also, there are still some machines that use this device:

$ grep -r USB_OHCI_PCI *
hw/hppa/Kconfig:    imply USB_OHCI_PCI
hw/mips/Kconfig:    imply USB_OHCI_PCI
hw/ppc/Kconfig:    imply USB_OHCI_PCI
hw/ppc/Kconfig:    imply USB_OHCI_PCI

pseries could certainly continue without OHCI AFAICT, but the others? Maybe this needs some discussion first... (thus putting some more people on CC:)

Thomas

#7 lore raw

Re: [PATCH 3/4] usb/ohci-pci: deprecate, don't build by default

Quoted 37 lines · Thomas Huth
Quoted 24 lines · Gerd Hoffmann

The xhci host adapter is the much better choice.

---
  hw/usb/hcd-ohci-pci.c | 1 +
  hw/usb/Kconfig        | 1 -

  2 files changed, 1 insertion(+), 1 deletion(-)
hw/usb/hcd-ohci-pci.c +1 -0
index 33ed9b6f5a52..88de657def71 100644
@@ -143,6 +143,7 @@ static void ohci_pci_class_init(ObjectClass *klass, void *data)
       dc->hotpluggable = false;
       dc->vmsd = &vmstate_ohci;
       dc->reset = usb_ohci_reset_pci;
+    klass->deprecation_note = "use qemu-xhci instead";
   }
   static const TypeInfo ohci_pci_info = {
hw/usb/Kconfig +0 -0
index 84bc7fbe36cd..c4a6ea5a687f 100644
@@ -17,7 +17,6 @@ config USB_OHCI_SYSBUS
Quoted 5 lines

  config USB_OHCI_PCI
      bool
-    default y if PCI_DEVICES
      depends on PCI
      select USB_OHCI

Not sure whether we should disable it by default just because it is deprecated. We don't do that for any other devices as far as I know.

Anyway, you should add the device to docs/about/deprecated.rst to really mark it as deprecated, since that's our official list (AFAIK).

Also, there are still some machines that use this device:

Quoted 7 lines
$ grep -r USB_OHCI_PCI *
hw/hppa/Kconfig:    imply USB_OHCI_PCI
hw/mips/Kconfig:    imply USB_OHCI_PCI
hw/ppc/Kconfig:    imply USB_OHCI_PCI
hw/ppc/Kconfig:    imply USB_OHCI_PCI

pseries could certainly continue without OHCI AFAICT, but the others? Maybe this needs some discussion first... (thus putting some more people on CC:)

There was never a XHCI host on any of the hppa machines, but the latest generation of HP machines do have built-in OHCI controllers. So, deprecating OHCI in favor of XHCI will prevent emulation of HP-UX on the hppa target.
So, for hppa the "xhci host adapter is NOT the much better choice.".

Helge

#8 lore raw

Re: [PATCH 3/4] usb/ohci-pci: deprecate, don't build by default

In reply to Thomas Huth
Quoted 6 lines · Thomas Huth
Quoted 6 lines
hw/usb/Kconfig +0 -0
index 84bc7fbe36cd..c4a6ea5a687f 100644
@@ -17,7 +17,6 @@ config USB_OHCI_SYSBUS
 
Quoted 10 lines

hw/usb/Kconfig config USB_OHCI_SYSBUS · line 21

Quoted 5 lines
hw/usb/Kconfig +0 -1
  config USB_OHCI_PCI
      bool
-    default y if PCI_DEVICES
      depends on PCI
      select USB_OHCI

Not sure whether we should disable it by default just because it is deprecated. We don't do that for any other devices as far as I know. Anyway, you should add the device to docs/about/deprecated.rst to really mark it as deprecated, since that's our official list (AFAIK).

That would mean removing it, but that's a bad idea. It's not like the device is blocking improvements elsewhere (in fact it's not even removing any code because the sysbus OHCI is still there).

Quoted 9 lines

Also, there are still some machines that use this device:

$ grep -r USB_OHCI_PCI *
hw/hppa/Kconfig:    imply USB_OHCI_PCI
hw/mips/Kconfig:    imply USB_OHCI_PCI
hw/ppc/Kconfig:    imply USB_OHCI_PCI
hw/ppc/Kconfig:    imply USB_OHCI_PCI

pseries could certainly continue without OHCI AFAICT, but the others?

Yeah, this needs to be a per-machine type choice to warn about discouraged devices. Some, such as Cirrus, can probably be unconditional, but still I wouldn't remove them.

Paolo

#9 lore raw

Re: [PATCH 3/4] usb/ohci-pci: deprecate, don't build by default

In reply to Thomas Huth
Quoted 43 lines · Thomas Huth
Quoted 24 lines · Gerd Hoffmann

The xhci host adapter is the much better choice.

---
  hw/usb/hcd-ohci-pci.c | 1 +
  hw/usb/Kconfig        | 1 -

  2 files changed, 1 insertion(+), 1 deletion(-)
hw/usb/hcd-ohci-pci.c +1 -0
index 33ed9b6f5a52..88de657def71 100644
@@ -143,6 +143,7 @@ static void ohci_pci_class_init(ObjectClass *klass, void *data)
       dc->hotpluggable = false;
       dc->vmsd = &vmstate_ohci;
       dc->reset = usb_ohci_reset_pci;
+    klass->deprecation_note = "use qemu-xhci instead";
   }
   static const TypeInfo ohci_pci_info = {
hw/usb/Kconfig +0 -0
index 84bc7fbe36cd..c4a6ea5a687f 100644
@@ -17,7 +17,6 @@ config USB_OHCI_SYSBUS
Quoted 5 lines

  config USB_OHCI_PCI
      bool
-    default y if PCI_DEVICES
      depends on PCI
      select USB_OHCI

Not sure whether we should disable it by default just because it is deprecated. We don't do that for any other devices as far as I know.

Anyway, you should add the device to docs/about/deprecated.rst to really mark it as deprecated, since that's our official list (AFAIK).

Also, there are still some machines that use this device:

$ grep -r USB_OHCI_PCI *
hw/hppa/Kconfig:    imply USB_OHCI_PCI
hw/mips/Kconfig:    imply USB_OHCI_PCI
hw/ppc/Kconfig:    imply USB_OHCI_PCI
hw/ppc/Kconfig:    imply USB_OHCI_PCI
Quoted 3 lines

pseries could certainly continue without OHCI AFAICT, but the others? Maybe this needs some discussion first... (thus putting some more people on CC:)

 Thomas

The mac99 machine has an in-built OHCI PCI interface so I don't think this device should be marked as deprecated. Normally in these cases isn't it just a matter of updating documentation to recommend XHCI over OHCI for particular uses?

ATB,

Mark.

#10 lore raw

PATCH 4/4 usb/hub: deprecate, don't build by default

In reply to Gerd Hoffmann

The hub supports only USB 1.1. When running out of usb ports it is in almost all cases the much better choice to add another usb host adapter (or increase the number of root ports when using xhci) instead of using the usb hub.

---
 hw/usb/dev-hub.c | 1 +
 hw/usb/Kconfig   | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
hw/usb/dev-hub.c +1 -0
index 06e9537d0356..68444d39534f 100644
@@ -686,6 +686,7 @@ static void usb_hub_class_initfn(ObjectClass *klass, void *data)
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "hub";
     dc->vmsd = &vmstate_usb_hub;
+    klass->deprecation_note = "use more root ports or additional hostadapters instead";
     device_class_set_props(dc, usb_hub_properties);
 }
 
hw/usb/Kconfig +0 -1
index c4a6ea5a687f..a8644c43296b 100644
@@ -66,7 +66,6 @@ config TUSB6010
 
 config USB_HUB
     bool
-    default y
     depends on USB
 
 config USB_HID
Signature · 1 line
2.45.1