Print a warning for deprecated and obsolete devices.
Also add support state to device listing.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/core/qdev.c | 8 +++++++-
qdev-monitor.c | 9 +++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 6b3cc55b27..6205522c3e 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)
{
+ ObjectClass *oc;
DeviceState *dev;
- if (object_class_by_name(type) == NULL) {
+ oc = object_class_by_name(type);
+ if (oc == NULL) {
return NULL;
}
+ if (qemu_is_deprecated(oc) ||
+ qemu_is_obsolete(oc)) {
+ qemu_warn_support_state("device", type, oc);
+ }
dev = DEVICE(object_new(type));
if (!dev) {
return NULL;
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 802c18a74e..80370372f9 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -115,6 +115,8 @@ static void out_printf(const char *fmt, ...)
static void qdev_print_devinfo(DeviceClass *dc)
{
+ ObjectClass *oc = OBJECT_CLASS(dc);
+
out_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc)));
if (dc->bus_type) {
out_printf(", bus %s", dc->bus_type);
@@ -128,6 +130,9 @@ static void qdev_print_devinfo(DeviceClass *dc)
if (!dc->user_creatable) {
out_printf(", no-user");
}
+ if (oc->supported.state != SUPPORT_STATE_UNSPECIFIED) {
+ out_printf(", %s", SupportState_str(oc->supported.state));
+ }
out_printf("\n");
}
@@ -579,6 +584,10 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
if (!dc) {
return NULL;
}
+ if (qemu_is_deprecated(OBJECT_CLASS(dc)) ||
+ qemu_is_obsolete(OBJECT_CLASS(dc))) {
+ qemu_warn_support_state("device", driver, OBJECT_CLASS(dc));
+ }
/* find bus */
path = qemu_opt_get(opts, "bus");
--
2.9.3
On Tue, Nov 06, 2018 at 11:23:33AM +0100, Gerd Hoffmann wrote:
> Print a warning for deprecated and obsolete devices.
> Also add support state to device listing.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Should we also add a runtime flag to block these?
E.g. I can see libvirt doing that and passing
the responsibility for what is reasonably
supported to qemu.
> ---
> hw/core/qdev.c | 8 +++++++-
> qdev-monitor.c | 9 +++++++++
> 2 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 6b3cc55b27..6205522c3e 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)
> {
> + ObjectClass *oc;
> DeviceState *dev;
>
> - if (object_class_by_name(type) == NULL) {
> + oc = object_class_by_name(type);
> + if (oc == NULL) {
> return NULL;
> }
> + if (qemu_is_deprecated(oc) ||
> + qemu_is_obsolete(oc)) {
> + qemu_warn_support_state("device", type, oc);
> + }
> dev = DEVICE(object_new(type));
> if (!dev) {
> return NULL;
> diff --git a/qdev-monitor.c b/qdev-monitor.c
> index 802c18a74e..80370372f9 100644
> --- a/qdev-monitor.c
> +++ b/qdev-monitor.c
> @@ -115,6 +115,8 @@ static void out_printf(const char *fmt, ...)
>
> static void qdev_print_devinfo(DeviceClass *dc)
> {
> + ObjectClass *oc = OBJECT_CLASS(dc);
> +
> out_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc)));
> if (dc->bus_type) {
> out_printf(", bus %s", dc->bus_type);
> @@ -128,6 +130,9 @@ static void qdev_print_devinfo(DeviceClass *dc)
> if (!dc->user_creatable) {
> out_printf(", no-user");
> }
> + if (oc->supported.state != SUPPORT_STATE_UNSPECIFIED) {
> + out_printf(", %s", SupportState_str(oc->supported.state));
> + }
> out_printf("\n");
> }
>
> @@ -579,6 +584,10 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
> if (!dc) {
> return NULL;
> }
> + if (qemu_is_deprecated(OBJECT_CLASS(dc)) ||
> + qemu_is_obsolete(OBJECT_CLASS(dc))) {
> + qemu_warn_support_state("device", driver, OBJECT_CLASS(dc));
> + }
>
> /* find bus */
> path = qemu_opt_get(opts, "bus");
> --
> 2.9.3
On Tue, Nov 06, 2018 at 09:36:44AM -0500, Michael S. Tsirkin wrote:
> On Tue, Nov 06, 2018 at 11:23:33AM +0100, Gerd Hoffmann wrote:
> > Print a warning for deprecated and obsolete devices.
> > Also add support state to device listing.
> >
> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>
> Should we also add a runtime flag to block these?
Yes, probably. My priority is to hash out the classification
first though, so it isn't in this series yet.
On the cmd line switches: How much flexibility do we want on this? We
can go for a simple -future switch, as suggested by armbru, disallowing
obsolete and deprecated devices. We could go for a full-blown ...
-policy {experimental,unsupported,...}={enable,warn,disable}
... or something inbetween.
Comments? Other ideas?
cheers,
Gerd
Gerd Hoffmann <kraxel@redhat.com> writes:
> Print a warning for deprecated and obsolete devices.
> Also add support state to device listing.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> hw/core/qdev.c | 8 +++++++-
> qdev-monitor.c | 9 +++++++++
> 2 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 6b3cc55b27..6205522c3e 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)
> {
> + ObjectClass *oc;
> DeviceState *dev;
>
> - if (object_class_by_name(type) == NULL) {
> + oc = object_class_by_name(type);
> + if (oc == NULL) {
> return NULL;
> }
> + if (qemu_is_deprecated(oc) ||
> + qemu_is_obsolete(oc)) {
> + qemu_warn_support_state("device", type, oc);
Looks like this:
$ qemu-system-x86_64 -nodefaults -S -display none -device cirrus-vga
qemu-system-x86_64: -device cirrus-vga: warning: device cirrus-vga is obsolete (use "-vga std" instead, see https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/)
I'd prefer:
$ qemu-system-x86_64 -nodefaults -S -display none -device cirrus-vga
qemu-system-x86_64: -device cirrus-vga: warning: device cirrus-vga is obsolete
Use "-vga std" instead, see
https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
The obvious way to get it:
void warn_support_state(const char *type, const char *name,
ObjectClass *oc)
{
const char *help = oc->supported.help;
warn_report("%s %s is %s", type, name,
SupportState_str(oc->supported.state));
if (help) {
error_printf("%s\n", help);
}
}
with the ->help suitably capitalized and formatted.
That should make qemu_warn_support_state() usable for the previous
patch, too.
Note I scratched the qemu_ prefix. Matter of taste, I guess.
> + }
> dev = DEVICE(object_new(type));
> if (!dev) {
> return NULL;
[...]
© 2016 - 2025 Red Hat, Inc.