All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>, Colin Lord <clord@redhat.com>
Cc: kwolf@redhat.com, den@openvz.org, qemu-devel@nongnu.org,
	qemu-block@nongnu.org, mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH 0/2] Dynamic module loading for block drivers
Date: Tue, 21 Jun 2016 12:01:35 +0200	[thread overview]
Message-ID: <c8b669ee-b073-efb9-5a59-797f3c15071c@redhat.com> (raw)
In-Reply-To: <20160621093252.GF32560@stefanha-x1.localdomain>



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):


retry:
    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;
	    block_module_load_one(block_driver_modules[i].library_name);
            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
shortcut.

Thanks,

Paolo

  reply	other threads:[~2016-06-21 10:01 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-15 18:40 [Qemu-devel] [PATCH 0/2] Dynamic module loading for block drivers Colin Lord
2016-06-15 18:40 ` [Qemu-devel] [PATCH 1/2] blockdev: Add dynamic generation of module_block.h Colin Lord
2016-06-15 22:48   ` Paolo Bonzini
2016-06-16  4:59   ` Fam Zheng
2016-06-16 13:57     ` Colin Lord
2016-06-17  9:57       ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-06-15 18:40 ` [Qemu-devel] [PATCH 2/2] blockdev: Add dynamic module loading for block drivers Colin Lord
2016-06-15 22:50   ` Paolo Bonzini
2016-06-16 14:00     ` Colin Lord
2016-06-16 14:05       ` Paolo Bonzini
2016-06-16 14:10         ` Colin Lord
2016-06-16 14:12           ` Paolo Bonzini
2016-06-17  9:54 ` [Qemu-devel] [Qemu-block] [PATCH 0/2] Dynamic " Stefan Hajnoczi
2016-06-20 15:32   ` Colin Lord
2016-06-21  9:32     ` Stefan Hajnoczi
2016-06-21 10:01       ` Paolo Bonzini [this message]
2016-06-21 15:42       ` Colin Lord
2016-06-21 16:59         ` [Qemu-devel] " Paolo Bonzini
2016-06-22 10:09           ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c8b669ee-b073-efb9-5a59-797f3c15071c@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=clord@redhat.com \
    --cc=den@openvz.org \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.