[Top][All Lists]

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

Re: [Qemu-block] [Qemu-devel] [PATCH 0/2] Dynamic module loading for blo

From: Paolo Bonzini
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 0/2] Dynamic module loading for block drivers
Date: Tue, 21 Jun 2016 12:01:35 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1

On 21/06/2016 11:32, Stefan Hajnoczi wrote:
> I think the issue comes from the fact that you are considering something
> like load_block_module(const char *filename) as the API instead of
> request_block_driver(const char *driver_name).  In the latter case it's
> possible to return a BlockDriver pointer.  In the former it's not.
> The request_block_driver() approach requires a mapping from block driver
> names to modules.  This can be achieved using a directory layout with
> symlinks (hmm...Windows portability?):
>   /usr/lib/qemu/block/
>     +--- sheepdog.so
>     +--- by-protocol/
>       +--- sheepdog+unix -> ../sheepdog.so
> request_block_driver() would look at
> /usr/lib/qemu/block/by-protocol/<protocol> to find the module file.

Another possibility is to add a ".loaded" element to the 
block_driver_modules[] array and break the recursion (or infinite loop):

    QLIST_FOREACH(drv1, &bdrv_drivers, list) {
        if (!strcmp(drv1->format_name, format_name)) {
            return drv1;

    for (i = 0; i < ARRAY_SIZE(block_driver_modules); ++i) {
        if (!block_driver_modules[i].loaded &&
            !strcmp(block_driver_modules[i].format_name, format_name)) {
            block_driver_modules[i].loaded = true;
            goto retry;

BTW, please give a name to block_driver_modules[x]'s type, so that you
can assign &block_driver_modules[i] to a pointer and use that as a



reply via email to

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