Libvirt has enhanced its accesability to XCP or XenServer via its API. Inorder to use this feature you must compile libvirt from source with this feature enables. below are the steps to compile libvirt and its dependencies.
Step 1: There are two modes of accessing XCP via libvirt.
* From the same machine where XCP is installed
* On a remote machine
But i would advice you to install libvirt on the same machine where XCP is installed as some native codes might require direct or local access.
Now,
Log in to the machine where you want to install libvirt.
Step 2: First you need to download and install xenapi package. Download xenapi package (libxenserver) from the following URL
ftp://193.166.3.2/pub/NetBSD/packages/distfiles/libxenserver-5.6.100-1-src.tar.bz2
Step 3: Open a terminal and extract the source
# cd <directory where it is downloaded>
# tar jxvf libxenserver-5.6.100-1-src.tar.bz2
# cd libxenserver
Step 4: Compile libxenserver. To compile you must have installed the following dependencies
* libxml2-dev
* libcurl3-dev
* zlib1g
in a debian/ubuntu based machine you can install like this
# apt-get install libxml2-dev
# apt-get install libcurl3-dev
# apt-get install zlib1g
There is a small change you have to make in the 'Makefile'
# vi Makefile
find the line (line no: 65)
$(TEST_PROGRAMS): test/%: test/%.o libxenserver.so
$(CC) $(LDFLAGS) -o $@ $< -L . -lxenserver
$(TEST_PROGRAMS): test/%: test/%.o libxenserver.so
$(CC) -o $@ $< -L . -lxenserver $(LDFLAGS)
Also find (line no: 73)
$(INSTALL_PROG) libxenserver.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)
and then compile
# make LIBDIR=lib/
# ar rcs libxenserver.a
# make install LIBDIR=lib/
Step 5: Download libvirt from
http://libvirt.org/sources/libvirt-0.10.2.tar.gz
Step 6: Configure and compile libvirt
# cd <directory where it is downloaded>
# tar zxvf libvirt-0.10.2.tar.gz
# cd libvirt-0.10.2
# ./configure --with-esx --with-xenapi=<path to libxenserver that you installed earlier> --prefix=/opt/libvirt
Here --prefix=/opt/libvirt is optional if you dont want it to install in system folders like /usr /bin ,etc
At the end of the above step, we must be able to identify that if libxenserver is included or not, from the output
NOTE:
1. While configuring if you find some errors that some package is missing, then install that package and reconfigure again.
eg:
configure: error: You must install device-mapper-devel/libdevmapper >= 1.0.0 to compile libvirt
Here you must install the package
libdevmapper-dev
Installation always require a development version, even though if it does not point it
2. Even though we have already installed libxenserver, sometimes the compiler cannot find LINK to libxenserver files
you can try the following solutions
# ldconfig
If this does not work, change the following code in "configure" file
# vi configure
Search for the line
LIBXENSERVER_LIBS="$LIBXENSERVER_LIBS -lxenserver"
Scroll below to find "else" part like this
if test "$with_xenapi" = "yes"; then
fail=1
fi
with_xenapi=no
And then run the above command again.
Next to compile,
# make
# make install
You can also check the api capabilities with respect to xenapi from the following URL.
http://libvirt.org/hvsupport.html
This concludes our step by step installation of libvirt with xenapi support. :)
Step 1: There are two modes of accessing XCP via libvirt.
* From the same machine where XCP is installed
* On a remote machine
But i would advice you to install libvirt on the same machine where XCP is installed as some native codes might require direct or local access.
Now,
Log in to the machine where you want to install libvirt.
Step 2: First you need to download and install xenapi package. Download xenapi package (libxenserver) from the following URL
ftp://193.166.3.2/pub/NetBSD/packages/distfiles/libxenserver-5.6.100-1-src.tar.bz2
Step 3: Open a terminal and extract the source
# cd <directory where it is downloaded>
# tar jxvf libxenserver-5.6.100-1-src.tar.bz2
# cd libxenserver
Step 4: Compile libxenserver. To compile you must have installed the following dependencies
* libxml2-dev
* libcurl3-dev
* zlib1g
in a debian/ubuntu based machine you can install like this
# apt-get install libxml2-dev
# apt-get install libcurl3-dev
# apt-get install zlib1g
There is a small change you have to make in the 'Makefile'
# vi Makefile
find the line (line no: 65)
$(TEST_PROGRAMS): test/%: test/%.o libxenserver.so
$(CC) $(LDFLAGS) -o $@ $< -L . -lxenserver
and replace it as
$(TEST_PROGRAMS): test/%: test/%.o libxenserver.so
$(CC) -o $@ $< -L . -lxenserver $(LDFLAGS)
Also find (line no: 73)
$(INSTALL_PROG) libxenserver.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)
replace with
$(INSTALL_DATA) libxenserver.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)
# make LIBDIR=lib/
# ar rcs libxenserver.a
# make install LIBDIR=lib/
Step 5: Download libvirt from
http://libvirt.org/sources/libvirt-0.10.2.tar.gz
Step 6: Configure and compile libvirt
# cd <directory where it is downloaded>
# tar zxvf libvirt-0.10.2.tar.gz
# cd libvirt-0.10.2
# ./configure --with-esx --with-xenapi=<path to libxenserver that you installed earlier> --prefix=/opt/libvirt
Here --prefix=/opt/libvirt is optional if you dont want it to install in system folders like /usr /bin ,etc
At the end of the above step, we must be able to identify that if libxenserver is included or not, from the output
NOTE:
1. While configuring if you find some errors that some package is missing, then install that package and reconfigure again.
eg:
configure: error: You must install device-mapper-devel/libdevmapper >= 1.0.0 to compile libvirt
Here you must install the package
libdevmapper-dev
Installation always require a development version, even though if it does not point it
2. Even though we have already installed libxenserver, sometimes the compiler cannot find LINK to libxenserver files
you can try the following solutions
# ldconfig
If this does not work, change the following code in "configure" file
# vi configure
Search for the line
LIBXENSERVER_LIBS="$LIBXENSERVER_LIBS -lxenserver"
Scroll below to find "else" part like this
if test "$with_xenapi" = "yes"; then
fail=1
fi
with_xenapi=no
Replace it with
with_xenapi=yes
LIBXENSERVER_LIBS="$LIBXENSERVER_LIBS -lxenserver"
Next to compile,
# make
# make install
You can also check the api capabilities with respect to xenapi from the following URL.
http://libvirt.org/hvsupport.html
This concludes our step by step installation of libvirt with xenapi support. :)
Tip:
ReplyDeleteWhen i tried to define or create a VM via xml on XCP, i faced a segmentation fault. To recover it, you can make the following changes
In file /src/xenapi/xenapi_utils.c
In function "createVifNetwork"
change the last line of the function from
return -1;
to
return 0;
Thank you
While configuring if you find the the following error
ReplyDeletechecking for gnutls/gnutls.h... yes
checking for gnutls_handshake in -lgnutls... no
configure: error: You must install the GnuTLS library in order to compile and run libvirt
Try installing gnutls-dev
and configure again
if you still find the same error then
install the following package
libcrypto++-dev
and configure again