From: Stefan Hajnoczi <stefanha@gmail.com>
To: "Richard W.M. Jones" <rjones@redhat.com>
Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org,
qemu-block@nongnu.org, den-lists@parallels.com
Subject: Re: [Qemu-devel] [PATCH v2 REPOST 1/2] Add dynamic module loading for block drivers
Date: Tue, 19 Apr 2016 10:43:37 +0100 [thread overview]
Message-ID: <20160419094337.GC16312@stefanha-x1.localdomain> (raw)
In-Reply-To: <1460468474-29812-2-git-send-email-rjones@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2330 bytes --]
On Tue, Apr 12, 2016 at 02:41:13PM +0100, Richard W.M. Jones wrote:
> From: Marc Marí <markmb@redhat.com>
>
> Extend the current module interface to allow for block drivers to be loaded
> dynamically on request.
I like this approach to run-time loading QEMU modules because it's not a
plugin system that would inevitably be abused by license violators.
> The only block drivers that can be converted into modules are the drivers
> that don't perform any init operation except for registering themselves. This
> is why libiscsi has been disabled as a module.
This libiscsi issue is easy to solve. Compile QemuOptsList
qemu_iscsi_opts into the main binary. Please do it in a separate
commit.
> @@ -2811,6 +2865,22 @@ void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
> }
> }
>
> + for (n = 0; n < ARRAY_SIZE(block_driver_modules); ++n) {
> + if (block_driver_modules[n].format_name) {
> + bool found = false;
> + int i = count;
> + while (formats && i && !found) {
> + found = !strcmp(formats[--i],
> + block_driver_modules[n].format_name);
> + }
> +
> + if (!found) {
> + formats = g_renew(const char *, formats, count + 1);
> + formats[count++] = block_driver_modules[n].format_name;
> + }
> + }
> + }
There is code duplication in other hunks but this is where I'd draw the
line. I can be done without copy-paste:
static const char **add_format(const char **formats, int *count,
const char *format_name)
{
int i;
while (i = 0; i < *count; i++) {
if (!strcmp(formats[i], format_name) {
return;
}
}
*count += 1;
formats = g_renew(const char *, formats, *count);
formats[*count] = format_name;
return formats;
}
...
QLIST_FOREACH(drv, &bdrv_drivers, list) {
if (drv->format_name) {
formats = add_format(formats, &count, drv->format_name);
}
}
for (n = 0; n < ARRAY_SIZE(block_driver_modules); ++n) {
if (block_driver_modules[n].format_name) {
formats = add_format(formats, &count,
block_driver_modules[n].format_name);
}
}
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2016-04-19 9:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-12 13:41 [Qemu-devel] [PATCH v2 REPOST 0/2] Add dynamic module loading for block drivers Richard W.M. Jones
2016-04-12 13:41 ` [Qemu-devel] [PATCH v2 REPOST 1/2] " Richard W.M. Jones
2016-04-19 9:43 ` Stefan Hajnoczi [this message]
2016-04-12 13:41 ` [Qemu-devel] [PATCH v2 REPOST 2/2] Add dynamic generation of module_block.h Richard W.M. Jones
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=20160419094337.GC16312@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=den-lists@parallels.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=rjones@redhat.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 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).