diff mbox series

[2/4] add QemuSupportState to DeviceClass

Message ID 20181030111348.14713-3-kraxel@redhat.com
State New
Headers show
Series Introducing QemuSupportState | expand

Commit Message

Gerd Hoffmann Oct. 30, 2018, 11:13 a.m. UTC
So we can tag device support state.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/hw/qdev-core.h | 2 ++
 hw/core/qdev.c         | 8 +++++++-
 qdev-monitor.c         | 7 +++++++
 3 files changed, 16 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index a24d0dd566..ff6bd3f08f 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -3,6 +3,7 @@ 
 
 #include "qemu/queue.h"
 #include "qemu/bitmap.h"
+#include "qemu/support-state.h"
 #include "qom/object.h"
 #include "hw/irq.h"
 #include "hw/hotplug.h"
@@ -105,6 +106,7 @@  typedef struct DeviceClass {
      */
     bool user_creatable;
     bool hotpluggable;
+    QemuSupportState supported;
 
     /* callbacks */
     DeviceReset reset;
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 6b3cc55b27..e788fca257 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -133,11 +133,17 @@  DeviceState *qdev_create(BusState *bus, const char *name)
 
 DeviceState *qdev_try_create(BusState *bus, const char *type)
 {
+    DeviceClass *dc;
     DeviceState *dev;
 
-    if (object_class_by_name(type) == NULL) {
+    dc = DEVICE_CLASS(object_class_by_name(type));
+    if (dc == NULL) {
         return NULL;
     }
+    if (qemu_is_deprecated(&dc->supported) ||
+        qemu_is_obsolete(&dc->supported)) {
+        qemu_warn_support_state("device", type, &dc->supported);
+    }
     dev = DEVICE(object_new(type));
     if (!dev) {
         return NULL;
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 802c18a74e..63cb43691c 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -128,6 +128,9 @@  static void qdev_print_devinfo(DeviceClass *dc)
     if (!dc->user_creatable) {
         out_printf(", no-user");
     }
+    if (dc->supported.state != SUPPORT_STATE_UNKNOWN) {
+        out_printf(", %s", SupportState_str(dc->supported.state));
+    }
     out_printf("\n");
 }
 
@@ -579,6 +582,10 @@  DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
     if (!dc) {
         return NULL;
     }
+    if (qemu_is_deprecated(&dc->supported) ||
+        qemu_is_obsolete(&dc->supported)) {
+        qemu_warn_support_state("device", driver, &dc->supported);
+    }
 
     /* find bus */
     path = qemu_opt_get(opts, "bus");