qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] hw/core/qdev: Increase qdev_realize() kindness


From: Markus Armbruster
Subject: Re: [PATCH] hw/core/qdev: Increase qdev_realize() kindness
Date: Mon, 06 Jul 2020 08:48:58 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Paolo Bonzini <pbonzini@redhat.com> writes:

> Are we sure that qdev_realize is never called with user-provided input? If

The only way to call qdev_realize() with a user-provided bus is -device
/ device_add via qdev_device_add().  qdev_device_add() carefully checks
the user-provided bus before passing it to qdev_realize().

> it's a programming error, the call chain will end up passing &error_abort
> anyway, won't it?

Correct.

>
> Paolo
>
> Il dom 5 lug 2020, 12:05 Philippe Mathieu-Daudé <f4bug@amsat.org> ha
> scritto:
>
>> On 7/5/20 7:46 AM, Paolo Bonzini wrote:
>> > On 20/06/20 17:38, Philippe Mathieu-Daudé wrote:
>> >> -    } else {
>> >> -        assert(!DEVICE_GET_CLASS(dev)->bus_type);
>> >> +    } else if (DEVICE_GET_CLASS(dev)->bus_type) {
>> >> +        error_report("%s: Unexpected bus '%s' for device '%s'",
>> >> +                     __func__, DEVICE_GET_CLASS(dev)->bus_type,
>> >> +                     object_get_typename(OBJECT(dev)));
>> >> +        abort();
>> >>      }
>> >>
>> >
>> > Since there is an errp, should we use it and be even kinder?
>>
>> This is a programming error, not an user triggerable condition,
>> so I'm not sure. IOW this must not happen, but if it does, then
>> the error message helps the developer to notice the problem without
>> having to use gdb.

I don't bother with reporting impossible errors nicely.  Statement, not
objection.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]