Skip to content

Instantly share code, notes, and snippets.

@ffledgling
Created March 4, 2018 20:52
Show Gist options
  • Save ffledgling/9e06ee32431d9a8f6d9bec3a0db35634 to your computer and use it in GitHub Desktop.
Save ffledgling/9e06ee32431d9a8f6d9bec3a0db35634 to your computer and use it in GitHub Desktop.
Compile a custom libvirt+libvirt-python+virt-manager stack

Download and install a custom version of libvirt/virsh

CUSTOM_ROOT=/home/ajaisingh/n4/nested-vm/

mkdir -p $CUSTOM_ROOT/src
wget https://libvirt.org/sources/libvirt-4.0.0.tar.xz

# Compiling a new version of libvirt (v4.0.0), requires libnl-devel, libnl-route, libyajl-devel, libdevmapper-devel

sudo apt-get install libnl-route-3-dev
sudo apt-get install libnl-3-dev
sudo apt-get install libyajl-dev libyajl2
sudo apt-get install libdevmapper-dev

# If this step fails with some libraries missing, install those too, this is pretty machine specific.
./configure --prefix=/home/ajaisingh/n4/nested-vm/

make -j120
make install

Install libvirt-python next because we need to use virt-manager and that requires libvirt python bindings

cd $CUSTOM_ROOT/src
wget https://libvirt.org/sources/python/libvirt-python-4.0.0.tar.gz
tar -xvf libvirt-python-4.0.0.tar.gz
cd libvirt-python-4.0.0/
export LD_LIBRARY_PATH=$CUSTOM_ROOT/lib
export PKG_CONFIG_PATH=$CUSTOM_ROOT/lib/pkgconfig:$PKG_CONFIG_PATH
python setup.py build
python setup.py install --root $CUSTOM_ROOT

Then we install a custom virt-manager into the same location and it should ideally pick up the newer python bindings. (Otherwise set PYTHONPATH at runtime)

cd $CUSTOM_ROOT/src
wget https://virt-manager.org/download/sources/virt-manager/virt-manager-1.5.1.tar.gz
tar -xvf virt-manager-1.5.1.tar.gz
cd virt-manager-1.5.1/
python setup.py install --root $CUSTOM_ROOT

Finally get it all in your $PATH:

export $PATH=$CUSTOM_ROOT/bin:$CUSTOM_ROOT/usr/bin:$PATH
@Marietto2008
Copy link

Marietto2008 commented May 29, 2021

There are some errors. This :

export PKG_CONFIG_PATH=$CUSTOM_ROOT/lib/pkgconfig:$PKG_CONFIG_PATH

becomes this :

export PKG_CONFIG_PATH=$CUSTOM_ROOT/lib/pkgconfig

and this :

export $PATH=$CUSTOM_ROOT/bin:$CUSTOM_ROOT/usr/bin:$PATH

becomes this :

export PATH=$CUSTOM_ROOT/bin:$CUSTOM_ROOT/usr/bin:$PATH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment