qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] qdev properties vs qom object properties


From: Paolo Bonzini
Subject: Re: [Qemu-devel] qdev properties vs qom object properties
Date: Mon, 5 Jun 2017 15:32:56 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0


On 05/06/2017 15:10, Peter Maydell wrote:
> I perpetually get confused about qdev properties vs QOM object
> properties.
> 
> Why do we have both of these APIs?
> How do they interact?

qdev properties are just a wrapper around QOM object properties, taking
care of:

- not allowing to set the property after realize

- providing default values

- letting people use the familiar DEFINE_PROP_* array syntax

- pretty printing for "info qtree" (which right now is only used by PCI
devfn and vlan properties)

> Which is the recommended one for new device code?
> Do we have a transition plan for old code?
> Where should I be looking for the documentation on this?

There is no transition plan, qdev properties are not going to go away
soon unless someone actually makes a plan.

Now that there are QOM class properties, it would actually be feasible
to make qdev_property_add_static define QOM properties on the class
rather than the object.  In other words, instead of

    dc->props = virtio_serial_pci_properties;

you'd have something like:

    qdev_add_class_properties(klass, usb_tablet_properties);

or even inlined calls like the following:

    QDEV_DEFINE_CLASS_PROP_UINT32(klass, "usb_version", USBHIDState,
                                  usb_version, 2);
    QDEV_DEFINE_CLASS_PROP_STRING(klass, "display", USBHIDState,
                                  display);
    QDEV_DEFINE_CLASS_PROP_UINT32(klass, "head", USBHIDState, head, 0);

> For a specific example, I see that target/arm is the only code
> using qdev_property_add_static(), but there's no indication
> that the function is deprecated or what the right thing to be
> doing instead is. Any suggestions?

The weird thing in ARM code is that the set of properties depends on the
CPU model.  That's the only reason why it uses
qdev_property_add_static() as far as I can see.

Paolo



reply via email to

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