[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [Qemu-devel] [PATCH v2 4/6] Warn on obsolete and deprecat
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-ppc] [Qemu-devel] [PATCH v2 4/6] Warn on obsolete and deprecated devices. |
Date: |
Thu, 29 Nov 2018 18:56:43 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Gerd Hoffmann <address@hidden> writes:
> Print a warning for deprecated and obsolete devices.
> Also add support state to device listing.
>
> Signed-off-by: Gerd Hoffmann <address@hidden>
> ---
> 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;
[...]
- [Qemu-ppc] [PATCH v2 0/6] Introducing QemuSupportState, Gerd Hoffmann, 2018/11/06
- [Qemu-ppc] [PATCH v2 4/6] Warn on obsolete and deprecated devices., Gerd Hoffmann, 2018/11/06
- [Qemu-ppc] [PATCH v2 1/6] move ObjectClass to typedefs.h, Gerd Hoffmann, 2018/11/06
- [Qemu-ppc] [PATCH v2 5/6] tag cirrus as obsolete, Gerd Hoffmann, 2018/11/06
- [Qemu-ppc] [PATCH v2 3/6] Use QemuSupportState for machine types., Gerd Hoffmann, 2018/11/06
- [Qemu-ppc] [PATCH v2 2/6] add QemuSupportState, Gerd Hoffmann, 2018/11/06