[PATCH 01/11] First little step towards libblockdev

Vratislav Podzimek vpodzime at redhat.com
Tue Feb 10 12:00:17 UTC 2015


On Tue, 2015-02-03 at 07:04 -0500, Anne Mulhern wrote:
> 
> 
> 
> ----- Original Message -----
> > From: "Vratislav Podzimek" <vpodzime at redhat.com>
> > To: anaconda-patches at lists.fedorahosted.org
> > Sent: Sunday, February 1, 2015 7:15:51 PM
> > Subject: [PATCH 01/11] First little step towards libblockdev
> > 
> > We need to import and init the library first and give it the logging function
> > for utils exection.
> 
> ^exection^execution ?
Good catch, thanks! Fixing locally.

> 
> > 
> > Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> > ---
> >  blivet/__init__.py | 9 +++++++++
> >  python-blivet.spec | 3 +++
> >  2 files changed, 12 insertions(+)
> > 
> > diff --git a/blivet/__init__.py b/blivet/__init__.py
> > index 3128c89..1514a1d 100644
> > --- a/blivet/__init__.py
> > +++ b/blivet/__init__.py
> > @@ -93,6 +93,15 @@ import contextlib
> >  
> >  import logging
> >  log = logging.getLogger("blivet")
> > +program_log = logging.getLogger("program")
> > +
> > +# XXX: respect the level? Need to translate between C and Python log levels.
> > +log_bd_message = lambda level, msg: program_log.info(msg)
> > +
> > +from gi.repository import BlockDev
> > +if not BlockDev.is_initialized():
> > +    # for now, we want all the plugins to be available (i.e. init() to
> > return True)
> 
> What will happen later?
Later blivet will/may not require all libblockdev's plugins to load. So
it will specify which plugins should be loaded. I'm working on this
"selective load" in libblockdev right now.

> 
> > +    assert BlockDev.init(force_plugins=None, log_func=log_bd_message)
> >  
> 
> I do not understand why you use assert here instead of the usual try/except,
> i.e., I don't see why you would want to pass this in production and fail in
> dev, asssuming we ever end up distinguishing the two.
I didn't know assert only applies when __debug__ is set. So this should
be changed to:

if not BlockDev.init(force_plugins=None, log_func=log_bd_message):
    raise RuntimeError("Failed to initialize the libblockdev library")

> 
> >  def enable_installer_mode():
> >      """ Configure the module for use by anaconda (OS installer). """
> > diff --git a/python-blivet.spec b/python-blivet.spec
> > index 258db88..b101bfa 100644
> > --- a/python-blivet.spec
> > +++ b/python-blivet.spec
> > @@ -20,6 +20,7 @@ Source0:
> > http://github.com/dwlehman/blivet/archive/%{realname}-%{version}.tar.gz
> >  %define pythoncryptsetupver 0.1.1
> >  %define utillinuxver 2.15.1
> >  %define lvm2ver 2.02.99
> > +%define libblockdevver 0.5
> >  
> >  BuildArch: noarch
> >  BuildRequires: gettext
> > @@ -43,6 +44,8 @@ Requires: btrfs-progs
> >  Requires: python-pyblock >= %{pythonpyblockver}
> >  Requires: device-mapper-multipath
> >  Requires: lsof
> > +Requires: libblockdev >= %{libblockdevver}
> > +Requires: libblockdev-plugins-all >= %{libblockdevver}
> >  
> >  %description
> >  The python-blivet package is a python module for examining and modifying
> > --
> > 2.1.0
> > 
> > _______________________________________________
> > anaconda-patches mailing list
> > anaconda-patches at lists.fedorahosted.org
> > https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> > 
> 
> About libblockdev:
> 
> Any chance you could use pointers to functions in 
> BDPluginStatus struct to turn that long chunk of loading code in load_plugins
> into a loop? It looks like you have decided it is necessary to include all
> plugin_api/*.c files in blockdev.c, so you might as well get the benefit.
That's definitely worth thinking about and changing in the future. But
right now I really want to leave everything that works as it is and
focus on blivet+libblockdev integration and all the bugs that come from
that. Thanks for the suggestion.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list