From: Stefan Hajnoczi <stefanha@gmail.com>
To: Colin Lord <clord@redhat.com>
Cc: qemu-devel@nongnu.org, kwolf@redhat.com,
	Marc Mari <markmb@redhat.com>,
	qemu-block@nongnu.org, mreitz@redhat.com
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 3/3] blockdev: Add dynamic module loading for block drivers
Date: Fri, 24 Jun 2016 11:04:43 +0100	[thread overview]
Message-ID: <20160624100443.GF9558@stefanha-x1.localdomain> (raw)
In-Reply-To: <1466631354-17309-4-git-send-email-clord@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2220 bytes --]
On Wed, Jun 22, 2016 at 05:35:54PM -0400, Colin Lord wrote:
> +    for (i = 0; i < ARRAY_SIZE(block_driver_modules); ++i) {
> +        if (!strcmp(block_driver_modules[i].format_name, format_name)) {
> +            block_module_load_one(block_driver_modules[i].library_name);
> +            /* Copying code is not nice, but this way the current discovery is
> +             * not modified. Calling recursively could fail if the library
> +             * has been deleted.
> +             */
> +            QLIST_FOREACH(drv1, &bdrv_drivers, list) {
> +                if (!strcmp(drv1->format_name, format_name)) {
> +                    return drv1;
> +                }
> +            }
> +        }
> +    }
> +
>      return NULL;
>  }
No recursion:
static BlockDriver *bdrv_do_find_format(const char *format_name)
{
    BlockDriver *drv1;
    QLIST_FOREACH(drv1, &bdrv_drivers, list) {
        if (!strcmp(drv1->format_name, format_name)) {
            return drv1;
        }
    }
    return NULL;
}
BlockDriver *bdrv_find_format(const char *format_name)
{
    BlockDriver *drv;
    size_t i;
    drv = bdrv_do_find_format(format_name);
    if (drv) {
        return drv;
    }
    /* The driver isn't registered, maybe we need to load a module */
    for (i = 0; i < ARRAY_SIZE(block_driver_modules); ++i) {
        if (!strcmp(block_driver_modules[i].format_name, format_name)) {
            block_module_load_one(block_driver_modules[i].library_name);
	    break;
        }
    }
    return bdrv_do_find_format(format_name);
}
>  
> @@ -447,8 +466,15 @@ int get_tmp_filename(char *filename, int size)
>  static BlockDriver *find_hdev_driver(const char *filename)
>  {
>      int score_max = 0, score;
> +    size_t i;
>      BlockDriver *drv = NULL, *d;
>  
> +    for (i = 0; i < ARRAY_SIZE(block_driver_modules); ++i) {
> +        if (block_driver_modules[i].has_probe_device) {
> +            block_module_load_one(block_driver_modules[i].library_name);
> +        }
> +    }
This patch series needs to solve probing so that we don't end up loading
all block drivers.  Fam's suggestion for a built-in probe.c sounds good
to me.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply	other threads:[~2016-06-24 10:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-22 21:35 [Qemu-devel] [PATCH 0/3] Dynamic module loading for block drivers Colin Lord
2016-06-22 21:35 ` [Qemu-devel] [PATCH 1/3] blockdev: prepare iSCSI block driver for dynamic loading Colin Lord
2016-06-23  1:22   ` Fam Zheng
2016-06-23 20:44     ` Colin Lord
2016-06-22 21:35 ` [Qemu-devel] [PATCH 2/3] blockdev: Add dynamic generation of module_block.h Colin Lord
2016-06-23  1:48   ` Fam Zheng
2016-06-24  9:54   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-06-22 21:35 ` [Qemu-devel] [PATCH 3/3] blockdev: Add dynamic module loading for block drivers Colin Lord
2016-06-23  2:00   ` Fam Zheng
2016-06-23  2:47   ` Fam Zheng
2016-06-24 10:04   ` Stefan Hajnoczi [this message]
2016-06-24 10:37     ` [Qemu-devel] [Qemu-block] " Daniel P. Berrange
2016-06-27  9:31       ` Fam Zheng
2016-06-27 12:44       ` Stefan Hajnoczi
2016-06-22 21:41 ` [Qemu-devel] [PATCH 0/3] Dynamic " Colin Lord
2016-06-23  1:53 ` Fam Zheng
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=20160624100443.GF9558@stefanha-x1.localdomain \
    --to=stefanha@gmail.com \
    --cc=clord@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=markmb@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).