[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] libxenstat python bindings



Travis Vachon wrote:

Hi
I seem to be having a little trouble with libxenstat, and was wondering
if the xenstat guys might be able to help.

I've pulled the xen-unstable.hg tree and done a somewhat clean install
(ie, post-make uninstall, as well as deleting the relevant libxenstat
libraries).
You have to install libxenstat.so to use the python bindings. libxenstat is not a supported interface for 3.0. It's in the tree for xentop. It may play a larger role in future versions but for right now it's function is pretty limited.

You may have better luck using the xc python bindings that are installed with Xend. You can get the same information as you can get in libxenstat just through a different interface.

In xen.lowlevel.xc, you want to use domain_get_info() and domain_get_vcpu_info().

Regards,

Anthony Liguori

Next, I entered the tools/xenstat/libxenstat directory and modified the
Makefile so that the shared libraries would be installed. I've included
my Makefile below.

I ran:

make
make install
make python-bindings
make install-python-bindings


Next, I started a python session and entered:

import xenstat
and got the following output.

Python 2.3.5 (#2, Sep  4 2005, 22:01:42)
[GCC 3.3.5 (Debian 1:3.3.5-13)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import xenstat
Traceback (most recent call last):
 File "<stdin>", line 1, in ?
 File "/usr/local/lib/python2.3/site-packages/xenstat.py", line 5, in ?
   import _xenstat
ImportError: /usr/local/lib/python2.3/site-packages/_xenstat.so: undefined 
symbol: xenstat_init


Any thoughts?

Thanks!

Travis

Makefile:

# libxenstat: statistics-collection library for Xen
# Copyright (C) International Business Machines Corp., 2005
# Author: Josh Triplett <josht@xxxxxxxxxx>
# # This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# # This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.

XEN_ROOT=../../..
include $(XEN_ROOT)/tools/Rules.mk
LINUX_ROOT := $(XEN_ROOT)/linux-2.6-xen-sparse

INSTALL         = install
INSTALL_PROG    = $(INSTALL) -m0755 -D
INSTALL_DATA    = $(INSTALL) -m0644 -D

prefix=/usr/local
includedir=$(prefix)/include
libdir=$(prefix)/lib

LDCONFIG=ldconfig
MAKE_LINK=ln -sf

MAJOR=0
MINOR=0

LIB=src/libxenstat.a
SHLIB=src/libxenstat.so.$(MAJOR).$(MINOR)
SHLIB_LINKS=src/libxenstat.so.$(MAJOR) src/libxenstat.so
OBJECTS=src/xenstat.o src/xen-interface.o
SONAME_FLAGS=-Wl,-soname -Wl,libxenstat.so.$(MAJOR)

WARN_FLAGS=-Wall -Werror

CFLAGS+=-Isrc -I$(XEN_LIBXC)
LDFLAGS+=-Lsrc

all:    $(LIB) $(SHLIB)


$(LIB): $(OBJECTS)
        $(AR) rc $@ $^
        $(RANLIB) $@

$(SHLIB): $(OBJECTS)
        $(CC) $(LDFLAGS) $(SONAME_FLAGS) -shared -o $@ $(OBJECTS)

src/xenstat.o: src/xenstat.c src/xenstat.h src/xen-interface.h
        $(CC) $(CFLAGS) $(WARN_FLAGS) -c -o $@ $<

src/xen-interface.o: src/xen-interface.c src/xen-interface.h
        $(CC) $(CFLAGS) $(WARN_FLAGS) -c -o $@ $<

src/libxenstat.so.$(MAJOR): $(LIB)
        $(MAKE_LINK) $(<F) $@

src/libxenstat.so: src/libxenstat.so.$(MAJOR)
        $(MAKE_LINK) $(<F) $@

install: all
        $(INSTALL_DATA) src/xenstat.h $(DESTDIR)$(includedir)/xenstat.h
        $(INSTALL_PROG) $(LIB) $(DESTDIR)$(libdir)/libxenstat.a
        $(INSTALL_PROG) $(SHLIB) \
                        $(DESTDIR)$(libdir)/libxenstat.so.$(MAJOR).$(MINOR)
        $(MAKE_LINK) libxenstat.so.$(MAJOR).$(MINOR) \
                     $(DESTDIR)$(libdir)/libxenstat.so.$(MAJOR)
        $(MAKE_LINK) libxenstat.so.$(MAJOR) \
                     $(DESTDIR)$(libdir)/libxenstat.so
        -$(LDCONFIG)

PYLIB=bindings/swig/python/_xenstat.so
PYMOD=bindings/swig/python/xenstat.py
PYSRC=bindings/swig/python/_xenstat.c
PERLLIB=bindings/swig/perl/xenstat.so
PERLMOD=bindings/swig/perl/xenstat.pm
PERLSRC=bindings/swig/perl/xenstat.c
BINDINGS=$(PYLIB) $(PYMOD) $(PERLLIB) $(PERLMOD)
BINDINGSRC=$(PYSRC) $(PERLSRC)

# The all-bindings target builds all the language bindings
all-bindings: perl-bindings python-bindings

# The install-bindings target installs all the language bindings
install-bindings: install-perl-bindings install-python-bindings

$(BINDINGS): $(SHLIB) $(SHLIB_LINKS) src/xenstat.h

SWIG_FLAGS=-module xenstat -Isrc

# Python bindings
PYTHON_VERSION=2.3
PYTHON_FLAGS=-I/usr/include/python$(PYTHON_VERSION) -lpython$(PYTHON_VERSION)
$(PYSRC) $(PYMOD): bindings/swig/xenstat.i
        swig -python $(SWIG_FLAGS) -outdir $(@D) -o $(PYSRC) $<

$(PYLIB): $(PYSRC)
        $(CC) $(CFLAGS) $(LDFLAGS) $(PYTHON_FLAGS) -shared -lxenstat -o $@ $<

python-bindings: $(PYLIB) $(PYMOD)

pythonlibdir=$(prefix)/lib/python$(PYTHON_VERSION)/site-packages
install-python-bindings: $(PYLIB) $(PYMOD)
        $(INSTALL_PROG) $(PYLIB) $(DESTDIR)$(pythonlibdir)/_xenstat.so
        $(INSTALL_PROG) $(PYMOD) $(DESTDIR)$(pythonlibdir)/xenstat.py

ifeq ($(XENSTAT_PYTHON_BINDINGS),y)
all: python-bindings
install: install-python-bindings
endif

# Perl bindings
PERL_FLAGS=`perl -MConfig -e 'print "$$Config{ccflags} 
-I$$Config{archlib}/CORE";'`
$(PERLSRC) $(PERLMOD): bindings/swig/xenstat.i
        swig -perl $(SWIG_FLAGS) -outdir $(@D) -o $(PERLSRC) $<

$(PERLLIB): $(PERLSRC)
        $(CC) $(CFLAGS) $(LDFLAGS) $(PERL_FLAGS) -shared -lxenstat -o $@ $<

perl-bindings: $(PERLLIB) $(PERLMOD)

perllibdir=$(prefix)/lib/perl5
perlmoddir=$(prefix)/share/perl5
install-perl-bindings: $(PERLLIB) $(PERLMOD)
        $(INSTALL_PROG) $(PERLLIB) $(DESTDIR)$(perllibdir)/xenstat.so
        $(INSTALL_PROG) $(PERLMOD) $(DESTDIR)$(perlmoddir)/xenstat.pm

ifeq ($(XENSTAT_PERL_BINDINGS),y)
all: perl-bindings
install: install-perl-bindings
endif

clean:
        rm -f $(LIB) $(SHLIB) $(SHLIB_LINKS) $(OBJECTS) \
              $(BINDINGS) $(BINDINGSRC)



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.