Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-18 Thread Paolo Bonzini
Il 18/09/2013 16:44, Richard Henderson ha scritto: > On 09/18/2013 04:45 AM, Paolo Bonzini wrote: >> But on Mac OS X a bundle (module loaded with dlopen) cannot have a >> dependency on another bundle, afaik. > > The documentation for NSAddImage suggests that they can: > >> NSADDIMAGE_OPTION_WITH_

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-18 Thread Richard Henderson
On 09/18/2013 04:45 AM, Paolo Bonzini wrote: > But on Mac OS X a bundle (module loaded with dlopen) cannot have a > dependency on another bundle, afaik. The documentation for NSAddImage suggests that they can: > NSADDIMAGE_OPTION_WITH_SEARCHING > With this option, the image_name passed for the li

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-18 Thread Paolo Bonzini
Il 17/09/2013 07:40, Richard Henderson ha scritto: > On 09/16/2013 06:29 PM, Fam Zheng wrote: >>> Link spice-qemu.char.so against spice-core.so. The DT_NEEDED entry will be >>> recorded, and ld.so will do the right thing. >>> >>> Anything else sounds way too much like Not Invented Here. >>> >> How

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-17 Thread Wenchao Xia
于 2013/9/16 19:29, Fam Zheng 写道: On Mon, 09/16 12:30, Paolo Bonzini wrote: Il 16/09/2013 12:21, Daniel P. Berrange ha scritto: On Mon, Sep 16, 2013 at 12:18:54PM +0200, Paolo Bonzini wrote: Il 16/09/2013 12:14, Daniel P. Berrange ha scritto: On Mon, Sep 16, 2013 at 12:09:47PM +0200, Paolo Bon

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-17 Thread Wenchao Xia
于 2013/9/16 18:38, Paolo Bonzini 写道: Il 16/09/2013 12:24, Alex Bligh ha scritto: At risk of heresy, can I suggest a rather simpler scheme that requires a total of zero infrastructure changes? Here's a patch against qemu 1.0 (sorry) Ubuntu dist (sorry) that uses weak binding to load and compile

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Fam Zheng
On Tue, 09/17 07:33, Alex Bligh wrote: > > On 17 Sep 2013, at 06:55, Fam Zheng wrote: > > >>> > >>> I think I'd just have one flat list > >>> of modules to load and ditch these MODULE_LOAD_ enums. > >> > >> Question is how to deal with qemu vs. qemu-img then. qemu needs > >> everything an

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Alex Bligh
On 17 Sep 2013, at 06:55, Fam Zheng wrote: >>> >>> I think I'd just have one flat list >>> of modules to load and ditch these MODULE_LOAD_ enums. >> >> Question is how to deal with qemu vs. qemu-img then. qemu needs >> everything and qemu-img needs the block drivers only (and loading >> s

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Fam Zheng
On Mon, 09/16 14:36, Gerd Hoffmann wrote: > On Mo, 2013-09-16 at 12:05 +0100, Daniel P. Berrange wrote: > > On Mon, Sep 16, 2013 at 02:50:24PM +0800, Fam Zheng wrote: > > > Added three types of modules: > > > > > > typedef enum { > > > MODULE_LOAD_BLOCK = 0, > > > MODULE_LOAD_U

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Richard Henderson
On 09/16/2013 06:29 PM, Fam Zheng wrote: >> Link spice-qemu.char.so against spice-core.so. The DT_NEEDED entry will be >> recorded, and ld.so will do the right thing. >> >> Anything else sounds way too much like Not Invented Here. >> > How to do the symbol checking as above if spice-core.so is aut

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Fam Zheng
On Mon, 09/16 15:31, Richard Henderson wrote: > On 09/16/2013 04:46 AM, Fam Zheng wrote: > > On Mon, 09/16 13:33, Paolo Bonzini wrote: > >> Il 16/09/2013 13:29, Fam Zheng ha scritto: > >>> An idea for single .so file: > >>> - before loads a .so, an empty initializer list is created. > >>> -

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Fam Zheng
On Mon, 09/16 15:16, Richard Henderson wrote: > On 09/16/2013 02:28 AM, Fam Zheng wrote: > > What's the disadvantage of this, and why are separate lists better? > > You're performing useless work, making the code more confusing in the process. > How can it not be better to have separate lists? >

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Richard Henderson
On 09/16/2013 04:00 AM, Paolo Bonzini wrote: > We could also have a huge web of shared objects like LibreOffice has > (spice-core.so depending on qemu-system.so, and spice.mo depending on > spice-core.so), but I'm not really suggesting that... I am. Although in our case I wouldn't expect the web

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Richard Henderson
On 09/16/2013 04:46 AM, Fam Zheng wrote: > On Mon, 09/16 13:33, Paolo Bonzini wrote: >> Il 16/09/2013 13:29, Fam Zheng ha scritto: >>> An idea for single .so file: >>> - before loads a .so, an empty initializer list is created. >>> - module_init adds a __attribute__((constructor)) function,

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Richard Henderson
On 09/16/2013 02:28 AM, Fam Zheng wrote: > What's the disadvantage of this, and why are separate lists better? You're performing useless work, making the code more confusing in the process. How can it not be better to have separate lists? r~

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Gerd Hoffmann
On Mo, 2013-09-16 at 12:05 +0100, Daniel P. Berrange wrote: > On Mon, Sep 16, 2013 at 02:50:24PM +0800, Fam Zheng wrote: > > Added three types of modules: > > > > typedef enum { > > MODULE_LOAD_BLOCK = 0, > > MODULE_LOAD_UI, > > MODULE_LOAD_NET, > > MODULE_LOAD_

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Fam Zheng
On Mon, 09/16 13:33, Paolo Bonzini wrote: > Il 16/09/2013 13:29, Fam Zheng ha scritto: > > An idea for single .so file: > > - before loads a .so, an empty initializer list is created. > > - module_init adds a __attribute__((constructor)) function, which > > appends > > its real initi

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Paolo Bonzini
Il 16/09/2013 13:29, Fam Zheng ha scritto: > An idea for single .so file: > - before loads a .so, an empty initializer list is created. > - module_init adds a __attribute__((constructor)) function, which appends > its real initializer to the initializer list. So this function is >

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Alex Bligh
On 16 Sep 2013, at 12:08, Paolo Bonzini wrote: > But the reason to do modularization is not to "cope with different > versions of libraries". In fact that's a problem that Fam's patches do > not solve at all. The reason to do modularization is to make libraries > optional, i.e. let them be comp

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Fam Zheng
On Mon, 09/16 12:30, Paolo Bonzini wrote: > Il 16/09/2013 12:21, Daniel P. Berrange ha scritto: > > On Mon, Sep 16, 2013 at 12:18:54PM +0200, Paolo Bonzini wrote: > >> Il 16/09/2013 12:14, Daniel P. Berrange ha scritto: > >>> On Mon, Sep 16, 2013 at 12:09:47PM +0200, Paolo Bonzini wrote: > Il

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Alex Bligh
On 16 Sep 2013, at 12:04, Daniel P. Berrange wrote: > On Mon, Sep 16, 2013 at 12:00:47PM +0100, Alex Bligh wrote: >> >> However, even if you don't use weak symbols, we could simply dlopen() >> a fixed list of modules known at compile time from a single directory >> (because we also know at compi

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Paolo Bonzini
Il 16/09/2013 13:00, Alex Bligh ha scritto: > > On 16 Sep 2013, at 11:38, Paolo Bonzini wrote: > >> No, librbd does need to be there for the other symbols that are not weak >> (e.g. rbd_aio_read). This approach cannot be "taken to the limit", i.e. >> removing the librbd dependency altogether. F

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Daniel P. Berrange
On Mon, Sep 16, 2013 at 02:50:24PM +0800, Fam Zheng wrote: > Added three types of modules: > > typedef enum { > MODULE_LOAD_BLOCK = 0, > MODULE_LOAD_UI, > MODULE_LOAD_NET, > MODULE_LOAD_MAX, > } module_load_type; > > and their loading function: > > voi

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Daniel P. Berrange
On Mon, Sep 16, 2013 at 12:00:47PM +0100, Alex Bligh wrote: > > However, even if you don't use weak symbols, we could simply dlopen() > a fixed list of modules known at compile time from a single directory > (because we also know at compile which executable needs what, e.g. > that qemu-img doesn't

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Alex Bligh
On 16 Sep 2013, at 11:38, Paolo Bonzini wrote: > No, librbd does need to be there for the other symbols that are not weak > (e.g. rbd_aio_read). This approach cannot be "taken to the limit", i.e. > removing the librbd dependency altogether. For example: > > xx.c: > int f(void) > { > retu

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Paolo Bonzini
Il 16/09/2013 12:57, Gerd Hoffmann ha scritto: > Hi, > >> With this patch, a module will not be able to use the module_init macro >> twice. I am not sure this is an acceptable limitation, especially if we >> do not have a dependency system within modules and/or load them with >> G_MODULE_LOCAL/

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Gerd Hoffmann
Hi, > With this patch, a module will not be able to use the module_init macro > twice. I am not sure this is an acceptable limitation, especially if we > do not have a dependency system within modules and/or load them with > G_MODULE_LOCAL/RTLD_LOCAL. Exactly. To modularize spice we need eith

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Fam Zheng
On Mon, 09/16 11:24, Alex Bligh wrote: > > On 16 Sep 2013, at 10:51, Fam Zheng wrote: > > > On Mon, 09/16 11:44, Paolo Bonzini wrote: > >> Il 16/09/2013 10:59, Daniel P. Berrange ha scritto: > The init function of dynamic module is no longer with > __attribute__((constructor)) as static

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Paolo Bonzini
Il 16/09/2013 12:24, Alex Bligh ha scritto: > At risk of heresy, can I suggest a rather simpler scheme that requires > a total of zero infrastructure changes? > > Here's a patch against qemu 1.0 (sorry) Ubuntu dist (sorry) that > uses weak binding to load and compile against any version of > librb

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Paolo Bonzini
Il 16/09/2013 12:21, Daniel P. Berrange ha scritto: > On Mon, Sep 16, 2013 at 12:18:54PM +0200, Paolo Bonzini wrote: >> Il 16/09/2013 12:14, Daniel P. Berrange ha scritto: >>> On Mon, Sep 16, 2013 at 12:09:47PM +0200, Paolo Bonzini wrote: Il 16/09/2013 11:51, Fam Zheng ha scritto: > On Mon

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Alex Bligh
On 16 Sep 2013, at 10:51, Fam Zheng wrote: > On Mon, 09/16 11:44, Paolo Bonzini wrote: >> Il 16/09/2013 10:59, Daniel P. Berrange ha scritto: The init function of dynamic module is no longer with __attribute__((constructor)) as static linked version, and need to be explicitly calle

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Daniel P. Berrange
On Mon, Sep 16, 2013 at 12:18:54PM +0200, Paolo Bonzini wrote: > Il 16/09/2013 12:14, Daniel P. Berrange ha scritto: > > On Mon, Sep 16, 2013 at 12:09:47PM +0200, Paolo Bonzini wrote: > >> Il 16/09/2013 11:51, Fam Zheng ha scritto: > >>> On Mon, 09/16 11:44, Paolo Bonzini wrote: > Il 16/09/201

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Paolo Bonzini
Il 16/09/2013 12:14, Daniel P. Berrange ha scritto: > On Mon, Sep 16, 2013 at 12:09:47PM +0200, Paolo Bonzini wrote: >> Il 16/09/2013 11:51, Fam Zheng ha scritto: >>> On Mon, 09/16 11:44, Paolo Bonzini wrote: Il 16/09/2013 10:59, Daniel P. Berrange ha scritto: >> The init function of dynam

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Daniel P. Berrange
On Mon, Sep 16, 2013 at 12:09:47PM +0200, Paolo Bonzini wrote: > Il 16/09/2013 11:51, Fam Zheng ha scritto: > > On Mon, 09/16 11:44, Paolo Bonzini wrote: > >> Il 16/09/2013 10:59, Daniel P. Berrange ha scritto: > The init function of dynamic module is no longer with > __attribute__((const

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Paolo Bonzini
Il 16/09/2013 11:51, Fam Zheng ha scritto: > On Mon, 09/16 11:44, Paolo Bonzini wrote: >> Il 16/09/2013 10:59, Daniel P. Berrange ha scritto: The init function of dynamic module is no longer with __attribute__((constructor)) as static linked version, and need to be explicitly called

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Fam Zheng
On Mon, 09/16 11:44, Paolo Bonzini wrote: > Il 16/09/2013 10:59, Daniel P. Berrange ha scritto: > >> The init function of dynamic module is no longer with > >> __attribute__((constructor)) as static linked version, and need to be > >> explicitly called once loaded. The function name is mangled with

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Paolo Bonzini
Il 16/09/2013 10:59, Daniel P. Berrange ha scritto: >> The init function of dynamic module is no longer with >> __attribute__((constructor)) as static linked version, and need to be >> explicitly called once loaded. The function name is mangled with per >> configure fingerprint as: >> >> init_

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Fam Zheng
On Mon, 09/16 09:59, Daniel P. Berrange wrote: > On Mon, Sep 16, 2013 at 02:50:24PM +0800, Fam Zheng wrote: > > Added three types of modules: > > > > typedef enum { > > MODULE_LOAD_BLOCK = 0, > > MODULE_LOAD_UI, > > MODULE_LOAD_NET, > > MODULE_LOAD_MAX, > >

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-16 Thread Daniel P. Berrange
On Mon, Sep 16, 2013 at 02:50:24PM +0800, Fam Zheng wrote: > Added three types of modules: > > typedef enum { > MODULE_LOAD_BLOCK = 0, > MODULE_LOAD_UI, > MODULE_LOAD_NET, > MODULE_LOAD_MAX, > } module_load_type; > > and their loading function: > > voi

[Qemu-devel] [PATCH v10 5/8] module: implement module loading

2013-09-15 Thread Fam Zheng
Added three types of modules: typedef enum { MODULE_LOAD_BLOCK = 0, MODULE_LOAD_UI, MODULE_LOAD_NET, MODULE_LOAD_MAX, } module_load_type; and their loading function: void module_load(module_load_type). which loads whitelisted ".so" files of the given