[PATCH 1/3] Add the s390 plugin.
Vratislav Podzimek
vpodzime at redhat.com
Tue May 19 10:44:12 UTC 2015
On Mon, 2015-05-18 at 15:10 -0400, Samantha N. Bueno wrote:
> Make some of the basic changes so that libblockdev will recognize the
> new plugin.
> ---
> Sconscript | 9 ++++++++-
> docs/libblockdev-docs.xml | 1 +
> docs/libblockdev-sections.txt | 12 +++++++++++
> features.rst | 10 ++++++++-
> src/lib/blockdev.c | 47 +++++++++++++++++++++++++++++++++++--------
> src/lib/plugins.h | 1 +
> 6 files changed, 70 insertions(+), 10 deletions(-)
>
> diff --git a/Sconscript b/Sconscript
> index 717198a..ce3ba1d 100644
> --- a/Sconscript
> +++ b/Sconscript
> @@ -7,7 +7,7 @@ MAIN_VERSION = "0.1.0"
> MAJOR_MINOR = MAIN_VERSION.rsplit(".", 1)[0]
> MAJOR_VERSION = MAIN_VERSION.split(".", 1)[0]
> LIB_FILES = ["src/lib/blockdev.c", "src/lib/blockdev.h", "src/lib/plugins.h"]
> -PLUGIN_NAMES = ["crypto", "dm", "loop", "lvm", "mpath", "swap", "btrfs", "mdraid"]
> +PLUGIN_NAMES = ["crypto", "dm", "loop", "lvm", "mpath", "swap", "btrfs", "mdraid", "s390"]
> PLUGIN_HEADER_FILES = ["build/plugin_apis/"+name+".h" for name in PLUGIN_NAMES]
> UTILS_FILES = ["src/utils/exec.c", "src/utils/sizes.c", "src/utils/exec.h", "src/utils/sizes.h"]
>
> @@ -78,6 +78,12 @@ swap_env.Append(LIBPATH=".")
> swap_env.Append(LIBS="bd_utils")
> plugins.append(swap_env.SharedLibrary("bd_swap", ["src/plugins/swap.c"]))
>
> +s390_env = glib_warnall_env.Clone()
> +s390_env.Append(CPPPATH="src/utils")
> +s390_env.Append(LIBPATH=".")
> +s390_env.Append(LIBS="bd_utils")
> +plugins.append(s390_env.SharedLibrary("bd_s390", ["src/plugins/s390.c"]))
> +
>
> ## boilerplate code generation
> bpg_builder = Builder(action=generate_boilerplate_files)
> @@ -93,6 +99,7 @@ boiler_code.append(bpg_env.BpG(["plugin_apis/loop.h", "plugin_apis/loop.c"], "sr
> boiler_code.append(bpg_env.BpG(["plugin_apis/mdraid.h", "plugin_apis/mdraid.c"], "src/lib/plugin_apis/mdraid.api"))
> boiler_code.append(bpg_env.BpG(["plugin_apis/mpath.h", "plugin_apis/mpath.c"], "src/lib/plugin_apis/mpath.api"))
> boiler_code.append(bpg_env.BpG(["plugin_apis/swap.h", "plugin_apis/swap.c"], "src/lib/plugin_apis/swap.api"))
> +boiler_code.append(bpg_env.BpG(["plugin_apis/s390.h", "plugin_apis/s390.c"], "src/lib/plugin_apis/s390.api"))
>
>
> ## the library itself
> diff --git a/docs/libblockdev-docs.xml b/docs/libblockdev-docs.xml
> index 32b712a..db3bacc 100644
> --- a/docs/libblockdev-docs.xml
> +++ b/docs/libblockdev-docs.xml
> @@ -30,6 +30,7 @@
> <xi:include href="xml/mpath.xml"/>
> <xi:include href="xml/plugins.xml"/>
> <xi:include href="xml/swap.xml"/>
> + <xi:include href="xml/s390.xml"/>
> <xi:include href="xml/utils.xml"/>
> </chapter>
>
> diff --git a/docs/libblockdev-sections.txt b/docs/libblockdev-sections.txt
> index 0e33ddb..d6f8fa8 100644
> --- a/docs/libblockdev-sections.txt
> +++ b/docs/libblockdev-sections.txt
> @@ -259,3 +259,15 @@ bd_swap_swapoff
> bd_swap_swapstatus
> </SECTION>
>
> +<SECTION>
> +<FILE>s390</FILE>
> +bd_s390_error_quark
> +BDS390Error
> +bd_s390_dasd_format
> +bd_s390_dasd_needs_format
> +bd_s390_sanitize_dev_input
> +bd_s390_dasd_online
> +bd_s390_dasd_is_ldl
> +bd_s390_zfcp_sanitize_wwpn_input
> +bd_s390_zfcp_sanitize_lun_input
> +</SECTION>
> diff --git a/features.rst b/features.rst
> index f2c6726..fff15e5 100644
> --- a/features.rst
> +++ b/features.rst
> @@ -235,7 +235,15 @@ s390
> DASD, zFCP
>
> :functions:
> - TBD by sbueno
> + * s390_dasd_format [DONE]
> + * s390_dasd_needs_format [DONE]
> + * s390_dasd_online [DONE]
> + * s390_dasd_is_ldl [DONE]
> + * s390_sanitize_dev_input [DONE]
> + * s390_zfcp_sanitize_wwpn_input [DONE]
> + * s390_zfcp_sanitize_lun_input [DONE]
> + * s390_zfcp_online
> + * s390_zfcp_offline
>
>
> KBD (Kernel Block Devices)
> diff --git a/src/lib/blockdev.c b/src/lib/blockdev.c
> index 44f987a..bc9265a 100644
> --- a/src/lib/blockdev.c
> +++ b/src/lib/blockdev.c
> @@ -19,6 +19,8 @@
> #include "plugin_apis/dm.h"
> #include "plugin_apis/mdraid.h"
> #include "plugin_apis/mdraid.c"
> +#include "plugin_apis/s390.h"
> +#include "plugin_apis/s390.c"
>
> /**
> * SECTION: blockdev
> @@ -41,7 +43,8 @@ static gchar * default_plugin_so[BD_PLUGIN_UNDEF] = {
> "libbd_lvm.so."MAJOR_VER, "libbd_btrfs.so."MAJOR_VER,
> "libbd_swap.so."MAJOR_VER, "libbd_loop.so."MAJOR_VER,
> "libbd_crypto.so."MAJOR_VER, "libbd_mpath.so."MAJOR_VER,
> - "libbd_dm.so."MAJOR_VER, "libbd_mdraid.so."MAJOR_VER
> + "libbd_dm.so."MAJOR_VER, "libbd_mdraid.so."MAJOR_VER,
> + "libbd_s390.so."MAJOR_VER
> };
> static BDPluginStatus plugins[BD_PLUGIN_UNDEF] = {
> {{BD_PLUGIN_LVM, NULL}, NULL},
> @@ -51,10 +54,11 @@ static BDPluginStatus plugins[BD_PLUGIN_UNDEF] = {
> {{BD_PLUGIN_CRYPTO, NULL}, NULL},
> {{BD_PLUGIN_MPATH, NULL}, NULL},
> {{BD_PLUGIN_DM, NULL}, NULL},
> - {{BD_PLUGIN_MDRAID, NULL}, NULL}
> + {{BD_PLUGIN_MDRAID, NULL}, NULL},
> + {{BD_PLUGIN_S390, NULL}, NULL}
> };
> static gchar* plugin_names[BD_PLUGIN_UNDEF] = {
> - "lvm", "btrfs", "swap", "loop", "crypto", "mpath", "dm", "mdraid"
> + "lvm", "btrfs", "swap", "loop", "crypto", "mpath", "dm", "mdraid", "s390"
> };
>
> static void set_plugin_so_name (BDPlugin name, gchar *so_name) {
> @@ -93,6 +97,10 @@ static void unload_plugins () {
> if (plugins[BD_PLUGIN_MDRAID].handle && !unload_mdraid (plugins[BD_PLUGIN_MDRAID].handle))
> g_warning ("Failed to close the mdraid plugin");
> plugins[BD_PLUGIN_MDRAID].handle = NULL;
> +
> + if (plugins[BD_PLUGIN_S390].handle && !unload_s390 (plugins[BD_PLUGIN_S390].handle))
> + g_warning ("Failed to close the s390 plugin");
> + plugins[BD_PLUGIN_S390].handle = NULL;
> }
>
> static gboolean load_plugins (BDPluginSpec **require_plugins, gboolean reload) {
> @@ -109,17 +117,38 @@ static gboolean load_plugins (BDPluginSpec **require_plugins, gboolean reload) {
> if (require_plugins) {
> /* set requested so names or defaults if so names are not specified */
> for (i=0; *(require_plugins + i); i++) {
> - if (require_plugins[i]->so_name)
> + if (require_plugins[i]->so_name) {
> +#if !defined(__s390__) && !defined(__s390x__)
> + if (require_plugins[i]->so_name != BD_PLUGIN_S390) {
> + continue;
> + }
> +#endif
Shouldn't the '!=' above be '=='? I understand it as:
if "not on s390":
if "processing the s390 plugin":
continue
the same applies for the other #if-#endif blocks below.
However, in this particular case, I think we should drop this guard as
if somebody explicitly requires the s390 plugin, we should try to load
it and/or fail in any case.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list