From nobody Sat Apr 27 22:39:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1486571401632450.2711071209163; Wed, 8 Feb 2017 08:30:01 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18GQfo7006007; Wed, 8 Feb 2017 11:26:41 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18GQdh2017859 for ; Wed, 8 Feb 2017 11:26:39 -0500 Received: from angien.brq.redhat.com (dhcp129-162.brq.redhat.com [10.34.129.162]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQbSh027100; Wed, 8 Feb 2017 11:26:39 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 17:27:01 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 01/11] configure: Fix configure output for RBD storage backend X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We'd print status for the 'dir' backend instead of the correct one. --- m4/virt-storage-rbd.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/m4/virt-storage-rbd.m4 b/m4/virt-storage-rbd.m4 index 0104b7cfc..48522a6a7 100644 --- a/m4/virt-storage-rbd.m4 +++ b/m4/virt-storage-rbd.m4 @@ -41,7 +41,7 @@ AC_DEFUN([LIBVIRT_STORAGE_CHECK_RBD], [ ]) AC_DEFUN([LIBVIRT_STORAGE_RESULT_RBD], [ - LIBVIRT_RESULT([RBD], [$with_storage_dir]) + LIBVIRT_RESULT([RBD], [$with_storage_rbd]) ]) AC_DEFUN([LIBVIRT_RESULT_RBD], [ --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 22:39:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1486571407881470.8776467071067; Wed, 8 Feb 2017 08:30:07 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQmGf023970; Wed, 8 Feb 2017 11:26:48 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18GQe9E017869 for ; Wed, 8 Feb 2017 11:26:40 -0500 Received: from angien.brq.redhat.com (dhcp129-162.brq.redhat.com [10.34.129.162]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQbSi027100; Wed, 8 Feb 2017 11:26:40 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 17:27:02 +0100 Message-Id: <113d6a0739c20f58b0a36d05d1db264a99c52152.1486571179.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 02/11] tests: storagepoolxml2xml: Remove compile conditionals X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The XML2XML test should work properly even if the storage backend is disabled, since it does not use it. --- tests/storagepoolxml2xmltest.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c index 98a844926..79bdc26da 100644 --- a/tests/storagepoolxml2xmltest.c +++ b/tests/storagepoolxml2xmltest.c @@ -97,16 +97,10 @@ mymain(void) DO_TEST("pool-gluster"); DO_TEST("pool-gluster-sub"); DO_TEST("pool-scsi-type-scsi-host-stable"); -#ifdef WITH_STORAGE_ZFS DO_TEST("pool-zfs"); DO_TEST("pool-zfs-sourcedev"); -#endif -#ifdef WITH_STORAGE_RBD DO_TEST("pool-rbd"); -#endif -#ifdef WITH_STORAGE_VSTORAGE DO_TEST("pool-vstorage"); -#endif return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 22:39:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1486571402982138.45990542096524; Wed, 8 Feb 2017 08:30:02 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQmjN023972; Wed, 8 Feb 2017 11:26:48 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18GQfxw017880 for ; Wed, 8 Feb 2017 11:26:41 -0500 Received: from angien.brq.redhat.com (dhcp129-162.brq.redhat.com [10.34.129.162]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQbSj027100; Wed, 8 Feb 2017 11:26:41 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 17:27:03 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 03/11] tests: drivermodule: Drop unused macro arguments X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Refactors of the test resulted into the second argument of the 'TEST' macro to be unused. Drop them. --- tests/virdrivermoduletest.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/tests/virdrivermoduletest.c b/tests/virdrivermoduletest.c index 870a07de6..09c1a614b 100644 --- a/tests/virdrivermoduletest.c +++ b/tests/virdrivermoduletest.c @@ -47,53 +47,50 @@ mymain(void) { int ret =3D 0; -#define TEST(name, dep1) = \ +#define TEST(name) = \ do { = \ if (virTestRun("Test driver " # name, testDriverModule, name) < 0)= \ ret =3D -1; = \ } while (0) #ifdef WITH_NETWORK -# define USE_NETWORK "network" - TEST("network", NULL); -#else -# define USE_NETWORK NULL + TEST("network"); #endif #ifdef WITH_INTERFACE - TEST("interface", NULL); + TEST("interface"); #endif #ifdef WITH_STORAGE - TEST("storage", NULL); + TEST("storage"); #endif #ifdef WITH_NODE_DEVICES - TEST("nodedev", NULL); + TEST("nodedev"); #endif #ifdef WITH_SECRETS - TEST("secret", NULL); + TEST("secret"); #endif #ifdef WITH_NWFILTER - TEST("nwfilter", NULL); + TEST("nwfilter"); #endif #ifdef WITH_XEN - TEST("xen", NULL); + TEST("xen"); #endif #ifdef WITH_LIBXL - TEST("libxl", NULL); + TEST("libxl"); #endif #ifdef WITH_QEMU - TEST("qemu", USE_NETWORK); + TEST("qemu"); #endif #ifdef WITH_LXC - TEST("lxc", USE_NETWORK); + TEST("lxc"); #endif #ifdef WITH_UML - TEST("uml", NULL); + TEST("uml"); #endif #ifdef WITH_VBOX - TEST("vbox", NULL); + TEST("vbox"); #endif #ifdef WITH_BHYVE - TEST("bhyve", NULL); + TEST("bhyve"); #endif return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 22:39:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1486571399049977.0923809885538; Wed, 8 Feb 2017 08:29:59 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18GQjVW017406; Wed, 8 Feb 2017 11:26:45 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18GQghW017888 for ; Wed, 8 Feb 2017 11:26:42 -0500 Received: from angien.brq.redhat.com (dhcp129-162.brq.redhat.com [10.34.129.162]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQbSk027100; Wed, 8 Feb 2017 11:26:42 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 17:27:04 +0100 Message-Id: <1e55ec6048fc7d98ea8807b86de7e67dc94f39c4.1486571179.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 04/11] driver: Split/refactor driver module loading X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Split the convoluted driver loader function into simpler parts which will potentially allow reuse. --- src/driver.c | 133 +++++++++++++++++++++++++++++-------= ---- src/driver.h | 3 + src/libvirt_driver_modules.syms | 1 + 3 files changed, 101 insertions(+), 36 deletions(-) diff --git a/src/driver.c b/src/driver.c index 67ac02006..783e08a28 100644 --- a/src/driver.c +++ b/src/driver.c @@ -43,15 +43,105 @@ VIR_LOG_INIT("driver"); # include # define DEFAULT_DRIVER_DIR LIBDIR "/libvirt/connection-driver" + +static void * +virDriverLoadModuleFile(const char *file) +{ + void *handle =3D NULL; + + VIR_DEBUG("Load module file '%s'", file); + + if (access(file, R_OK) < 0) { + VIR_INFO("Module %s not accessible", file); + return NULL; + } + + virUpdateSelfLastChanged(file); + + if (!(handle =3D dlopen(file, RTLD_NOW | RTLD_GLOBAL))) + VIR_ERROR(_("failed to load module %s %s"), file, dlerror()); + + return handle; +} + + +static void * +virDriverLoadModuleFunc(void *handle, + const char *funcname) +{ + void *regsym; + + VIR_DEBUG("Lookup function '%s'", funcname); + + if (!(regsym =3D dlsym(handle, funcname))) + VIR_ERROR(_("Missing module registration symbol %s"), funcname); + + return regsym; +} + + +/** + * virDriverLoadModuleFull: + * @path: filename of module to load + * @regfunc: name of the function that registers the module + * @handle: Returns handle of the loaded library if not NULL + * + * Loads a loadable module named @path and calls the + * registration function @regfunc. If @handle is not NULL the handle is re= turned + * in the variable. Otherwise the handle is leaked so that the module stays + * loaded forever. + * + * The module is automatically looked up in the appropriate place (git or + * installed directory). + * + * Returns 0 on success, 1 if the module was not found and -1 on any error. + */ +int +virDriverLoadModuleFull(const char *path, + const char *regfunc, + void **handle) +{ + void *rethandle =3D NULL; + int (*regsym)(void); + int ret =3D -1; + + VIR_DEBUG("Module load %s", path); + + if (!(rethandle =3D virDriverLoadModuleFile(path))) { + ret =3D 1; + goto cleanup; + } + + if (!(regsym =3D virDriverLoadModuleFunc(rethandle, regfunc))) + goto cleanup; + + if ((*regsym)() < 0) { + VIR_ERROR(_("Failed module registration %s"), regfunc); + goto cleanup; + } + + if (handle) + VIR_STEAL_PTR(*handle, rethandle); + else + rethandle =3D NULL; + + ret =3D 0; + + cleanup: + if (rethandle) + dlclose(rethandle); + return ret; +} + + void * virDriverLoadModule(const char *name) { - char *modfile =3D NULL, *regfunc =3D NULL, *fixedname =3D NULL; + char *modfile =3D NULL; + char *fixedname =3D NULL; + char *regfunc =3D NULL; char *tmp; void *handle =3D NULL; - int (*regsym)(void); - - VIR_DEBUG("Module load %s", name); if (!(modfile =3D virFileFindResourceFull(name, "libvirt_driver_", @@ -61,19 +151,6 @@ virDriverLoadModule(const char *name) "LIBVIRT_DRIVER_DIR"))) return NULL; - if (access(modfile, R_OK) < 0) { - VIR_INFO("Module %s not accessible", modfile); - goto cleanup; - } - - virUpdateSelfLastChanged(modfile); - - handle =3D dlopen(modfile, RTLD_NOW | RTLD_GLOBAL); - if (!handle) { - VIR_ERROR(_("failed to load module %s %s"), modfile, dlerror()); - goto cleanup; - } - if (VIR_STRDUP_QUIET(fixedname, name) < 0) { VIR_ERROR(_("out of memory")); goto cleanup; @@ -88,29 +165,13 @@ virDriverLoadModule(const char *name) if (virAsprintfQuiet(®func, "%sRegister", fixedname) < 0) goto cleanup; - regsym =3D dlsym(handle, regfunc); - if (!regsym) { - VIR_ERROR(_("Missing module registration symbol %s"), regfunc); - goto cleanup; - } - - if ((*regsym)() < 0) { - VIR_ERROR(_("Failed module registration %s"), regfunc); - goto cleanup; - } - - VIR_FREE(modfile); - VIR_FREE(regfunc); - VIR_FREE(fixedname); - return handle; + virDriverLoadModuleFull(modfile, regfunc, &handle); cleanup: VIR_FREE(modfile); - VIR_FREE(regfunc); VIR_FREE(fixedname); - if (handle) - dlclose(handle); - return NULL; + VIR_FREE(regfunc); + return handle; } diff --git a/src/driver.h b/src/driver.h index e4e382b63..885e8843e 100644 --- a/src/driver.h +++ b/src/driver.h @@ -100,5 +100,8 @@ int virSetSharedSecretDriver(virSecretDriverPtr driver)= ATTRIBUTE_RETURN_CHECK; int virSetSharedStorageDriver(virStorageDriverPtr driver) ATTRIBUTE_RETURN= _CHECK; void *virDriverLoadModule(const char *name); +int virDriverLoadModuleFull(const char *name, + const char *regfunc, + void **handle); #endif /* __VIR_DRIVER_H__ */ diff --git a/src/libvirt_driver_modules.syms b/src/libvirt_driver_modules.s= yms index f9d0ee9b9..bd9bf1c31 100644 --- a/src/libvirt_driver_modules.syms +++ b/src/libvirt_driver_modules.syms @@ -4,6 +4,7 @@ # driver.h virDriverLoadModule; +virDriverLoadModuleFull; # Let emacs know we want case-insensitive sorting # Local Variables: --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 22:39:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1486571411811525.4781021779213; Wed, 8 Feb 2017 08:30:11 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQmmq023971; Wed, 8 Feb 2017 11:26:48 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18GQhK1017895 for ; Wed, 8 Feb 2017 11:26:43 -0500 Received: from angien.brq.redhat.com (dhcp129-162.brq.redhat.com [10.34.129.162]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQbSl027100; Wed, 8 Feb 2017 11:26:43 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 17:27:05 +0100 Message-Id: <4fd8905849511d280e36a3b378a444b8dddb316a.1486571179.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 05/11] daemon: Refactor connection driver module loading X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Pass the registration function name to virDriverLoadModule so that we can later call specific functions if necessary (e.g. for testing purposes). This gets rid of the rather ugly automatic name generator and unifies the code to load/initialize the modules. It's also clear which registration function gets called. --- daemon/libvirtd.c | 136 ++++++++++++++++------------------------= ---- src/driver.c | 37 +++--------- src/driver.h | 3 +- tests/virdrivermoduletest.c | 23 ++++++-- 4 files changed, 77 insertions(+), 122 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index b6d76ed84..2f9f5c77d 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -341,6 +341,14 @@ static int daemonErrorLogFilter(virErrorPtr err, int p= riority) return priority; } + +#ifdef WITH_DRIVER_MODULES +# define VIR_DAEMON_LOAD_MODULE(func, module) \ + virDriverLoadModule(module, #func) +#else +# define VIR_DAEMON_LOAD_MODULE(func, module) \ + func() +#endif static void daemonInitialize(void) { /* @@ -350,99 +358,55 @@ static void daemonInitialize(void) * driver, since their resources must be auto-started before any * domains can be auto-started. */ -#ifdef WITH_DRIVER_MODULES /* We don't care if any of these fail, because the whole point * is to allow users to only install modules they want to use. * If they try to open a connection for a module that * is not loaded they'll get a suitable error at that point */ -# ifdef WITH_NETWORK - virDriverLoadModule("network"); -# endif -# ifdef WITH_INTERFACE - virDriverLoadModule("interface"); -# endif -# ifdef WITH_STORAGE - virDriverLoadModule("storage"); -# endif -# ifdef WITH_NODE_DEVICES - virDriverLoadModule("nodedev"); -# endif -# ifdef WITH_SECRETS - virDriverLoadModule("secret"); -# endif -# ifdef WITH_NWFILTER - virDriverLoadModule("nwfilter"); -# endif -# ifdef WITH_XEN - virDriverLoadModule("xen"); -# endif -# ifdef WITH_LIBXL - virDriverLoadModule("libxl"); -# endif -# ifdef WITH_QEMU - virDriverLoadModule("qemu"); -# endif -# ifdef WITH_LXC - virDriverLoadModule("lxc"); -# endif -# ifdef WITH_UML - virDriverLoadModule("uml"); -# endif -# ifdef WITH_VBOX - virDriverLoadModule("vbox"); -# endif -# ifdef WITH_BHYVE - virDriverLoadModule("bhyve"); -# endif -# ifdef WITH_VZ - virDriverLoadModule("vz"); -# endif -#else -# ifdef WITH_NETWORK - networkRegister(); -# endif -# ifdef WITH_INTERFACE - interfaceRegister(); -# endif -# ifdef WITH_STORAGE - storageRegister(); -# endif -# ifdef WITH_NODE_DEVICES - nodedevRegister(); -# endif -# ifdef WITH_SECRETS - secretRegister(); -# endif -# ifdef WITH_NWFILTER - nwfilterRegister(); -# endif -# ifdef WITH_XEN - xenRegister(); -# endif -# ifdef WITH_LIBXL - libxlRegister(); -# endif -# ifdef WITH_QEMU - qemuRegister(); -# endif -# ifdef WITH_LXC - lxcRegister(); -# endif -# ifdef WITH_UML - umlRegister(); -# endif -# ifdef WITH_VBOX - vboxRegister(); -# endif -# ifdef WITH_BHYVE - bhyveRegister(); -# endif -# ifdef WITH_VZ - vzRegister(); -# endif +#ifdef WITH_NETWORK + VIR_DAEMON_LOAD_MODULE(networkRegister, "network"); +#endif +#ifdef WITH_INTERFACE + VIR_DAEMON_LOAD_MODULE(interfaceRegister, "interface"); +#endif +#ifdef WITH_STORAGE + VIR_DAEMON_LOAD_MODULE(storageRegister, "storage"); +#endif +#ifdef WITH_NODE_DEVICES + VIR_DAEMON_LOAD_MODULE(nodedevRegister, "nodedev"); +#endif +#ifdef WITH_SECRETS + VIR_DAEMON_LOAD_MODULE(secretRegister, "secret"); +#endif +#ifdef WITH_NWFILTER + VIR_DAEMON_LOAD_MODULE(nwfilterRegister, "nwfilter"); +#endif +#ifdef WITH_XEN + VIR_DAEMON_LOAD_MODULE(xenRegister, "xen"); +#endif +#ifdef WITH_LIBXL + VIR_DAEMON_LOAD_MODULE(libxlRegister, "libxl"); +#endif +#ifdef WITH_QEMU + VIR_DAEMON_LOAD_MODULE(qemuRegister, "qemu"); +#endif +#ifdef WITH_LXC + VIR_DAEMON_LOAD_MODULE(lxcRegister, "lxc"); +#endif +#ifdef WITH_UML + VIR_DAEMON_LOAD_MODULE(umlRegister, "uml"); +#endif +#ifdef WITH_VBOX + VIR_DAEMON_LOAD_MODULE(vboxRegister, "vbox"); +#endif +#ifdef WITH_BHYVE + VIR_DAEMON_LOAD_MODULE(bhyveRegister, "bhyve"); +#endif +#ifdef WITH_VZ + VIR_DAEMON_LOAD_MODULE(vzRegister, "vz"); #endif } +#undef VIR_DAEMON_LOAD_MODULE static int ATTRIBUTE_NONNULL(3) diff --git a/src/driver.c b/src/driver.c index 783e08a28..f47bea0fb 100644 --- a/src/driver.c +++ b/src/driver.c @@ -23,15 +23,12 @@ #include #include -#include #include "driver.h" #include "viralloc.h" #include "virfile.h" #include "virlog.h" -#include "virutil.h" #include "configmake.h" -#include "virstring.h" VIR_LOG_INIT("driver"); @@ -134,14 +131,12 @@ virDriverLoadModuleFull(const char *path, } -void * -virDriverLoadModule(const char *name) +int +virDriverLoadModule(const char *name, + const char *regfunc) { char *modfile =3D NULL; - char *fixedname =3D NULL; - char *regfunc =3D NULL; - char *tmp; - void *handle =3D NULL; + int ret; if (!(modfile =3D virFileFindResourceFull(name, "libvirt_driver_", @@ -149,29 +144,13 @@ virDriverLoadModule(const char *name) abs_topbuilddir "/src/.libs", DEFAULT_DRIVER_DIR, "LIBVIRT_DRIVER_DIR"))) - return NULL; - - if (VIR_STRDUP_QUIET(fixedname, name) < 0) { - VIR_ERROR(_("out of memory")); - goto cleanup; - } - - /* convert something_like_this into somethingLikeThis */ - while ((tmp =3D strchr(fixedname, '_'))) { - memmove(tmp, tmp + 1, strlen(tmp)); - *tmp =3D c_toupper(*tmp); - } - - if (virAsprintfQuiet(®func, "%sRegister", fixedname) < 0) - goto cleanup; + return 1; - virDriverLoadModuleFull(modfile, regfunc, &handle); + ret =3D virDriverLoadModuleFull(modfile, regfunc, NULL); - cleanup: VIR_FREE(modfile); - VIR_FREE(fixedname); - VIR_FREE(regfunc); - return handle; + + return ret; } diff --git a/src/driver.h b/src/driver.h index 885e8843e..420f6455d 100644 --- a/src/driver.h +++ b/src/driver.h @@ -99,7 +99,8 @@ int virSetSharedNWFilterDriver(virNWFilterDriverPtr drive= r) ATTRIBUTE_RETURN_CHE int virSetSharedSecretDriver(virSecretDriverPtr driver) ATTRIBUTE_RETURN_C= HECK; int virSetSharedStorageDriver(virStorageDriverPtr driver) ATTRIBUTE_RETURN= _CHECK; -void *virDriverLoadModule(const char *name); +int virDriverLoadModule(const char *name, + const char *regfunc); int virDriverLoadModuleFull(const char *name, const char *regfunc, void **handle); diff --git a/tests/virdrivermoduletest.c b/tests/virdrivermoduletest.c index 09c1a614b..e440350c2 100644 --- a/tests/virdrivermoduletest.c +++ b/tests/virdrivermoduletest.c @@ -30,12 +30,18 @@ VIR_LOG_INIT("tests.drivermoduletest"); +struct testDriverModuleData { + const char *module; + const char *regfunc; +}; + + static int testDriverModule(const void *args) { - const char *name =3D args; + const struct testDriverModuleData *data =3D args; /* coverity[leaked_storage] */ - if (!virDriverLoadModule(name)) + if (virDriverLoadModule(data->module, data->regfunc) !=3D 0) return -1; return 0; @@ -46,13 +52,18 @@ static int mymain(void) { int ret =3D 0; + struct testDriverModuleData data; -#define TEST(name) = \ - do { = \ - if (virTestRun("Test driver " # name, testDriverModule, name) < 0)= \ - ret =3D -1; = \ +#define TEST_FULL(name, fnc) = \ + do { = \ + data.module =3D name; = \ + data.regfunc =3D fnc; = \ + if (virTestRun("Test driver " # name, testDriverModule, &data) < 0= ) \ + ret =3D -1; = \ } while (0) +#define TEST(name) TEST_FULL(name, name "Register") + #ifdef WITH_NETWORK TEST("network"); #endif --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 22:39:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 148657142796989.01252939842516; Wed, 8 Feb 2017 08:30:27 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18GQoLC017429; Wed, 8 Feb 2017 11:26:50 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18GQiSi017900 for ; Wed, 8 Feb 2017 11:26:44 -0500 Received: from angien.brq.redhat.com (dhcp129-162.brq.redhat.com [10.34.129.162]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQbSm027100; Wed, 8 Feb 2017 11:26:44 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 17:27:06 +0100 Message-Id: <1bad01839f899e4fbed51a21f80a2957f5a8e9b0.1486571179.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 06/11] storage: backend: Refactor registration of the backend drivers X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add APIs that allow to dynamically register driver backends so that the list of available drivers does not need to be known during compile time. This will allow us to modularize the storage driver on runtime. --- src/storage/storage_backend.c | 111 ++++++++++++++++++++++-------= ---- src/storage/storage_backend.h | 5 ++ src/storage/storage_backend_disk.c | 7 +++ src/storage/storage_backend_disk.h | 4 +- src/storage/storage_backend_fs.c | 27 ++++++++ src/storage/storage_backend_fs.h | 11 +--- src/storage/storage_backend_gluster.c | 13 +++- src/storage/storage_backend_gluster.h | 5 +- src/storage/storage_backend_iscsi.c | 7 +++ src/storage/storage_backend_iscsi.h | 4 +- src/storage/storage_backend_logical.c | 7 +++ src/storage/storage_backend_logical.h | 4 +- src/storage/storage_backend_mpath.c | 8 +++ src/storage/storage_backend_mpath.h | 4 +- src/storage/storage_backend_rbd.c | 7 +++ src/storage/storage_backend_rbd.h | 4 +- src/storage/storage_backend_scsi.c | 7 +++ src/storage/storage_backend_scsi.h | 4 +- src/storage/storage_backend_sheepdog.c | 7 +++ src/storage/storage_backend_sheepdog.h | 4 +- src/storage/storage_backend_vstorage.c | 7 +++ src/storage/storage_backend_vstorage.h | 4 +- src/storage/storage_backend_zfs.c | 7 +++ src/storage/storage_backend_zfs.h | 4 +- src/storage/storage_driver.c | 2 + tests/virstoragetest.c | 4 ++ 26 files changed, 200 insertions(+), 78 deletions(-) diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 500d7567d..d8099be36 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -72,67 +72,106 @@ VIR_LOG_INIT("storage.storage_backend"); -static virStorageBackendPtr backends[] =3D { -#if WITH_STORAGE_DIR - &virStorageBackendDirectory, -#endif -#if WITH_STORAGE_FS - &virStorageBackendFileSystem, - &virStorageBackendNetFileSystem, +#define VIR_STORAGE_BACKENDS_MAX 20 + +static virStorageBackendPtr virStorageBackends[VIR_STORAGE_BACKENDS_MAX]; +static size_t virStorageBackendsCount; +static virStorageFileBackendPtr virStorageFileBackends[VIR_STORAGE_BACKEND= S_MAX]; +static size_t virStorageFileBackendsCount; + +#define VIR_STORAGE_BACKEND_REGISTER(name) = \ + if (name() < 0) = \ + return -1 + +int +virStorageBackendDriversRegister(void) +{ +#if WITH_STORAGE_DIR || WITH_STORAGE_FS + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendFsRegister); #endif #if WITH_STORAGE_LVM - &virStorageBackendLogical, + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendLogicalRegister); #endif #if WITH_STORAGE_ISCSI - &virStorageBackendISCSI, + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendISCSIRegister); #endif #if WITH_STORAGE_SCSI - &virStorageBackendSCSI, + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendSCSIRegister); #endif #if WITH_STORAGE_MPATH - &virStorageBackendMpath, + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendMpathRegister); #endif #if WITH_STORAGE_DISK - &virStorageBackendDisk, + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendDiskRegister); #endif #if WITH_STORAGE_RBD - &virStorageBackendRBD, + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendRBDRegister); #endif #if WITH_STORAGE_SHEEPDOG - &virStorageBackendSheepdog, + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendSheepdogRegister); #endif #if WITH_STORAGE_GLUSTER - &virStorageBackendGluster, + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendGlusterRegister); #endif #if WITH_STORAGE_ZFS - &virStorageBackendZFS, + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendZFSRegister); #endif #if WITH_STORAGE_VSTORAGE - &virStorageBackendVstorage, + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendVstorageRegister); #endif - NULL -}; + return 0; +} +#undef VIR_STORAGE_BACKEND_REGISTER -static virStorageFileBackendPtr fileBackends[] =3D { -#if WITH_STORAGE_FS - &virStorageFileBackendFile, - &virStorageFileBackendBlock, -#endif -#if WITH_STORAGE_GLUSTER - &virStorageFileBackendGluster, -#endif - NULL -}; + +int +virStorageBackendRegister(virStorageBackendPtr backend) +{ + VIR_DEBUG("Registering storage backend '%s'", + virStorageTypeToString(backend->type)); + + if (virStorageBackendsCount >=3D VIR_STORAGE_BACKENDS_MAX) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Too many drivers, cannot register storage backen= d '%s'"), + virStorageTypeToString(backend->type)); + return -1; + } + + virStorageBackends[virStorageBackendsCount] =3D backend; + virStorageBackendsCount++; + return 0; +} + + +int +virStorageBackendFileRegister(virStorageFileBackendPtr backend) +{ + VIR_DEBUG("Registering storage file backend '%s' protocol '%s'", + virStorageTypeToString(backend->type), + virStorageNetProtocolTypeToString(backend->protocol)); + + if (virStorageFileBackendsCount >=3D VIR_STORAGE_BACKENDS_MAX) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Too many drivers, cannot register storage file " + "backend '%s'"), + virStorageTypeToString(backend->type)); + return -1; + } + + virStorageFileBackends[virStorageFileBackendsCount] =3D backend; + virStorageFileBackendsCount++; + return 0; +} virStorageBackendPtr virStorageBackendForType(int type) { size_t i; - for (i =3D 0; backends[i]; i++) - if (backends[i]->type =3D=3D type) - return backends[i]; + for (i =3D 0; i < virStorageBackendsCount; i++) + if (virStorageBackends[i]->type =3D=3D type) + return virStorageBackends[i]; virReportError(VIR_ERR_INTERNAL_ERROR, _("missing backend for pool type %d (%s)"), @@ -148,13 +187,13 @@ virStorageFileBackendForTypeInternal(int type, { size_t i; - for (i =3D 0; fileBackends[i]; i++) { - if (fileBackends[i]->type =3D=3D type) { + for (i =3D 0; i < virStorageFileBackendsCount; i++) { + if (virStorageFileBackends[i]->type =3D=3D type) { if (type =3D=3D VIR_STORAGE_TYPE_NETWORK && - fileBackends[i]->protocol !=3D protocol) + virStorageFileBackends[i]->protocol !=3D protocol) continue; - return fileBackends[i]; + return virStorageFileBackends[i]; } } diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h index b8fb368bb..ca6c19c45 100644 --- a/src/storage/storage_backend.h +++ b/src/storage/storage_backend.h @@ -198,4 +198,9 @@ struct _virStorageFileBackend { virStorageFileBackendChown storageFileChown; }; +int virStorageBackendDriversRegister(void); + +int virStorageBackendRegister(virStorageBackendPtr backend); +int virStorageBackendFileRegister(virStorageFileBackendPtr backend); + #endif /* __VIR_STORAGE_BACKEND_H__ */ diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backe= nd_disk.c index 819f1e5c4..50bdd3646 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -937,3 +937,10 @@ virStorageBackend virStorageBackendDisk =3D { .downloadVol =3D virStorageBackendVolDownloadLocal, .wipeVol =3D virStorageBackendDiskVolWipe, }; + + +int +virStorageBackendDiskRegister(void) +{ + return virStorageBackendRegister(&virStorageBackendDisk); +} diff --git a/src/storage/storage_backend_disk.h b/src/storage/storage_backe= nd_disk.h index aaabe6224..e614ca278 100644 --- a/src/storage/storage_backend_disk.h +++ b/src/storage/storage_backend_disk.h @@ -24,8 +24,6 @@ #ifndef __VIR_STORAGE_BACKEND_DISK_H__ # define __VIR_STORAGE_BACKEND_DISK_H__ -# include "storage_backend.h" - -extern virStorageBackend virStorageBackendDisk; +int virStorageBackendDiskRegister(void); #endif /* __VIR_STORAGE_BACKEND_DISK_H__ */ diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index 54bcc5777..551fd945d 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -877,3 +877,30 @@ virStorageFileBackend virStorageFileBackendDir =3D { .storageFileGetUniqueIdentifier =3D virStorageFileBackendFileGetUnique= Identifier, }; + + +int +virStorageBackendFsRegister(void) +{ + if (virStorageBackendRegister(&virStorageBackendDirectory) < 0) + return -1; + +#if WITH_STORAGE_FS + if (virStorageBackendRegister(&virStorageBackendFileSystem) < 0) + return -1; + + if (virStorageBackendRegister(&virStorageBackendNetFileSystem) < 0) + return -1; +#endif /* WITH_STORAGE_FS */ + + if (virStorageBackendFileRegister(&virStorageFileBackendFile) < 0) + return -1; + + if (virStorageBackendFileRegister(&virStorageFileBackendBlock) < 0) + return -1; + + if (virStorageBackendFileRegister(&virStorageFileBackendDir) < 0) + return -1; + + return 0; +} diff --git a/src/storage/storage_backend_fs.h b/src/storage/storage_backend= _fs.h index 94fe11138..8f381352c 100644 --- a/src/storage/storage_backend_fs.h +++ b/src/storage/storage_backend_fs.h @@ -24,15 +24,6 @@ #ifndef __VIR_STORAGE_BACKEND_FS_H__ # define __VIR_STORAGE_BACKEND_FS_H__ -# include "storage_backend.h" +int virStorageBackendFsRegister(void); -# if WITH_STORAGE_FS -extern virStorageBackend virStorageBackendFileSystem; -extern virStorageBackend virStorageBackendNetFileSystem; -# endif - -extern virStorageBackend virStorageBackendDirectory; - -extern virStorageFileBackend virStorageFileBackendFile; -extern virStorageFileBackend virStorageFileBackendBlock; #endif /* __VIR_STORAGE_BACKEND_FS_H__ */ diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_ba= ckend_gluster.c index 7be2d9e81..52c9ee372 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -843,6 +843,17 @@ virStorageFileBackend virStorageFileBackendGluster =3D= { .storageFileChown =3D virStorageFileBackendGlusterChown, .storageFileGetUniqueIdentifier =3D virStorageFileBackendGlusterGetUni= queIdentifier, +}; -}; +int +virStorageBackendGlusterRegister(void) +{ + if (virStorageBackendRegister(&virStorageBackendGluster) < 0) + return -1; + + if (virStorageBackendFileRegister(&virStorageFileBackendGluster) < 0) + return -1; + + return 0; +} diff --git a/src/storage/storage_backend_gluster.h b/src/storage/storage_ba= ckend_gluster.h index 679601624..91b8d8275 100644 --- a/src/storage/storage_backend_gluster.h +++ b/src/storage/storage_backend_gluster.h @@ -22,9 +22,6 @@ #ifndef __VIR_STORAGE_BACKEND_GLUSTER_H__ # define __VIR_STORAGE_BACKEND_GLUSTER_H__ -# include "storage_backend.h" - -extern virStorageBackend virStorageBackendGluster; -extern virStorageFileBackend virStorageFileBackendGluster; +int virStorageBackendGlusterRegister(void); #endif /* __VIR_STORAGE_BACKEND_GLUSTER_H__ */ diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_back= end_iscsi.c index 281334124..866fa7415 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -437,3 +437,10 @@ virStorageBackend virStorageBackendISCSI =3D { .downloadVol =3D virStorageBackendVolDownloadLocal, .wipeVol =3D virStorageBackendVolWipeLocal, }; + + +int +virStorageBackendISCSIRegister(void) +{ + return virStorageBackendRegister(&virStorageBackendISCSI); +} diff --git a/src/storage/storage_backend_iscsi.h b/src/storage/storage_back= end_iscsi.h index da3b22c44..98d2b3ef2 100644 --- a/src/storage/storage_backend_iscsi.h +++ b/src/storage/storage_backend_iscsi.h @@ -24,8 +24,6 @@ #ifndef __VIR_STORAGE_BACKEND_ISCSI_H__ # define __VIR_STORAGE_BACKEND_ISCSI_H__ -# include "storage_backend.h" - -extern virStorageBackend virStorageBackendISCSI; +int virStorageBackendISCSIRegister(void); #endif /* __VIR_STORAGE_BACKEND_ISCSI_H__ */ diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index b0191aa45..756c62e90 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -1112,3 +1112,10 @@ virStorageBackend virStorageBackendLogical =3D { .downloadVol =3D virStorageBackendVolDownloadLocal, .wipeVol =3D virStorageBackendLogicalVolWipe, }; + + +int +virStorageBackendLogicalRegister(void) +{ + return virStorageBackendRegister(&virStorageBackendLogical); +} diff --git a/src/storage/storage_backend_logical.h b/src/storage/storage_ba= ckend_logical.h index c646fd6a6..c0f62cd18 100644 --- a/src/storage/storage_backend_logical.h +++ b/src/storage/storage_backend_logical.h @@ -24,8 +24,6 @@ #ifndef __VIR_STORAGE_BACKEND_LOGICAL_H__ # define __VIR_STORAGE_BACKEND_LOGICAL_H__ -# include "storage_backend.h" - -extern virStorageBackend virStorageBackendLogical; +int virStorageBackendLogicalRegister(void); #endif /* __VIR_STORAGE_BACKEND_LOGICAL_H__ */ diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_back= end_mpath.c index a5d692a07..4bb38bb52 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -32,6 +32,7 @@ #include "virerror.h" #include "storage_conf.h" #include "storage_backend.h" +#include "storage_backend_mpath.h" #include "viralloc.h" #include "virlog.h" #include "virfile.h" @@ -278,3 +279,10 @@ virStorageBackend virStorageBackendMpath =3D { .downloadVol =3D virStorageBackendVolDownloadLocal, .wipeVol =3D virStorageBackendVolWipeLocal, }; + + +int +virStorageBackendMpathRegister(void) +{ + return virStorageBackendRegister(&virStorageBackendMpath); +} diff --git a/src/storage/storage_backend_mpath.h b/src/storage/storage_back= end_mpath.h index b66664576..c14dcc3cf 100644 --- a/src/storage/storage_backend_mpath.h +++ b/src/storage/storage_backend_mpath.h @@ -24,8 +24,6 @@ #ifndef __VIR_STORAGE_BACKEND_MPATH_H__ # define __VIR_STORAGE_BACKEND_MPATH_H__ -# include "storage_backend.h" - -extern virStorageBackend virStorageBackendMpath; +int virStorageBackendMpathRegister(void); #endif /* __VIR_STORAGE_BACKEND_MPATH_H__ */ diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 45beb107a..c806d6d30 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -1294,3 +1294,10 @@ virStorageBackend virStorageBackendRBD =3D { .resizeVol =3D virStorageBackendRBDResizeVol, .wipeVol =3D virStorageBackendRBDVolWipe }; + + +int +virStorageBackendRBDRegister(void) +{ + return virStorageBackendRegister(&virStorageBackendRBD); +} diff --git a/src/storage/storage_backend_rbd.h b/src/storage/storage_backen= d_rbd.h index e60caa957..21a43fd51 100644 --- a/src/storage/storage_backend_rbd.h +++ b/src/storage/storage_backend_rbd.h @@ -23,8 +23,6 @@ #ifndef __VIR_STORAGE_BACKEND_RBD_H__ # define __VIR_STORAGE_BACKEND_RBD_H__ -# include "storage_backend.h" - -extern virStorageBackend virStorageBackendRBD; +int virStorageBackendRBDRegister(void); #endif /* __VIR_STORAGE_BACKEND_RBD_H__ */ diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backe= nd_scsi.c index 0cc11486b..6e2e22a8c 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -531,3 +531,10 @@ virStorageBackend virStorageBackendSCSI =3D { .downloadVol =3D virStorageBackendVolDownloadLocal, .wipeVol =3D virStorageBackendVolWipeLocal, }; + + +int +virStorageBackendSCSIRegister(void) +{ + return virStorageBackendRegister(&virStorageBackendSCSI); +} diff --git a/src/storage/storage_backend_scsi.h b/src/storage/storage_backe= nd_scsi.h index 1ba53a57c..efd01658b 100644 --- a/src/storage/storage_backend_scsi.h +++ b/src/storage/storage_backend_scsi.h @@ -24,8 +24,6 @@ #ifndef __VIR_STORAGE_BACKEND_SCSI_H__ # define __VIR_STORAGE_BACKEND_SCSI_H__ -# include "storage_backend.h" - -extern virStorageBackend virStorageBackendSCSI; +int virStorageBackendSCSIRegister(void); #endif /* __VIR_STORAGE_BACKEND_SCSI_H__ */ diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_b= ackend_sheepdog.c index 36458a562..a9a2301e6 100644 --- a/src/storage/storage_backend_sheepdog.c +++ b/src/storage/storage_backend_sheepdog.c @@ -417,3 +417,10 @@ virStorageBackend virStorageBackendSheepdog =3D { .deleteVol =3D virStorageBackendSheepdogDeleteVol, .resizeVol =3D virStorageBackendSheepdogResizeVol, }; + + +int +virStorageBackendSheepdogRegister(void) +{ + return virStorageBackendRegister(&virStorageBackendSheepdog); +} diff --git a/src/storage/storage_backend_sheepdog.h b/src/storage/storage_b= ackend_sheepdog.h index df2ead5ed..e96832309 100644 --- a/src/storage/storage_backend_sheepdog.h +++ b/src/storage/storage_backend_sheepdog.h @@ -27,8 +27,6 @@ #ifndef __VIR_STORAGE_BACKEND_SHEEPDOG_H__ # define __VIR_STORAGE_BACKEND_SHEEPDOG_H__ -# include "storage_backend.h" - -extern virStorageBackend virStorageBackendSheepdog; +int virStorageBackendSheepdogRegister(void); #endif /* __VIR_STORAGE_BACKEND_SHEEPDOG_H__ */ diff --git a/src/storage/storage_backend_vstorage.c b/src/storage/storage_b= ackend_vstorage.c index ac1fa756c..fb0613853 100644 --- a/src/storage/storage_backend_vstorage.c +++ b/src/storage/storage_backend_vstorage.c @@ -183,3 +183,10 @@ virStorageBackend virStorageBackendVstorage =3D { .downloadVol =3D virStorageBackendVolDownloadLocal, .wipeVol =3D virStorageBackendVolWipeLocal, }; + + +int +virStorageBackendVstorageRegister(void) +{ + return virStorageBackendRegister(&virStorageBackendVstorage); +} diff --git a/src/storage/storage_backend_vstorage.h b/src/storage/storage_b= ackend_vstorage.h index 262e454c0..0a29c597f 100644 --- a/src/storage/storage_backend_vstorage.h +++ b/src/storage/storage_backend_vstorage.h @@ -21,8 +21,6 @@ #ifndef __VIR_STORAGE_BACKEND_VSTORAGE_H__ # define __VIR_STORAGE_BACKEND_VSTORAGE_H__ -# include "storage_backend.h" - -extern virStorageBackend virStorageBackendVstorage; +int virStorageBackendVstorageRegister(void); #endif /* __VIR_STORAGE_BACKEND_VSTORAGE_H__ */ diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backen= d_zfs.c index 70c533a7f..004d95a53 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -467,3 +467,10 @@ virStorageBackend virStorageBackendZFS =3D { .uploadVol =3D virStorageBackendVolUploadLocal, .downloadVol =3D virStorageBackendVolDownloadLocal, }; + + +int +virStorageBackendZFSRegister(void) +{ + return virStorageBackendRegister(&virStorageBackendZFS); +} diff --git a/src/storage/storage_backend_zfs.h b/src/storage/storage_backen= d_zfs.h index 4c34b5909..076ff2799 100644 --- a/src/storage/storage_backend_zfs.h +++ b/src/storage/storage_backend_zfs.h @@ -22,8 +22,6 @@ #ifndef __VIR_STORAGE_BACKEND_ZFS_H__ # define __VIR_STORAGE_BACKEND_ZFS_H__ -# include "storage_backend.h" - -extern virStorageBackend virStorageBackendZFS; +int virStorageBackendZFSRegister(void); #endif /* __VIR_STORAGE_BACKEND_ZFS_H__ */ diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index ed4772ad9..7fafbcf75 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -2840,6 +2840,8 @@ static virStateDriver stateDriver =3D { int storageRegister(void) { + if (virStorageBackendDriversRegister() < 0) + return -1; if (virSetSharedStorageDriver(&storageDriver) < 0) return -1; if (virRegisterStateDriver(&stateDriver) < 0) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index f766df115..d715fd762 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -32,6 +32,7 @@ #include "dirname.h" #include "storage/storage_driver.h" +#include "storage/storage_backend.h" #define VIR_FROM_THIS VIR_FROM_NONE @@ -731,6 +732,9 @@ mymain(void) virStorageSourcePtr chain2; /* short for chain->backingStore */ virStorageSourcePtr chain3; /* short for chain2->backingStore */ + if (virStorageBackendDriversRegister() < 0) + return -1; + /* Prep some files with qemu-img; if that is not found on PATH, or * if it lacks support for qcow2 and qed, skip this test. */ if ((ret =3D testPrepImages()) !=3D 0) --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 22:39:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1486571411503592.245494298811; Wed, 8 Feb 2017 08:30:11 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQqFO038669; Wed, 8 Feb 2017 11:26:52 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18GQjRo017913 for ; Wed, 8 Feb 2017 11:26:45 -0500 Received: from angien.brq.redhat.com (dhcp129-162.brq.redhat.com [10.34.129.162]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQbSn027100; Wed, 8 Feb 2017 11:26:45 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 17:27:07 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 07/11] storage: Turn driver backends into (static) modules X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Compile the storage driver into modules rather than by compiling all files together. All modules are still linked together statically. --- src/Makefile.am | 114 ++++++++++++++++++++++++++++++++++++++++++++++++----= ---- 1 file changed, 98 insertions(+), 16 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 2f32d4197..b71209a9d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1674,52 +1674,134 @@ noinst_LTLIBRARIES +=3D libvirt_driver_storage.la #libvirt_la_BUILT_LIBADD +=3D libvirt_driver_storage.la endif ! WITH_DRIVER_MODULES libvirt_driver_storage_impl_la_SOURCES +=3D $(STORAGE_DRIVER_SOURCES) -libvirt_driver_storage_impl_la_SOURCES +=3D $(STORAGE_DRIVER_FS_SOURCES) + + +libvirt_storage_backend_fs_la_SOURCES =3D $(STORAGE_DRIVER_FS_SOURCES) +libvirt_storage_backend_fs_la_CFLAGS =3D \ + -I$(srcdir)/conf \ + $(AM_CFLAGS) + +noinst_LTLIBRARIES +=3D libvirt_storage_backend_fs.la +libvirt_driver_storage_impl_la_LIBADD +=3D libvirt_storage_backend_fs.la endif WITH_STORAGE if WITH_STORAGE_LVM -libvirt_driver_storage_impl_la_SOURCES +=3D $(STORAGE_DRIVER_LVM_SOURCES) +libvirt_storage_backend_logical_la_SOURCES =3D \ + $(STORAGE_DRIVER_LVM_SOURCES) +libvirt_storage_backend_logical_la_CFLAGS =3D \ + -I$(srcdir)/conf \ + $(AM_CFLAGS) + +noinst_LTLIBRARIES +=3D libvirt_storage_backend_logical.la +libvirt_driver_storage_impl_la_LIBADD +=3D \ + libvirt_storage_backend_logical.la endif WITH_STORAGE_LVM if WITH_STORAGE_ISCSI -libvirt_driver_storage_impl_la_SOURCES +=3D $(STORAGE_DRIVER_ISCSI_SOURCES) +libvirt_storage_backend_iscsi_la_SOURCES =3D \ + $(STORAGE_DRIVER_ISCSI_SOURCES) +libvirt_storage_backend_iscsi_la_CFLAGS =3D \ + -I$(srcdir)/conf \ + -I$(srcdir)/secret \ + $(AM_CFLAGS) + +noinst_LTLIBRARIES +=3D libvirt_storage_backend_iscsi.la +libvirt_driver_storage_impl_la_LIBADD +=3D \ + libvirt_storage_backend_iscsi.la endif WITH_STORAGE_ISCSI if WITH_STORAGE_SCSI -libvirt_driver_storage_impl_la_SOURCES +=3D $(STORAGE_DRIVER_SCSI_SOURCES) +libvirt_storage_backend_scsi_la_SOURCES =3D $(STORAGE_DRIVER_SCSI_SOURCES) +libvirt_storage_backend_scsi_la_CFLAGS =3D \ + -I$(srcdir)/conf \ + $(AM_CFLAGS) + +noinst_LTLIBRARIES +=3D libvirt_storage_backend_scsi.la +libvirt_driver_storage_impl_la_LIBADD +=3D libvirt_storage_backend_scsi.la endif WITH_STORAGE_SCSI if WITH_STORAGE_MPATH -libvirt_driver_storage_impl_la_SOURCES +=3D $(STORAGE_DRIVER_MPATH_SOURCES) -libvirt_driver_storage_impl_la_CFLAGS +=3D $(DEVMAPPER_CFLAGS) -libvirt_driver_storage_impl_la_LIBADD +=3D $(DEVMAPPER_LIBS) +libvirt_storage_backend_mpath_la_SOURCES =3D \ + $(STORAGE_DRIVER_MPATH_SOURCES) +libvirt_storage_backend_mpath_la_LIBADD =3D $(DEVMAPPER_LIBS) +libvirt_storage_backend_mpath_la_CFLAGS =3D \ + -I$(srcdir)/conf \ + $(DEVMAPPER_CFLAGS) \ + $(AM_CFLAGS) + +noinst_LTLIBRARIES +=3D libvirt_storage_backend_mpath.la +libvirt_driver_storage_impl_la_LIBADD +=3D \ + libvirt_storage_backend_mpath.la endif WITH_STORAGE_MPATH if WITH_STORAGE_DISK -libvirt_driver_storage_impl_la_SOURCES +=3D $(STORAGE_DRIVER_DISK_SOURCES) +libvirt_storage_backend_disk_la_SOURCES =3D $(STORAGE_DRIVER_DISK_SOURCES) +libvirt_storage_backend_disk_la_CFLAGS =3D \ + -I$(srcdir)/conf \ + $(AM_CFLAGS) + +noinst_LTLIBRARIES +=3D libvirt_storage_backend_disk.la +libvirt_driver_storage_impl_la_LIBADD +=3D libvirt_storage_backend_disk.la endif WITH_STORAGE_DISK if WITH_STORAGE_RBD -libvirt_driver_storage_impl_la_SOURCES +=3D $(STORAGE_DRIVER_RBD_SOURCES) -libvirt_driver_storage_impl_la_LIBADD +=3D $(LIBRBD_LIBS) +libvirt_storage_backend_rbd_la_SOURCES =3D $(STORAGE_DRIVER_RBD_SOURCES) +libvirt_storage_backend_rbd_la_LIBADD =3D $(LIBRBD_LIBS) +libvirt_storage_backend_rbd_la_CFLAGS =3D \ + -I$(srcdir)/conf \ + -I$(srcdir)/secret \ + $(AM_CFLAGS) + +noinst_LTLIBRARIES +=3D libvirt_storage_backend_rbd.la +libvirt_driver_storage_impl_la_LIBADD +=3D libvirt_storage_backend_rbd.la endif WITH_STORAGE_RBD if WITH_STORAGE_SHEEPDOG -libvirt_driver_storage_impl_la_SOURCES +=3D $(STORAGE_DRIVER_SHEEPDOG_SOUR= CES) +libvirt_storage_backend_sheepdog_la_SOURCES =3D \ + $(STORAGE_DRIVER_SHEEPDOG_SOURCES) +libvirt_storage_backend_sheepdog_la_CFLAGS =3D \ + -I$(srcdir)/conf \ + $(AM_CFLAGS) + +noinst_LTLIBRARIES +=3D libvirt_storage_backend_sheepdog.la +libvirt_driver_storage_impl_la_LIBADD +=3D \ + libvirt_storage_backend_sheepdog.la endif WITH_STORAGE_SHEEPDOG if WITH_STORAGE_GLUSTER -libvirt_driver_storage_impl_la_SOURCES +=3D $(STORAGE_DRIVER_GLUSTER_SOURC= ES) -libvirt_driver_storage_impl_la_CFLAGS +=3D $(GLUSTERFS_CFLAGS) -libvirt_driver_storage_impl_la_LIBADD +=3D $(GLUSTERFS_LIBS) +libvirt_storage_backend_gluster_la_SOURCES =3D \ + $(STORAGE_DRIVER_GLUSTER_SOURCES) +libvirt_storage_backend_gluster_la_LIBADD =3D $(GLUSTERFS_LIBS) +libvirt_storage_backend_gluster_la_CFLAGS =3D \ + -I$(srcdir)/conf \ + $(GLUSTERFS_CFLAGS) \ + $(AM_CFLAGS) + +noinst_LTLIBRARIES +=3D libvirt_storage_backend_gluster.la +libvirt_driver_storage_impl_la_LIBADD +=3D \ + libvirt_storage_backend_gluster.la endif WITH_STORAGE_GLUSTER if WITH_STORAGE_ZFS -libvirt_driver_storage_impl_la_SOURCES +=3D $(STORAGE_DRIVER_ZFS_SOURCES) +libvirt_storage_backend_zfs_la_SOURCES =3D $(STORAGE_DRIVER_ZFS_SOURCES) +libvirt_storage_backend_zfs_la_CFLAGS =3D \ + -I$(srcdir)/conf \ + $(AM_CFLAGS) + +noinst_LTLIBRARIES +=3D libvirt_storage_backend_zfs.la +libvirt_driver_storage_impl_la_LIBADD +=3D libvirt_storage_backend_zfs.la endif WITH_STORAGE_ZFS if WITH_STORAGE_VSTORAGE -libvirt_driver_storage_impl_la_SOURCES +=3D $(STORAGE_DRIVER_VSTORAGE_SOUR= CES) +libvirt_storage_backend_vstorage_la_SOURCES =3D \ + $(STORAGE_DRIVER_VSTORAGE_SOURCES) +libvirt_storage_backend_vstorage_la_CFLAGS =3D \ + -I$(srcdir)/conf \ + $(AM_CFLAGS) + +noinst_LTLIBRARIES +=3D libvirt_storage_backend_vstorage.la +libvirt_driver_storage_impl_la_LIBADD +=3D \ + libvirt_storage_backend_vstorage.la endif WITH_STORAGE_VSTORAGE if WITH_NODE_DEVICES --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 22:39:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1486571440822251.59982118633798; Wed, 8 Feb 2017 08:30:40 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQqV2038668; Wed, 8 Feb 2017 11:26:52 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18GQkYi017925 for ; Wed, 8 Feb 2017 11:26:46 -0500 Received: from angien.brq.redhat.com (dhcp129-162.brq.redhat.com [10.34.129.162]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQbSo027100; Wed, 8 Feb 2017 11:26:46 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 17:27:08 +0100 Message-Id: <1c5750d6e6a38035106a8a475988a67317d70931.1486571179.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 08/11] storage: Turn storage backends into dynamic modules X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If driver modules are enabled turn storage driver backends into dynamically loadable objects. This will allow greater modularity for binary distributions, where heavyweight dependencies as rbd and gluster can be avoided by selecting only a subset of drivers if the rest is not necessary. The storage modules are installed into 'LIBDIR/libvirt/storage-backend/' and users can't override the location by using 'LIBVIRT_STORAGE_BACKEND_DIR' environment variable. rpm based distros will at this point install all the backends when libvirt-daemon-driver-storage package is installed. --- libvirt.spec.in | 17 +++++++++ src/Makefile.am | 85 +++++++++++++++++++++++++++++++++++++++= +++- src/storage/storage_backend.c | 60 +++++++++++++++++++++++------- tests/Makefile.am | 4 +- 4 files changed, 151 insertions(+), 15 deletions(-) diff --git a/libvirt.spec.in b/libvirt.spec.in index e8c272bd7..3098ed2dd 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1234,6 +1234,8 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/lock-driver/*= .la rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/lock-driver/*.a rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/connection-driver/*.la rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/connection-driver/*.a +rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/storage-backend/*.la +rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/storage-backend/*.a %if %{with_wireshark} %if 0%{fedora} >=3D 24 rm -f $RPM_BUILD_ROOT%{_libdir}/wireshark/plugins/libvirt.la @@ -1689,6 +1691,21 @@ exit 0 %files daemon-driver-storage %attr(0755, root, root) %{_libexecdir}/libvirt_parthelper %{_libdir}/%{name}/connection-driver/libvirt_driver_storage.so +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_fs.so +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_disk.so +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_logical.so +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_scsi.so +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_iscsi.so +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_mpath.so +%if %{with_storage_gluster} +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_gluster.so +%endif +%if %{with_storage_rbd} +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_rbd.so +%endif +%if %{with_storage_sheepdog} +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_sheepdog.so +%endif %if %{with_qemu} %files daemon-driver-qemu diff --git a/src/Makefile.am b/src/Makefile.am index b71209a9d..cdac7a1b5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -970,9 +970,12 @@ SECRET_DRIVER_SOURCES =3D \ secret/secret_driver.h secret/secret_driver.c # Storage backend specific impls +STORAGE_DRIVER_BACKEND_SOURCES =3D \ + storage/storage_backend.h storage/storage_backend.c + STORAGE_DRIVER_SOURCES =3D \ storage/storage_driver.h storage/storage_driver.c \ - storage/storage_backend.h storage/storage_backend.c \ + $(STORAGE_DRIVER_BACKEND_SOURCES) \ storage/storage_util.h storage/storage_util.c STORAGE_DRIVER_FS_SOURCES =3D \ @@ -1660,6 +1663,12 @@ if WITH_BLKID libvirt_driver_storage_impl_la_CFLAGS +=3D $(BLKID_CFLAGS) libvirt_driver_storage_impl_la_LIBADD +=3D $(BLKID_LIBS) endif WITH_BLKID + +if WITH_DRIVER_MODULES +storagebackenddir =3D $(libdir)/libvirt/storage-backend +storagebackend_LTLIBRARIES =3D +endif WITH_DRIVER_MODULES + if WITH_STORAGE noinst_LTLIBRARIES +=3D libvirt_driver_storage_impl.la libvirt_driver_storage_la_SOURCES =3D @@ -1681,8 +1690,14 @@ libvirt_storage_backend_fs_la_CFLAGS =3D \ -I$(srcdir)/conf \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_fs.la +libvirt_storage_backend_fs_la_LDFLAGS =3D \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES +=3D libvirt_storage_backend_fs.la libvirt_driver_storage_impl_la_LIBADD +=3D libvirt_storage_backend_fs.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE if WITH_STORAGE_LVM @@ -1692,9 +1707,15 @@ libvirt_storage_backend_logical_la_CFLAGS =3D \ -I$(srcdir)/conf \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_logical.la +libvirt_storage_backend_logical_la_LDFLAGS =3D \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES +=3D libvirt_storage_backend_logical.la libvirt_driver_storage_impl_la_LIBADD +=3D \ libvirt_storage_backend_logical.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_LVM if WITH_STORAGE_ISCSI @@ -1705,9 +1726,15 @@ libvirt_storage_backend_iscsi_la_CFLAGS =3D \ -I$(srcdir)/secret \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_iscsi.la +libvirt_storage_backend_iscsi_la_LDFLAGS =3D \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES +=3D libvirt_storage_backend_iscsi.la libvirt_driver_storage_impl_la_LIBADD +=3D \ libvirt_storage_backend_iscsi.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_ISCSI if WITH_STORAGE_SCSI @@ -1716,8 +1743,14 @@ libvirt_storage_backend_scsi_la_CFLAGS =3D \ -I$(srcdir)/conf \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_scsi.la +libvirt_storage_backend_scsi_la_LDFLAGS =3D \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES +=3D libvirt_storage_backend_scsi.la libvirt_driver_storage_impl_la_LIBADD +=3D libvirt_storage_backend_scsi.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_SCSI if WITH_STORAGE_MPATH @@ -1729,9 +1762,15 @@ libvirt_storage_backend_mpath_la_CFLAGS =3D \ $(DEVMAPPER_CFLAGS) \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_mpath.la +libvirt_storage_backend_mpath_la_LDFLAGS =3D \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES +=3D libvirt_storage_backend_mpath.la libvirt_driver_storage_impl_la_LIBADD +=3D \ libvirt_storage_backend_mpath.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_MPATH if WITH_STORAGE_DISK @@ -1740,8 +1779,14 @@ libvirt_storage_backend_disk_la_CFLAGS =3D \ -I$(srcdir)/conf \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_disk.la +libvirt_storage_backend_disk_la_LDFLAGS =3D \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES +=3D libvirt_storage_backend_disk.la libvirt_driver_storage_impl_la_LIBADD +=3D libvirt_storage_backend_disk.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_DISK if WITH_STORAGE_RBD @@ -1752,8 +1797,14 @@ libvirt_storage_backend_rbd_la_CFLAGS =3D \ -I$(srcdir)/secret \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_rbd.la +libvirt_storage_backend_rbd_la_LDFLAGS =3D \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES +=3D libvirt_storage_backend_rbd.la libvirt_driver_storage_impl_la_LIBADD +=3D libvirt_storage_backend_rbd.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_RBD if WITH_STORAGE_SHEEPDOG @@ -1763,9 +1814,23 @@ libvirt_storage_backend_sheepdog_la_CFLAGS =3D \ -I$(srcdir)/conf \ $(AM_CFLAGS) +libvirt_storage_backend_sheepdog_priv_la_SOURCES =3D \ + $(STORAGE_DRIVER_SHEEPDOG_SOURCES) \ + $(STORAGE_DRIVER_BACKEND_SOURCES) +libvirt_storage_backend_sheepdog_priv_la_CFLAGS =3D \ + -I$(srcdir)/conf \ + $(AM_CFLAGS) +noinst_LTLIBRARIES +=3D libvirt_storage_backend_sheepdog_priv.la + +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_sheepdog.la +libvirt_storage_backend_sheepdog_la_LDFLAGS =3D \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES +=3D libvirt_storage_backend_sheepdog.la libvirt_driver_storage_impl_la_LIBADD +=3D \ libvirt_storage_backend_sheepdog.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_SHEEPDOG if WITH_STORAGE_GLUSTER @@ -1777,9 +1842,15 @@ libvirt_storage_backend_gluster_la_CFLAGS =3D \ $(GLUSTERFS_CFLAGS) \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_gluster.la +libvirt_storage_backend_gluster_la_LDFLAGS =3D \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES +=3D libvirt_storage_backend_gluster.la libvirt_driver_storage_impl_la_LIBADD +=3D \ libvirt_storage_backend_gluster.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_GLUSTER if WITH_STORAGE_ZFS @@ -1788,8 +1859,14 @@ libvirt_storage_backend_zfs_la_CFLAGS =3D \ -I$(srcdir)/conf \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_zfs.la +libvirt_storage_backend_zfs_la_LDFLAGS =3D \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES +=3D libvirt_storage_backend_zfs.la libvirt_driver_storage_impl_la_LIBADD +=3D libvirt_storage_backend_zfs.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_ZFS if WITH_STORAGE_VSTORAGE @@ -1799,9 +1876,15 @@ libvirt_storage_backend_vstorage_la_CFLAGS =3D \ -I$(srcdir)/conf \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_vstorage.la +libvirt_storage_backend_vstorage_la_LDFLAGS =3D \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES +=3D libvirt_storage_backend_vstorage.la libvirt_driver_storage_impl_la_LIBADD +=3D \ libvirt_storage_backend_vstorage.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_VSTORAGE if WITH_NODE_DEVICES diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index d8099be36..32f45e841 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -33,6 +33,8 @@ #include "virstoragefile.h" #include "storage_backend.h" #include "virlog.h" +#include "virfile.h" +#include "configmake.h" #if WITH_STORAGE_LVM # include "storage_backend_logical.h" @@ -79,45 +81,77 @@ static size_t virStorageBackendsCount; static virStorageFileBackendPtr virStorageFileBackends[VIR_STORAGE_BACKEND= S_MAX]; static size_t virStorageFileBackendsCount; -#define VIR_STORAGE_BACKEND_REGISTER(name) = \ - if (name() < 0) = \ +#if WITH_DRIVER_MODULES + +# define STORAGE_BACKEND_MODULE_DIR LIBDIR "/libvirt/storage-backend" + +static int +virStorageDriverLoadBackendModule(const char *name, + const char *regfunc) +{ + char *modfile =3D NULL; + int ret; + + if (!(modfile =3D virFileFindResourceFull(name, + "libvirt_storage_backend_", + ".so", + abs_topbuilddir "/src/.libs", + STORAGE_BACKEND_MODULE_DIR, + "LIBVIRT_STORAGE_BACKEND_DIR")= )) + return 1; + + ret =3D virDriverLoadModuleFull(modfile, regfunc, NULL); + + VIR_FREE(modfile); + + return ret; +} + + +# define VIR_STORAGE_BACKEND_REGISTER(func, module) = \ + if (virStorageDriverLoadBackendModule(module, #func) < 0) = \ + return -1 +#else +# define VIR_STORAGE_BACKEND_REGISTER(func, module) = \ + if (func() < 0) = \ return -1 +#endif int virStorageBackendDriversRegister(void) { #if WITH_STORAGE_DIR || WITH_STORAGE_FS - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendFsRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendFsRegister, "fs"); #endif #if WITH_STORAGE_LVM - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendLogicalRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendLogicalRegister, "logica= l"); #endif #if WITH_STORAGE_ISCSI - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendISCSIRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendISCSIRegister, "iscsi"); #endif #if WITH_STORAGE_SCSI - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendSCSIRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendSCSIRegister, "scsi"); #endif #if WITH_STORAGE_MPATH - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendMpathRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendMpathRegister, "mpath"); #endif #if WITH_STORAGE_DISK - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendDiskRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendDiskRegister, "disk"); #endif #if WITH_STORAGE_RBD - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendRBDRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendRBDRegister, "rbd"); #endif #if WITH_STORAGE_SHEEPDOG - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendSheepdogRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendSheepdogRegister, "sheep= dog"); #endif #if WITH_STORAGE_GLUSTER - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendGlusterRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendGlusterRegister, "gluste= r"); #endif #if WITH_STORAGE_ZFS - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendZFSRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendZFSRegister, "zfs"); #endif #if WITH_STORAGE_VSTORAGE - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendVstorageRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendVstorageRegister, "vstor= age"); #endif return 0; diff --git a/tests/Makefile.am b/tests/Makefile.am index e923178f2..401253da3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -804,7 +804,9 @@ storagebackendsheepdogtest_SOURCES =3D \ storagebackendsheepdogtest.c \ testutils.c testutils.h storagebackendsheepdogtest_LDADD =3D \ - ../src/libvirt_driver_storage_impl.la $(LDADDS) + ../src/libvirt_driver_storage_impl.la \ + ../src/libvirt_storage_backend_sheepdog_priv.la \ + $(LDADDS) else ! WITH_STORAGE_SHEEPDOG EXTRA_DIST +=3D storagebackendsheepdogtest.c endif ! WITH_STORAGE_SHEEPDOG --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 22:39:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1486571406033905.4166994028345; Wed, 8 Feb 2017 08:30:06 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18GQpNW006027; Wed, 8 Feb 2017 11:26:51 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18GQli2017931 for ; Wed, 8 Feb 2017 11:26:47 -0500 Received: from angien.brq.redhat.com (dhcp129-162.brq.redhat.com [10.34.129.162]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQbSp027100; Wed, 8 Feb 2017 11:26:47 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 17:27:09 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 09/11] tests: drivermodule: Make sure that all compiled storage backends can be loaded X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add a new storage driver registration function that will force the backend code to fail if any of the storage backend modules can't be loaded. This will make sure that they work and are present. --- src/storage/storage_backend.c | 16 ++++++++++++---- src/storage/storage_backend.h | 2 +- src/storage/storage_driver.c | 19 +++++++++++++++++-- src/storage/storage_driver.h | 1 + tests/virdrivermoduletest.c | 2 +- tests/virstoragetest.c | 2 +- 6 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 32f45e841..ce278b99c 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -87,7 +87,8 @@ static size_t virStorageFileBackendsCount; static int virStorageDriverLoadBackendModule(const char *name, - const char *regfunc) + const char *regfunc, + bool forceload) { char *modfile =3D NULL; int ret; @@ -100,7 +101,14 @@ virStorageDriverLoadBackendModule(const char *name, "LIBVIRT_STORAGE_BACKEND_DIR")= )) return 1; - ret =3D virDriverLoadModuleFull(modfile, regfunc, NULL); + if ((ret =3D virDriverLoadModuleFull(modfile, regfunc, NULL)) !=3D 0) { + if (forceload) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to load storage backend module '%s'"), + name); + ret =3D -1; + } + } VIR_FREE(modfile); @@ -109,7 +117,7 @@ virStorageDriverLoadBackendModule(const char *name, # define VIR_STORAGE_BACKEND_REGISTER(func, module) = \ - if (virStorageDriverLoadBackendModule(module, #func) < 0) = \ + if (virStorageDriverLoadBackendModule(module, #func, allbackends) < 0)= \ return -1 #else # define VIR_STORAGE_BACKEND_REGISTER(func, module) = \ @@ -118,7 +126,7 @@ virStorageDriverLoadBackendModule(const char *name, #endif int -virStorageBackendDriversRegister(void) +virStorageBackendDriversRegister(bool allbackends ATTRIBUTE_UNUSED) { #if WITH_STORAGE_DIR || WITH_STORAGE_FS VIR_STORAGE_BACKEND_REGISTER(virStorageBackendFsRegister, "fs"); diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h index ca6c19c45..f433071f4 100644 --- a/src/storage/storage_backend.h +++ b/src/storage/storage_backend.h @@ -198,7 +198,7 @@ struct _virStorageFileBackend { virStorageFileBackendChown storageFileChown; }; -int virStorageBackendDriversRegister(void); +int virStorageBackendDriversRegister(bool allmodules); int virStorageBackendRegister(virStorageBackendPtr backend); int virStorageBackendFileRegister(virStorageFileBackendPtr backend); diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 7fafbcf75..0bc047f23 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -2838,9 +2838,10 @@ static virStateDriver stateDriver =3D { .stateReload =3D storageStateReload, }; -int storageRegister(void) +static int +storageRegisterFull(bool allbackends) { - if (virStorageBackendDriversRegister() < 0) + if (virStorageBackendDriversRegister(allbackends) < 0) return -1; if (virSetSharedStorageDriver(&storageDriver) < 0) return -1; @@ -2850,6 +2851,20 @@ int storageRegister(void) } +int +storageRegister(void) +{ + return storageRegisterFull(false); +} + + +int +storageRegisterAll(void) +{ + return storageRegisterFull(true); +} + + /* ----------- file handlers cooperating with storage driver -------------= -- */ static bool virStorageFileIsInitialized(const virStorageSource *src) diff --git a/src/storage/storage_driver.h b/src/storage/storage_driver.h index 682c9ff82..f0aca3671 100644 --- a/src/storage/storage_driver.h +++ b/src/storage/storage_driver.h @@ -70,5 +70,6 @@ char *virStoragePoolObjBuildTempFilePath(virStoragePoolOb= jPtr pool, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; int storageRegister(void); +int storageRegisterAll(void); #endif /* __VIR_STORAGE_DRIVER_H__ */ diff --git a/tests/virdrivermoduletest.c b/tests/virdrivermoduletest.c index e440350c2..13d51a8e9 100644 --- a/tests/virdrivermoduletest.c +++ b/tests/virdrivermoduletest.c @@ -71,7 +71,7 @@ mymain(void) TEST("interface"); #endif #ifdef WITH_STORAGE - TEST("storage"); + TEST_FULL("storage", "storageRegisterAll"); #endif #ifdef WITH_NODE_DEVICES TEST("nodedev"); diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index d715fd762..36567753b 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -732,7 +732,7 @@ mymain(void) virStorageSourcePtr chain2; /* short for chain->backingStore */ virStorageSourcePtr chain3; /* short for chain2->backingStore */ - if (virStorageBackendDriversRegister() < 0) + if (virStorageBackendDriversRegister(false) < 0) return -1; /* Prep some files with qemu-img; if that is not found on PATH, or --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 22:39:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1486571415610461.735789669278; Wed, 8 Feb 2017 08:30:15 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQrBW038682; Wed, 8 Feb 2017 11:26:53 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18GQmeq017939 for ; Wed, 8 Feb 2017 11:26:48 -0500 Received: from angien.brq.redhat.com (dhcp129-162.brq.redhat.com [10.34.129.162]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQbSq027100; Wed, 8 Feb 2017 11:26:48 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 17:27:10 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 10/11] spec: Modularize the storage driver X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Create a new set of sub-packages containing the new storage driver modules so that certain heavy-weight backends (gluster, rbd) can be installed separately only if required. To keep backward compatibility the 'libvirt-driver-storage' package will be turned into a virtual package pulling in all the new storage backend sub-packages. The storage driver module will be moved into libvirt-driver-storage-core including the filesystem backend which is mandatory. This then allows to make libvirt-daemon-driver-qemu depend only on the core of the storage driver. All other meta-packages still depend on the full storage driver and thus pull in all the backends. --- libvirt.spec.in | 168 +++++++++++++++++++++++++++++++++++++++++++++++-----= ---- 1 file changed, 143 insertions(+), 25 deletions(-) diff --git a/libvirt.spec.in b/libvirt.spec.in index 3098ed2dd..9b2ca1c42 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -583,35 +583,13 @@ Requires: libvirt-daemon =3D %{version}-%{release} The secret driver plugin for the libvirtd daemon, providing an implementation of the secret key APIs. - -%package daemon-driver-storage -Summary: Storage driver plugin for the libvirtd daemon +%package daemon-driver-storage-core +Summary: Storage driver plugin including base backends for the libvirtd da= emon Group: Development/Libraries Requires: libvirt-daemon =3D %{version}-%{release} Requires: nfs-utils # For mkfs Requires: util-linux -# For glusterfs -%if 0%{?fedora} -Requires: glusterfs-client >=3D 2.0.1 -%endif -# gluster cli tool for pool discovery -%if (0%{?fedora} || 0%{?with_storage_gluster}) -Requires: /usr/sbin/gluster -%endif -# For LVM drivers -Requires: lvm2 -# For ISCSI driver -Requires: iscsi-initiator-utils -# For disk driver -Requires: parted -Requires: device-mapper -# For multipath support -Requires: device-mapper -%if %{with_storage_sheepdog} -# For Sheepdog support -Requires: sheepdog -%endif %if %{with_qemu} # From QEMU RPMs Requires: /usr/bin/qemu-img @@ -622,6 +600,128 @@ Requires: /usr/sbin/qcow-create %endif %endif +%description daemon-driver-storage-core +The storage driver plugin for the libvirtd daemon, providing +an implementation of the storage APIs using files, local disks, LVM, SCSI, +iSCSI, and multipath storage. + +%package daemon-driver-storage-logical +Summary: Storage driver plugin for lvm volumes +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core =3D %{version}-%{release} +Requires: lvm2 + +%description daemon-driver-storage-logical +The storage driver backend adding implementation of the storage APIs for b= lock +volumes using lvm. + + +%package daemon-driver-storage-disk +Summary: Storage driver plugin for disk +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core =3D %{version}-%{release} +Requires: parted +Requires: device-mapper + +%description daemon-driver-storage-disk +The storage driver backend adding implementation of the storage APIs for b= lock +volumes using the host disks. + + +%package daemon-driver-storage-scsi +Summary: Storage driver plugin for local scsi devices +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core =3D %{version}-%{release} + +%description daemon-driver-storage-scsi +The storage driver backend adding implementation of the storage APIs for s= csi +host devices. + + +%package daemon-driver-storage-iscsi +Summary: Storage driver plugin for iscsi +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core =3D %{version}-%{release} +Requires: iscsi-initiator-utils + +%description daemon-driver-storage-iscsi +The storage driver backend adding implementation of the storage APIs for i= scsi +volumes using the host iscsi stack. + + +%package daemon-driver-storage-mpath +Summary: Storage driver plugin for multipath volumes +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core =3D %{version}-%{release} +Requires: device-mapper + +%description daemon-driver-storage-mpath +The storage driver backend adding implementation of the storage APIs for +multipath storage using device mapper. + + +%if %{with_storage_gluster} +%package daemon-driver-storage-gluster +Summary: Storage driver plugin for gluster +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core =3D %{version}-%{release} + %if 0%{?fedora} +Requires: glusterfs-client >=3D 2.0.1 + %endif + %if (0%{?fedora} || 0%{?with_storage_gluster}) +Requires: /usr/sbin/gluster + %endif + +%description daemon-driver-storage-gluster +The storage driver backend adding implementation of the storage APIs for g= luster +volumes using libgfapi. +%endif + + +%if %{with_storage_rbd} +%package daemon-driver-storage-rbd +Summary: Storage driver plugin for rbd +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core =3D %{version}-%{release} + +%description daemon-driver-storage-rbd +The storage driver backend adding implementation of the storage APIs for r= bd +volumes using the ceph protocol. +%endif + + +%if %{with_storage_sheepdog} +%package daemon-driver-storage-sheepdog +Summary: Storage driver plugin for sheepdog +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core =3D %{version}-%{release} +Requires: sheepdog + +%description daemon-driver-storage-sheepdog +The storage driver backend adding implementation of the storage APIs for +sheepdog volumes using. +%endif + + +%package daemon-driver-storage +Summary: Storage driver plugin including all backends for the libvirtd dae= mon +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core =3D %{version}-%{release} +Requires: libvirt-daemon-driver-storage-disk =3D %{version}-%{release} +Requires: libvirt-daemon-driver-storage-logical =3D %{version}-%{release} +Requires: libvirt-daemon-driver-storage-scsi =3D %{version}-%{release} +Requires: libvirt-daemon-driver-storage-iscsi =3D %{version}-%{release} +Requires: libvirt-daemon-driver-storage-mpath =3D %{version}-%{release} +%if %{with_storage_gluster} +Requires: libvirt-daemon-driver-storage-gluster =3D %{version}-%{release} +%endif +%if %{with_storage_rbd} +Requires: libvirt-daemon-driver-storage-rbd =3D %{version}-%{release} +%endif +%if %{with_storage_sheepdog} +Requires: libvirt-daemon-driver-storage-sheepdog =3D %{version}-%{release} +%endif + %description daemon-driver-storage The storage driver plugin for the libvirtd daemon, providing an implementation of the storage APIs using LVM, iSCSI, @@ -635,7 +735,7 @@ Group: Development/Libraries Requires: libvirt-daemon =3D %{version}-%{release} # There really is a hard cross-driver dependency here Requires: libvirt-daemon-driver-network =3D %{version}-%{release} -Requires: libvirt-daemon-driver-storage =3D %{version}-%{release} +Requires: libvirt-daemon-driver-storage-core =3D %{version}-%{release} Requires: /usr/bin/qemu-img # For image compression Requires: gzip @@ -1689,21 +1789,39 @@ exit 0 %{_libdir}/%{name}/connection-driver/libvirt_driver_secret.so %files daemon-driver-storage + +%files daemon-driver-storage-core %attr(0755, root, root) %{_libexecdir}/libvirt_parthelper %{_libdir}/%{name}/connection-driver/libvirt_driver_storage.so %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_fs.so + +%files daemon-driver-storage-disk %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_disk.so + +%files daemon-driver-storage-logical %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_logical.so + +%files daemon-driver-storage-scsi %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_scsi.so + +%files daemon-driver-storage-iscsi %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_iscsi.so + +%files daemon-driver-storage-mpath %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_mpath.so + %if %{with_storage_gluster} +%files daemon-driver-storage-gluster %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_gluster.so %endif + %if %{with_storage_rbd} +%files daemon-driver-storage-rbd %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_rbd.so %endif + %if %{with_storage_sheepdog} +%files daemon-driver-storage-sheepdog %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_sheepdog.so %endif --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 22:39:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1486571407310536.8742419756578; Wed, 8 Feb 2017 08:30:07 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQrGw024015; Wed, 8 Feb 2017 11:26:53 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v18GQnN8017956 for ; Wed, 8 Feb 2017 11:26:49 -0500 Received: from angien.brq.redhat.com (dhcp129-162.brq.redhat.com [10.34.129.162]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v18GQbSr027100; Wed, 8 Feb 2017 11:26:49 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 8 Feb 2017 17:27:11 +0100 Message-Id: <6759a4ed4cd769775b2c7fd4ef53697573d912fa.1486571179.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 11/11] news: Mention storage driver split X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- docs/news.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 69ed6a75e..041515253 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -43,6 +43,16 @@ and network. + + + storage: modularize the storage driver + + + Split up the storage driver backends into loadable modules so th= at + binary distributions don't have to compromise on shipping the st= orage + driver with all backends which may pull in too many dependencies. + +
--=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list