[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH 3/3] blockdev: Add dynamic module loading for bl
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-block] [PATCH 3/3] blockdev: Add dynamic module loading for block drivers |
Date: |
Fri, 24 Jun 2016 11:04:43 +0100 |
User-agent: |
Mutt/1.6.1 (2016-04-27) |
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.
signature.asc
Description: PGP signature