mirror of https://gitee.com/openkylin/libvirt.git
Remove python binding
The python binding now lives in http://libvirt.org/git/?p=libvirt-python.git that repo also provides an RPM which is upgrade compatible with the old libvirt-python sub-RPM. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
604f79b360
commit
a7a1244a73
|
@ -91,17 +91,7 @@
|
|||
/mkinstalldirs
|
||||
/po/*
|
||||
/proxy/
|
||||
/python/generated.stamp
|
||||
/python/generator.py.stamp
|
||||
/python/libvirt-export.c
|
||||
/python/libvirt-lxc-export.c
|
||||
/python/libvirt-lxc.[ch]
|
||||
/python/libvirt-qemu-export.c
|
||||
/python/libvirt-qemu.[ch]
|
||||
/python/libvirt.[ch]
|
||||
/python/libvirt.py
|
||||
/python/libvirt_lxc.py
|
||||
/python/libvirt_qemu.py
|
||||
/python/
|
||||
/run
|
||||
/sc_*
|
||||
/src/.*.stamp
|
||||
|
|
|
@ -20,8 +20,8 @@ LCOV = lcov
|
|||
GENHTML = genhtml
|
||||
|
||||
SUBDIRS = . gnulib/lib include src daemon tools docs gnulib/tests \
|
||||
python tests po examples/domain-events/events-c examples/hellolibvirt \
|
||||
examples/dominfo examples/domsuspend examples/python examples/apparmor \
|
||||
tests po examples/domain-events/events-c examples/hellolibvirt \
|
||||
examples/dominfo examples/domsuspend examples/apparmor \
|
||||
examples/xml/nwfilter examples/openauth examples/systemtap
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
@ -40,7 +40,6 @@ EXTRA_DIST = \
|
|||
Makefile.nonreentrant \
|
||||
autogen.sh \
|
||||
cfg.mk \
|
||||
examples/domain-events/events-python \
|
||||
run.in \
|
||||
AUTHORS.in \
|
||||
$(XML_EXAMPLES)
|
||||
|
@ -74,8 +73,6 @@ check-local: all tests
|
|||
|
||||
tests:
|
||||
@(cd docs/examples ; $(MAKE) MAKEFLAGS+=--silent tests)
|
||||
@(if [ "$(pythondir)" != "" ] ; then cd python ; \
|
||||
$(MAKE) MAKEFLAGS+=--silent tests ; fi)
|
||||
|
||||
cov: clean-cov
|
||||
mkdir $(top_builddir)/coverage
|
||||
|
|
|
@ -86,8 +86,7 @@ if test -x /usr/bin/i686-w64-mingw32-gcc ; then
|
|||
--prefix="$AUTOBUILD_INSTALL_ROOT/i686-w64-mingw32/sys-root/mingw" \
|
||||
--enable-expensive-tests \
|
||||
--enable-werror \
|
||||
--without-libvirtd \
|
||||
--without-python
|
||||
--without-libvirtd
|
||||
|
||||
make
|
||||
make install
|
||||
|
@ -107,8 +106,7 @@ if test -x /usr/bin/x86_64-w64-mingw32-gcc ; then
|
|||
--prefix="$AUTOBUILD_INSTALL_ROOT/x86_64-w64-mingw32/sys-root/mingw" \
|
||||
--enable-expensive-tests \
|
||||
--enable-werror \
|
||||
--without-libvirtd \
|
||||
--without-python
|
||||
--without-libvirtd
|
||||
|
||||
make
|
||||
make install
|
||||
|
|
7
cfg.mk
7
cfg.mk
|
@ -958,14 +958,11 @@ exclude_file_name_regexp--sc_prohibit_VIR_ERR_NO_MEMORY = \
|
|||
|
||||
exclude_file_name_regexp--sc_prohibit_access_xok = ^src/util/virutil\.c$$
|
||||
|
||||
exclude_file_name_regexp--sc_prohibit_always_true_header_tests = \
|
||||
^python/(libvirt-(lxc-|qemu-)?override|typewrappers)\.c$$
|
||||
|
||||
exclude_file_name_regexp--sc_prohibit_asprintf = \
|
||||
^(bootstrap.conf$$|src/util/virstring\.[ch]$$|examples/domain-events/events-c/event-test\.c$$|tests/vircgroupmock\.c$$)
|
||||
|
||||
exclude_file_name_regexp--sc_prohibit_strdup = \
|
||||
^(docs/|examples/|python/|src/util/virstring\.c|tests/virnetserverclientmock.c$$)
|
||||
^(docs/|examples/|src/util/virstring\.c|tests/virnetserverclientmock.c$$)
|
||||
|
||||
exclude_file_name_regexp--sc_prohibit_close = \
|
||||
(\.p[yl]$$|^docs/|^(src/util/virfile\.c|src/libvirt\.c|tests/vir(cgroup|pci)mock\.c)$$)
|
||||
|
@ -1033,7 +1030,7 @@ exclude_file_name_regexp--sc_prohibit_include_public_headers_quote = \
|
|||
^src/internal\.h$$
|
||||
|
||||
exclude_file_name_regexp--sc_prohibit_include_public_headers_brackets = \
|
||||
^(python/|tools/|examples/|include/libvirt/(virterror|libvirt-(qemu|lxc))\.h$$)
|
||||
^(tools/|examples/|include/libvirt/(virterror|libvirt-(qemu|lxc))\.h$$)
|
||||
|
||||
exclude_file_name_regexp--sc_prohibit_int_ijk = \
|
||||
^(src/remote_protocol-structs|src/remote/remote_protocol.x|cfg.mk|include/)$
|
||||
|
|
89
configure.ac
89
configure.ac
|
@ -2012,84 +2012,8 @@ fi
|
|||
AM_CONDITIONAL([WITH_HYPERV], [test "$with_hyperv" = "yes"])
|
||||
|
||||
|
||||
dnl
|
||||
dnl check for python
|
||||
dnl
|
||||
|
||||
AC_ARG_WITH([python],
|
||||
[AS_HELP_STRING([--with-python],
|
||||
[Build python bindings @<:@default=yes@:>@])],
|
||||
[],[with_python=yes])
|
||||
|
||||
if test "$enable_shared:$with_python" = no:yes; then
|
||||
AC_MSG_WARN([Disabling shared libraries is incompatible with building Python extensions.])
|
||||
AC_MSG_WARN([Ignoring --with-python.])
|
||||
with_python=no
|
||||
fi
|
||||
|
||||
PYTHON_VERSION=
|
||||
PYTHON_INCLUDES=
|
||||
if test "$with_python" != "no" ; then
|
||||
if test -x "$with_python/bin/python"
|
||||
then
|
||||
AC_MSG_NOTICE(Found python in $with_python/bin/python)
|
||||
PYTHON="$with_python/bin/python"
|
||||
with_python=yes
|
||||
else
|
||||
if test -x "$with_python"
|
||||
then
|
||||
AC_MSG_NOTICE(Found python in $with_python)
|
||||
PYTHON="$with_python"
|
||||
with_python=yes
|
||||
else
|
||||
if test -x "$PYTHON"
|
||||
then
|
||||
AC_MSG_NOTICE(Found python in environment PYTHON=$PYTHON)
|
||||
with_python=yes
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$with_python" = "yes" ; then
|
||||
AM_PATH_PYTHON(,, [:])
|
||||
|
||||
if test "$PYTHON" != : ; then
|
||||
PYTHON_CONFIG="$PYTHON-config"
|
||||
|
||||
if test -x "$PYTHON_CONFIG"
|
||||
then
|
||||
PYTHON_INCLUDES=`$PYTHON_CONFIG --includes`
|
||||
else
|
||||
if test -r $PYTHON_EXEC_PREFIX/include/python$PYTHON_VERSION/Python.h
|
||||
then
|
||||
PYTHON_INCLUDES=-I$PYTHON_EXEC_PREFIX/include/python$PYTHON_VERSION
|
||||
else
|
||||
if test -r $prefix/include/python$PYTHON_VERSION/Python.h
|
||||
then
|
||||
PYTHON_INCLUDES=-I$prefix/include/python$PYTHON_VERSION
|
||||
else
|
||||
if test -r /usr/include/python$PYTHON_VERSION/Python.h
|
||||
then
|
||||
PYTHON_INCLUDES=-I/usr/include/python$PYTHON_VERSION
|
||||
else
|
||||
AC_MSG_ERROR([You must install python-devel to build Python bindings])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
AC_MSG_ERROR([You must install python to build Python bindings])
|
||||
fi
|
||||
else
|
||||
AC_MSG_NOTICE([Could not find python in $with_python, disabling bindings])
|
||||
with_python=no
|
||||
fi
|
||||
fi
|
||||
AM_CONDITIONAL([WITH_PYTHON], [test "$with_python" = "yes"])
|
||||
AC_SUBST([PYTHON_VERSION])
|
||||
AC_SUBST([PYTHON_INCLUDES])
|
||||
|
||||
dnl Allow perl overrides
|
||||
dnl Allow perl/python overrides
|
||||
AC_PATH_PROG([PYTHON], [python])
|
||||
AC_PATH_PROG([PERL], [perl])
|
||||
|
||||
AC_ARG_ENABLE([with-test-suite],
|
||||
|
@ -2227,7 +2151,6 @@ dnl Copied from libxml2 configure.in, but I removed mingw changes
|
|||
dnl for now since I'm not supporting mingw at present. - RWMJ
|
||||
CYGWIN_EXTRA_LDFLAGS=
|
||||
CYGWIN_EXTRA_LIBADD=
|
||||
CYGWIN_EXTRA_PYTHON_LIBADD=
|
||||
MINGW_EXTRA_LDFLAGS=
|
||||
WIN32_EXTRA_CFLAGS=
|
||||
dnl libvirt.syms is generated in builddir, but libvirt_qemu.syms is in git;
|
||||
|
@ -2241,10 +2164,6 @@ case "$host" in
|
|||
CYGWIN_EXTRA_LDFLAGS="-no-undefined"
|
||||
CYGWIN_EXTRA_LIBADD="${INTLLIBS}"
|
||||
MSCOM_LIBS="-lole32 -loleaut32"
|
||||
|
||||
if test "x$PYTHON_VERSION" != "x"; then
|
||||
CYGWIN_EXTRA_PYTHON_LIBADD="-L/usr/lib/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
|
||||
fi
|
||||
;;
|
||||
*-*-mingw*)
|
||||
MINGW_EXTRA_LDFLAGS="-no-undefined"
|
||||
|
@ -2279,7 +2198,6 @@ case "$host" in
|
|||
esac
|
||||
AC_SUBST([CYGWIN_EXTRA_LDFLAGS])
|
||||
AC_SUBST([CYGWIN_EXTRA_LIBADD])
|
||||
AC_SUBST([CYGWIN_EXTRA_PYTHON_LIBADD])
|
||||
AC_SUBST([MINGW_EXTRA_LDFLAGS])
|
||||
AC_SUBST([WIN32_EXTRA_CFLAGS])
|
||||
AC_SUBST([LIBVIRT_SYMBOL_FILE])
|
||||
|
@ -2613,7 +2531,6 @@ AC_CONFIG_FILES([\
|
|||
libvirt.pc libvirt.spec mingw-libvirt.spec \
|
||||
po/Makefile.in \
|
||||
include/libvirt/Makefile include/libvirt/libvirt.h \
|
||||
python/Makefile \
|
||||
daemon/Makefile \
|
||||
tools/Makefile \
|
||||
tests/Makefile \
|
||||
|
@ -2622,7 +2539,6 @@ AC_CONFIG_FILES([\
|
|||
examples/domsuspend/Makefile \
|
||||
examples/dominfo/Makefile \
|
||||
examples/openauth/Makefile \
|
||||
examples/python/Makefile \
|
||||
examples/hellolibvirt/Makefile \
|
||||
examples/systemtap/Makefile \
|
||||
examples/xml/nwfilter/Makefile])
|
||||
|
@ -2778,7 +2694,6 @@ AC_MSG_NOTICE([])
|
|||
AC_MSG_NOTICE([ Debug: $enable_debug])
|
||||
AC_MSG_NOTICE([ Use -Werror: $set_werror])
|
||||
AC_MSG_NOTICE([ Warning Flags: $WARN_CFLAGS])
|
||||
AC_MSG_NOTICE([ Python: $with_python])
|
||||
AC_MSG_NOTICE([ DTrace: $with_dtrace])
|
||||
AC_MSG_NOTICE([ numad: $with_numad])
|
||||
AC_MSG_NOTICE([ XML Catalog: $XML_CATALOG_FILE])
|
||||
|
|
|
@ -1,591 +0,0 @@
|
|||
#!/usr/bin/python -u
|
||||
#
|
||||
#
|
||||
#
|
||||
#################################################################################
|
||||
# Start off by implementing a general purpose event loop for anyones use
|
||||
#################################################################################
|
||||
|
||||
import sys
|
||||
import getopt
|
||||
import os
|
||||
import libvirt
|
||||
import select
|
||||
import errno
|
||||
import time
|
||||
import threading
|
||||
|
||||
# For the sake of demonstration, this example program includes
|
||||
# an implementation of a pure python event loop. Most applications
|
||||
# would be better off just using the default libvirt event loop
|
||||
# APIs, instead of implementing this in python. The exception is
|
||||
# where an application wants to integrate with an existing 3rd
|
||||
# party event loop impl
|
||||
#
|
||||
# Change this to 'False' to make the demo use the native
|
||||
# libvirt event loop impl
|
||||
use_pure_python_event_loop = True
|
||||
|
||||
do_debug = False
|
||||
def debug(msg):
|
||||
global do_debug
|
||||
if do_debug:
|
||||
print msg
|
||||
|
||||
#
|
||||
# This general purpose event loop will support waiting for file handle
|
||||
# I/O and errors events, as well as scheduling repeatable timers with
|
||||
# a fixed interval.
|
||||
#
|
||||
# It is a pure python implementation based around the poll() API
|
||||
#
|
||||
class virEventLoopPure:
|
||||
# This class contains the data we need to track for a
|
||||
# single file handle
|
||||
class virEventLoopPureHandle:
|
||||
def __init__(self, handle, fd, events, cb, opaque):
|
||||
self.handle = handle
|
||||
self.fd = fd
|
||||
self.events = events
|
||||
self.cb = cb
|
||||
self.opaque = opaque
|
||||
|
||||
def get_id(self):
|
||||
return self.handle
|
||||
|
||||
def get_fd(self):
|
||||
return self.fd
|
||||
|
||||
def get_events(self):
|
||||
return self.events
|
||||
|
||||
def set_events(self, events):
|
||||
self.events = events
|
||||
|
||||
def dispatch(self, events):
|
||||
self.cb(self.handle,
|
||||
self.fd,
|
||||
events,
|
||||
self.opaque)
|
||||
|
||||
# This class contains the data we need to track for a
|
||||
# single periodic timer
|
||||
class virEventLoopPureTimer:
|
||||
def __init__(self, timer, interval, cb, opaque):
|
||||
self.timer = timer
|
||||
self.interval = interval
|
||||
self.cb = cb
|
||||
self.opaque = opaque
|
||||
self.lastfired = 0
|
||||
|
||||
def get_id(self):
|
||||
return self.timer
|
||||
|
||||
def get_interval(self):
|
||||
return self.interval
|
||||
|
||||
def set_interval(self, interval):
|
||||
self.interval = interval
|
||||
|
||||
def get_last_fired(self):
|
||||
return self.lastfired
|
||||
|
||||
def set_last_fired(self, now):
|
||||
self.lastfired = now
|
||||
|
||||
def dispatch(self):
|
||||
self.cb(self.timer,
|
||||
self.opaque)
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.poll = select.poll()
|
||||
self.pipetrick = os.pipe()
|
||||
self.pendingWakeup = False
|
||||
self.runningPoll = False
|
||||
self.nextHandleID = 1
|
||||
self.nextTimerID = 1
|
||||
self.handles = []
|
||||
self.timers = []
|
||||
self.quit = False
|
||||
|
||||
# The event loop can be used from multiple threads at once.
|
||||
# Specifically while the main thread is sleeping in poll()
|
||||
# waiting for events to occur, another thread may come along
|
||||
# and add/update/remove a file handle, or timer. When this
|
||||
# happens we need to interrupt the poll() sleep in the other
|
||||
# thread, so that it'll see the file handle / timer changes.
|
||||
#
|
||||
# Using OS level signals for this is very unreliable and
|
||||
# hard to implement correctly. Thus we use the real classic
|
||||
# "self pipe" trick. A anonymous pipe, with one end registered
|
||||
# with the event loop for input events. When we need to force
|
||||
# the main thread out of a poll() sleep, we simple write a
|
||||
# single byte of data to the other end of the pipe.
|
||||
debug("Self pipe watch %d write %d" %(self.pipetrick[0], self.pipetrick[1]))
|
||||
self.poll.register(self.pipetrick[0], select.POLLIN)
|
||||
|
||||
|
||||
# Calculate when the next timeout is due to occur, returning
|
||||
# the absolute timestamp for the next timeout, or 0 if there is
|
||||
# no timeout due
|
||||
def next_timeout(self):
|
||||
next = 0
|
||||
for t in self.timers:
|
||||
last = t.get_last_fired()
|
||||
interval = t.get_interval()
|
||||
if interval < 0:
|
||||
continue
|
||||
if next == 0 or (last + interval) < next:
|
||||
next = last + interval
|
||||
|
||||
return next
|
||||
|
||||
# Lookup a virEventLoopPureHandle object based on file descriptor
|
||||
def get_handle_by_fd(self, fd):
|
||||
for h in self.handles:
|
||||
if h.get_fd() == fd:
|
||||
return h
|
||||
return None
|
||||
|
||||
# Lookup a virEventLoopPureHandle object based on its event loop ID
|
||||
def get_handle_by_id(self, handleID):
|
||||
for h in self.handles:
|
||||
if h.get_id() == handleID:
|
||||
return h
|
||||
return None
|
||||
|
||||
|
||||
# This is the heart of the event loop, performing one single
|
||||
# iteration. It asks when the next timeout is due, and then
|
||||
# calcuates the maximum amount of time it is able to sleep
|
||||
# for in poll() pending file handle events.
|
||||
#
|
||||
# It then goes into the poll() sleep.
|
||||
#
|
||||
# When poll() returns, there will zero or more file handle
|
||||
# events which need to be dispatched to registered callbacks
|
||||
# It may also be time to fire some periodic timers.
|
||||
#
|
||||
# Due to the coarse granularity of schedular timeslices, if
|
||||
# we ask for a sleep of 500ms in order to satisfy a timer, we
|
||||
# may return up to 1 schedular timeslice early. So even though
|
||||
# our sleep timeout was reached, the registered timer may not
|
||||
# technically be at its expiry point. This leads to us going
|
||||
# back around the loop with a crazy 5ms sleep. So when checking
|
||||
# if timeouts are due, we allow a margin of 20ms, to avoid
|
||||
# these pointless repeated tiny sleeps.
|
||||
def run_once(self):
|
||||
sleep = -1
|
||||
self.runningPoll = True
|
||||
try:
|
||||
next = self.next_timeout()
|
||||
debug("Next timeout due at %d" % next)
|
||||
if next > 0:
|
||||
now = int(time.time() * 1000)
|
||||
if now >= next:
|
||||
sleep = 0
|
||||
else:
|
||||
sleep = (next - now) / 1000.0
|
||||
|
||||
debug("Poll with a sleep of %d" % sleep)
|
||||
events = self.poll.poll(sleep)
|
||||
|
||||
# Dispatch any file handle events that occurred
|
||||
for (fd, revents) in events:
|
||||
# See if the events was from the self-pipe
|
||||
# telling us to wakup. if so, then discard
|
||||
# the data just continue
|
||||
if fd == self.pipetrick[0]:
|
||||
self.pendingWakeup = False
|
||||
data = os.read(fd, 1)
|
||||
continue
|
||||
|
||||
h = self.get_handle_by_fd(fd)
|
||||
if h:
|
||||
debug("Dispatch fd %d handle %d events %d" % (fd, h.get_id(), revents))
|
||||
h.dispatch(self.events_from_poll(revents))
|
||||
|
||||
now = int(time.time() * 1000)
|
||||
for t in self.timers:
|
||||
interval = t.get_interval()
|
||||
if interval < 0:
|
||||
continue
|
||||
|
||||
want = t.get_last_fired() + interval
|
||||
# Deduct 20ms, since scheduler timeslice
|
||||
# means we could be ever so slightly early
|
||||
if now >= (want-20):
|
||||
debug("Dispatch timer %d now %s want %s" % (t.get_id(), str(now), str(want)))
|
||||
t.set_last_fired(now)
|
||||
t.dispatch()
|
||||
|
||||
except (os.error, select.error), e:
|
||||
if e.args[0] != errno.EINTR:
|
||||
raise
|
||||
finally:
|
||||
self.runningPoll = False
|
||||
|
||||
|
||||
# Actually the event loop forever
|
||||
def run_loop(self):
|
||||
self.quit = False
|
||||
while not self.quit:
|
||||
self.run_once()
|
||||
|
||||
def interrupt(self):
|
||||
if self.runningPoll and not self.pendingWakeup:
|
||||
self.pendingWakeup = True
|
||||
os.write(self.pipetrick[1], 'c')
|
||||
|
||||
|
||||
# Registers a new file handle 'fd', monitoring for 'events' (libvirt
|
||||
# event constants), firing the callback cb() when an event occurs.
|
||||
# Returns a unique integer identier for this handle, that should be
|
||||
# used to later update/remove it
|
||||
def add_handle(self, fd, events, cb, opaque):
|
||||
handleID = self.nextHandleID + 1
|
||||
self.nextHandleID = self.nextHandleID + 1
|
||||
|
||||
h = self.virEventLoopPureHandle(handleID, fd, events, cb, opaque)
|
||||
self.handles.append(h)
|
||||
|
||||
self.poll.register(fd, self.events_to_poll(events))
|
||||
self.interrupt()
|
||||
|
||||
debug("Add handle %d fd %d events %d" % (handleID, fd, events))
|
||||
|
||||
return handleID
|
||||
|
||||
# Registers a new timer with periodic expiry at 'interval' ms,
|
||||
# firing cb() each time the timer expires. If 'interval' is -1,
|
||||
# then the timer is registered, but not enabled
|
||||
# Returns a unique integer identier for this handle, that should be
|
||||
# used to later update/remove it
|
||||
def add_timer(self, interval, cb, opaque):
|
||||
timerID = self.nextTimerID + 1
|
||||
self.nextTimerID = self.nextTimerID + 1
|
||||
|
||||
h = self.virEventLoopPureTimer(timerID, interval, cb, opaque)
|
||||
self.timers.append(h)
|
||||
self.interrupt()
|
||||
|
||||
debug("Add timer %d interval %d" % (timerID, interval))
|
||||
|
||||
return timerID
|
||||
|
||||
# Change the set of events to be monitored on the file handle
|
||||
def update_handle(self, handleID, events):
|
||||
h = self.get_handle_by_id(handleID)
|
||||
if h:
|
||||
h.set_events(events)
|
||||
self.poll.unregister(h.get_fd())
|
||||
self.poll.register(h.get_fd(), self.events_to_poll(events))
|
||||
self.interrupt()
|
||||
|
||||
debug("Update handle %d fd %d events %d" % (handleID, h.get_fd(), events))
|
||||
|
||||
# Change the periodic frequency of the timer
|
||||
def update_timer(self, timerID, interval):
|
||||
for h in self.timers:
|
||||
if h.get_id() == timerID:
|
||||
h.set_interval(interval)
|
||||
self.interrupt()
|
||||
|
||||
debug("Update timer %d interval %d" % (timerID, interval))
|
||||
break
|
||||
|
||||
# Stop monitoring for events on the file handle
|
||||
def remove_handle(self, handleID):
|
||||
handles = []
|
||||
for h in self.handles:
|
||||
if h.get_id() == handleID:
|
||||
self.poll.unregister(h.get_fd())
|
||||
debug("Remove handle %d fd %d" % (handleID, h.get_fd()))
|
||||
else:
|
||||
handles.append(h)
|
||||
self.handles = handles
|
||||
self.interrupt()
|
||||
|
||||
# Stop firing the periodic timer
|
||||
def remove_timer(self, timerID):
|
||||
timers = []
|
||||
for h in self.timers:
|
||||
if h.get_id() != timerID:
|
||||
timers.append(h)
|
||||
debug("Remove timer %d" % timerID)
|
||||
self.timers = timers
|
||||
self.interrupt()
|
||||
|
||||
# Convert from libvirt event constants, to poll() events constants
|
||||
def events_to_poll(self, events):
|
||||
ret = 0
|
||||
if events & libvirt.VIR_EVENT_HANDLE_READABLE:
|
||||
ret |= select.POLLIN
|
||||
if events & libvirt.VIR_EVENT_HANDLE_WRITABLE:
|
||||
ret |= select.POLLOUT
|
||||
if events & libvirt.VIR_EVENT_HANDLE_ERROR:
|
||||
ret |= select.POLLERR
|
||||
if events & libvirt.VIR_EVENT_HANDLE_HANGUP:
|
||||
ret |= select.POLLHUP
|
||||
return ret
|
||||
|
||||
# Convert from poll() event constants, to libvirt events constants
|
||||
def events_from_poll(self, events):
|
||||
ret = 0
|
||||
if events & select.POLLIN:
|
||||
ret |= libvirt.VIR_EVENT_HANDLE_READABLE
|
||||
if events & select.POLLOUT:
|
||||
ret |= libvirt.VIR_EVENT_HANDLE_WRITABLE
|
||||
if events & select.POLLNVAL:
|
||||
ret |= libvirt.VIR_EVENT_HANDLE_ERROR
|
||||
if events & select.POLLERR:
|
||||
ret |= libvirt.VIR_EVENT_HANDLE_ERROR
|
||||
if events & select.POLLHUP:
|
||||
ret |= libvirt.VIR_EVENT_HANDLE_HANGUP
|
||||
return ret
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Now glue an instance of the general event loop into libvirt's event loop
|
||||
###########################################################################
|
||||
|
||||
# This single global instance of the event loop wil be used for
|
||||
# monitoring libvirt events
|
||||
eventLoop = virEventLoopPure()
|
||||
|
||||
# This keeps track of what thread is running the event loop,
|
||||
# (if it is run in a background thread)
|
||||
eventLoopThread = None
|
||||
|
||||
|
||||
# These next set of 6 methods are the glue between the official
|
||||
# libvirt events API, and our particular impl of the event loop
|
||||
#
|
||||
# There is no reason why the 'virEventLoopPure' has to be used.
|
||||
# An application could easily may these 6 glue methods hook into
|
||||
# another event loop such as GLib's, or something like the python
|
||||
# Twisted event framework.
|
||||
|
||||
def virEventAddHandleImpl(fd, events, cb, opaque):
|
||||
global eventLoop
|
||||
return eventLoop.add_handle(fd, events, cb, opaque)
|
||||
|
||||
def virEventUpdateHandleImpl(handleID, events):
|
||||
global eventLoop
|
||||
return eventLoop.update_handle(handleID, events)
|
||||
|
||||
def virEventRemoveHandleImpl(handleID):
|
||||
global eventLoop
|
||||
return eventLoop.remove_handle(handleID)
|
||||
|
||||
def virEventAddTimerImpl(interval, cb, opaque):
|
||||
global eventLoop
|
||||
return eventLoop.add_timer(interval, cb, opaque)
|
||||
|
||||
def virEventUpdateTimerImpl(timerID, interval):
|
||||
global eventLoop
|
||||
return eventLoop.update_timer(timerID, interval)
|
||||
|
||||
def virEventRemoveTimerImpl(timerID):
|
||||
global eventLoop
|
||||
return eventLoop.remove_timer(timerID)
|
||||
|
||||
# This tells libvirt what event loop implementation it
|
||||
# should use
|
||||
def virEventLoopPureRegister():
|
||||
libvirt.virEventRegisterImpl(virEventAddHandleImpl,
|
||||
virEventUpdateHandleImpl,
|
||||
virEventRemoveHandleImpl,
|
||||
virEventAddTimerImpl,
|
||||
virEventUpdateTimerImpl,
|
||||
virEventRemoveTimerImpl)
|
||||
|
||||
# Directly run the event loop in the current thread
|
||||
def virEventLoopPureRun():
|
||||
global eventLoop
|
||||
eventLoop.run_loop()
|
||||
|
||||
def virEventLoopNativeRun():
|
||||
while True:
|
||||
libvirt.virEventRunDefaultImpl()
|
||||
|
||||
# Spawn a background thread to run the event loop
|
||||
def virEventLoopPureStart():
|
||||
global eventLoopThread
|
||||
virEventLoopPureRegister()
|
||||
eventLoopThread = threading.Thread(target=virEventLoopPureRun, name="libvirtEventLoop")
|
||||
eventLoopThread.setDaemon(True)
|
||||
eventLoopThread.start()
|
||||
|
||||
def virEventLoopNativeStart():
|
||||
global eventLoopThread
|
||||
libvirt.virEventRegisterDefaultImpl()
|
||||
eventLoopThread = threading.Thread(target=virEventLoopNativeRun, name="libvirtEventLoop")
|
||||
eventLoopThread.setDaemon(True)
|
||||
eventLoopThread.start()
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Everything that now follows is a simple demo of domain lifecycle events
|
||||
##########################################################################
|
||||
def eventToString(event):
|
||||
eventStrings = ( "Defined",
|
||||
"Undefined",
|
||||
"Started",
|
||||
"Suspended",
|
||||
"Resumed",
|
||||
"Stopped",
|
||||
"Shutdown",
|
||||
"PMSuspended",
|
||||
"Crashed" )
|
||||
return eventStrings[event]
|
||||
|
||||
def detailToString(event, detail):
|
||||
eventStrings = (
|
||||
( "Added", "Updated" ),
|
||||
( "Removed", ),
|
||||
( "Booted", "Migrated", "Restored", "Snapshot", "Wakeup" ),
|
||||
( "Paused", "Migrated", "IOError", "Watchdog", "Restored", "Snapshot", "API error" ),
|
||||
( "Unpaused", "Migrated", "Snapshot" ),
|
||||
( "Shutdown", "Destroyed", "Crashed", "Migrated", "Saved", "Failed", "Snapshot"),
|
||||
( "Finished", ),
|
||||
( "Memory", "Disk" ),
|
||||
( "Panicked", )
|
||||
)
|
||||
return eventStrings[event][detail]
|
||||
|
||||
def myDomainEventCallback1 (conn, dom, event, detail, opaque):
|
||||
print "myDomainEventCallback1 EVENT: Domain %s(%s) %s %s" % (dom.name(), dom.ID(),
|
||||
eventToString(event),
|
||||
detailToString(event, detail))
|
||||
|
||||
def myDomainEventCallback2 (conn, dom, event, detail, opaque):
|
||||
print "myDomainEventCallback2 EVENT: Domain %s(%s) %s %s" % (dom.name(), dom.ID(),
|
||||
eventToString(event),
|
||||
detailToString(event, detail))
|
||||
|
||||
def myDomainEventRebootCallback(conn, dom, opaque):
|
||||
print "myDomainEventRebootCallback: Domain %s(%s)" % (dom.name(), dom.ID())
|
||||
|
||||
def myDomainEventRTCChangeCallback(conn, dom, utcoffset, opaque):
|
||||
print "myDomainEventRTCChangeCallback: Domain %s(%s) %d" % (dom.name(), dom.ID(), utcoffset)
|
||||
|
||||
def myDomainEventWatchdogCallback(conn, dom, action, opaque):
|
||||
print "myDomainEventWatchdogCallback: Domain %s(%s) %d" % (dom.name(), dom.ID(), action)
|
||||
|
||||
def myDomainEventIOErrorCallback(conn, dom, srcpath, devalias, action, opaque):
|
||||
print "myDomainEventIOErrorCallback: Domain %s(%s) %s %s %d" % (dom.name(), dom.ID(), srcpath, devalias, action)
|
||||
|
||||
def myDomainEventGraphicsCallback(conn, dom, phase, localAddr, remoteAddr, authScheme, subject, opaque):
|
||||
print "myDomainEventGraphicsCallback: Domain %s(%s) %d %s" % (dom.name(), dom.ID(), phase, authScheme)
|
||||
|
||||
def myDomainEventDiskChangeCallback(conn, dom, oldSrcPath, newSrcPath, devAlias, reason, opaque):
|
||||
print "myDomainEventDiskChangeCallback: Domain %s(%s) disk change oldSrcPath: %s newSrcPath: %s devAlias: %s reason: %s" % (
|
||||
dom.name(), dom.ID(), oldSrcPath, newSrcPath, devAlias, reason)
|
||||
def myDomainEventTrayChangeCallback(conn, dom, devAlias, reason, opaque):
|
||||
print "myDomainEventTrayChangeCallback: Domain %s(%s) tray change devAlias: %s reason: %s" % (
|
||||
dom.name(), dom.ID(), devAlias, reason)
|
||||
def myDomainEventPMWakeupCallback(conn, dom, reason, opaque):
|
||||
print "myDomainEventPMWakeupCallback: Domain %s(%s) system pmwakeup" % (
|
||||
dom.name(), dom.ID())
|
||||
def myDomainEventPMSuspendCallback(conn, dom, reason, opaque):
|
||||
print "myDomainEventPMSuspendCallback: Domain %s(%s) system pmsuspend" % (
|
||||
dom.name(), dom.ID())
|
||||
def myDomainEventBalloonChangeCallback(conn, dom, actual, opaque):
|
||||
print "myDomainEventBalloonChangeCallback: Domain %s(%s) %d" % (dom.name(), dom.ID(), actual)
|
||||
def myDomainEventPMSuspendDiskCallback(conn, dom, reason, opaque):
|
||||
print "myDomainEventPMSuspendDiskCallback: Domain %s(%s) system pmsuspend_disk" % (
|
||||
dom.name(), dom.ID())
|
||||
def myDomainEventDeviceRemovedCallback(conn, dom, dev, opaque):
|
||||
print "myDomainEventDeviceRemovedCallback: Domain %s(%s) device removed: %s" % (
|
||||
dom.name(), dom.ID(), dev)
|
||||
|
||||
run = True
|
||||
|
||||
def myConnectionCloseCallback(conn, reason, opaque):
|
||||
reasonStrings = (
|
||||
"Error", "End-of-file", "Keepalive", "Client",
|
||||
)
|
||||
print "myConnectionCloseCallback: %s: %s" % (conn.getURI(), reasonStrings[reason])
|
||||
run = False
|
||||
|
||||
def usage(out=sys.stderr):
|
||||
print >>out, "usage: "+os.path.basename(sys.argv[0])+" [-hdl] [uri]"
|
||||
print >>out, " uri will default to qemu:///system"
|
||||
print >>out, " --help, -h Print this help message"
|
||||
print >>out, " --debug, -d Print debug output"
|
||||
print >>out, " --loop, -l Toggle event-loop-implementation"
|
||||
|
||||
def main():
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "hdl", ["help", "debug", "loop"])
|
||||
except getopt.GetoptError, err:
|
||||
# print help information and exit:
|
||||
print str(err) # will print something like "option -a not recognized"
|
||||
usage()
|
||||
sys.exit(2)
|
||||
for o, a in opts:
|
||||
if o in ("-h", "--help"):
|
||||
usage(sys.stdout)
|
||||
sys.exit()
|
||||
if o in ("-d", "--debug"):
|
||||
global do_debug
|
||||
do_debug = True
|
||||
if o in ("-l", "--loop"):
|
||||
global use_pure_python_event_loop
|
||||
use_pure_python_event_loop ^= True
|
||||
|
||||
if len(args) >= 1:
|
||||
uri = args[0]
|
||||
else:
|
||||
uri = "qemu:///system"
|
||||
|
||||
print "Using uri:" + uri
|
||||
|
||||
# Run a background thread with the event loop
|
||||
if use_pure_python_event_loop:
|
||||
virEventLoopPureStart()
|
||||
else:
|
||||
virEventLoopNativeStart()
|
||||
|
||||
vc = libvirt.openReadOnly(uri)
|
||||
|
||||
# Close connection on exit (to test cleanup paths)
|
||||
old_exitfunc = getattr(sys, 'exitfunc', None)
|
||||
def exit():
|
||||
print "Closing " + str(vc)
|
||||
vc.close()
|
||||
if (old_exitfunc): old_exitfunc()
|
||||
sys.exitfunc = exit
|
||||
|
||||
vc.registerCloseCallback(myConnectionCloseCallback, None)
|
||||
|
||||
#Add 2 callbacks to prove this works with more than just one
|
||||
vc.domainEventRegister(myDomainEventCallback1,None)
|
||||
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_LIFECYCLE, myDomainEventCallback2, None)
|
||||
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_REBOOT, myDomainEventRebootCallback, None)
|
||||
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_RTC_CHANGE, myDomainEventRTCChangeCallback, None)
|
||||
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_IO_ERROR, myDomainEventIOErrorCallback, None)
|
||||
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_WATCHDOG, myDomainEventWatchdogCallback, None)
|
||||
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_GRAPHICS, myDomainEventGraphicsCallback, None)
|
||||
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_DISK_CHANGE, myDomainEventDiskChangeCallback, None)
|
||||
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_TRAY_CHANGE, myDomainEventTrayChangeCallback, None)
|
||||
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_PMWAKEUP, myDomainEventPMWakeupCallback, None)
|
||||
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_PMSUSPEND, myDomainEventPMSuspendCallback, None)
|
||||
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE, myDomainEventBalloonChangeCallback, None)
|
||||
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK, myDomainEventPMSuspendDiskCallback, None)
|
||||
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED, myDomainEventDeviceRemovedCallback, None)
|
||||
|
||||
vc.setKeepAlive(5, 3)
|
||||
|
||||
# The rest of your app would go here normally, but for sake
|
||||
# of demo we'll just go to sleep. The other option is to
|
||||
# run the event loop in your main thread if your app is
|
||||
# totally event based.
|
||||
while run:
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,21 +0,0 @@
|
|||
## Copyright (C) 2005-2013 Red Hat, Inc.
|
||||
##
|
||||
## 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.
|
||||
##
|
||||
## You should have received a copy of the GNU Lesser General Public
|
||||
## License along with this library. If not, see
|
||||
## <http://www.gnu.org/licenses/>.
|
||||
|
||||
EXTRA_DIST= \
|
||||
README \
|
||||
consolecallback.py \
|
||||
topology.py \
|
||||
dominfo.py domrestore.py domsave.py domstart.py esxlist.py
|
|
@ -1,33 +0,0 @@
|
|||
Some simple examples on how to use the Python API for libvirt
|
||||
|
||||
The examples are:
|
||||
|
||||
dominfo.py - print information about a running domU based on the results of
|
||||
virDomainGetInfo and virDomainGetXMLDesc
|
||||
domstart.py - create a domU from an XML description if the domU isn't
|
||||
running yet
|
||||
domsave.py - save all running domU's into a directory
|
||||
domrestore.py - restore domU's from their saved files in a directory
|
||||
esxlist.py - list active domains of an VMware ESX host and print some info.
|
||||
also demonstrates how to use the libvirt.openAuth() method
|
||||
|
||||
The XML files in this directory are examples of the XML format that libvirt
|
||||
expects, and will have to be adapted for your setup. They are only needed
|
||||
for domstart.py
|
||||
|
||||
|
||||
Some additional notes for the esxlist.py example:
|
||||
|
||||
You may see remote errors complaining about missing certificates:
|
||||
|
||||
Cannot access CA certificate '/usr/local/etc/pki/CA/cacert.pem': No such file
|
||||
or directory
|
||||
|
||||
This is expected, libvirt tries to find network and storage drivers for ESX,
|
||||
but those are not implemented yet (November 2009). While searching for this
|
||||
drivers, libvirt may try to start a local libvirtd instance, but fails because
|
||||
of the missing certificates. It'll warn about that:
|
||||
|
||||
Failed to find the network: Is the daemon running?
|
||||
|
||||
This is also expected and can be ignored.
|
|
@ -1,88 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# consolecallback - provide a persistent console that survives guest reboots
|
||||
|
||||
import sys, os, logging, libvirt, tty, termios, atexit
|
||||
|
||||
def reset_term():
|
||||
termios.tcsetattr(0, termios.TCSADRAIN, attrs)
|
||||
|
||||
def error_handler(unused, error):
|
||||
# The console stream errors on VM shutdown; we don't care
|
||||
if (error[0] == libvirt.VIR_ERR_RPC and
|
||||
error[1] == libvirt.VIR_FROM_STREAMS):
|
||||
return
|
||||
logging.warn(error)
|
||||
|
||||
class Console(object):
|
||||
def __init__(self, uri, uuid):
|
||||
self.uri = uri
|
||||
self.uuid = uuid
|
||||
self.connection = libvirt.open(uri)
|
||||
self.domain = self.connection.lookupByUUIDString(uuid)
|
||||
self.state = self.domain.state(0)
|
||||
self.connection.domainEventRegister(lifecycle_callback, self)
|
||||
self.stream = None
|
||||
self.run_console = True
|
||||
logging.info("%s initial state %d, reason %d",
|
||||
self.uuid, self.state[0], self.state[1])
|
||||
|
||||
def check_console(console):
|
||||
if (console.state[0] == libvirt.VIR_DOMAIN_RUNNING or
|
||||
console.state[0] == libvirt.VIR_DOMAIN_PAUSED):
|
||||
if console.stream is None:
|
||||
console.stream = console.connection.newStream(libvirt.VIR_STREAM_NONBLOCK)
|
||||
console.domain.openConsole(None, console.stream, 0)
|
||||
console.stream.eventAddCallback(libvirt.VIR_STREAM_EVENT_READABLE, stream_callback, console)
|
||||
else:
|
||||
if console.stream:
|
||||
console.stream.eventRemoveCallback()
|
||||
console.stream = None
|
||||
|
||||
return console.run_console
|
||||
|
||||
def stdin_callback(watch, fd, events, console):
|
||||
readbuf = os.read(fd, 1024)
|
||||
if readbuf.startswith(""):
|
||||
console.run_console = False
|
||||
return
|
||||
if console.stream:
|
||||
console.stream.send(readbuf)
|
||||
|
||||
def stream_callback(stream, events, console):
|
||||
try:
|
||||
received_data = console.stream.recv(1024)
|
||||
except:
|
||||
return
|
||||
os.write(0, received_data)
|
||||
|
||||
def lifecycle_callback (connection, domain, event, detail, console):
|
||||
console.state = console.domain.state(0)
|
||||
logging.info("%s transitioned to state %d, reason %d",
|
||||
console.uuid, console.state[0], console.state[1])
|
||||
|
||||
# main
|
||||
if len(sys.argv) != 3:
|
||||
print "Usage:", sys.argv[0], "URI UUID"
|
||||
print "for example:", sys.argv[0], "'qemu:///system' '32ad945f-7e78-c33a-e96d-39f25e025d81'"
|
||||
sys.exit(1)
|
||||
|
||||
uri = sys.argv[1]
|
||||
uuid = sys.argv[2]
|
||||
|
||||
print "Escape character is ^]"
|
||||
logging.basicConfig(filename='msg.log', level=logging.DEBUG)
|
||||
logging.info("URI: %s", uri)
|
||||
logging.info("UUID: %s", uuid)
|
||||
|
||||
libvirt.virEventRegisterDefaultImpl()
|
||||
libvirt.registerErrorHandler(error_handler, None)
|
||||
|
||||
atexit.register(reset_term)
|
||||
attrs = termios.tcgetattr(0)
|
||||
tty.setraw(0)
|
||||
|
||||
console = Console(uri, uuid)
|
||||
console.stdin_watch = libvirt.virEventAddHandle(0, libvirt.VIR_EVENT_HANDLE_READABLE, stdin_callback, console)
|
||||
|
||||
while check_console(console):
|
||||
libvirt.virEventRunDefaultImpl()
|
|
@ -1,80 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# dominfo - print some information about a domain
|
||||
|
||||
import libvirt
|
||||
import sys
|
||||
import os
|
||||
import libxml2
|
||||
import pdb
|
||||
|
||||
def usage():
|
||||
print 'Usage: %s DOMAIN' % sys.argv[0]
|
||||
print ' Print information about the domain DOMAIN'
|
||||
|
||||
def print_section(title):
|
||||
print "\n%s" % title
|
||||
print "=" * 60
|
||||
|
||||
def print_entry(key, value):
|
||||
print "%-10s %-10s" % (key, value)
|
||||
|
||||
def print_xml(key, ctx, path):
|
||||
res = ctx.xpathEval(path)
|
||||
if res is None or len(res) == 0:
|
||||
value="Unknown"
|
||||
else:
|
||||
value = res[0].content
|
||||
print_entry(key, value)
|
||||
return value
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
|
||||
name = sys.argv[1]
|
||||
|
||||
# Connect to libvirt
|
||||
conn = libvirt.openReadOnly(None)
|
||||
if conn is None:
|
||||
print 'Failed to open connection to the hypervisor'
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
dom = conn.lookupByName(name)
|
||||
# Annoyiingly, libvirt prints its own error message here
|
||||
except libvirt.libvirtError:
|
||||
print "Domain %s is not running" % name
|
||||
sys.exit(0)
|
||||
|
||||
info = dom.info()
|
||||
print_section("Domain info")
|
||||
print_entry("State:", info[0])
|
||||
print_entry("MaxMem:", info[1])
|
||||
print_entry("UsedMem:", info[2])
|
||||
print_entry("VCPUs:", info[3])
|
||||
|
||||
# Read some info from the XML desc
|
||||
xmldesc = dom.XMLDesc(0)
|
||||
doc = libxml2.parseDoc(xmldesc)
|
||||
ctx = doc.xpathNewContext()
|
||||
print_section("Kernel")
|
||||
print_xml("Type:", ctx, "/domain/os/type")
|
||||
print_xml("Kernel:", ctx, "/domain/os/kernel")
|
||||
print_xml("initrd:", ctx, "/domain/os/initrd")
|
||||
print_xml("cmdline:", ctx, "/domain/os/cmdline")
|
||||
|
||||
print_section("Devices")
|
||||
devs = ctx.xpathEval("/domain/devices/*")
|
||||
for d in devs:
|
||||
ctx.setContextNode(d)
|
||||
#pdb.set_trace()
|
||||
type = print_xml("Type:", ctx, "@type")
|
||||
if type == "file":
|
||||
print_xml("Source:", ctx, "source/@file")
|
||||
print_xml("Target:", ctx, "target/@dev")
|
||||
elif type == "block":
|
||||
print_xml("Source:", ctx, "source/@dev")
|
||||
print_xml("Target:", ctx, "target/@dev")
|
||||
elif type == "bridge":
|
||||
print_xml("Source:", ctx, "source/@bridge")
|
||||
print_xml("MAC Addr:", ctx, "mac/@address")
|
|
@ -1,36 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# domstart - make sure a given domU is running, if not start it
|
||||
|
||||
import libvirt
|
||||
import sys
|
||||
import os
|
||||
import libxml2
|
||||
import pdb
|
||||
|
||||
def usage():
|
||||
print 'Usage: %s DIR' % sys.argv[0]
|
||||
print ' Restore all the domains contained in DIR'
|
||||
print ' It is assumed that all files in DIR are'
|
||||
print ' images of domU\'s previously created with save'
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
|
||||
dir = sys.argv[1]
|
||||
imgs = os.listdir(dir)
|
||||
|
||||
conn = libvirt.open(None)
|
||||
if conn is None:
|
||||
print 'Failed to open connection to the hypervisor'
|
||||
sys.exit(1)
|
||||
|
||||
for img in imgs:
|
||||
file = os.path.join(dir, img)
|
||||
print "Restoring %s ... " % img,
|
||||
sys.stdout.flush()
|
||||
ret = conn.restore(file)
|
||||
if ret == 0:
|
||||
print "done"
|
||||
else:
|
||||
print "error %d" % ret
|
|
@ -1,40 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# domstart - make sure a given domU is running, if not start it
|
||||
|
||||
import libvirt
|
||||
import sys
|
||||
import os
|
||||
import libxml2
|
||||
import pdb
|
||||
|
||||
def usage():
|
||||
print 'Usage: %s DIR' % sys.argv[0]
|
||||
print ' Save all currently running domU\'s into DIR'
|
||||
print ' DIR must exist and be writable by this process'
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
|
||||
dir = sys.argv[1]
|
||||
|
||||
conn = libvirt.open(None)
|
||||
if conn is None:
|
||||
print 'Failed to open connection to the hypervisor'
|
||||
sys.exit(1)
|
||||
|
||||
doms = conn.listDomainsID()
|
||||
for id in doms:
|
||||
if id == 0:
|
||||
continue
|
||||
dom = conn.lookupByID(id)
|
||||
print "Saving %s[%d] ... " % (dom.name(), id),
|
||||
sys.stdout.flush()
|
||||
path = os.path.join(dir, dom.name())
|
||||
ret = dom.save(path)
|
||||
if ret == 0:
|
||||
print "done"
|
||||
else:
|
||||
print "error %d" % ret
|
||||
|
||||
#pdb.set_trace()
|
|
@ -1,50 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# domstart - make sure a given domU is running, if not start it
|
||||
|
||||
import libvirt
|
||||
import sys
|
||||
import os
|
||||
import libxml2
|
||||
import pdb
|
||||
|
||||
# Parse the XML description of domU from FNAME
|
||||
# and return a tuple (name, xmldesc) where NAME
|
||||
# is the name of the domain, and xmldesc is the contetn of FNAME
|
||||
def read_domain(fname):
|
||||
fp = open(fname, "r")
|
||||
xmldesc = fp.read()
|
||||
fp.close()
|
||||
|
||||
doc = libxml2.parseDoc(xmldesc)
|
||||
name = doc.xpathNewContext().xpathEval("/domain/name")[0].content
|
||||
return (name, xmldesc)
|
||||
|
||||
def usage():
|
||||
print 'Usage: %s domain.xml' % sys.argv[0]
|
||||
print ' Check that the domain described by DOMAIN.XML is running'
|
||||
print ' If the domain is not running, create it'
|
||||
print ' DOMAIN.XML must be a XML description of the domain'
|
||||
print ' in libvirt\'s XML format'
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
|
||||
(name, xmldesc) = read_domain(sys.argv[1])
|
||||
|
||||
conn = libvirt.open(None)
|
||||
if conn is None:
|
||||
print 'Failed to open connection to the hypervisor'
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
dom = conn.lookupByName(name)
|
||||
except libvirt.libvirtError:
|
||||
print "Starting domain %s ... " % name,
|
||||
sys.stdout.flush()
|
||||
dom = conn.createLinux(xmldesc, 0)
|
||||
if dom is None:
|
||||
print "failed"
|
||||
sys.exit(1)
|
||||
else:
|
||||
print "done"
|
|
@ -1,155 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# esxlist - list active domains of an ESX host and print some info.
|
||||
# also demonstrates how to use the libvirt.openAuth() method
|
||||
|
||||
import libvirt
|
||||
import sys
|
||||
import os
|
||||
import libxml2
|
||||
import getpass
|
||||
|
||||
|
||||
def usage():
|
||||
print "Usage: %s HOSTNAME" % sys.argv[0]
|
||||
print " List active domains of HOSTNAME and print some info"
|
||||
|
||||
|
||||
# This is the callback method passed to libvirt.openAuth() (see below).
|
||||
#
|
||||
# The credentials argument is a list of credentials that libvirt (actually
|
||||
# the ESX driver) would like to request. An element of this list is itself a
|
||||
# list containing 5 items (4 inputs, 1 output):
|
||||
# - the credential type, e.g. libvirt.VIR_CRED_AUTHNAME
|
||||
# - a prompt to be displayed to the user
|
||||
# - a challenge, the ESX driver sets this to the hostname to allow automatic
|
||||
# distinction between requests for ESX and vCenter credentials
|
||||
# - a default result for the request
|
||||
# - a place to store the actual result for the request
|
||||
#
|
||||
# The user_data argument is the user data item of the auth argument (see below)
|
||||
# passed to libvirt.openAuth().
|
||||
def request_credentials(credentials, user_data):
|
||||
for credential in credentials:
|
||||
if credential[0] == libvirt.VIR_CRED_AUTHNAME:
|
||||
# prompt the user to input a authname. display the provided message
|
||||
credential[4] = raw_input(credential[1] + ": ")
|
||||
|
||||
# if the user just hits enter raw_input() returns an empty string.
|
||||
# in this case return the default result through the last item of
|
||||
# the list
|
||||
if len(credential[4]) == 0:
|
||||
credential[4] = credential[3]
|
||||
elif credential[0] == libvirt.VIR_CRED_NOECHOPROMPT:
|
||||
# use the getpass module to prompt the user to input a password.
|
||||
# display the provided message and return the result through the
|
||||
# last item of the list
|
||||
credential[4] = getpass.getpass(credential[1] + ": ")
|
||||
else:
|
||||
return -1
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def print_section(title):
|
||||
print "\n%s" % title
|
||||
print "=" * 60
|
||||
|
||||
|
||||
def print_entry(key, value):
|
||||
print "%-10s %-10s" % (key, value)
|
||||
|
||||
|
||||
def print_xml(key, ctx, path):
|
||||
res = ctx.xpathEval(path)
|
||||
|
||||
if res is None or len(res) == 0:
|
||||
value = "Unknown"
|
||||
else:
|
||||
value = res[0].content
|
||||
|
||||
print_entry(key, value)
|
||||
|
||||
return value
|
||||
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
hostname = sys.argv[1]
|
||||
|
||||
# Connect to libvirt
|
||||
uri = "esx://%s/?no_verify=1" % hostname
|
||||
|
||||
# The auth argument is a list that contains 3 items:
|
||||
# - a list of supported credential types
|
||||
# - a callable that takes 2 arguments
|
||||
# - user data that will be passed to the callable as second argument
|
||||
#
|
||||
# In this example the supported credential types are VIR_CRED_AUTHNAME and
|
||||
# VIR_CRED_NOECHOPROMPT, the callable is the unbound method request_credentials
|
||||
# (see above) and the user data is None.
|
||||
#
|
||||
# libvirt (actually the ESX driver) will call the callable to request
|
||||
# credentials in order to log into the ESX host. The callable would also be
|
||||
# called if the connection URI would reference a vCenter to request credentials
|
||||
# in order to log into the vCenter
|
||||
auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_NOECHOPROMPT],
|
||||
request_credentials, None]
|
||||
conn = libvirt.openAuth(uri, auth, 0)
|
||||
|
||||
if conn is None:
|
||||
print "Failed to open connection to %s" % hostname
|
||||
sys.exit(1)
|
||||
|
||||
state_names = { libvirt.VIR_DOMAIN_RUNNING : "running",
|
||||
libvirt.VIR_DOMAIN_BLOCKED : "idle",
|
||||
libvirt.VIR_DOMAIN_PAUSED : "paused",
|
||||
libvirt.VIR_DOMAIN_SHUTDOWN : "in shutdown",
|
||||
libvirt.VIR_DOMAIN_SHUTOFF : "shut off",
|
||||
libvirt.VIR_DOMAIN_CRASHED : "crashed",
|
||||
libvirt.VIR_DOMAIN_NOSTATE : "no state" }
|
||||
|
||||
for id in conn.listDomainsID():
|
||||
domain = conn.lookupByID(id)
|
||||
info = domain.info()
|
||||
|
||||
print_section("Domain " + domain.name())
|
||||
print_entry("ID:", id)
|
||||
print_entry("UUID:", domain.UUIDString())
|
||||
print_entry("State:", state_names[info[0]])
|
||||
print_entry("MaxMem:", info[1])
|
||||
print_entry("UsedMem:", info[2])
|
||||
print_entry("VCPUs:", info[3])
|
||||
|
||||
# Read some info from the XML desc
|
||||
print_section("Devices of " + domain.name())
|
||||
|
||||
xmldesc = domain.XMLDesc(0)
|
||||
doc = libxml2.parseDoc(xmldesc)
|
||||
ctx = doc.xpathNewContext()
|
||||
devs = ctx.xpathEval("/domain/devices/*")
|
||||
first = True
|
||||
|
||||
for d in devs:
|
||||
ctx.setContextNode(d)
|
||||
|
||||
if not first:
|
||||
print "------------------------------------------------------------"
|
||||
else:
|
||||
first = False
|
||||
|
||||
print_entry("Device", d.name)
|
||||
|
||||
type = print_xml("Type:", ctx, "@type")
|
||||
|
||||
if type == "file":
|
||||
print_xml("Source:", ctx, "source/@file")
|
||||
print_xml("Target:", ctx, "target/@dev")
|
||||
elif type == "block":
|
||||
print_xml("Source:", ctx, "source/@dev")
|
||||
print_xml("Target:", ctx, "target/@dev")
|
||||
elif type == "bridge":
|
||||
print_xml("Source:", ctx, "source/@bridge")
|
||||
print_xml("MAC Addr:", ctx, "mac/@address")
|
|
@ -1,45 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# Parse topology information from the capabilities XML and use
|
||||
# them to calculate host topology
|
||||
#
|
||||
# Authors:
|
||||
# Amador Pahim <apahim@redhat.com>
|
||||
# Peter Krempa <pkrempa@redhat.com>
|
||||
|
||||
import libvirt
|
||||
import sys
|
||||
from xml.dom import minidom
|
||||
|
||||
try:
|
||||
conn = libvirt.openReadOnly(None)
|
||||
except libvirt.libvirtError:
|
||||
print 'Failed to connect to the hypervisor'
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
capsXML = conn.getCapabilities()
|
||||
except libvirt.libvirtError:
|
||||
print 'Failed to request capabilities'
|
||||
sys.exit(1)
|
||||
|
||||
caps = minidom.parseString(capsXML)
|
||||
host = caps.getElementsByTagName('host')[0]
|
||||
cells = host.getElementsByTagName('cells')[0]
|
||||
total_cpus = cells.getElementsByTagName('cpu').length
|
||||
|
||||
socketIds = []
|
||||
siblingsIds = []
|
||||
|
||||
socketIds = [ proc.getAttribute('socket_id')
|
||||
for proc in cells.getElementsByTagName('cpu')
|
||||
if proc.getAttribute('socket_id') not in socketIds ]
|
||||
|
||||
siblingsIds = [ proc.getAttribute('siblings')
|
||||
for proc in cells.getElementsByTagName('cpu')
|
||||
if proc.getAttribute('siblings') not in siblingsIds ]
|
||||
|
||||
print "Host topology"
|
||||
print "NUMA nodes:", cells.getAttribute('num')
|
||||
print " Sockets:", len(set(socketIds))
|
||||
print " Cores:", len(set(siblingsIds))
|
||||
print " Threads:", total_cpus
|
|
@ -126,7 +126,6 @@
|
|||
%define with_libssh2 0%{!?_without_libssh2:0}
|
||||
|
||||
# Non-server/HV driver defaults which are always enabled
|
||||
%define with_python 0%{!?_without_python:1}
|
||||
%define with_sasl 0%{!?_without_sasl:1}
|
||||
|
||||
|
||||
|
@ -425,7 +424,7 @@ BuildRequires: gettext-devel
|
|||
BuildRequires: libtool
|
||||
BuildRequires: /usr/bin/pod2man
|
||||
%endif
|
||||
BuildRequires: python-devel
|
||||
BuildRequires: python
|
||||
%if %{with_systemd}
|
||||
BuildRequires: systemd-units
|
||||
%endif
|
||||
|
@ -1145,19 +1144,6 @@ Includes the Sanlock lock manager plugin for the QEMU
|
|||
driver
|
||||
%endif
|
||||
|
||||
%if %{with_python}
|
||||
%package python
|
||||
Summary: Python bindings for the libvirt library
|
||||
Group: Development/Libraries
|
||||
Requires: %{name}-client = %{version}-%{release}
|
||||
|
||||
%description python
|
||||
The libvirt-python package contains a module that permits applications
|
||||
written in the Python programming language to use the interface
|
||||
supplied by the libvirt library to use the virtualization capabilities
|
||||
of recent versions of Linux (and other OSes).
|
||||
%endif
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
|
@ -1222,10 +1208,6 @@ of recent versions of Linux (and other OSes).
|
|||
%define _without_polkit --without-polkit
|
||||
%endif
|
||||
|
||||
%if ! %{with_python}
|
||||
%define _without_python --without-python
|
||||
%endif
|
||||
|
||||
%if ! %{with_libvirtd}
|
||||
%define _without_libvirtd --without-libvirtd
|
||||
%endif
|
||||
|
@ -1378,7 +1360,6 @@ of recent versions of Linux (and other OSes).
|
|||
%{?_without_sasl} \
|
||||
%{?_without_avahi} \
|
||||
%{?_without_polkit} \
|
||||
%{?_without_python} \
|
||||
%{?_without_libvirtd} \
|
||||
%{?_without_uml} \
|
||||
%{?_without_phyp} \
|
||||
|
@ -1432,14 +1413,12 @@ rm -fr %{buildroot}
|
|||
# on RHEL 5, thus we need to expand it here.
|
||||
make install DESTDIR=%{?buildroot} SYSTEMD_UNIT_DIR=%{_unitdir}
|
||||
|
||||
for i in domain-events/events-c dominfo domsuspend hellolibvirt openauth python xml/nwfilter systemtap
|
||||
for i in domain-events/events-c dominfo domsuspend hellolibvirt openauth xml/nwfilter systemtap
|
||||
do
|
||||
(cd examples/$i ; make clean ; rm -rf .deps .libs Makefile Makefile.in)
|
||||
done
|
||||
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
|
||||
rm -f $RPM_BUILD_ROOT%{_libdir}/*.a
|
||||
rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.la
|
||||
rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.a
|
||||
rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/lock-driver/*.la
|
||||
rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/lock-driver/*.a
|
||||
%if %{with_driver_modules}
|
||||
|
@ -2105,18 +2084,6 @@ exit 0
|
|||
%doc examples/xml
|
||||
%doc examples/systemtap
|
||||
|
||||
%if %{with_python}
|
||||
%files python
|
||||
%defattr(-, root, root)
|
||||
|
||||
%{_libdir}/python*/site-packages/libvirt.py*
|
||||
%{_libdir}/python*/site-packages/libvirt_qemu.py*
|
||||
%{_libdir}/python*/site-packages/libvirt_lxc.py*
|
||||
%{_libdir}/python*/site-packages/libvirtmod*
|
||||
%doc examples/python
|
||||
%doc examples/domain-events/events-python
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Mon Nov 4 2013 Daniel Veillard <veillard@redhat.com> - 1.1.4-1
|
||||
- Add support for AArch64 architecture
|
||||
|
|
|
@ -217,14 +217,6 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
|
|||
#endif
|
||||
])
|
||||
|
||||
dnl Needed to keep compile quiet on python 2.4
|
||||
save_WARN_CFLAGS=$WARN_CFLAGS
|
||||
WARN_CFLAGS=
|
||||
gl_WARN_ADD([-Wno-redundant-decls])
|
||||
WARN_PYTHON_CFLAGS=$WARN_CFLAGS
|
||||
AC_SUBST(WARN_PYTHON_CFLAGS)
|
||||
WARN_CFLAGS=$save_WARN_CFLAGS
|
||||
|
||||
if test "$gl_cv_warn_c__Wlogical_op" = yes &&
|
||||
test "$lv_cv_gcc_wlogical_op_broken" = yes; then
|
||||
AC_DEFINE_UNQUOTED([BROKEN_GCC_WLOGICALOP], 1,
|
||||
|
|
|
@ -146,7 +146,6 @@ autoreconf -if
|
|||
--without-sasl \
|
||||
--without-avahi \
|
||||
--without-polkit \
|
||||
--without-python \
|
||||
--without-libvirtd \
|
||||
--without-uml \
|
||||
%{?_without_phyp} \
|
||||
|
|
|
@ -1,173 +0,0 @@
|
|||
# Makefile for libvirt python library
|
||||
|
||||
## Copyright (C) 2005-2013 Red Hat, Inc.
|
||||
##
|
||||
## 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.
|
||||
##
|
||||
## You should have received a copy of the GNU Lesser General Public
|
||||
## License along with this library. If not, see
|
||||
## <http://www.gnu.org/licenses/>.
|
||||
|
||||
INCLUDES = \
|
||||
$(PYTHON_INCLUDES) \
|
||||
-I$(top_builddir)/gnulib/lib \
|
||||
-I$(top_srcdir)/gnulib/lib \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir)/src \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/src/util \
|
||||
-I$(top_builddir)/include \
|
||||
-I$(top_srcdir)/include \
|
||||
$(GETTEXT_CPPFLAGS)
|
||||
|
||||
AM_CFLAGS = $(WARN_CFLAGS)
|
||||
AM_LDFLAGS = \
|
||||
$(RELRO_LDFLAGS) \
|
||||
$(NO_INDIRECT_LDFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
CLASSES_EXTRA = \
|
||||
libvirt-override-virConnect.py \
|
||||
libvirt-override-virDomain.py \
|
||||
libvirt-override-virDomainSnapshot.py \
|
||||
libvirt-override-virStoragePool.py \
|
||||
libvirt-override-virStream.py
|
||||
|
||||
EXTRA_DIST = \
|
||||
generator.py \
|
||||
typewrappers.c \
|
||||
typewrappers.h \
|
||||
libvirt-override.c \
|
||||
libvirt-override.py \
|
||||
libvirt-override-api.xml \
|
||||
libvirt-lxc-override.c \
|
||||
libvirt-lxc-override-api.xml \
|
||||
libvirt-qemu-override.c \
|
||||
libvirt-qemu-override-api.xml \
|
||||
sanitytest.py \
|
||||
$(CLASSES_EXTRA) \
|
||||
$(DOCS)
|
||||
|
||||
if WITH_PYTHON
|
||||
mylibs = \
|
||||
$(top_builddir)/src/libvirt.la \
|
||||
$(top_builddir)/gnulib/lib/libgnu.la
|
||||
myqemulibs = \
|
||||
$(top_builddir)/src/libvirt-qemu.la \
|
||||
$(top_builddir)/gnulib/lib/libgnu.la
|
||||
mylxclibs = \
|
||||
$(top_builddir)/src/libvirt-lxc.la \
|
||||
$(top_builddir)/gnulib/lib/libgnu.la
|
||||
|
||||
all-local: libvirt.py libvirt_qemu.py libvirt_lxc.py
|
||||
|
||||
pyexec_LTLIBRARIES = libvirtmod.la libvirtmod_qemu.la libvirtmod_lxc.la
|
||||
|
||||
libvirtmod_la_SOURCES = libvirt-override.c typewrappers.c
|
||||
nodist_libvirtmod_la_SOURCES = libvirt.c libvirt.h
|
||||
# Python <= 2.4 header files contain a redundant decl, hence we
|
||||
# need extra flags here
|
||||
libvirtmod_la_CFLAGS = $(WARN_CFLAGS) $(WARN_PYTHON_CFLAGS)
|
||||
|
||||
libvirtmod_la_LDFLAGS = -module -avoid-version -shared \
|
||||
-L$(top_builddir)/src/.libs \
|
||||
$(AM_LDFLAGS) \
|
||||
$(CYGWIN_EXTRA_LDFLAGS)
|
||||
libvirtmod_la_LIBADD = $(mylibs) \
|
||||
$(CYGWIN_EXTRA_LIBADD) $(CYGWIN_EXTRA_PYTHON_LIBADD)
|
||||
|
||||
libvirtmod_qemu_la_SOURCES = libvirt-qemu-override.c typewrappers.c
|
||||
nodist_libvirtmod_qemu_la_SOURCES = libvirt-qemu.c libvirt-qemu.h
|
||||
# Python <= 2.4 header files contain a redundant decl, hence we
|
||||
# need extra flags here
|
||||
libvirtmod_qemu_la_CFLAGS = $(WARN_PYTHON_CFLAGS)
|
||||
|
||||
libvirtmod_qemu_la_LDFLAGS = -module -avoid-version -shared \
|
||||
-L$(top_builddir)/src/.libs \
|
||||
$(AM_LDFLAGS) \
|
||||
$(CYGWIN_EXTRA_LDFLAGS)
|
||||
libvirtmod_qemu_la_LIBADD = $(myqemulibs) \
|
||||
$(CYGWIN_EXTRA_LIBADD) $(CYGWIN_EXTRA_PYTHON_LIBADD)
|
||||
|
||||
libvirtmod_lxc_la_SOURCES = libvirt-lxc-override.c typewrappers.c
|
||||
nodist_libvirtmod_lxc_la_SOURCES = libvirt-lxc.c libvirt-lxc.h
|
||||
# Python <= 2.4 header files contain a redundant decl, hence we
|
||||
# need extra flags here
|
||||
libvirtmod_lxc_la_CFLAGS = $(WARN_PYTHON_CFLAGS)
|
||||
|
||||
libvirtmod_lxc_la_LDFLAGS = -module -avoid-version -shared \
|
||||
-L$(top_builddir)/src/.libs \
|
||||
$(AM_LDFLAGS) \
|
||||
$(CYGWIN_EXTRA_LDFLAGS)
|
||||
libvirtmod_lxc_la_LIBADD = $(mylxclibs) \
|
||||
$(CYGWIN_EXTRA_LIBADD) $(CYGWIN_EXTRA_PYTHON_LIBADD)
|
||||
|
||||
GENERATE = generator.py
|
||||
API_DESC = $(top_srcdir)/docs/libvirt-api.xml \
|
||||
$(srcdir)/libvirt-override-api.xml
|
||||
GENERATED= libvirt-export.c \
|
||||
libvirt.c \
|
||||
libvirt.h \
|
||||
libvirt.py
|
||||
|
||||
QEMU_API_DESC = $(top_srcdir)/docs/libvirt-qemu-api.xml \
|
||||
$(srcdir)/libvirt-qemu-override-api.xml
|
||||
QEMU_GENERATED= libvirt-qemu-export.c \
|
||||
libvirt-qemu.c \
|
||||
libvirt-qemu.h \
|
||||
libvirt_qemu.py
|
||||
|
||||
LXC_API_DESC = $(top_srcdir)/docs/libvirt-lxc-api.xml \
|
||||
$(srcdir)/libvirt-lxc-override-api.xml
|
||||
LXC_GENERATED= libvirt-lxc-export.c \
|
||||
libvirt-lxc.c \
|
||||
libvirt-lxc.h \
|
||||
libvirt_lxc.py
|
||||
|
||||
$(GENERATE).stamp: $(srcdir)/$(GENERATE) \
|
||||
$(API_DESC) \
|
||||
$(QEMU_API_DESC) \
|
||||
$(LXC_API_DESC) \
|
||||
$(CLASSES_EXTRA)
|
||||
$(AM_V_GEN)$(PYTHON) $(srcdir)/$(GENERATE) $(PYTHON) && \
|
||||
touch $@
|
||||
|
||||
$(GENERATED) $(QEMU_GENERATED) $(LXC_GENERATED): $(GENERATE).stamp
|
||||
|
||||
$(libvirtmod_la_OBJECTS): $(GENERATED)
|
||||
$(libvirtmod_qemu_la_OBJECTS): $(QEMU_GENERATED)
|
||||
$(libvirtmod_lxc_la_OBJECTS): $(LXC_GENERATED)
|
||||
|
||||
check-local:
|
||||
$(AM_V_GEN)../run $(PYTHON) $(srcdir)/sanitytest.py
|
||||
|
||||
install-data-local:
|
||||
$(mkinstalldirs) $(DESTDIR)$(pyexecdir)
|
||||
$(INSTALL) -m 0644 libvirt.py $(DESTDIR)$(pyexecdir)
|
||||
$(INSTALL) -m 0644 libvirt_lxc.py $(DESTDIR)$(pyexecdir)
|
||||
$(INSTALL) -m 0644 libvirt_qemu.py $(DESTDIR)$(pyexecdir)
|
||||
|
||||
uninstall-local:
|
||||
rm -f $(DESTDIR)$(pyexecdir)/libvirt.py
|
||||
rm -f $(DESTDIR)$(pyexecdir)/libvirt_lxc.py
|
||||
rm -f $(DESTDIR)$(pyexecdir)/libvirt_qemu.py
|
||||
|
||||
CLEANFILES= $(GENERATED) $(QEMU_GENERATED) $(LXC_GENERATED) $(GENERATE).stamp \
|
||||
*.pyc
|
||||
|
||||
else ! WITH_PYTHON
|
||||
all:
|
||||
endif ! WITH_PYTHON
|
||||
|
||||
dummy:
|
||||
|
||||
tests test: all dummy
|
||||
-@(cd tests && $(MAKE) MAKEFLAGS+=--silent tests)
|
|
@ -1,27 +0,0 @@
|
|||
libvirt Python Bindings README
|
||||
==============================
|
||||
|
||||
Most of the libvirt python binding code is automatically generated
|
||||
using the script generator.py, and the API description from
|
||||
docs/libvirt-api.xml
|
||||
|
||||
|
||||
Manually written files:
|
||||
|
||||
- libvirt-override.c: methods where the C binding needs to be hand crafted
|
||||
- libvirt-override.py: global methods where the C and python bindings have different args
|
||||
- libvirt-override-api.xml: methods where the auto-extracted API docs are not
|
||||
suitable for python auto-generator. Overriding this if the method is going
|
||||
into libvirt-override.c, but we still want auto-generated libvirt-override.py
|
||||
- libvirt-override-virConnect.py: virConnect class methods
|
||||
- typewrappers.h,.c: Python object wrappers for each libvirt C object
|
||||
|
||||
|
||||
Auto-generated files:
|
||||
|
||||
- libvirt.py: The main python binding. Comprises auto-generated code, along
|
||||
with contents from libvirt-override.py and libvirt-override-virConnect.py
|
||||
- libvirt.c, libvirt.h: The C glue layer for the python binding. Comprises
|
||||
auto-generated code, along with libvirt-override.c
|
||||
- libvirt-export.c: List of auto-generated C methods, included into
|
||||
the libvirt-override.c method table
|
1976
python/generator.py
1976
python/generator.py
File diff suppressed because it is too large
Load Diff
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<api name='libvir-lxc-python'>
|
||||
<symbols>
|
||||
<function name='virDomainLxcOpenNamespace' file='python-lxc'>
|
||||
<info><![CDATA[This API is LXC specific, so it will only work with hypervisor
|
||||
connections to the LXC driver.
|
||||
|
||||
Open the namespaces associated with the container @domain
|
||||
and return a list of file descriptors associated with the
|
||||
container.
|
||||
|
||||
The returned file descriptors are intended to be used with
|
||||
the setns() system call.]]></info>
|
||||
<return type='int' info='the list of open file descriptors, or -1 on error'/>
|
||||
<arg name='domain' type='virDomainPtr' info='a domain object'/>
|
||||
<arg name='flags' type='unsigned int' info='currently unused, pass 0'/>
|
||||
</function>
|
||||
</symbols>
|
||||
</api>
|
|
@ -1,142 +0,0 @@
|
|||
/*
|
||||
* libvir.c: this modules implements the main part of the glue of the
|
||||
* libvir library and the Python interpreter. It provides the
|
||||
* entry points where an automatically generated stub is
|
||||
* unpractical
|
||||
*
|
||||
* Copyright (C) 2012-2013 Red Hat, Inc.
|
||||
*
|
||||
* Daniel Veillard <veillard@redhat.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Horrible kludge to work around even more horrible name-space pollution
|
||||
via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
|
||||
which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
|
||||
#undef HAVE_PTHREAD_H
|
||||
|
||||
#include <Python.h>
|
||||
#include <libvirt/libvirt-lxc.h>
|
||||
#include <libvirt/virterror.h>
|
||||
#include "typewrappers.h"
|
||||
#include "libvirt-lxc.h"
|
||||
#include "viralloc.h"
|
||||
#include "virfile.h"
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
extern void initlibvirtmod_lxc(void);
|
||||
#else
|
||||
extern void initcygvirtmod_lxc(void);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
# define DEBUG_ERROR 1
|
||||
#endif
|
||||
|
||||
#if DEBUG_ERROR
|
||||
# define DEBUG(fmt, ...) \
|
||||
printf(fmt, __VA_ARGS__)
|
||||
#else
|
||||
# define DEBUG(fmt, ...) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
/* The two-statement sequence "Py_INCREF(Py_None); return Py_None;"
|
||||
is so common that we encapsulate it here. Now, each use is simply
|
||||
return VIR_PY_NONE; */
|
||||
#define VIR_PY_NONE (Py_INCREF (Py_None), Py_None)
|
||||
#define VIR_PY_INT_FAIL (libvirt_intWrap(-1))
|
||||
#define VIR_PY_INT_SUCCESS (libvirt_intWrap(0))
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Statistics *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
static PyObject *
|
||||
libvirt_lxc_virDomainLxcOpenNamespace(PyObject *self ATTRIBUTE_UNUSED,
|
||||
PyObject *args) {
|
||||
PyObject *py_retval;
|
||||
virDomainPtr domain;
|
||||
PyObject *pyobj_domain;
|
||||
unsigned int flags;
|
||||
int c_retval;
|
||||
int *fdlist = NULL;
|
||||
size_t i;
|
||||
|
||||
if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainLxcOpenNamespace",
|
||||
&pyobj_domain, &flags))
|
||||
return NULL;
|
||||
domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
|
||||
|
||||
if (domain == NULL)
|
||||
return VIR_PY_NONE;
|
||||
LIBVIRT_BEGIN_ALLOW_THREADS;
|
||||
c_retval = virDomainLxcOpenNamespace(domain, &fdlist, flags);
|
||||
LIBVIRT_END_ALLOW_THREADS;
|
||||
|
||||
if (c_retval < 0)
|
||||
return VIR_PY_NONE;
|
||||
|
||||
py_retval = PyList_New(0);
|
||||
for (i = 0; i < c_retval; i++) {
|
||||
PyObject *item = NULL;
|
||||
|
||||
if ((item = PyInt_FromLong(fdlist[i])) == NULL)
|
||||
goto error;
|
||||
|
||||
if (PyList_Append(py_retval, item) < 0) {
|
||||
Py_DECREF(item);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
VIR_FREE(fdlist);
|
||||
return py_retval;
|
||||
|
||||
error:
|
||||
for (i = 0; i < c_retval; i++) {
|
||||
VIR_FORCE_CLOSE(fdlist[i]);
|
||||
}
|
||||
VIR_FREE(fdlist);
|
||||
return VIR_PY_NONE;
|
||||
}
|
||||
/************************************************************************
|
||||
* *
|
||||
* The registration stuff *
|
||||
* *
|
||||
************************************************************************/
|
||||
static PyMethodDef libvirtLxcMethods[] = {
|
||||
#include "libvirt-lxc-export.c"
|
||||
{(char *) "virDomainLxcOpenNamespace", libvirt_lxc_virDomainLxcOpenNamespace, METH_VARARGS, NULL},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
void
|
||||
#ifndef __CYGWIN__
|
||||
initlibvirtmod_lxc
|
||||
#else
|
||||
initcygvirtmod_lxc
|
||||
#endif
|
||||
(void)
|
||||
{
|
||||
static int initialized = 0;
|
||||
|
||||
if (initialized != 0)
|
||||
return;
|
||||
|
||||
if (virInitialize() < 0)
|
||||
return;
|
||||
|
||||
/* initialize the python extension module */
|
||||
Py_InitModule((char *)
|
||||
#ifndef __CYGWIN__
|
||||
"libvirtmod_lxc"
|
||||
#else
|
||||
"cygvirtmod_lxc"
|
||||
#endif
|
||||
, libvirtLxcMethods);
|
||||
|
||||
initialized = 1;
|
||||
}
|
|
@ -1,613 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<api name='libvir-python'>
|
||||
<!-- This file lists libvirt API functions whose Python stubs are
|
||||
written by hand in libvirt-override.c, but the Python-level code
|
||||
are still automatically generated by the generator.py script.
|
||||
|
||||
The type of return value is supposed to be C type. If a function's
|
||||
stub will return a python non-integer data type like string, list,
|
||||
tuple, dictionary, etc, please use "char *" as the type of its return
|
||||
value.
|
||||
-->
|
||||
<symbols>
|
||||
<function name="virConnectGetVersion" file='python'>
|
||||
<info>Returns the running hypervisor version of the connection host</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<return type='int' info="0 on success, -1 on error"/>
|
||||
</function>
|
||||
<function name="virConnectGetLibVersion" file='python'>
|
||||
<info>Returns the libvirt version of the connection host</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<return type='int' info="0 on success, -1 on error"/>
|
||||
</function>
|
||||
<function name="virConnectListDomainsID" file='python'>
|
||||
<info>Returns the list of the ID of the domains on the hypervisor</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<return type='char *' info="the list of ID or None in case of error"/>
|
||||
</function>
|
||||
<function name='virConnectListDefinedDomains' file='python'>
|
||||
<info>list the defined domains, stores the pointers to the names in @names</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<return type='char *' info='the list of Names or None in case of error'/>
|
||||
</function>
|
||||
<function name='virConnectListAllDomains' file='python'>
|
||||
<info>returns list of all defined domains</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<arg name='flags' type='unsigned int' info='optional flags'/>
|
||||
<return type='char *' info='the list of domains or None in case of error'/>
|
||||
</function>
|
||||
<function name='virConnectListNetworks' file='python'>
|
||||
<info>list the networks, stores the pointers to the names in @names</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<return type='char *' info='the list of Names or None in case of error'/>
|
||||
</function>
|
||||
<function name='virConnectListDefinedNetworks' file='python'>
|
||||
<info>list the defined networks, stores the pointers to the names in @names</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<return type='char *' info='the list of Names or None in case of error'/>
|
||||
</function>
|
||||
<function name='virConnectListAllNetworks' file='python'>
|
||||
<info>returns list of all networks</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<arg name='flags' type='unsigned int' info='optional flags'/>
|
||||
<return type='char *' info='the list of networks or None in case of error'/>
|
||||
</function>
|
||||
<function name='virDomainLookupByUUID' file='python'>
|
||||
<info>Try to lookup a domain on the given hypervisor based on its UUID.</info>
|
||||
<return type='virDomainPtr' info='a new domain object or NULL in case of failure'/>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<arg name='uuid' type='const unsigned char *' info='the UUID string for the domain, must be 16 bytes'/>
|
||||
</function>
|
||||
<function name='virNetworkLookupByUUID' file='python'>
|
||||
<info>Try to lookup a network on the given hypervisor based on its UUID.</info>
|
||||
<return type='virNetworkPtr' info='a new network object or NULL in case of failure'/>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<arg name='uuid' type='const unsigned char *' info='the UUID string for the network, must be 16 bytes'/>
|
||||
</function>
|
||||
<function name='virDomainGetInfo' file='python'>
|
||||
<info>Extract information about a domain. Note that if the connection used to get the domain is limited only a partial set of the information can be extracted.</info>
|
||||
<return type='char *' info='the list of information or None in case of error'/>
|
||||
<arg name='domain' type='virDomainPtr' info='a domain object'/>
|
||||
</function>
|
||||
<function name='virDomainGetState' file='python'>
|
||||
<info>Extract domain state.</info>
|
||||
<return type='char *' info='the list containing state and reason or None in case of error'/>
|
||||
<arg name='domain' type='virDomainPtr' info='a domain object'/>
|
||||
<arg name='flags' type='unsigned int' info='additional flags'/>
|
||||
</function>
|
||||
<function name='virDomainGetControlInfo' file='python'>
|
||||
<info>Extract details about current state of control interface to a domain.</info>
|
||||
<return type='char *' info='the list of information or None in case of error'/>
|
||||
<arg name='domain' type='virDomainPtr' info='a domain object'/>
|
||||
<arg name='flags' type='unsigned int' info='additional flags'/>
|
||||
</function>
|
||||
<function name='virDomainGetBlockInfo' file='python'>
|
||||
<info>Extract information about a domain block device size</info>
|
||||
<return type='char *' info='the list of information or None in case of error'/>
|
||||
<arg name='domain' type='virDomainPtr' info='a domain object'/>
|
||||
<arg name='path' type='const char *' info='path to the block device or file'/>
|
||||
<arg name='flags' type='unsigned int' info='currently unused'/>
|
||||
</function>
|
||||
<function name='virDomainGetJobInfo' file='python'>
|
||||
<info>Extract information about an active job being processed for a domain.</info>
|
||||
<return type='char *' info='the list of information or None in case of error'/>
|
||||
<arg name='domain' type='virDomainPtr' info='a domain object'/>
|
||||
</function>
|
||||
<function name='virDomainGetJobStats' file='python'>
|
||||
<info>Extract information about an active job being processed for a domain.</info>
|
||||
<return type='char *' info='dictionary mapping field names to values or None in case of error'/>
|
||||
<arg name='domain' type='virDomainPtr' info='a domain object'/>
|
||||
<arg name='flags' type='unsigned int' info='flags, currently unused, pass 0.'/>
|
||||
</function>
|
||||
<function name='virNodeGetInfo' file='python'>
|
||||
<info>Extract hardware information about the Node. Note that the memory size is reported in MiB instead of KiB.</info>
|
||||
<return type='char *' info='the list of information or None in case of error'/>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
</function>
|
||||
<function name='virNodeGetCPUStats' file='python'>
|
||||
<info>Extract node's CPU statistics.</info>
|
||||
<return type='char *' info='dictionary mapping field names to values or None in case of error'/>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to hypervisor connection'/>
|
||||
<arg name='cpuNum' type='int' info='number of node cpu. (VIR_NODE_CPU_STATS_ALL_CPUS means total cpu statistics)'/>
|
||||
<arg name='flags' type='unsigned int' info='additional flags'/>
|
||||
</function>
|
||||
<function name='virNodeGetMemoryStats' file='python'>
|
||||
<info>Extract node's memory statistics.</info>
|
||||
<return type='char *' info='dictionary mapping field names to values or None in case of error'/>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to hypervisor connection'/>
|
||||
<arg name='cellNum' type='int' info='number of node cell. (VIR_NODE_MEMORY_STATS_ALL_CELLS means total cell statistics)'/>
|
||||
<arg name='flags' type='unsigned int' info='additional flags'/>
|
||||
</function>
|
||||
<function name='virDomainGetUUID' file='python'>
|
||||
<info>Extract the UUID unique Identifier of a domain.</info>
|
||||
<return type='char *' info='the 16 bytes string or None in case of error'/>
|
||||
<arg name='domain' type='virDomainPtr' info='a domain object'/>
|
||||
</function>
|
||||
<function name='virDomainGetUUIDString' file='python'>
|
||||
<info>Fetch globally unique ID of the domain as a string.</info>
|
||||
<return type='char *' info='the UUID string or None in case of error'/>
|
||||
<arg name='pool' type='virDomainPtr' info='a domain object'/>
|
||||
</function>
|
||||
<function name='virNetworkGetUUID' file='python'>
|
||||
<info>Extract the UUID unique Identifier of a network.</info>
|
||||
<return type='char *' info='the 16 bytes string or None in case of error'/>
|
||||
<arg name='domain' type='virNetworkPtr' info='a network object'/>
|
||||
</function>
|
||||
<function name='virNetworkGetUUIDString' file='python'>
|
||||
<info>Fetch globally unique ID of the network as a string.</info>
|
||||
<return type='char *' info='the UUID string or None in case of error'/>
|
||||
<arg name='net' type='virNetworkPtr' info='a network object'/>
|
||||
</function>
|
||||
<function name='virStoragePoolGetUUID' file='python'>
|
||||
<info>Extract the UUID unique Identifier of a storage pool.</info>
|
||||
<return type='char *' info='the 16 bytes string or None in case of error'/>
|
||||
<arg name='pool' type='virStoragePoolPtr' info='a storage pool object'/>
|
||||
</function>
|
||||
<function name='virStoragePoolGetUUIDString' file='python'>
|
||||
<info>Fetch globally unique ID of the storage pool as a string.</info>
|
||||
<return type='char *' info='the UUID string or None in case of error'/>
|
||||
<arg name='pool' type='virStoragePoolPtr' info='a storage pool object'/>
|
||||
</function>
|
||||
<function name='virNetworkGetAutostart' file='python'>
|
||||
<info>Extract the autostart flag for a network.</info>
|
||||
<return type='int' info='the autostart flag, or None in case of error'/>
|
||||
<arg name='domain' type='virNetworkPtr' info='a network object'/>
|
||||
</function>
|
||||
<function name='virDomainGetAutostart' file='python'>
|
||||
<info>Extract the autostart flag for a domain</info>
|
||||
<return type='int' info='the autostart flag, or None in case of error'/>
|
||||
<arg name='domain' type='virDomainPtr' info='a network object'/>
|
||||
</function>
|
||||
<function name='virStoragePoolGetAutostart' file='python'>
|
||||
<info>Extract the autostart flag for a storage pool</info>
|
||||
<return type='int' info='the autostart flag, or None in case of error'/>
|
||||
<arg name='pool' type='virStoragePoolPtr' info='a storage pool object'/>
|
||||
</function>
|
||||
<function name='virDomainBlockStats' file='python'>
|
||||
<info>Extracts block device statistics for a domain</info>
|
||||
<return type='char *' info='a tuple of statistics'/>
|
||||
<arg name='domain' type='virDomainPtr' info='a domain object'/>
|
||||
<arg name='path' type='char *' info='the path for the block device'/>
|
||||
</function>
|
||||
<function name='virDomainBlockStatsFlags' file='python'>
|
||||
<info>Extracts block device statistics parameters of a running domain</info>
|
||||
<return type='char *' info='None in case of error, returns a dictionary of params'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
|
||||
<arg name='path' type='char *' info='the path for the block device'/>
|
||||
<arg name='flags' type='int' info='flags (unused; pass 0)'/>
|
||||
</function>
|
||||
<function name='virDomainGetCPUStats' file='python'>
|
||||
<info>Extracts CPU statistics for a running domain. On success it will
|
||||
return a list of data of dictionary type. If boolean total is False or 0, the
|
||||
first element of the list refers to CPU0 on the host, second element is
|
||||
CPU1, and so on. The format of data struct is as follows:
|
||||
[{cpu_time:xxx}, {cpu_time:xxx}, ...]
|
||||
If it is True or 1, it returns total domain CPU statistics in the format of
|
||||
[{cpu_time:xxx, user_time:xxx, system_time:xxx}]</info>
|
||||
<return type='char *' info='returns a list of dictionary in case of success, None in case of error'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
|
||||
<arg name='total' type='bool' info='on true, return total domain CPU statistics, false return per-cpu info'/>
|
||||
<arg name='flags' type='int' info='flags (unused; pass 0)'/>
|
||||
</function>
|
||||
<function name='virDomainInterfaceStats' file='python'>
|
||||
<info>Extracts interface device statistics for a domain</info>
|
||||
<return type='char *' info='a tuple of statistics'/>
|
||||
<arg name='domain' type='virDomainPtr' info='a domain object'/>
|
||||
<arg name='path' type='char *' info='the path for the interface device'/>
|
||||
</function>
|
||||
<function name='virDomainMemoryStats' file='python'>
|
||||
<info>Extracts memory statistics for a domain</info>
|
||||
<return type='char *' info='a dictionary of statistics'/>
|
||||
<arg name='domain' type='virDomainPtr' info='a domain object'/>
|
||||
</function>
|
||||
<function name="virNodeGetCellsFreeMemory" file='python'>
|
||||
<info>Returns the available memory for a list of cells</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<arg name='startCell' type='int' info='first cell in the list'/>
|
||||
<arg name='maxCells' type='int' info='number of cell in the list'/>
|
||||
<return type='char *' info="the list available memory in the cells"/>
|
||||
</function>
|
||||
<function name='virDomainGetSchedulerParameters' file='python'>
|
||||
<info>Get the scheduler parameters, the @params array will be filled with the values.</info>
|
||||
<return type='char *' info='None in case of error, returns a dictionary of params.'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
|
||||
</function>
|
||||
<function name='virDomainGetSchedulerParametersFlags' file='python'>
|
||||
<info>Get the scheduler parameters</info>
|
||||
<return type='char *' info='None in case of error, returns a dictionary of params'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
|
||||
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
|
||||
</function>
|
||||
<function name='virDomainGetSchedulerType' file='python'>
|
||||
<info>Get the scheduler type.</info>
|
||||
<return type='char *' info='NULL in case of error. The caller must free the returned string.'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
|
||||
</function>
|
||||
<function name='virDomainGetVcpus' file='python'>
|
||||
<info>Extract information about virtual CPUs of domain, store it in info array and also in cpumaps if this pointer is'nt NULL.</info>
|
||||
<return type='int' info='the number of info filled in case of success, -1 in case of failure.'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object, or NULL for Domain0'/>
|
||||
</function>
|
||||
<function name='virDomainPinVcpu' file='python'>
|
||||
<info>Dynamically change the real CPUs which can be allocated to a virtual CPU. This function requires privileged access to the hypervisor.</info>
|
||||
<return type='int' info='0 in case of success, -1 in case of failure.'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object, or NULL for Domain0'/>
|
||||
<arg name='vcpu' type='unsigned int' info='virtual CPU number'/>
|
||||
<arg name='cpumap' type='unsigned char *' info='pointer to a bit map of real CPUs (in 8-bit bytes) (IN) Each bit set to 1 means that corresponding CPU is usable. Bytes are stored in little-endian order: CPU0-7, 8-15... In each byte, lowest CPU number is least significant bit.'/>
|
||||
</function>
|
||||
<function name='virDomainPinVcpuFlags' file='python'>
|
||||
<info>Dynamically change the real CPUs which can be allocated to a virtual CPU. This function requires privileged access to the hypervisor.</info>
|
||||
<return type='int' info='0 in case of success, -1 in case of failure.'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object, or NULL for Domain0'/>
|
||||
<arg name='vcpu' type='unsigned int' info='virtual CPU number'/>
|
||||
<arg name='cpumap' type='unsigned char *' info='pointer to a bit map of real CPUs (in 8-bit bytes) (IN) Each bit set to 1 means that corresponding CPU is usable. Bytes are stored in little-endian order: CPU0-7, 8-15... In each byte, lowest CPU number is least significant bit.'/>
|
||||
<arg name='flags' type='int' info='flags to specify'/>
|
||||
</function>
|
||||
<function name='virDomainGetVcpuPinInfo' file='python'>
|
||||
<info>Query the CPU affinity setting of all virtual CPUs of domain</info>
|
||||
<return type='char *' info='the array of cpumap'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object, or NULL for Domain0'/>
|
||||
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
|
||||
</function>
|
||||
<function name='virDomainGetEmulatorPinInfo' file='python'>
|
||||
<info>Query the CPU affinity setting of the emulator process of domain</info>
|
||||
<return type='char *' info='the array of cpumap'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
|
||||
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
|
||||
</function>
|
||||
<function name='virDomainPinEmulator' file='python'>
|
||||
<info>Dynamically change the real CPUs which can be allocated to the emulator process of a domain.
|
||||
This function requires privileged access to the hypervisor.</info>
|
||||
<return type='int' info='0 in case of success, -1 in case of failure.'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object, or NULL for Domain0'/>
|
||||
<arg name='cpumap' type='unsigned char *' info='pointer to a bit map of real CPUs (in 8-bit bytes) (IN) Each bit set to 1 means that corresponding CPU is usable. Bytes are stored in little-endian order: CPU0-7, 8-15... In each byte, lowest CPU number is least significant bit.'/>
|
||||
<arg name='flags' type='int' info='flags to specify'/>
|
||||
</function>
|
||||
<function name='virDomainSetSchedulerParameters' file='python'>
|
||||
<info>Change the scheduler parameters</info>
|
||||
<return type='int' info='-1 in case of error, 0 in case of success.'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
|
||||
<arg name='params' type='virSchedParameterPtr' info='pointer to scheduler parameter objects'/>
|
||||
</function>
|
||||
<function name='virDomainSetSchedulerParametersFlags' file='python'>
|
||||
<info>Change the scheduler parameters</info>
|
||||
<return type='int' info='-1 in case of error, 0 in case of success.'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
|
||||
<arg name='params' type='virSchedParameterPtr' info='pointer to scheduler parameter objects'/>
|
||||
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
|
||||
</function>
|
||||
<function name='virDomainSetBlkioParameters' file='python'>
|
||||
<info>Change the blkio tunables</info>
|
||||
<return type='int' info='-1 in case of error, 0 in case of success.'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
|
||||
<arg name='params' type='virBlkioParameterPtr' info='pointer to blkio tunable objects'/>
|
||||
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
|
||||
</function>
|
||||
<function name='virDomainGetBlkioParameters' file='python'>
|
||||
<info>Get the blkio parameters</info>
|
||||
<return type='char *' info='None in case of error, returns a dictionary of params'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
|
||||
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
|
||||
</function>
|
||||
<function name='virDomainSetMemoryParameters' file='python'>
|
||||
<info>Change the memory tunables</info>
|
||||
<return type='int' info='-1 in case of error, 0 in case of success.'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
|
||||
<arg name='params' type='virMemoryParameterPtr' info='pointer to memory tunable objects'/>
|
||||
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
|
||||
</function>
|
||||
<function name='virDomainGetMemoryParameters' file='python'>
|
||||
<info>Get the memory parameters</info>
|
||||
<return type='char *' info='None in case of error, returns a dictionary of params'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
|
||||
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
|
||||
</function>
|
||||
<function name='virDomainSetNumaParameters' file='python'>
|
||||
<info>Change the NUMA tunables</info>
|
||||
<return type='int' info='-1 in case of error, 0 in case of success.'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
|
||||
<arg name='params' type='virTypedParameterPtr' info='pointer to numa tunable objects'/>
|
||||
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
|
||||
</function>
|
||||
<function name='virDomainGetNumaParameters' file='python'>
|
||||
<info>Get the NUMA parameters</info>
|
||||
<return type='char *' info='returns a dictionary of params in case of success, None in case of error'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
|
||||
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
|
||||
</function>
|
||||
<function name='virDomainSetInterfaceParameters' file='python'>
|
||||
<info>Change the bandwidth tunables for a interface device</info>
|
||||
<arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
|
||||
<arg name='device' type='const char *' info='interface name'/>
|
||||
<arg name='params' type='virTypedParameterPtr' info='Pointer to bandwidth tuning params object'/>
|
||||
<arg name='flags' type='unsigned int' info='an OR'ed set of virDomainModificationImpact'/>
|
||||
<return type='int' info='0 in case of success, -1 in case of failure'/>
|
||||
</function>
|
||||
<function name='virDomainGetInterfaceParameters' file='python'>
|
||||
<info>Get the bandwidth tunables for a interface device</info>
|
||||
<arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
|
||||
<arg name='device' type='const char *' info='interface name'/>
|
||||
<arg name='flags' type='unsigned int' info='an OR'ed set of virDomainModificationImpact'/>
|
||||
<return type='char *' info='the bandwidth tunables value or None in case of error'/>
|
||||
</function>
|
||||
|
||||
<function name='virConnectListStoragePools' file='python'>
|
||||
<info>list the storage pools, stores the pointers to the names in @names</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<return type='char *' info='the list of Names of None in case of error'/>
|
||||
</function>
|
||||
<function name='virConnectListDefinedStoragePools' file='python'>
|
||||
<info>list the defined storage pool, stores the pointers to the names in @names</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<return type='char *' info='the list of Names of None in case of error'/>
|
||||
</function>
|
||||
<function name='virConnectListAllStoragePools' file='python'>
|
||||
<info>returns list of all storage pools</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<arg name='flags' type='unsigned int' info='optional flags'/>
|
||||
<return type='char *' info='the list of pools or None in case of error'/>
|
||||
</function>
|
||||
<function name='virStoragePoolListVolumes' file='python'>
|
||||
<info>list the storage volumes, stores the pointers to the names in @names</info>
|
||||
<arg name='pool' type='virStoragePoolPtr' info='pointer to the storage pool'/>
|
||||
<return type='char *' info='the list of Names or None in case of error'/>
|
||||
</function>
|
||||
<function name='virStoragePoolListAllVolumes' file='python'>
|
||||
<info>return list of storage volume objects</info>
|
||||
<arg name='pool' type='virStoragePoolPtr' info='pointer to the storage pool'/>
|
||||
<arg name='flags' type='unsigned int' info='optional flags'/>
|
||||
<return type='char *' info='the list of volumes or None in case of error'/>
|
||||
</function>
|
||||
<function name='virStoragePoolGetInfo' file='python'>
|
||||
<info>Extract information about a storage pool. Note that if the connection used to get the domain is limited only a partial set of the information can be extracted.</info>
|
||||
<return type='char *' info='the list of information or None in case of error'/>
|
||||
<arg name='pool' type='virStoragePoolPtr' info='a storage pool object'/>
|
||||
</function>
|
||||
<function name='virStorageVolGetInfo' file='python'>
|
||||
<info>Extract information about a storage volume. Note that if the connection used to get the domain is limited only a partial set of the information can be extracted.</info>
|
||||
<return type='char *' info='the list of information or None in case of error'/>
|
||||
<arg name='vol' type='virStorageVolPtr' info='a storage vol object'/>
|
||||
</function>
|
||||
<function name='virNodeListDevices' file='python'>
|
||||
<info>list the node devices</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<arg name='cap' type='const unsigned char *' info='capability name'/>
|
||||
<arg name='flags' type='unsigned int' info='flags (unused; pass 0)'/>
|
||||
<return type='char *' info='the list of Names or None in case of error'/>
|
||||
</function>
|
||||
<function name='virConnectListAllNodeDevices' file='python'>
|
||||
<info>returns list of all host node devices</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<arg name='flags' type='unsigned int' info='optional flags'/>
|
||||
<return type='char *' info='the list of host node device or None in case of error'/>
|
||||
</function>
|
||||
<function name='virNodeDeviceListCaps' file='python'>
|
||||
<info>list the node device's capabilities</info>
|
||||
<arg name='dev' type='virNodeDevicePtr' info='pointer to the node device'/>
|
||||
<return type='char *' info='the list of Names or None in case of error'/>
|
||||
</function>
|
||||
<function name='virSecretGetValue' file='libvirt' module='libvirt'>
|
||||
<info>Fetches the value associated with a secret.</info>
|
||||
<return type='char *' info='the secret value or None in case of error'/>
|
||||
<arg name='secret' type='virSecretPtr' info='virSecret secret'/>
|
||||
<arg name='flags' type='unsigned int' info='flags (unused; pass 0)'/>
|
||||
</function>
|
||||
<function name='virConnectListSecrets' file='libvirt' module='libvirt'>
|
||||
<info>List the defined secret IDs</info>
|
||||
<arg name='conn' type='virConnectPtr' info='virConnect connection'/>
|
||||
<return type='char *' info='the list of secret IDs or None in case of error'/>
|
||||
</function>
|
||||
<function name='virConnectListAllSecrets' file='python'>
|
||||
<info>returns list of all interfaces</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<arg name='flags' type='unsigned int' info='optional flags'/>
|
||||
<return type='char *' info='the list of secrets or None in case of error'/>
|
||||
</function>
|
||||
<function name='virSecretSetValue' file='libvirt' module='libvirt'>
|
||||
<info>Associates a value with a secret.</info>
|
||||
<return type='int' info='0 on success, -1 on failure.'/>
|
||||
<arg name='secret' type='virSecretPtr' info='virSecret secret'/>
|
||||
<arg name='value' type='const char *' info='The secret value'/>
|
||||
<arg name='flags' type='unsigned int' info='flags (unused; pass 0)'/>
|
||||
</function>
|
||||
<function name='virSecretLookupByUUID' file='python'>
|
||||
<info>Try to lookup a secret on the given hypervisor based on its UUID.</info>
|
||||
<return type='virSecretPtr' info='a new secret object or NULL in case of failure'/>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<arg name='uuid' type='const unsigned char *' info='the UUID string for the secret, must be 16 bytes'/>
|
||||
</function>
|
||||
<function name='virSecretGetUUID' file='python'>
|
||||
<info>Extract the UUID unique Identifier of a secret.</info>
|
||||
<return type='char *' info='the 16 bytes string or None in case of error'/>
|
||||
<arg name='secret' type='virSecretPtr' info='a secret object'/>
|
||||
</function>
|
||||
<function name='virSecretGetUUIDString' file='python'>
|
||||
<info>Fetch globally unique ID of the secret as a string.</info>
|
||||
<return type='char *' info='the UUID string or None in case of error'/>
|
||||
<arg name='secret' type='virSecretPtr' info='a secret object'/>
|
||||
</function>
|
||||
<function name='virConnectListNWFilters' file='libvirt' module='libvirt'>
|
||||
<info>List the defined network filters</info>
|
||||
<arg name='conn' type='virConnectPtr' info='virConnect connection'/>
|
||||
<return type='char *' info='the list of network filter IDs or None in case of error'/>
|
||||
</function>
|
||||
<function name='virConnectListAllNWFilters' file='python'>
|
||||
<info>returns list of all network fitlers</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<arg name='flags' type='unsigned int' info='optional flags'/>
|
||||
<return type='char *' info='the list of network filters or None in case of error'/>
|
||||
</function>
|
||||
<function name='virNWFilterLookupByUUID' file='python'>
|
||||
<info>Try to lookup a network filter on the given hypervisor based on its UUID.</info>
|
||||
<return type='virNWFilterPtr' info='a new network filter object or NULL in case of failure'/>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<arg name='uuid' type='const unsigned char *' info='the UUID string for the secret, must be 16 bytes'/>
|
||||
</function>
|
||||
<function name='virNWFilterGetUUID' file='python'>
|
||||
<info>Extract the UUID unique Identifier of a network filter.</info>
|
||||
<return type='char *' info='the 16 bytes string or None in case of error'/>
|
||||
<arg name='nwfilter' type='virNWFilterPtr' info='a network filter object'/>
|
||||
</function>
|
||||
<function name='virNWFilterGetUUIDString' file='python'>
|
||||
<info>Fetch globally unique ID of the network filter as a string.</info>
|
||||
<return type='char *' info='the UUID string or None in case of error'/>
|
||||
<arg name='nwfilter' type='virNWFilterPtr' info='a network filter object'/>
|
||||
</function>
|
||||
<function name='virConnectListInterfaces' file='python'>
|
||||
<info>list the running interfaces, stores the pointers to the names in @names</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<return type='char *' info='the list of Names of None in case of error'/>
|
||||
</function>
|
||||
<function name='virConnectListDefinedInterfaces' file='python'>
|
||||
<info>list the defined interfaces, stores the pointers to the names in @names</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<return type='char *' info='the list of Names of None in case of error'/>
|
||||
</function>
|
||||
<function name='virConnectListAllInterfaces' file='python'>
|
||||
<info>returns list of all interfaces</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<arg name='flags' type='unsigned int' info='optional flags'/>
|
||||
<return type='char *' info='the list of interfaces or None in case of error'/>
|
||||
</function>
|
||||
<function name='virConnectBaselineCPU' file='python'>
|
||||
<info>Computes the most feature-rich CPU which is compatible with all given host CPUs.</info>
|
||||
<return type='char *' info='XML description of the computed CPU or NULL on error.'/>
|
||||
<arg name='conn' type='virConnectPtr' info='virConnect connection'/>
|
||||
<arg name='xmlCPUs' type='const char **' info='array of XML descriptions of host CPUs'/>
|
||||
<arg name='flags' type='unsigned int' info='fine-tuning flags, currently unused, pass 0.'/>
|
||||
</function>
|
||||
<function name='virConnectGetCPUModelNames' file='python'>
|
||||
<info>Get the list of supported CPU models.</info>
|
||||
<return type='char *' info='list of supported CPU models'/>
|
||||
<arg name='conn' type='virConnectPtr' info='virConnect connection'/>
|
||||
<arg name='arch' type='const char *' info='arch'/>
|
||||
<arg name='flags' type='unsigned int' info='fine-tuning flags, currently unused, pass 0.'/>
|
||||
</function>
|
||||
<function name='virDomainSnapshotListNames' file='python'>
|
||||
<info>collect the list of snapshot names for the given domain</info>
|
||||
<arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
|
||||
<arg name='flags' type='unsigned int' info='flags'/>
|
||||
<return type='char *' info='the list of Names or None in case of error'/>
|
||||
</function>
|
||||
<function name='virDomainListAllSnapshots' file='python'>
|
||||
<info>returns the list of snapshots for the given domain</info>
|
||||
<arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
|
||||
<arg name='flags' type='unsigned int' info='flags'/>
|
||||
<return type='char *' info='the list of snapshots or None in case of error'/>
|
||||
</function>
|
||||
<function name='virDomainSnapshotListChildrenNames' file='python'>
|
||||
<info>collect the list of child snapshot names for the given snapshot</info>
|
||||
<arg name='snapshot' type='virDomainSnapshotPtr' info='pointer to the snapshot'/>
|
||||
<arg name='flags' type='unsigned int' info='flags'/>
|
||||
<return type='char *' info='the list of Names or None in case of error'/>
|
||||
</function>
|
||||
<function name='virDomainSnapshotListAllChildren' file='python'>
|
||||
<info>returns the list of child snapshots for the given snapshot</info>
|
||||
<arg name='snapshot' type='virDomainSnapshotPtr' info='pointer to the snapshot'/>
|
||||
<arg name='flags' type='unsigned int' info='flags'/>
|
||||
<return type='char *' info='the list of snapshots or None in case of error'/>
|
||||
</function>
|
||||
<function name='virDomainRevertToSnapshot' file='python'>
|
||||
<info>revert the domain to the given snapshot</info>
|
||||
<arg name='dom' type='virDomainPtr' info='dummy domain pointer'/>
|
||||
<arg name='snap' type='virDomainSnapshotPtr' info='pointer to the snapshot'/>
|
||||
<arg name='flags' type='unsigned int' info='flags'/>
|
||||
<return type='int' info="0 on success, -1 on error"/>
|
||||
</function>
|
||||
<function name='virDomainGetBlockJobInfo' file='python'>
|
||||
<info>Get progress information for a block job</info>
|
||||
<arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
|
||||
<arg name='path' type='const char *' info='Fully-qualified filename of disk'/>
|
||||
<arg name='flags' type='unsigned int' info='fine-tuning flags, currently unused, pass 0.'/>
|
||||
<return type='char *' info='A dictionary containing job information.' />
|
||||
</function>
|
||||
<function name='virDomainMigrateGetCompressionCache' file='python'>
|
||||
<info>Get current size of the cache (in bytes) used for compressing
|
||||
repeatedly transferred memory pages during live migration.</info>
|
||||
<arg name='domain' type='virDomainPtr' info='a domain object'/>
|
||||
<arg name='flags' type='unsigned int' info='flags, currently unused, pass 0.'/>
|
||||
<return type='unsigned long long' info='current cache size, or None in case of error'/>
|
||||
</function>
|
||||
<function name='virDomainMigrateGetMaxSpeed' file='python'>
|
||||
<info>Get currently configured maximum migration speed for a domain</info>
|
||||
<arg name='domain' type='virDomainPtr' info='a domain object'/>
|
||||
<arg name='flags' type='unsigned int' info='flags, currently unused, pass 0.'/>
|
||||
<return type='unsigned long' info='current max migration speed, or None in case of error'/>
|
||||
</function>
|
||||
<function name='virDomainMigrate3' file='python'>
|
||||
<info>Migrate the domain object from its current host to the destination host
|
||||
given by dconn (a connection to the destination host).</info>
|
||||
<arg name='domain' type='virDomainPtr' info='a domain object'/>
|
||||
<arg name='dconn' type='virConnectPtr' info='pointer to the destination host connection'/>
|
||||
<arg name='params' type='char *' info='dictionary with migration parameters'/>
|
||||
<arg name='flags' type='unsigned int' info='an OR'ed set of virDomainMigrateFlags'/>
|
||||
<return type='virDomainPtr' info='a new domain object or NULL in case of failure'/>
|
||||
</function>
|
||||
<function name='virDomainMigrateToURI3' file='python'>
|
||||
<info>Migrate the domain object from its current host to the destination host
|
||||
given by URI.</info>
|
||||
<arg name='domain' type='virDomainPtr' info='a domain object'/>
|
||||
<arg name='dconnuri' type='virConnectPtr' info='URI for target libvirtd if @flags includes VIR_MIGRATE_PEER2PEER'/>
|
||||
<arg name='params' type='char *' info='dictionary with migration parameters'/>
|
||||
<arg name='flags' type='unsigned int' info='an OR'ed set of virDomainMigrateFlags'/>
|
||||
<return type='int' info='0 in case of success, -1 in case of failure.'/>
|
||||
</function>
|
||||
<function name='virDomainSetBlockIoTune' file='python'>
|
||||
<info>Change the I/O tunables for a block device</info>
|
||||
<arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
|
||||
<arg name='disk' type='const char *' info='disk name'/>
|
||||
<arg name='params' type='virTypedParameterPtr' info='Pointer to blkio tuning params object'/>
|
||||
<arg name='flags' type='unsigned int' info='an OR'ed set of virDomainModificationImpact'/>
|
||||
<return type='int' info='0 in case of success, -1 in case of failure'/>
|
||||
</function>
|
||||
<function name='virDomainGetBlockIoTune' file='python'>
|
||||
<info>Get the I/O tunables for a block device</info>
|
||||
<arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
|
||||
<arg name='disk' type='const char *' info='disk name'/>
|
||||
<arg name='flags' type='unsigned int' info='an OR'ed set of virDomainModificationImpact'/>
|
||||
<return type='char *' info='the I/O tunables value or None in case of error'/>
|
||||
</function>
|
||||
<function name='virDomainBlockPeek' file='python'>
|
||||
<info>Read the contents of domain's disk device</info>
|
||||
<arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
|
||||
<arg name='disk' type='const char *' info='disk name'/>
|
||||
<arg name='offset' type='unsigned long long' info='offset within block device'/>
|
||||
<arg name='size' type='size_t' info='size to read'/>
|
||||
<arg name='flags' type='unsigned int' info='unused, always pass 0'/>
|
||||
<return type='char *' info='the returned buffer or None in case of error'/>
|
||||
</function>
|
||||
<function name='virDomainMemoryPeek' file='python'>
|
||||
<info>Read the contents of domain's memory</info>
|
||||
<arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
|
||||
<arg name='start' type='unsigned long long' info='start of memory to peek'/>
|
||||
<arg name='size' type='size_t' info='size of memory to peek'/>
|
||||
<arg name='flags' type='unsigned int' info='an OR'ed set of virDomainMemoryFlags'/>
|
||||
<return type='char *' info='the returned buffer or None in case of error'/>
|
||||
</function>
|
||||
<function name='virDomainGetDiskErrors' file='python'>
|
||||
<info>Extract errors on disk devices.</info>
|
||||
<return type='char *' info='dictionary of disks and their errors or None in case of error'/>
|
||||
<arg name='domain' type='virDomainPtr' info='a domain object'/>
|
||||
<arg name='flags' type='unsigned int' info='unused, always pass 0'/>
|
||||
</function>
|
||||
<function name='virNodeSetMemoryParameters' file='python'>
|
||||
<info>Change the node memory tunables</info>
|
||||
<return type='int' info='-1 in case of error, 0 in case of success.'/>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<arg name='params' type='virTypedParameterPtr' info='pointer to the memory tunable objects'/>
|
||||
<arg name='flags' type='int' info='unused, always pass 0'/>
|
||||
</function>
|
||||
<function name='virNodeGetMemoryParameters' file='python'>
|
||||
<info>Get the node memory parameters</info>
|
||||
<return type='char *' info='None in case of error, returns a dictionary of params'/>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<arg name='flags' type='int' info='unused, always pass 0'/>
|
||||
</function>
|
||||
<function name='virNodeGetCPUMap' file='python'>
|
||||
<info>Get node CPU information</info>
|
||||
<return type='char *' info='(cpunum, cpumap, online) on success, None on error'/>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<arg name='flags' type='int' info='unused, pass 0'/>
|
||||
</function>
|
||||
</symbols>
|
||||
</api>
|
|
@ -1,351 +0,0 @@
|
|||
def __del__(self):
|
||||
try:
|
||||
for cb,opaque in self.domainEventCallbacks.items():
|
||||
del self.domainEventCallbacks[cb]
|
||||
del self.domainEventCallbacks
|
||||
libvirtmod.virConnectDomainEventDeregister(self._o, self)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
if self._o is not None:
|
||||
libvirtmod.virConnectClose(self._o)
|
||||
self._o = None
|
||||
|
||||
def domainEventDeregister(self, cb):
|
||||
"""Removes a Domain Event Callback. De-registering for a
|
||||
domain callback will disable delivery of this event type """
|
||||
try:
|
||||
del self.domainEventCallbacks[cb]
|
||||
if len(self.domainEventCallbacks) == 0:
|
||||
del self.domainEventCallbacks
|
||||
ret = libvirtmod.virConnectDomainEventDeregister(self._o, self)
|
||||
if ret == -1: raise libvirtError ('virConnectDomainEventDeregister() failed', conn=self)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def domainEventRegister(self, cb, opaque):
|
||||
"""Adds a Domain Event Callback. Registering for a domain
|
||||
callback will enable delivery of the events """
|
||||
try:
|
||||
self.domainEventCallbacks[cb] = opaque
|
||||
except AttributeError:
|
||||
self.domainEventCallbacks = {cb:opaque}
|
||||
ret = libvirtmod.virConnectDomainEventRegister(self._o, self)
|
||||
if ret == -1: raise libvirtError ('virConnectDomainEventRegister() failed', conn=self)
|
||||
|
||||
def _dispatchDomainEventCallbacks(self, dom, event, detail):
|
||||
"""Dispatches events to python user domain event callbacks
|
||||
"""
|
||||
try:
|
||||
for cb,opaque in self.domainEventCallbacks.items():
|
||||
cb(self,dom,event,detail,opaque)
|
||||
return 0
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def _dispatchDomainEventLifecycleCallback(self, dom, event, detail, cbData):
|
||||
"""Dispatches events to python user domain lifecycle event callbacks
|
||||
"""
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(self, virDomain(self, _obj=dom), event, detail, opaque)
|
||||
return 0
|
||||
|
||||
def _dispatchDomainEventGenericCallback(self, dom, cbData):
|
||||
"""Dispatches events to python user domain generic event callbacks
|
||||
"""
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(self, virDomain(self, _obj=dom), opaque)
|
||||
return 0
|
||||
|
||||
def _dispatchDomainEventRTCChangeCallback(self, dom, offset, cbData):
|
||||
"""Dispatches events to python user domain RTC change event callbacks
|
||||
"""
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(self, virDomain(self, _obj=dom), offset ,opaque)
|
||||
return 0
|
||||
|
||||
def _dispatchDomainEventWatchdogCallback(self, dom, action, cbData):
|
||||
"""Dispatches events to python user domain watchdog event callbacks
|
||||
"""
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(self, virDomain(self, _obj=dom), action, opaque)
|
||||
return 0
|
||||
|
||||
def _dispatchDomainEventIOErrorCallback(self, dom, srcPath, devAlias,
|
||||
action, cbData):
|
||||
"""Dispatches events to python user domain IO error event callbacks
|
||||
"""
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(self, virDomain(self, _obj=dom), srcPath, devAlias, action, opaque)
|
||||
return 0
|
||||
|
||||
def _dispatchDomainEventIOErrorReasonCallback(self, dom, srcPath,
|
||||
devAlias, action, reason,
|
||||
cbData):
|
||||
"""Dispatches events to python user domain IO error event callbacks
|
||||
"""
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(self, virDomain(self, _obj=dom), srcPath, devAlias, action,
|
||||
reason, opaque)
|
||||
return 0
|
||||
|
||||
def _dispatchDomainEventGraphicsCallback(self, dom, phase, localAddr,
|
||||
remoteAddr, authScheme, subject,
|
||||
cbData):
|
||||
"""Dispatches events to python user domain graphics event callbacks
|
||||
"""
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(self, virDomain(self, _obj=dom), phase, localAddr, remoteAddr,
|
||||
authScheme, subject, opaque)
|
||||
return 0
|
||||
|
||||
def dispatchDomainEventBlockPullCallback(self, dom, path, type, status, cbData):
|
||||
"""Dispatches events to python user domain blockJob event callbacks
|
||||
"""
|
||||
try:
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(self, virDomain(self, _obj=dom), path, type, status, opaque)
|
||||
return 0
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def _dispatchDomainEventDiskChangeCallback(self, dom, oldSrcPath, newSrcPath, devAlias, reason, cbData):
|
||||
"""Dispatches event to python user domain diskChange event callbacks
|
||||
"""
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(self, virDomain(self, _obj=dom), oldSrcPath, newSrcPath, devAlias, reason, opaque)
|
||||
return 0
|
||||
|
||||
def _dispatchDomainEventTrayChangeCallback(self, dom, devAlias, reason, cbData):
|
||||
"""Dispatches event to python user domain trayChange event callbacks
|
||||
"""
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(self, virDomain(self, _obj=dom), devAlias, reason, opaque)
|
||||
return 0
|
||||
|
||||
def _dispatchDomainEventPMWakeupCallback(self, dom, reason, cbData):
|
||||
"""Dispatches event to python user domain pmwakeup event callbacks
|
||||
"""
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(self, virDomain(self, _obj=dom), reason, opaque)
|
||||
return 0
|
||||
|
||||
def _dispatchDomainEventPMSuspendCallback(self, dom, reason, cbData):
|
||||
"""Dispatches event to python user domain pmsuspend event callbacks
|
||||
"""
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(self, virDomain(self, _obj=dom), reason, opaque)
|
||||
return 0
|
||||
|
||||
def _dispatchDomainEventBalloonChangeCallback(self, dom, actual, cbData):
|
||||
"""Dispatches events to python user domain balloon change event callbacks
|
||||
"""
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(self, virDomain(self, _obj=dom), actual, opaque)
|
||||
return 0
|
||||
|
||||
def _dispatchDomainEventPMSuspendDiskCallback(self, dom, reason, cbData):
|
||||
"""Dispatches event to python user domain pmsuspend-disk event callbacks
|
||||
"""
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(self, virDomain(self, _obj=dom), reason, opaque)
|
||||
return 0
|
||||
|
||||
def _dispatchDomainEventDeviceRemovedCallback(self, dom, devAlias, cbData):
|
||||
"""Dispatches event to python user domain device removed event callbacks
|
||||
"""
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(self, virDomain(self, _obj=dom), devAlias, opaque)
|
||||
return 0
|
||||
|
||||
def domainEventDeregisterAny(self, callbackID):
|
||||
"""Removes a Domain Event Callback. De-registering for a
|
||||
domain callback will disable delivery of this event type """
|
||||
try:
|
||||
ret = libvirtmod.virConnectDomainEventDeregisterAny(self._o, callbackID)
|
||||
if ret == -1: raise libvirtError ('virConnectDomainEventDeregisterAny() failed', conn=self)
|
||||
del self.domainEventCallbackID[callbackID]
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def domainEventRegisterAny(self, dom, eventID, cb, opaque):
|
||||
"""Adds a Domain Event Callback. Registering for a domain
|
||||
callback will enable delivery of the events """
|
||||
if not hasattr(self, 'domainEventCallbackID'):
|
||||
self.domainEventCallbackID = {}
|
||||
cbData = { "cb": cb, "conn": self, "opaque": opaque }
|
||||
if dom is None:
|
||||
ret = libvirtmod.virConnectDomainEventRegisterAny(self._o, None, eventID, cbData)
|
||||
else:
|
||||
ret = libvirtmod.virConnectDomainEventRegisterAny(self._o, dom._o, eventID, cbData)
|
||||
if ret == -1:
|
||||
raise libvirtError ('virConnectDomainEventRegisterAny() failed', conn=self)
|
||||
self.domainEventCallbackID[ret] = opaque
|
||||
return ret
|
||||
|
||||
def listAllDomains(self, flags=0):
|
||||
"""List all domains and returns a list of domain objects"""
|
||||
ret = libvirtmod.virConnectListAllDomains(self._o, flags)
|
||||
if ret is None:
|
||||
raise libvirtError("virConnectListAllDomains() failed", conn=self)
|
||||
|
||||
retlist = list()
|
||||
for domptr in ret:
|
||||
retlist.append(virDomain(self, _obj=domptr))
|
||||
|
||||
return retlist
|
||||
|
||||
def listAllStoragePools(self, flags=0):
|
||||
"""Returns a list of storage pool objects"""
|
||||
ret = libvirtmod.virConnectListAllStoragePools(self._o, flags)
|
||||
if ret is None:
|
||||
raise libvirtError("virConnectListAllStoragePools() failed", conn=self)
|
||||
|
||||
retlist = list()
|
||||
for poolptr in ret:
|
||||
retlist.append(virStoragePool(self, _obj=poolptr))
|
||||
|
||||
return retlist
|
||||
|
||||
def listAllNetworks(self, flags=0):
|
||||
"""Returns a list of network objects"""
|
||||
ret = libvirtmod.virConnectListAllNetworks(self._o, flags)
|
||||
if ret is None:
|
||||
raise libvirtError("virConnectListAllNetworks() failed", conn=self)
|
||||
|
||||
retlist = list()
|
||||
for netptr in ret:
|
||||
retlist.append(virNetwork(self, _obj=netptr))
|
||||
|
||||
return retlist
|
||||
|
||||
def listAllInterfaces(self, flags=0):
|
||||
"""Returns a list of interface objects"""
|
||||
ret = libvirtmod.virConnectListAllInterfaces(self._o, flags)
|
||||
if ret is None:
|
||||
raise libvirtError("virConnectListAllInterfaces() failed", conn=self)
|
||||
|
||||
retlist = list()
|
||||
for ifaceptr in ret:
|
||||
retlist.append(virInterface(self, _obj=ifaceptr))
|
||||
|
||||
return retlist
|
||||
|
||||
def listAllDevices(self, flags=0):
|
||||
"""Returns a list of host node device objects"""
|
||||
ret = libvirtmod.virConnectListAllNodeDevices(self._o, flags)
|
||||
if ret is None:
|
||||
raise libvirtError("virConnectListAllNodeDevices() failed", conn=self)
|
||||
|
||||
retlist = list()
|
||||
for devptr in ret:
|
||||
retlist.append(virNodeDevice(self, _obj=devptr))
|
||||
|
||||
return retlist
|
||||
|
||||
def listAllNWFilters(self, flags=0):
|
||||
"""Returns a list of network filter objects"""
|
||||
ret = libvirtmod.virConnectListAllNWFilters(self._o, flags)
|
||||
if ret is None:
|
||||
raise libvirtError("virConnectListAllNWFilters() failed", conn=self)
|
||||
|
||||
retlist = list()
|
||||
for filter_ptr in ret:
|
||||
retlist.append(virNWFilter(self, _obj=filter_ptr))
|
||||
|
||||
return retlist
|
||||
|
||||
def listAllSecrets(self, flags=0):
|
||||
"""Returns a list of secret objects"""
|
||||
ret = libvirtmod.virConnectListAllSecrets(self._o, flags)
|
||||
if ret is None:
|
||||
raise libvirtError("virConnectListAllSecrets() failed", conn=self)
|
||||
|
||||
retlist = list()
|
||||
for secret_ptr in ret:
|
||||
retlist.append(virSecret(self, _obj=secret_ptr))
|
||||
|
||||
return retlist
|
||||
|
||||
def _dispatchCloseCallback(self, reason, cbData):
|
||||
"""Dispatches events to python user close callback"""
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(self, reason, opaque)
|
||||
return 0
|
||||
|
||||
|
||||
def unregisterCloseCallback(self):
|
||||
"""Removes a close event callback"""
|
||||
ret = libvirtmod.virConnectUnregisterCloseCallback(self._o)
|
||||
if ret == -1: raise libvirtError ('virConnectUnregisterCloseCallback() failed', conn=self)
|
||||
|
||||
def registerCloseCallback(self, cb, opaque):
|
||||
"""Adds a close event callback, providing a notification
|
||||
when a connection fails / closes"""
|
||||
cbData = { "cb": cb, "conn": self, "opaque": opaque }
|
||||
ret = libvirtmod.virConnectRegisterCloseCallback(self._o, cbData)
|
||||
if ret == -1:
|
||||
raise libvirtError ('virConnectRegisterCloseCallback() failed', conn=self)
|
||||
return ret
|
||||
|
||||
def createXMLWithFiles(self, xmlDesc, files, flags=0):
|
||||
"""Launch a new guest domain, based on an XML description similar
|
||||
to the one returned by virDomainGetXMLDesc()
|
||||
This function may require privileged access to the hypervisor.
|
||||
The domain is not persistent, so its definition will disappear when it
|
||||
is destroyed, or if the host is restarted (see virDomainDefineXML() to
|
||||
define persistent domains).
|
||||
|
||||
@files provides an array of file descriptors which will be
|
||||
made available to the 'init' process of the guest. The file
|
||||
handles exposed to the guest will be renumbered to start
|
||||
from 3 (ie immediately following stderr). This is only
|
||||
supported for guests which use container based virtualization
|
||||
technology.
|
||||
|
||||
If the VIR_DOMAIN_START_PAUSED flag is set, the guest domain
|
||||
will be started, but its CPUs will remain paused. The CPUs
|
||||
can later be manually started using virDomainResume.
|
||||
|
||||
If the VIR_DOMAIN_START_AUTODESTROY flag is set, the guest
|
||||
domain will be automatically destroyed when the virConnectPtr
|
||||
object is finally released. This will also happen if the
|
||||
client application crashes / loses its connection to the
|
||||
libvirtd daemon. Any domains marked for auto destroy will
|
||||
block attempts at migration, save-to-file, or snapshots. """
|
||||
ret = libvirtmod.virDomainCreateXMLWithFiles(self._o, xmlDesc, files, flags)
|
||||
if ret is None:raise libvirtError('virDomainCreateXMLWithFiles() failed', conn=self)
|
||||
__tmp = virDomain(self,_obj=ret)
|
||||
return __tmp
|
|
@ -1,49 +0,0 @@
|
|||
def listAllSnapshots(self, flags=0):
|
||||
"""List all snapshots and returns a list of snapshot objects"""
|
||||
ret = libvirtmod.virDomainListAllSnapshots(self._o, flags)
|
||||
if ret is None:
|
||||
raise libvirtError("virDomainListAllSnapshots() failed", conn=self)
|
||||
|
||||
retlist = list()
|
||||
for snapptr in ret:
|
||||
retlist.append(virDomainSnapshot(self, _obj=snapptr))
|
||||
|
||||
return retlist
|
||||
|
||||
|
||||
def createWithFiles(self, files, flags=0):
|
||||
"""Launch a defined domain. If the call succeeds the domain moves from the
|
||||
defined to the running domains pools.
|
||||
|
||||
@files provides an array of file descriptors which will be
|
||||
made available to the 'init' process of the guest. The file
|
||||
handles exposed to the guest will be renumbered to start
|
||||
from 3 (ie immediately following stderr). This is only
|
||||
supported for guests which use container based virtualization
|
||||
technology.
|
||||
|
||||
If the VIR_DOMAIN_START_PAUSED flag is set, or if the guest domain
|
||||
has a managed save image that requested paused state (see
|
||||
virDomainManagedSave()) the guest domain will be started, but its
|
||||
CPUs will remain paused. The CPUs can later be manually started
|
||||
using virDomainResume(). In all other cases, the guest domain will
|
||||
be running.
|
||||
|
||||
If the VIR_DOMAIN_START_AUTODESTROY flag is set, the guest
|
||||
domain will be automatically destroyed when the virConnectPtr
|
||||
object is finally released. This will also happen if the
|
||||
client application crashes / loses its connection to the
|
||||
libvirtd daemon. Any domains marked for auto destroy will
|
||||
block attempts at migration, save-to-file, or snapshots.
|
||||
|
||||
If the VIR_DOMAIN_START_BYPASS_CACHE flag is set, and there is a
|
||||
managed save file for this domain (created by virDomainManagedSave()),
|
||||
then libvirt will attempt to bypass the file system cache while restoring
|
||||
the file, or fail if it cannot do so for the given system; this can allow
|
||||
less pressure on file system cache, but also risks slowing loads from NFS.
|
||||
|
||||
If the VIR_DOMAIN_START_FORCE_BOOT flag is set, then any managed save
|
||||
file for this domain is discarded, and the domain boots from scratch. """
|
||||
ret = libvirtmod.virDomainCreateWithFiles(self._o, files, flags)
|
||||
if ret == -1: raise libvirtError ('virDomainCreateWithFiles() failed', dom=self)
|
||||
return ret
|
|
@ -1,19 +0,0 @@
|
|||
def getConnect(self):
|
||||
"""Get the connection that owns the domain that a snapshot was created for"""
|
||||
return self.connect()
|
||||
|
||||
def getDomain(self):
|
||||
"""Get the domain that a snapshot was created for"""
|
||||
return self.domain()
|
||||
|
||||
def listAllChildren(self, flags=0):
|
||||
"""List all child snapshots and returns a list of snapshot objects"""
|
||||
ret = libvirtmod.virDomainSnapshotListAllChildren(self._o, flags)
|
||||
if ret is None:
|
||||
raise libvirtError("virDomainSnapshotListAllChildren() failed", conn=self)
|
||||
|
||||
retlist = list()
|
||||
for snapptr in ret:
|
||||
retlist.append(virDomainSnapshot(self, _obj=snapptr))
|
||||
|
||||
return retlist
|
|
@ -1,11 +0,0 @@
|
|||
def listAllVolumes(self, flags=0):
|
||||
"""List all storage volumes and returns a list of storage volume objects"""
|
||||
ret = libvirtmod.virStoragePoolListAllVolumes(self._o, flags)
|
||||
if ret is None:
|
||||
raise libvirtError("virStoragePoolListAllVolumes() failed", conn=self)
|
||||
|
||||
retlist = list()
|
||||
for volptr in ret:
|
||||
retlist.append(virStorageVol(self, _obj=volptr))
|
||||
|
||||
return retlist
|
|
@ -1,125 +0,0 @@
|
|||
def __del__(self):
|
||||
try:
|
||||
if self.cb:
|
||||
libvirtmod.virStreamEventRemoveCallback(self._o)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
if self._o is not None:
|
||||
libvirtmod.virStreamFree(self._o)
|
||||
self._o = None
|
||||
|
||||
def _dispatchStreamEventCallback(self, events, cbData):
|
||||
"""
|
||||
Dispatches events to python user's stream event callbacks
|
||||
"""
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(self, events, opaque)
|
||||
return 0
|
||||
|
||||
def eventAddCallback(self, events, cb, opaque):
|
||||
self.cb = cb
|
||||
cbData = {"stream": self, "cb" : cb, "opaque" : opaque}
|
||||
ret = libvirtmod.virStreamEventAddCallback(self._o, events, cbData)
|
||||
if ret == -1: raise libvirtError ('virStreamEventAddCallback() failed')
|
||||
|
||||
def recvAll(self, handler, opaque):
|
||||
"""Receive the entire data stream, sending the data to the
|
||||
requested data sink. This is simply a convenient alternative
|
||||
to virStreamRecv, for apps that do blocking-I/o.
|
||||
|
||||
A hypothetical handler function looks like:
|
||||
|
||||
def handler(stream, # virStream instance
|
||||
buf, # string containing received data
|
||||
opaque): # extra data passed to recvAll as opaque
|
||||
fd = opaque
|
||||
return os.write(fd, buf)
|
||||
"""
|
||||
while True:
|
||||
got = self.recv(1024*64)
|
||||
if got == -2:
|
||||
raise libvirtError("cannot use recvAll with "
|
||||
"nonblocking stream")
|
||||
if len(got) == 0:
|
||||
break
|
||||
|
||||
try:
|
||||
ret = handler(self, got, opaque)
|
||||
if type(ret) is int and ret < 0:
|
||||
raise RuntimeError("recvAll handler returned %d" % ret)
|
||||
except Exception, e:
|
||||
try:
|
||||
self.abort()
|
||||
except:
|
||||
pass
|
||||
raise e
|
||||
|
||||
def sendAll(self, handler, opaque):
|
||||
"""
|
||||
Send the entire data stream, reading the data from the
|
||||
requested data source. This is simply a convenient alternative
|
||||
to virStreamSend, for apps that do blocking-I/o.
|
||||
|
||||
A hypothetical handler function looks like:
|
||||
|
||||
def handler(stream, # virStream instance
|
||||
nbytes, # int amt of data to read
|
||||
opaque): # extra data passed to recvAll as opaque
|
||||
fd = opaque
|
||||
return os.read(fd, nbytes)
|
||||
"""
|
||||
while True:
|
||||
try:
|
||||
got = handler(self, 1024*64, opaque)
|
||||
except:
|
||||
try:
|
||||
self.abort()
|
||||
except:
|
||||
pass
|
||||
raise e
|
||||
|
||||
if got == "":
|
||||
break
|
||||
|
||||
ret = self.send(got)
|
||||
if ret == -2:
|
||||
raise libvirtError("cannot use sendAll with "
|
||||
"nonblocking stream")
|
||||
|
||||
def recv(self, nbytes):
|
||||
"""Reads a series of bytes from the stream. This method may
|
||||
block the calling application for an arbitrary amount
|
||||
of time.
|
||||
|
||||
Errors are not guaranteed to be reported synchronously
|
||||
with the call, but may instead be delayed until a
|
||||
subsequent call.
|
||||
|
||||
On success, the received data is returned. On failure, an
|
||||
exception is raised. If the stream is a NONBLOCK stream and
|
||||
the request would block, integer -2 is returned.
|
||||
"""
|
||||
ret = libvirtmod.virStreamRecv(self._o, nbytes)
|
||||
if ret is None: raise libvirtError ('virStreamRecv() failed')
|
||||
return ret
|
||||
|
||||
def send(self, data):
|
||||
"""Write a series of bytes to the stream. This method may
|
||||
block the calling application for an arbitrary amount
|
||||
of time. Once an application has finished sending data
|
||||
it should call virStreamFinish to wait for successful
|
||||
confirmation from the driver, or detect any error
|
||||
|
||||
This method may not be used if a stream source has been
|
||||
registered
|
||||
|
||||
Errors are not guaranteed to be reported synchronously
|
||||
with the call, but may instead be delayed until a
|
||||
subsequent call.
|
||||
"""
|
||||
ret = libvirtmod.virStreamSend(self._o, data, len(data))
|
||||
if ret == -1: raise libvirtError ('virStreamSend() failed')
|
||||
return ret
|
File diff suppressed because it is too large
Load Diff
|
@ -1,209 +0,0 @@
|
|||
#
|
||||
# Manually written part of python bindings for libvirt
|
||||
#
|
||||
|
||||
# On cygwin, the DLL is called cygvirtmod.dll
|
||||
try:
|
||||
import libvirtmod
|
||||
except ImportError, lib_e:
|
||||
try:
|
||||
import cygvirtmod as libvirtmod
|
||||
except ImportError, cyg_e:
|
||||
if str(cyg_e).count("No module named"):
|
||||
raise lib_e
|
||||
|
||||
import types
|
||||
|
||||
# The root of all libvirt errors.
|
||||
class libvirtError(Exception):
|
||||
def __init__(self, defmsg, conn=None, dom=None, net=None, pool=None, vol=None):
|
||||
|
||||
# Never call virConnGetLastError().
|
||||
# virGetLastError() is now thread local
|
||||
err = virGetLastError()
|
||||
if err is None:
|
||||
msg = defmsg
|
||||
else:
|
||||
msg = err[2]
|
||||
|
||||
Exception.__init__(self, msg)
|
||||
|
||||
self.err = err
|
||||
|
||||
def get_error_code(self):
|
||||
if self.err is None:
|
||||
return None
|
||||
return self.err[0]
|
||||
|
||||
def get_error_domain(self):
|
||||
if self.err is None:
|
||||
return None
|
||||
return self.err[1]
|
||||
|
||||
def get_error_message(self):
|
||||
if self.err is None:
|
||||
return None
|
||||
return self.err[2]
|
||||
|
||||
def get_error_level(self):
|
||||
if self.err is None:
|
||||
return None
|
||||
return self.err[3]
|
||||
|
||||
def get_str1(self):
|
||||
if self.err is None:
|
||||
return None
|
||||
return self.err[4]
|
||||
|
||||
def get_str2(self):
|
||||
if self.err is None:
|
||||
return None
|
||||
return self.err[5]
|
||||
|
||||
def get_str3(self):
|
||||
if self.err is None:
|
||||
return None
|
||||
return self.err[6]
|
||||
|
||||
def get_int1(self):
|
||||
if self.err is None:
|
||||
return None
|
||||
return self.err[7]
|
||||
|
||||
def get_int2(self):
|
||||
if self.err is None:
|
||||
return None
|
||||
return self.err[8]
|
||||
|
||||
#
|
||||
# register the libvirt global error handler
|
||||
#
|
||||
def registerErrorHandler(f, ctx):
|
||||
"""Register a Python function for error reporting.
|
||||
The function is called back as f(ctx, error), with error
|
||||
being a list of information about the error being raised.
|
||||
Returns 1 in case of success."""
|
||||
return libvirtmod.virRegisterErrorHandler(f,ctx)
|
||||
|
||||
def openAuth(uri, auth, flags=0):
|
||||
ret = libvirtmod.virConnectOpenAuth(uri, auth, flags)
|
||||
if ret is None:raise libvirtError('virConnectOpenAuth() failed')
|
||||
return virConnect(_obj=ret)
|
||||
|
||||
|
||||
#
|
||||
# Return library version.
|
||||
#
|
||||
def getVersion (name = None):
|
||||
"""If no name parameter is passed (or name is None) then the
|
||||
version of the libvirt library is returned as an integer.
|
||||
|
||||
If a name is passed and it refers to a driver linked to the
|
||||
libvirt library, then this returns a tuple of (library version,
|
||||
driver version).
|
||||
|
||||
If the name passed refers to a non-existent driver, then you
|
||||
will get the exception 'no support for hypervisor'.
|
||||
|
||||
Versions numbers are integers: 1000000*major + 1000*minor + release."""
|
||||
if name is None:
|
||||
ret = libvirtmod.virGetVersion ()
|
||||
else:
|
||||
ret = libvirtmod.virGetVersion (name)
|
||||
if ret is None: raise libvirtError ("virGetVersion() failed")
|
||||
return ret
|
||||
|
||||
|
||||
#
|
||||
# Invoke an EventHandle callback
|
||||
#
|
||||
def _eventInvokeHandleCallback(watch, fd, event, opaque, opaquecompat=None):
|
||||
"""
|
||||
Invoke the Event Impl Handle Callback in C
|
||||
"""
|
||||
# libvirt 0.9.2 and earlier required custom event loops to know
|
||||
# that opaque=(cb, original_opaque) and pass the values individually
|
||||
# to this wrapper. This should handle the back compat case, and make
|
||||
# future invocations match the virEventHandleCallback prototype
|
||||
if opaquecompat:
|
||||
callback = opaque
|
||||
opaque = opaquecompat
|
||||
else:
|
||||
callback = opaque[0]
|
||||
opaque = opaque[1]
|
||||
|
||||
libvirtmod.virEventInvokeHandleCallback(watch, fd, event, callback, opaque)
|
||||
|
||||
#
|
||||
# Invoke an EventTimeout callback
|
||||
#
|
||||
def _eventInvokeTimeoutCallback(timer, opaque, opaquecompat=None):
|
||||
"""
|
||||
Invoke the Event Impl Timeout Callback in C
|
||||
"""
|
||||
# libvirt 0.9.2 and earlier required custom event loops to know
|
||||
# that opaque=(cb, original_opaque) and pass the values individually
|
||||
# to this wrapper. This should handle the back compat case, and make
|
||||
# future invocations match the virEventTimeoutCallback prototype
|
||||
if opaquecompat:
|
||||
callback = opaque
|
||||
opaque = opaquecompat
|
||||
else:
|
||||
callback = opaque[0]
|
||||
opaque = opaque[1]
|
||||
|
||||
libvirtmod.virEventInvokeTimeoutCallback(timer, callback, opaque)
|
||||
|
||||
def _dispatchEventHandleCallback(watch, fd, events, cbData):
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(watch, fd, events, opaque)
|
||||
return 0
|
||||
|
||||
def _dispatchEventTimeoutCallback(timer, cbData):
|
||||
cb = cbData["cb"]
|
||||
opaque = cbData["opaque"]
|
||||
|
||||
cb(timer, opaque)
|
||||
return 0
|
||||
|
||||
def virEventAddHandle(fd, events, cb, opaque):
|
||||
"""
|
||||
register a callback for monitoring file handle events
|
||||
|
||||
@fd: file handle to monitor for events
|
||||
@events: bitset of events to watch from virEventHandleType constants
|
||||
@cb: callback to invoke when an event occurs
|
||||
@opaque: user data to pass to callback
|
||||
|
||||
Example callback prototype is:
|
||||
def cb(watch, # int id of the handle
|
||||
fd, # int file descriptor the event occurred on
|
||||
events, # int bitmap of events that have occurred
|
||||
opaque): # opaque data passed to eventAddHandle
|
||||
"""
|
||||
cbData = {"cb" : cb, "opaque" : opaque}
|
||||
ret = libvirtmod.virEventAddHandle(fd, events, cbData)
|
||||
if ret == -1: raise libvirtError ('virEventAddHandle() failed')
|
||||
return ret
|
||||
|
||||
def virEventAddTimeout(timeout, cb, opaque):
|
||||
"""
|
||||
register a callback for a timer event
|
||||
|
||||
@timeout: time between events in milliseconds
|
||||
@cb: callback to invoke when an event occurs
|
||||
@opaque: user data to pass to callback
|
||||
|
||||
Setting timeout to -1 will disable the timer. Setting the timeout
|
||||
to zero will cause it to fire on every event loop iteration.
|
||||
|
||||
Example callback prototype is:
|
||||
def cb(timer, # int id of the timer
|
||||
opaque): # opaque data passed to eventAddTimeout
|
||||
"""
|
||||
cbData = {"cb" : cb, "opaque" : opaque}
|
||||
ret = libvirtmod.virEventAddTimeout(timeout, cbData)
|
||||
if ret == -1: raise libvirtError ('virEventAddTimeout() failed')
|
||||
return ret
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<api name='libvir-qemu-python'>
|
||||
<symbols>
|
||||
<function name='virDomainQemuMonitorCommand' file='python-qemu'>
|
||||
<info>Send an arbitrary monitor command through qemu monitor of domain</info>
|
||||
<return type='str *' info='the command output or None in case of error'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
|
||||
<arg name='cmd' type='const char *' info='the command which will be passed to QEMU monitor'/>
|
||||
<arg name='flags' type='unsigned int' info='an OR'ed set of virDomainQemuMonitorCommandFlags'/>
|
||||
</function>
|
||||
<function name='virDomainQemuAgentCommand' file='python-qemu'>
|
||||
<info>Send a Guest Agent command to domain</info>
|
||||
<return type='str *' info='the command output'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to the domain'/>
|
||||
<arg name='cmd' type='const char *' info='guest agent command on domain'/>
|
||||
<arg name='timeout' type='int' info='timeout seconds'/>
|
||||
<arg name='flags' type='unsigned int' info='execution flags'/>
|
||||
</function>
|
||||
</symbols>
|
||||
</api>
|
|
@ -1,154 +0,0 @@
|
|||
/*
|
||||
* libvir.c: this modules implements the main part of the glue of the
|
||||
* libvir library and the Python interpreter. It provides the
|
||||
* entry points where an automatically generated stub is
|
||||
* unpractical
|
||||
*
|
||||
* Copyright (C) 2011-2012 Red Hat, Inc.
|
||||
*
|
||||
* Daniel Veillard <veillard@redhat.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Horrible kludge to work around even more horrible name-space pollution
|
||||
via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
|
||||
which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
|
||||
#undef HAVE_PTHREAD_H
|
||||
|
||||
#include <Python.h>
|
||||
#include <libvirt/libvirt-qemu.h>
|
||||
#include <libvirt/virterror.h>
|
||||
#include "typewrappers.h"
|
||||
#include "libvirt-qemu.h"
|
||||
#include "viralloc.h"
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
extern void initlibvirtmod_qemu(void);
|
||||
#else
|
||||
extern void initcygvirtmod_qemu(void);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
# define DEBUG_ERROR 1
|
||||
#endif
|
||||
|
||||
#if DEBUG_ERROR
|
||||
# define DEBUG(fmt, ...) \
|
||||
printf(fmt, __VA_ARGS__)
|
||||
#else
|
||||
# define DEBUG(fmt, ...) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
/* The two-statement sequence "Py_INCREF(Py_None); return Py_None;"
|
||||
is so common that we encapsulate it here. Now, each use is simply
|
||||
return VIR_PY_NONE; */
|
||||
#define VIR_PY_NONE (Py_INCREF (Py_None), Py_None)
|
||||
#define VIR_PY_INT_FAIL (libvirt_intWrap(-1))
|
||||
#define VIR_PY_INT_SUCCESS (libvirt_intWrap(0))
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Statistics *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
static PyObject *
|
||||
libvirt_qemu_virDomainQemuMonitorCommand(PyObject *self ATTRIBUTE_UNUSED,
|
||||
PyObject *args) {
|
||||
PyObject *py_retval;
|
||||
char *result = NULL;
|
||||
virDomainPtr domain;
|
||||
PyObject *pyobj_domain;
|
||||
unsigned int flags;
|
||||
char *cmd;
|
||||
int c_retval;
|
||||
|
||||
if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainQemuMonitorCommand",
|
||||
&pyobj_domain, &cmd, &flags))
|
||||
return NULL;
|
||||
domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
|
||||
|
||||
if (domain == NULL)
|
||||
return VIR_PY_NONE;
|
||||
LIBVIRT_BEGIN_ALLOW_THREADS;
|
||||
c_retval = virDomainQemuMonitorCommand(domain, cmd, &result, flags);
|
||||
LIBVIRT_END_ALLOW_THREADS;
|
||||
|
||||
if (c_retval < 0)
|
||||
return VIR_PY_NONE;
|
||||
|
||||
py_retval = PyString_FromString(result);
|
||||
VIR_FREE(result);
|
||||
return py_retval;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
libvirt_qemu_virDomainQemuAgentCommand(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
|
||||
{
|
||||
PyObject *py_retval;
|
||||
char *result = NULL;
|
||||
virDomainPtr domain;
|
||||
PyObject *pyobj_domain;
|
||||
int timeout;
|
||||
unsigned int flags;
|
||||
char *cmd;
|
||||
|
||||
if (!PyArg_ParseTuple(args, (char *)"Ozii:virDomainQemuAgentCommand",
|
||||
&pyobj_domain, &cmd, &timeout, &flags))
|
||||
return NULL;
|
||||
domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
|
||||
|
||||
if (domain == NULL)
|
||||
return VIR_PY_NONE;
|
||||
LIBVIRT_BEGIN_ALLOW_THREADS;
|
||||
result = virDomainQemuAgentCommand(domain, cmd, timeout, flags);
|
||||
LIBVIRT_END_ALLOW_THREADS;
|
||||
|
||||
if (!result)
|
||||
return VIR_PY_NONE;
|
||||
|
||||
py_retval = PyString_FromString(result);
|
||||
VIR_FREE(result);
|
||||
return py_retval;
|
||||
}
|
||||
/************************************************************************
|
||||
* *
|
||||
* The registration stuff *
|
||||
* *
|
||||
************************************************************************/
|
||||
static PyMethodDef libvirtQemuMethods[] = {
|
||||
#include "libvirt-qemu-export.c"
|
||||
{(char *) "virDomainQemuMonitorCommand", libvirt_qemu_virDomainQemuMonitorCommand, METH_VARARGS, NULL},
|
||||
{(char *) "virDomainQemuAgentCommand", libvirt_qemu_virDomainQemuAgentCommand, METH_VARARGS, NULL},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
void
|
||||
#ifndef __CYGWIN__
|
||||
initlibvirtmod_qemu
|
||||
#else
|
||||
initcygvirtmod_qemu
|
||||
#endif
|
||||
(void)
|
||||
{
|
||||
static int initialized = 0;
|
||||
|
||||
if (initialized != 0)
|
||||
return;
|
||||
|
||||
if (virInitialize() < 0)
|
||||
return;
|
||||
|
||||
/* initialize the python extension module */
|
||||
Py_InitModule((char *)
|
||||
#ifndef __CYGWIN__
|
||||
"libvirtmod_qemu"
|
||||
#else
|
||||
"cygvirtmod_qemu"
|
||||
#endif
|
||||
, libvirtQemuMethods);
|
||||
|
||||
initialized = 1;
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import libvirt
|
||||
|
||||
globals = dir(libvirt)
|
||||
|
||||
# Sanity test that the generator hasn't gone wrong
|
||||
|
||||
# Look for core classes
|
||||
for clsname in ["virConnect",
|
||||
"virDomain",
|
||||
"virDomainSnapshot",
|
||||
"virInterface",
|
||||
"virNWFilter",
|
||||
"virNodeDevice",
|
||||
"virNetwork",
|
||||
"virSecret",
|
||||
"virStoragePool",
|
||||
"virStorageVol",
|
||||
"virStream",
|
||||
]:
|
||||
assert(clsname in globals)
|
||||
assert(object in getattr(libvirt, clsname).__bases__)
|
||||
|
||||
# Constants
|
||||
assert("VIR_CONNECT_RO" in globals)
|
||||
|
||||
# Error related bits
|
||||
assert("libvirtError" in globals)
|
||||
assert("VIR_ERR_AUTH_FAILED" in globals)
|
||||
assert("virGetLastError" in globals)
|
||||
|
||||
# Some misc methods
|
||||
assert("virInitialize" in globals)
|
||||
assert("virEventAddHandle" in globals)
|
||||
assert("virEventRegisterDefaultImpl" in globals)
|
|
@ -1,524 +0,0 @@
|
|||
/*
|
||||
* types.c: converter functions between the internal representation
|
||||
* and the Python objects
|
||||
*
|
||||
* Copyright (C) 2005, 2007, 2012 Red Hat, Inc.
|
||||
*
|
||||
* Daniel Veillard <veillard@redhat.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Horrible kludge to work around even more horrible name-space pollution
|
||||
* via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
|
||||
* which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
|
||||
#undef HAVE_PTHREAD_H
|
||||
|
||||
#include "typewrappers.h"
|
||||
|
||||
#include "viralloc.h"
|
||||
|
||||
#ifndef Py_CAPSULE_H
|
||||
typedef void(*PyCapsule_Destructor)(void *, void *);
|
||||
#endif
|
||||
|
||||
static PyObject *
|
||||
libvirt_buildPyObject(void *cobj,
|
||||
const char *name,
|
||||
PyCapsule_Destructor destr)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
#ifdef Py_CAPSULE_H
|
||||
ret = PyCapsule_New(cobj, name, destr);
|
||||
#else
|
||||
ret = PyCObject_FromVoidPtrAndDesc(cobj, (void *) name, destr);
|
||||
#endif /* _TEST_CAPSULE */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_intWrap(int val)
|
||||
{
|
||||
PyObject *ret;
|
||||
ret = PyInt_FromLong((long) val);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_longWrap(long val)
|
||||
{
|
||||
PyObject *ret;
|
||||
ret = PyInt_FromLong(val);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_ulongWrap(unsigned long val)
|
||||
{
|
||||
PyObject *ret;
|
||||
ret = PyLong_FromLong(val);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_longlongWrap(long long val)
|
||||
{
|
||||
PyObject *ret;
|
||||
ret = PyLong_FromUnsignedLongLong((unsigned long long) val);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_ulonglongWrap(unsigned long long val)
|
||||
{
|
||||
PyObject *ret;
|
||||
ret = PyLong_FromUnsignedLongLong(val);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_charPtrSizeWrap(char *str, Py_ssize_t size)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (str == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
ret = PyString_FromStringAndSize(str, size);
|
||||
VIR_FREE(str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_charPtrWrap(char *str)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (str == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
ret = PyString_FromString(str);
|
||||
VIR_FREE(str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_constcharPtrWrap(const char *str)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (str == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
ret = PyString_FromString(str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
libvirt_intUnwrap(PyObject *obj, int *val)
|
||||
{
|
||||
long long_val;
|
||||
|
||||
if (!obj) {
|
||||
PyErr_SetString(PyExc_TypeError, "unexpected type");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If obj is type of PyInt_Type, PyInt_AsLong converts it
|
||||
* to C long type directly. If it is of PyLong_Type, PyInt_AsLong
|
||||
* will call PyLong_AsLong() to deal with it automatically.
|
||||
*/
|
||||
long_val = PyInt_AsLong(obj);
|
||||
if ((long_val == -1) && PyErr_Occurred())
|
||||
return -1;
|
||||
|
||||
#if LONG_MAX != INT_MAX
|
||||
if (long_val >= INT_MIN && long_val <= INT_MAX) {
|
||||
*val = long_val;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"Python int too large to convert to C int");
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
*val = long_val;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
libvirt_uintUnwrap(PyObject *obj, unsigned int *val)
|
||||
{
|
||||
long long_val;
|
||||
|
||||
if (!obj) {
|
||||
PyErr_SetString(PyExc_TypeError, "unexpected type");
|
||||
return -1;
|
||||
}
|
||||
|
||||
long_val = PyInt_AsLong(obj);
|
||||
if ((long_val == -1) && PyErr_Occurred())
|
||||
return -1;
|
||||
|
||||
if (long_val >= 0 && long_val <= UINT_MAX) {
|
||||
*val = long_val;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"Python int too large to convert to C unsigned int");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
libvirt_longUnwrap(PyObject *obj, long *val)
|
||||
{
|
||||
long long_val;
|
||||
|
||||
if (!obj) {
|
||||
PyErr_SetString(PyExc_TypeError, "unexpected type");
|
||||
return -1;
|
||||
}
|
||||
|
||||
long_val = PyInt_AsLong(obj);
|
||||
if ((long_val == -1) && PyErr_Occurred())
|
||||
return -1;
|
||||
|
||||
*val = long_val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
libvirt_ulongUnwrap(PyObject *obj, unsigned long *val)
|
||||
{
|
||||
long long_val;
|
||||
|
||||
if (!obj) {
|
||||
PyErr_SetString(PyExc_TypeError, "unexpected type");
|
||||
return -1;
|
||||
}
|
||||
|
||||
long_val = PyInt_AsLong(obj);
|
||||
if ((long_val == -1) && PyErr_Occurred())
|
||||
return -1;
|
||||
|
||||
if (long_val >= 0) {
|
||||
*val = long_val;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"negative Python int cannot be converted to C unsigned long");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
libvirt_longlongUnwrap(PyObject *obj, long long *val)
|
||||
{
|
||||
long long llong_val = -1;
|
||||
|
||||
if (!obj) {
|
||||
PyErr_SetString(PyExc_TypeError, "unexpected type");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If obj is of PyInt_Type, PyLong_AsLongLong
|
||||
* will call PyInt_AsLong() to handle it automatically.
|
||||
*/
|
||||
if (PyInt_Check(obj) || PyLong_Check(obj))
|
||||
llong_val = PyLong_AsLongLong(obj);
|
||||
else
|
||||
PyErr_SetString(PyExc_TypeError, "an integer is required");
|
||||
|
||||
if ((llong_val == -1) && PyErr_Occurred())
|
||||
return -1;
|
||||
|
||||
*val = llong_val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
libvirt_ulonglongUnwrap(PyObject *obj, unsigned long long *val)
|
||||
{
|
||||
unsigned long long ullong_val = -1;
|
||||
long long llong_val;
|
||||
|
||||
if (!obj) {
|
||||
PyErr_SetString(PyExc_TypeError, "unexpected type");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* The PyLong_AsUnsignedLongLong doesn't check the type of
|
||||
* obj, only accept argument of PyLong_Type, so we check it instead.
|
||||
*/
|
||||
if (PyInt_Check(obj)) {
|
||||
llong_val = PyInt_AsLong(obj);
|
||||
if (llong_val < 0)
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"negative Python int cannot be converted to C unsigned long long");
|
||||
else
|
||||
ullong_val = llong_val;
|
||||
} else if (PyLong_Check(obj)) {
|
||||
ullong_val = PyLong_AsUnsignedLongLong(obj);
|
||||
} else {
|
||||
PyErr_SetString(PyExc_TypeError, "an integer is required");
|
||||
}
|
||||
|
||||
if ((ullong_val == -1) && PyErr_Occurred())
|
||||
return -1;
|
||||
|
||||
*val = ullong_val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
libvirt_doubleUnwrap(PyObject *obj, double *val)
|
||||
{
|
||||
double double_val;
|
||||
|
||||
if (!obj) {
|
||||
PyErr_SetString(PyExc_TypeError, "unexpected type");
|
||||
return -1;
|
||||
}
|
||||
|
||||
double_val = PyFloat_AsDouble(obj);
|
||||
if ((double_val == -1) && PyErr_Occurred())
|
||||
return -1;
|
||||
|
||||
*val = double_val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
libvirt_boolUnwrap(PyObject *obj, bool *val)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!obj) {
|
||||
PyErr_SetString(PyExc_TypeError, "unexpected type");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((ret = PyObject_IsTrue(obj)) < 0)
|
||||
return ret;
|
||||
|
||||
*val = ret > 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_virDomainPtrWrap(virDomainPtr node)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (node == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
ret = libvirt_buildPyObject(node, "virDomainPtr", NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_virNetworkPtrWrap(virNetworkPtr node)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (node == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
ret = libvirt_buildPyObject(node, "virNetworkPtr", NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_virInterfacePtrWrap(virInterfacePtr node)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (node == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
ret = libvirt_buildPyObject(node, "virInterfacePtr", NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_virStoragePoolPtrWrap(virStoragePoolPtr node)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (node == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
ret = libvirt_buildPyObject(node, "virStoragePoolPtr", NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_virStorageVolPtrWrap(virStorageVolPtr node)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (node == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
ret = libvirt_buildPyObject(node, "virStorageVolPtr", NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_virConnectPtrWrap(virConnectPtr node)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (node == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
ret = libvirt_buildPyObject(node, "virConnectPtr", NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_virNodeDevicePtrWrap(virNodeDevicePtr node)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (node == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
ret = libvirt_buildPyObject(node, "virNodeDevicePtr", NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_virSecretPtrWrap(virSecretPtr node)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (node == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
ret = libvirt_buildPyObject(node, "virSecretPtr", NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_virNWFilterPtrWrap(virNWFilterPtr node)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (node == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
ret = libvirt_buildPyObject(node, "virNWFilterPtr", NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_virStreamPtrWrap(virStreamPtr node)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (node == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
ret = libvirt_buildPyObject(node, "virStreamPtr", NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_virDomainSnapshotPtrWrap(virDomainSnapshotPtr node)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (node == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
ret = libvirt_buildPyObject(node, "virDomainSnapshotPtr", NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_virEventHandleCallbackWrap(virEventHandleCallback node)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (node == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
printf("%s: WARNING - Wrapping None\n", __func__);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
ret = libvirt_buildPyObject(node, "virEventHandleCallback", NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_virEventTimeoutCallbackWrap(virEventTimeoutCallback node)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (node == NULL) {
|
||||
printf("%s: WARNING - Wrapping None\n", __func__);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
ret = libvirt_buildPyObject(node, "virEventTimeoutCallback", NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_virFreeCallbackWrap(virFreeCallback node)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (node == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
ret = libvirt_buildPyObject(node, "virFreeCallback", NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
libvirt_virVoidPtrWrap(void* node)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
if (node == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
ret = libvirt_buildPyObject(node, "void*", NULL);
|
||||
return ret;
|
||||
}
|
|
@ -1,239 +0,0 @@
|
|||
/*
|
||||
* libvirt_wrap.h: type wrappers for libvir python bindings
|
||||
*
|
||||
* Copyright (C) 2005, 2011-2012 Red Hat, Inc.
|
||||
*
|
||||
* Daniel Veillard <veillard@redhat.com>
|
||||
*/
|
||||
|
||||
#include <Python.h>
|
||||
#include <stdbool.h>
|
||||
#include <libvirt/libvirt.h>
|
||||
#include <libvirt/virterror.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
# ifdef ATTRIBUTE_UNUSED
|
||||
# undef ATTRIBUTE_UNUSED
|
||||
# endif
|
||||
# ifndef ATTRIBUTE_UNUSED
|
||||
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
# endif /* ATTRIBUTE_UNUSED */
|
||||
#else
|
||||
# define ATTRIBUTE_UNUSED
|
||||
#endif
|
||||
|
||||
/* Work around really old python. */
|
||||
#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5
|
||||
typedef ssize_t Py_ssize_t;
|
||||
#endif
|
||||
|
||||
#define PyvirConnect_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(((PyvirConnect_Object *)(v))->obj))
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
virConnectPtr obj;
|
||||
} PyvirConnect_Object;
|
||||
|
||||
|
||||
#define PyvirDomain_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(((PyvirDomain_Object *)(v))->obj))
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
virDomainPtr obj;
|
||||
} PyvirDomain_Object;
|
||||
|
||||
|
||||
#define PyvirNetwork_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(((PyvirNetwork_Object *)(v))->obj))
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
virNetworkPtr obj;
|
||||
} PyvirNetwork_Object;
|
||||
|
||||
|
||||
#define PyvirInterface_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(((PyvirInterface_Object *)(v))->obj))
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
virInterfacePtr obj;
|
||||
} PyvirInterface_Object;
|
||||
|
||||
|
||||
#define PyvirStoragePool_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(((PyvirStoragePool_Object *)(v))->obj))
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
virStoragePoolPtr obj;
|
||||
} PyvirStoragePool_Object;
|
||||
|
||||
|
||||
#define PyvirStorageVol_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(((PyvirStorageVol_Object *)(v))->obj))
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
virStorageVolPtr obj;
|
||||
} PyvirStorageVol_Object;
|
||||
|
||||
|
||||
#define PyvirNodeDevice_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(((PyvirNodeDevice_Object *)(v))->obj))
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
virNodeDevicePtr obj;
|
||||
} PyvirNodeDevice_Object;
|
||||
|
||||
#define PyvirSecret_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(((PyvirSecret_Object *)(v))->obj))
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
virSecretPtr obj;
|
||||
} PyvirSecret_Object;
|
||||
|
||||
#define PyvirNWFilter_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(((PyvirNWFilter_Object *)(v))->obj))
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
virNWFilterPtr obj;
|
||||
} PyvirNWFilter_Object;
|
||||
|
||||
|
||||
#define PyvirStream_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(((PyvirStream_Object *)(v))->obj))
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
virStreamPtr obj;
|
||||
} PyvirStream_Object;
|
||||
|
||||
|
||||
#define PyvirDomainSnapshot_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(((PyvirDomainSnapshot_Object *)(v))->obj))
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
virDomainSnapshotPtr obj;
|
||||
} PyvirDomainSnapshot_Object;
|
||||
|
||||
|
||||
#define PyvirEventHandleCallback_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(((PyvirEventHandleCallback_Object *)(v))->obj))
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
virEventHandleCallback obj;
|
||||
} PyvirEventHandleCallback_Object;
|
||||
|
||||
#define PyvirEventTimeoutCallback_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(((PyvirEventTimeoutCallback_Object *)(v))->obj))
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
virEventTimeoutCallback obj;
|
||||
} PyvirEventTimeoutCallback_Object;
|
||||
|
||||
#define PyvirFreeCallback_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(((PyvirFreeCallback_Object *)(v))->obj))
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
virFreeCallback obj;
|
||||
} PyvirFreeCallback_Object;
|
||||
|
||||
#define PyvirVoidPtr_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(((PyvirVoidPtr_Object *)(v))->obj))
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
void* obj;
|
||||
} PyvirVoidPtr_Object;
|
||||
|
||||
PyObject * libvirt_intWrap(int val);
|
||||
PyObject * libvirt_longWrap(long val);
|
||||
PyObject * libvirt_ulongWrap(unsigned long val);
|
||||
PyObject * libvirt_longlongWrap(long long val);
|
||||
PyObject * libvirt_ulonglongWrap(unsigned long long val);
|
||||
PyObject * libvirt_charPtrWrap(char *str);
|
||||
PyObject * libvirt_charPtrSizeWrap(char *str, Py_ssize_t size);
|
||||
PyObject * libvirt_constcharPtrWrap(const char *str);
|
||||
int libvirt_intUnwrap(PyObject *obj, int *val);
|
||||
int libvirt_uintUnwrap(PyObject *obj, unsigned int *val);
|
||||
int libvirt_longUnwrap(PyObject *obj, long *val);
|
||||
int libvirt_ulongUnwrap(PyObject *obj, unsigned long *val);
|
||||
int libvirt_longlongUnwrap(PyObject *obj, long long *val);
|
||||
int libvirt_ulonglongUnwrap(PyObject *obj, unsigned long long *val);
|
||||
int libvirt_doubleUnwrap(PyObject *obj, double *val);
|
||||
int libvirt_boolUnwrap(PyObject *obj, bool *val);
|
||||
PyObject * libvirt_virConnectPtrWrap(virConnectPtr node);
|
||||
PyObject * libvirt_virDomainPtrWrap(virDomainPtr node);
|
||||
PyObject * libvirt_virNetworkPtrWrap(virNetworkPtr node);
|
||||
PyObject * libvirt_virInterfacePtrWrap(virInterfacePtr node);
|
||||
PyObject * libvirt_virStoragePoolPtrWrap(virStoragePoolPtr node);
|
||||
PyObject * libvirt_virStorageVolPtrWrap(virStorageVolPtr node);
|
||||
PyObject * libvirt_virEventHandleCallbackWrap(virEventHandleCallback node);
|
||||
PyObject * libvirt_virEventTimeoutCallbackWrap(virEventTimeoutCallback node);
|
||||
PyObject * libvirt_virFreeCallbackWrap(virFreeCallback node);
|
||||
PyObject * libvirt_virVoidPtrWrap(void* node);
|
||||
PyObject * libvirt_virNodeDevicePtrWrap(virNodeDevicePtr node);
|
||||
PyObject * libvirt_virSecretPtrWrap(virSecretPtr node);
|
||||
PyObject * libvirt_virNWFilterPtrWrap(virNWFilterPtr node);
|
||||
PyObject * libvirt_virStreamPtrWrap(virStreamPtr node);
|
||||
PyObject * libvirt_virDomainSnapshotPtrWrap(virDomainSnapshotPtr node);
|
||||
|
||||
|
||||
/* Provide simple macro statement wrappers (adapted from GLib, in turn from Perl):
|
||||
* LIBVIRT_STMT_START { statements; } LIBVIRT_STMT_END;
|
||||
* can be used as a single statement, as in
|
||||
* if (x) LIBVIRT_STMT_START { ... } LIBVIRT_STMT_END; else ...
|
||||
*
|
||||
* When GCC is compiling C code in non-ANSI mode, it will use the
|
||||
* compiler __extension__ to wrap the statements within `({' and '})' braces.
|
||||
* When compiling on platforms where configure has defined
|
||||
* HAVE_DOWHILE_MACROS, statements will be wrapped with `do' and `while (0)'.
|
||||
* For any other platforms (SunOS4 is known to have this issue), wrap the
|
||||
* statements with `if (1)' and `else (void) 0'.
|
||||
*/
|
||||
#if !(defined (LIBVIRT_STMT_START) && defined (LIBVIRT_STMT_END))
|
||||
# if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus)
|
||||
# define LIBVIRT_STMT_START (void) __extension__ (
|
||||
# define LIBVIRT_STMT_END )
|
||||
# else /* !(__GNUC__ && !__STRICT_ANSI__ && !__cplusplus) */
|
||||
# if defined (HAVE_DOWHILE_MACROS)
|
||||
# define LIBVIRT_STMT_START do
|
||||
# define LIBVIRT_STMT_END while (0)
|
||||
# else /* !HAVE_DOWHILE_MACROS */
|
||||
# define LIBVIRT_STMT_START if (1)
|
||||
# define LIBVIRT_STMT_END else (void) 0
|
||||
# endif /* !HAVE_DOWHILE_MACROS */
|
||||
# endif /* !(__GNUC__ && !__STRICT_ANSI__ && !__cplusplus) */
|
||||
#endif
|
||||
|
||||
#define LIBVIRT_BEGIN_ALLOW_THREADS \
|
||||
LIBVIRT_STMT_START { \
|
||||
PyThreadState *_save = NULL; \
|
||||
if (PyEval_ThreadsInitialized()) \
|
||||
_save = PyEval_SaveThread();
|
||||
|
||||
#define LIBVIRT_END_ALLOW_THREADS \
|
||||
if (PyEval_ThreadsInitialized()) \
|
||||
PyEval_RestoreThread(_save); \
|
||||
} LIBVIRT_STMT_END
|
||||
|
||||
#define LIBVIRT_ENSURE_THREAD_STATE \
|
||||
LIBVIRT_STMT_START { \
|
||||
PyGILState_STATE _save = PyGILState_UNLOCKED; \
|
||||
if (PyEval_ThreadsInitialized()) \
|
||||
_save = PyGILState_Ensure();
|
||||
|
||||
#define LIBVIRT_RELEASE_THREAD_STATE \
|
||||
if (PyEval_ThreadsInitialized()) \
|
||||
PyGILState_Release(_save); \
|
||||
} LIBVIRT_STMT_END
|
9
run.in
9
run.in
|
@ -58,15 +58,6 @@ export LIBVIRT_LOCK_MANAGER_PLUGIN_DIR="$b/src/.libs"
|
|||
export VIRTLOCKD_PATH="$b/src/virtlockd"
|
||||
export LIBVIRTD_PATH="$b/daemon/libvirtd"
|
||||
|
||||
# For Python.
|
||||
export PYTHON=@PYTHON@
|
||||
if [ -z "$PYTHONPATH" ]; then
|
||||
PYTHONPATH="$b/python:$b/python/.libs"
|
||||
else
|
||||
PYTHONPATH="$b/python:$b/python/.libs:$PYTHONPATH"
|
||||
fi
|
||||
export PYTHONPATH
|
||||
|
||||
# This is a cheap way to find some use-after-free and uninitialized
|
||||
# read problems when using glibc.
|
||||
random_val="$(awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)"
|
||||
|
|
Loading…
Reference in New Issue