On Mon, Mar 26, 2012 at 7:54 PM, Stefan Hajnoczi <stefa...@gmail.com> wrote: > On Mon, Mar 26, 2012 at 6:40 AM, <zwu.ker...@gmail.com> wrote: >> From: Zhi Yong Wu <wu...@linux.vnet.ibm.com> >> >> Sending the patchset is mainly intended to get some comments and void the >> wrong development direction. >> >> The patchset is used to qomify -netdev, but it introduce one infrastructure >> for host devices based on raw Class and Object, not qdev. So they are not >> related with DeviceClass and DeviceState. >> >> patch #1 introduce one new class and object for host devices. > > A common infrastructure for host devices is useful. The Property > mechanism in hw/qdev-properties.c is especially good. I think host > devices will also need to 2-step creation process (init and realize). Yeah. > > I think the qdev-properties.c code can mostly be shared. It currently > uses the qdev DeviceState class but I think it only really access the > Property array. struct Property { const char *name; PropertyInfo *info; int offset; uint8_t bitnr; uint8_t qtype; int64_t defval; };
struct PropertyInfo { const char *name; const char *legacy_name; const char **enum_table; int64_t min; int64_t max; int (*parse)(DeviceState *dev, Property *prop, const char *str); int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len); ObjectPropertyAccessor *get; ObjectPropertyAccessor *set; ObjectPropertyRelease *release; }; Like above, its member functions pointers use DeviceState, so we will have to consider how to make this PropertyInfo more generic and be used by other Class and Object which are not based on DeviceState. > > Therefore it should be possible to really share a single copy of the > code. We don't need to duplicate Property for host devices, instead > we can extract it out of hw/. Yeah, but we need to make some effort to reach this goal. > > Stefan -- Regards, Zhi Yong Wu