[Libguestfs] Notes on building libguestfs in a systemd-nspawn container

Kashyap Chamarthy kchamart at redhat.com
Thu Jan 30 02:11:33 UTC 2014


Last night I was tinkering with `systemd-nspawn` -- namespace based
container for testing, I thought I'll post  what I tried with libguestfs
here:


Prerequisite
------------

Because of an audit subsystem incompatibility bug - rhbz#966807[1], turn
off auditing by booting the host w/ 'audit=0' on Kernel command line.
(NOTE: There's work in progress[2] in upstream Kernel to fix this.)


Create container
----------------

On the host, specify an installroot (/srv) and install a minimal Fedora
20 distribution:

    $ yum -y --releasever=20 --nogpg \
        --installroot=/srv/testcontainer \
        --disablerepo='*' --enablerepo=fedora \
        install systemd passwd yum \
        fedora-release vim-minimal

Boot into the container, set a password:

    $ systemd-nspawn -D /srv/testcontainer
    [. . .]
    -bash-4.2# passwd

Start the container w/ systemd:

    $ systemd-nspawn -bD /srv/testcontainer
    [. . .]
    -bash-4.2#


Building Libguestfs
-------------------

Inside the minimal Fedora 20 container, install libguestfs dependencies,
clone the libguestfs git repository:

    -bash-4.2# yum-builddep libguestfs -y

    -bash-4.2# git clone git://github.com/libguestfs/libguestfs.git

Build and test libguestfs in the container:

    -bash-4.2# cd libguestfs

    -bash-4.2# ./autogen.sh && time make 2>&1 \
                | tee /tmp/libguestfs-compile.log

     -bash-4.2# time make -k check \
     LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1 2>&1 \
     | tee /tmp/libguestfs-test.log


Notes
-----

- If you need to build a container without networking (once all the
  relevant dependencies are cloned/and network related operations
  are done), the container can be invoked with no network
  devices (except loopback):

    $ systemd-nspawn -bD /srv/testcontainer --private-network
    [. . .]
    -bash-4.2#

- Single `make` job timing to compile everything:

    real    31m9.792s
    user    17m18.359s
    sys     13m17.868s

- `make -k check` is still running as I write this, albeit
   a bit slow.



  [1] https://bugzilla.redhat.com/show_bug.cgi?id=966807
  [2] https://www.redhat.com/archives/linux-audit/2013-May/msg00065.html


-- 
/kashyap




More information about the Libguestfs mailing list