Message ID | 4EB1914C.8070706@codemonkey.ws |
---|---|
State | New |
Headers | show |
On Wed, Nov 2, 2011 at 6:51 PM, Anthony Liguori <anthony@codemonkey.ws> wrote: > @@ -77,6 +78,20 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, > const ch > continue; > return info; > } > + > + /* try to load an appropriately named module */ > + { > + char *path = g_module_build_path(PREFIX, info->name); > + GModule *mod = g_module_open(path, G_MODULE_BIND_LOCAL); > + void (*init)(void); > + > + if (g_module_symbol(mod, "mod_init", &init)) { > + init(); We need taint marker support from day 1. Or perhaps a nicer thing: require each module to declare a support URL string. QEMU will print out support URLs when displaying version information or on startup. This way it's easy to indentify who to ask for help if QEMU appears broken - we'll know if a third-party plugin is involved. Stefan
diff --git a/hw/qdev.c b/hw/qdev.c index 50976dd..1d5aea7 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -58,6 +58,7 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const cha { DeviceInfo *info; +again: /* first check device names */ for (info = device_info_list; info != NULL; info = info->next) { if (bus_info && info->bus_info != bus_info) @@ -77,6 +78,20 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const ch continue; return info; } + + /* try to load an appropriately named module */ + { + char *path = g_module_build_path(PREFIX, info->name); + GModule *mod = g_module_open(path, G_MODULE_BIND_LOCAL); + void (*init)(void); + + if (g_module_symbol(mod, "mod_init", &init)) { + init(); + goto again; + } + } + + return NULL; }