From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asSC9-0007N8-QJ for qemu-devel@nongnu.org; Tue, 19 Apr 2016 05:43:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1asSC4-00073X-Rp for qemu-devel@nongnu.org; Tue, 19 Apr 2016 05:43:45 -0400 Date: Tue, 19 Apr 2016 10:43:37 +0100 From: Stefan Hajnoczi Message-ID: <20160419094337.GC16312@stefanha-x1.localdomain> References: <1460468474-29812-1-git-send-email-rjones@redhat.com> <1460468474-29812-2-git-send-email-rjones@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="DSayHWYpDlRfCAAQ" Content-Disposition: inline In-Reply-To: <1460468474-29812-2-git-send-email-rjones@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 REPOST 1/2] Add dynamic module loading for block drivers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Richard W.M. Jones" Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, den-lists@parallels.com --DSayHWYpDlRfCAAQ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 12, 2016 at 02:41:13PM +0100, Richard W.M. Jones wrote: > From: Marc Mar=ED >=20 > Extend the current module interface to allow for block drivers to be load= ed > 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), > } > } > =20 > + for (n =3D 0; n < ARRAY_SIZE(block_driver_modules); ++n) { > + if (block_driver_modules[n].format_name) { > + bool found =3D false; > + int i =3D count; > + while (formats && i && !found) { > + found =3D !strcmp(formats[--i], > + block_driver_modules[n].format_name); > + } > + > + if (!found) { > + formats =3D g_renew(const char *, formats, count + 1); > + formats[count++] =3D 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 =3D 0; i < *count; i++) { if (!strcmp(formats[i], format_name) { return; } } *count +=3D 1; formats =3D g_renew(const char *, formats, *count); formats[*count] =3D format_name; return formats; } =2E.. QLIST_FOREACH(drv, &bdrv_drivers, list) { if (drv->format_name) { formats =3D add_format(formats, &count, drv->format_name); } } for (n =3D 0; n < ARRAY_SIZE(block_driver_modules); ++n) { if (block_driver_modules[n].format_name) { formats =3D add_format(formats, &count, block_driver_modules[n].format_name); } } --DSayHWYpDlRfCAAQ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJXFf3JAAoJEJykq7OBq3PIRL4IAMi1zex1F6lflrgphQf0yCgY iyPaqY7v3CKo6IH/Tc19BPW8V/gztT22xWtu0H1EFkWpX5PVKe92QfmDEaosPbsm 0xBQaJ9SR6IFRAGXPYvoxI+WFJbhjs4MJAVUZxnXR2jSDJZz/ydCh07yEWMpDFZc gWMagNnB8tB6B7rOkDOWXqAc6NG+FcPWBfgiI2/xuBPgtHJGi+2JnyspNGzaOBYp tM3UDEyg1f3LYYC+0F+7nmleUv0oY4agBk4Gr/QPIm1Pi451M2S08gBIMzjy1ZkK U0dTCYpzQT1fng8gdbQwSjuR11ze3u3mwzuBl3QtUdUWVHHniDPZL8g4STN/DBE= =+68a -----END PGP SIGNATURE----- --DSayHWYpDlRfCAAQ--