qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] QOM: Can devices having link properties be user-creatab


From: Peter Maydell
Subject: Re: [Qemu-devel] QOM: Can devices having link properties be user-creatable?
Date: Fri, 12 Oct 2018 14:14:55 +0100

On 12 October 2018 at 14:06, Philippe Mathieu-Daudé <address@hidden> wrote:
> On 12/10/2018 15:01, Peter Maydell wrote:
>> On 12 October 2018 at 13:47, Philippe Mathieu-Daudé <address@hidden> wrote:
>>> While looking at Mao's series
>>> (https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg02519.html) I
>>> wondered if devices having link properties can be user-creatable.
>>>
>>> Using the following patch (I don't think this is correct to put qdev
>>> code into qobject, but I used this as PoC):
>>>
>>> -- >8 --
>>> diff --git a/qom/object.c b/qom/object.c
>>> index 547dcf97c3..2dd3a25531 100644
>>> --- a/qom/object.c
>>> +++ b/qom/object.c
>>> @@ -16,4 +16,5 @@
>>>  #include "qom/object_interfaces.h"
>>>  #include "qemu/cutils.h"
>>> +#include "qemu/error-report.h"
>>>  #include "qapi/visitor.h"
>>>  #include "qapi/string-input-visitor.h"
>>> @@ -1662,4 +1663,11 @@ void object_property_add_link(Object *obj, const
>>> char *name,
>>>      gchar *full_type;
>>>      ObjectProperty *op;
>>> +    ObjectClass *klass = object_get_class(obj);
>>> +
>>> +    if (klass && object_dynamic_cast(obj, TYPE_DEVICE) &&
>>> +                 DEVICE_CLASS(klass)->user_creatable == false) {
>>> +        warn_report("Device type '%s' is user_creatable "
>>> +                    "(linked property: '%s')", type, name);
>>> +    }
>>>
>>>      prop->child = child;
>>> ---
>>>
>>> I get:
>>>
>>> $ aarch64-softmmu/qemu-system-aarch64 -M virt
>>> qemu-system-aarch64: warning: Device type 'bus' is user_creatable
>>> (linked property: 'parent_bus')
>>> qemu-system-aarch64: warning: Device type 'qemu:memory-region' is
>>> user_creatable (linked property: 'memory')
>>
>> Is your warning printing the wrong thing? "bus", "irq",
>> etc don't seem like names of devices...
>
> Oh indeed I inverted (type, name) :)

Yes, but also what we want to know is the type name of
the object obj we're adding the link property to (that
is the object which is marked user-creatable). The
"type" variable here is the type of the thing being linked.
So I think printing object_get_typename(obj) would be helpful.

thanks
-- PMM



reply via email to

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