On 12/01/2011 04:53 PM, Anthony Liguori wrote: > >> What does the client code looks like for link<PCIDevice>? > > I'm not sure what you mean by client code,
This: > but consider a device called UsbController that looks like: > > struct UsbController > { > DeviceState parent; > > UsbDevice *slave; // link property > }; > > To add this as a link, somewhere in the init function you would do: > > > static void usb_controller_initfn(UsbController *dev) > { > ... > qdev_property_add_link(DEVICE(dev), "slave", "UsbDevice", > (DeviceState **)&dev->slave, NULL); > } Issues: - this is an object property, not a class property, so to get a list of properties we need to instantiate an object. - "UsbDevice" as the type is not type safe at compile time - ditto for the cast > > If you want to set the property explicitly, you would just do: > > dev->slave = some_other_device > > You don't need to use any special function to manipulate the link. > Stylistically, I'd prefer that all devices exposed accessor functions > and that you did these things through accessors so that we had clear > rules about what's public and private. Also, so we can have observers that trigger on changes. -- error compiling committee.c: too many arguments to function