[libvirt] [PATCH] Remove python binding

Daniel P. Berrange berrange at redhat.com
Fri Nov 22 16:59:59 UTC 2013


From: "Daniel P. Berrange" <berrange at redhat.com>

The python binding now lives in

  http://libvirt.org/git/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 at redhat.com>
---
 .gitignore                                         |   11 -
 Makefile.am                                        |    7 +-
 autobuild.sh                                       |    6 +-
 cfg.mk                                             |    7 +-
 configure.ac                                       |   86 -
 examples/domain-events/events-python/event-test.py |  591 --
 examples/python/Makefile.am                        |   21 -
 examples/python/README                             |   33 -
 examples/python/consolecallback.py                 |   88 -
 examples/python/dominfo.py                         |   80 -
 examples/python/domrestore.py                      |   36 -
 examples/python/domsave.py                         |   40 -
 examples/python/domstart.py                        |   50 -
 examples/python/esxlist.py                         |  155 -
 examples/python/topology.py                        |   45 -
 libvirt.spec.in                                    |   36 +-
 m4/virt-compile-warnings.m4                        |    8 -
 mingw-libvirt.spec.in                              |    1 -
 python/Makefile.am                                 |  173 -
 python/README                                      |   27 -
 python/generator.py                                | 1976 ------
 python/libvirt-lxc-override-api.xml                |   19 -
 python/libvirt-lxc-override.c                      |  142 -
 python/libvirt-override-api.xml                    |  613 --
 python/libvirt-override-virConnect.py              |  351 -
 python/libvirt-override-virDomain.py               |   49 -
 python/libvirt-override-virDomainSnapshot.py       |   19 -
 python/libvirt-override-virStoragePool.py          |   11 -
 python/libvirt-override-virStream.py               |  125 -
 python/libvirt-override.c                          | 7379 --------------------
 python/libvirt-override.py                         |  209 -
 python/libvirt-qemu-override-api.xml               |   20 -
 python/libvirt-qemu-override.c                     |  154 -
 python/sanitytest.py                               |   36 -
 python/typewrappers.c                              |  524 --
 python/typewrappers.h                              |  239 -
 run.in                                             |    9 -
 37 files changed, 7 insertions(+), 13369 deletions(-)
 delete mode 100644 examples/domain-events/events-python/event-test.py
 delete mode 100644 examples/python/Makefile.am
 delete mode 100644 examples/python/README
 delete mode 100644 examples/python/consolecallback.py
 delete mode 100755 examples/python/dominfo.py
 delete mode 100755 examples/python/domrestore.py
 delete mode 100755 examples/python/domsave.py
 delete mode 100755 examples/python/domstart.py
 delete mode 100755 examples/python/esxlist.py
 delete mode 100755 examples/python/topology.py
 delete mode 100644 python/Makefile.am
 delete mode 100644 python/README
 delete mode 100755 python/generator.py
 delete mode 100644 python/libvirt-lxc-override-api.xml
 delete mode 100644 python/libvirt-lxc-override.c
 delete mode 100644 python/libvirt-override-api.xml
 delete mode 100644 python/libvirt-override-virConnect.py
 delete mode 100644 python/libvirt-override-virDomain.py
 delete mode 100644 python/libvirt-override-virDomainSnapshot.py
 delete mode 100644 python/libvirt-override-virStoragePool.py
 delete mode 100644 python/libvirt-override-virStream.py
 delete mode 100644 python/libvirt-override.c
 delete mode 100644 python/libvirt-override.py
 delete mode 100644 python/libvirt-qemu-override-api.xml
 delete mode 100644 python/libvirt-qemu-override.c
 delete mode 100644 python/sanitytest.py
 delete mode 100644 python/typewrappers.c
 delete mode 100644 python/typewrappers.h

diff --git a/.gitignore b/.gitignore
index 6b024e7..faabd33 100644
--- a/.gitignore
+++ b/.gitignore
@@ -91,17 +91,6 @@
 /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
 /run
 /sc_*
 /src/.*.stamp
diff --git a/Makefile.am b/Makefile.am
index 192a378..957aa9f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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
diff --git a/autobuild.sh b/autobuild.sh
index 3109b49..f682b51 100755
--- a/autobuild.sh
+++ b/autobuild.sh
@@ -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
diff --git a/cfg.mk b/cfg.mk
index befd231..bd3dd48 100644
--- a/cfg.mk
+++ b/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/)$
diff --git a/configure.ac b/configure.ac
index 6003871..044cf37 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2012,83 +2012,6 @@ 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
 AC_PATH_PROG([PERL], [perl])
 
@@ -2227,7 +2150,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 +2163,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 +2197,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 +2530,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 +2538,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 +2693,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])
diff --git a/examples/domain-events/events-python/event-test.py b/examples/domain-events/events-python/event-test.py
deleted file mode 100644
index 84f5259..0000000
--- a/examples/domain-events/events-python/event-test.py
+++ /dev/null
@@ -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()
diff --git a/examples/python/Makefile.am b/examples/python/Makefile.am
deleted file mode 100644
index 7823c20..0000000
--- a/examples/python/Makefile.am
+++ /dev/null
@@ -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
diff --git a/examples/python/README b/examples/python/README
deleted file mode 100644
index f4db76c..0000000
--- a/examples/python/README
+++ /dev/null
@@ -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.
diff --git a/examples/python/consolecallback.py b/examples/python/consolecallback.py
deleted file mode 100644
index d8e33a9..0000000
--- a/examples/python/consolecallback.py
+++ /dev/null
@@ -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()
diff --git a/examples/python/dominfo.py b/examples/python/dominfo.py
deleted file mode 100755
index bfa3ca3..0000000
--- a/examples/python/dominfo.py
+++ /dev/null
@@ -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")
diff --git a/examples/python/domrestore.py b/examples/python/domrestore.py
deleted file mode 100755
index fffc90f..0000000
--- a/examples/python/domrestore.py
+++ /dev/null
@@ -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
diff --git a/examples/python/domsave.py b/examples/python/domsave.py
deleted file mode 100755
index bac4536..0000000
--- a/examples/python/domsave.py
+++ /dev/null
@@ -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()
diff --git a/examples/python/domstart.py b/examples/python/domstart.py
deleted file mode 100755
index b14fad1..0000000
--- a/examples/python/domstart.py
+++ /dev/null
@@ -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"
diff --git a/examples/python/esxlist.py b/examples/python/esxlist.py
deleted file mode 100755
index c55424f..0000000
--- a/examples/python/esxlist.py
+++ /dev/null
@@ -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")
diff --git a/examples/python/topology.py b/examples/python/topology.py
deleted file mode 100755
index 62effe3..0000000
--- a/examples/python/topology.py
+++ /dev/null
@@ -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 at redhat.com>
-#   Peter Krempa <pkrempa at 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
diff --git a/libvirt.spec.in b/libvirt.spec.in
index bbce8b5..5bc53a0 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -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,6 @@ BuildRequires: gettext-devel
 BuildRequires: libtool
 BuildRequires: /usr/bin/pod2man
 %endif
-BuildRequires: python-devel
 %if %{with_systemd}
 BuildRequires: systemd-units
 %endif
@@ -1145,19 +1143,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 +1207,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 +1359,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 +1412,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 +2083,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 at redhat.com> - 1.1.4-1
 - Add support for AArch64 architecture
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index 8f905cc..1547e03 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -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,
diff --git a/mingw-libvirt.spec.in b/mingw-libvirt.spec.in
index e13407e..1734a48 100644
--- a/mingw-libvirt.spec.in
+++ b/mingw-libvirt.spec.in
@@ -146,7 +146,6 @@ autoreconf -if
   --without-sasl \
   --without-avahi \
   --without-polkit \
-  --without-python \
   --without-libvirtd \
   --without-uml \
   %{?_without_phyp} \
diff --git a/python/Makefile.am b/python/Makefile.am
deleted file mode 100644
index c9c2a8b..0000000
--- a/python/Makefile.am
+++ /dev/null
@@ -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)
diff --git a/python/README b/python/README
deleted file mode 100644
index 02d4cc4..0000000
--- a/python/README
+++ /dev/null
@@ -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
diff --git a/python/generator.py b/python/generator.py
deleted file mode 100755
index 20f5dff..0000000
--- a/python/generator.py
+++ /dev/null
@@ -1,1976 +0,0 @@
-#!/usr/bin/python -u
-#
-# generate python wrappers from the XML API description
-#
-
-functions = {}
-lxc_functions = {}
-qemu_functions = {}
-enums = {} # { enumType: { enumConstant: enumValue } }
-lxc_enums = {} # { enumType: { enumConstant: enumValue } }
-qemu_enums = {} # { enumType: { enumConstant: enumValue } }
-
-import os
-import sys
-import string
-import re
-
-quiet=True
-
-if __name__ == "__main__":
-    # launched as a script
-    srcPref = os.path.dirname(sys.argv[0])
-    if len(sys.argv) > 1:
-        python = sys.argv[1]
-    else:
-        print "Python binary not specified"
-        sys.exit(1)
-else:
-    # imported
-    srcPref = os.path.dirname(__file__)
-
-#######################################################################
-#
-#  That part if purely the API acquisition phase from the
-#  libvirt API description
-#
-#######################################################################
-import os
-import xml.sax
-
-debug = 0
-
-def getparser():
-    # Attach parser to an unmarshalling object. return both objects.
-    target = docParser()
-    parser = xml.sax.make_parser()
-    parser.setContentHandler(target)
-    return parser, target
-
-class docParser(xml.sax.handler.ContentHandler):
-    def __init__(self):
-        self._methodname = None
-        self._data = []
-        self.in_function = 0
-
-        self.startElement = self.start
-        self.endElement = self.end
-        self.characters = self.data
-
-    def close(self):
-        if debug:
-            print "close"
-
-    def getmethodname(self):
-        return self._methodname
-
-    def data(self, text):
-        if debug:
-            print "data %s" % text
-        self._data.append(text)
-
-    def cdata(self, text):
-        if debug:
-            print "data %s" % text
-        self._data.append(text)
-
-    def start(self, tag, attrs):
-        if debug:
-            print "start %s, %s" % (tag, attrs)
-        if tag == 'function':
-            self._data = []
-            self.in_function = 1
-            self.function = None
-            self.function_cond = None
-            self.function_args = []
-            self.function_descr = None
-            self.function_return = None
-            self.function_file = None
-            self.function_module= None
-            if attrs.has_key('name'):
-                self.function = attrs['name']
-            if attrs.has_key('file'):
-                self.function_file = attrs['file']
-            if attrs.has_key('module'):
-                self.function_module= attrs['module']
-        elif tag == 'cond':
-            self._data = []
-        elif tag == 'info':
-            self._data = []
-        elif tag == 'arg':
-            if self.in_function == 1:
-                self.function_arg_name = None
-                self.function_arg_type = None
-                self.function_arg_info = None
-                if attrs.has_key('name'):
-                    self.function_arg_name = attrs['name']
-                    if self.function_arg_name == 'from':
-                        self.function_arg_name = 'frm'
-                if attrs.has_key('type'):
-                    self.function_arg_type = attrs['type']
-                if attrs.has_key('info'):
-                    self.function_arg_info = attrs['info']
-        elif tag == 'return':
-            if self.in_function == 1:
-                self.function_return_type = None
-                self.function_return_info = None
-                self.function_return_field = None
-                if attrs.has_key('type'):
-                    self.function_return_type = attrs['type']
-                if attrs.has_key('info'):
-                    self.function_return_info = attrs['info']
-                if attrs.has_key('field'):
-                    self.function_return_field = attrs['field']
-        elif tag == 'enum':
-            # enums come from header files, hence virterror.h
-            if (attrs['file'] == "libvirt" or
-                attrs['file'] == "virterror"):
-                enum(attrs['type'],attrs['name'],attrs['value'])
-            elif attrs['file'] == "libvirt-lxc":
-                lxc_enum(attrs['type'],attrs['name'],attrs['value'])
-            elif attrs['file'] == "libvirt-qemu":
-                qemu_enum(attrs['type'],attrs['name'],attrs['value'])
-
-    def end(self, tag):
-        if debug:
-            print "end %s" % tag
-        if tag == 'function':
-            # fuctions come from source files, hence 'virerror.c'
-            if self.function is not None:
-                if (self.function_module == "libvirt" or
-                    self.function_module == "virevent" or
-                    self.function_module == "virerror"):
-                    function(self.function, self.function_descr,
-                             self.function_return, self.function_args,
-                             self.function_file, self.function_module,
-                             self.function_cond)
-                elif self.function_module == "libvirt-lxc":
-                    lxc_function(self.function, self.function_descr,
-                             self.function_return, self.function_args,
-                             self.function_file, self.function_module,
-                             self.function_cond)
-                elif self.function_module == "libvirt-qemu":
-                    qemu_function(self.function, self.function_descr,
-                             self.function_return, self.function_args,
-                             self.function_file, self.function_module,
-                             self.function_cond)
-                elif self.function_file == "python":
-                    function(self.function, self.function_descr,
-                             self.function_return, self.function_args,
-                             self.function_file, self.function_module,
-                             self.function_cond)
-                elif self.function_file == "python-lxc":
-                    lxc_function(self.function, self.function_descr,
-                                  self.function_return, self.function_args,
-                                  self.function_file, self.function_module,
-                                  self.function_cond)
-                elif self.function_file == "python-qemu":
-                    qemu_function(self.function, self.function_descr,
-                                  self.function_return, self.function_args,
-                                  self.function_file, self.function_module,
-                                  self.function_cond)
-                self.in_function = 0
-        elif tag == 'arg':
-            if self.in_function == 1:
-                self.function_args.append([self.function_arg_name,
-                                           self.function_arg_type,
-                                           self.function_arg_info])
-        elif tag == 'return':
-            if self.in_function == 1:
-                self.function_return = [self.function_return_type,
-                                        self.function_return_info,
-                                        self.function_return_field]
-        elif tag == 'info':
-            str = ''
-            for c in self._data:
-                str = str + c
-            if self.in_function == 1:
-                self.function_descr = str
-        elif tag == 'cond':
-            str = ''
-            for c in self._data:
-                str = str + c
-            if self.in_function == 1:
-                self.function_cond = str
-
-
-def function(name, desc, ret, args, file, module, cond):
-    functions[name] = (desc, ret, args, file, module, cond)
-
-def qemu_function(name, desc, ret, args, file, module, cond):
-    qemu_functions[name] = (desc, ret, args, file, module, cond)
-
-def lxc_function(name, desc, ret, args, file, module, cond):
-    lxc_functions[name] = (desc, ret, args, file, module, cond)
-
-def enum(type, name, value):
-    if not enums.has_key(type):
-        enums[type] = {}
-    if value == 'VIR_TYPED_PARAM_INT':
-        value = 1
-    elif value == 'VIR_TYPED_PARAM_UINT':
-        value = 2
-    elif value == 'VIR_TYPED_PARAM_LLONG':
-        value = 3
-    elif value == 'VIR_TYPED_PARAM_ULLONG':
-        value = 4
-    elif value == 'VIR_TYPED_PARAM_DOUBLE':
-        value = 5
-    elif value == 'VIR_TYPED_PARAM_BOOLEAN':
-        value = 6
-    elif value == 'VIR_DOMAIN_AFFECT_CURRENT':
-        value = 0
-    elif value == 'VIR_DOMAIN_AFFECT_LIVE':
-        value = 1
-    elif value == 'VIR_DOMAIN_AFFECT_CONFIG':
-        value = 2
-    if name[-5:] != '_LAST':
-        enums[type][name] = value
-
-def lxc_enum(type, name, value):
-    if not lxc_enums.has_key(type):
-        lxc_enums[type] = {}
-    lxc_enums[type][name] = value
-
-def qemu_enum(type, name, value):
-    if not qemu_enums.has_key(type):
-        qemu_enums[type] = {}
-    qemu_enums[type][name] = value
-
-
-#######################################################################
-#
-#  Some filtering rukes to drop functions/types which should not
-#  be exposed as-is on the Python interface
-#
-#######################################################################
-
-functions_failed = []
-lxc_functions_failed = []
-qemu_functions_failed = []
-functions_skipped = [
-    "virConnectListDomains",
-]
-lxc_functions_skipped = []
-qemu_functions_skipped = []
-
-skipped_modules = {
-}
-
-skipped_types = {
-#    'int *': "usually a return type",
-     'virConnectDomainEventCallback': "No function types in python",
-     'virConnectDomainEventGenericCallback': "No function types in python",
-     'virConnectDomainEventRTCChangeCallback': "No function types in python",
-     'virConnectDomainEventWatchdogCallback': "No function types in python",
-     'virConnectDomainEventIOErrorCallback': "No function types in python",
-     'virConnectDomainEventGraphicsCallback': "No function types in python",
-     'virStreamEventCallback': "No function types in python",
-     'virEventHandleCallback': "No function types in python",
-     'virEventTimeoutCallback': "No function types in python",
-     'virDomainBlockJobInfoPtr': "Not implemented yet",
-}
-
-#######################################################################
-#
-#  Table of remapping to/from the python type or class to the C
-#  counterpart.
-#
-#######################################################################
-
-py_types = {
-    'void': (None, None, None, None),
-    'int':  ('i', None, "int", "int"),
-    'long':  ('l', None, "long", "long"),
-    'double':  ('d', None, "double", "double"),
-    'unsigned int':  ('i', None, "int", "int"),
-    'unsigned long':  ('l', None, "long", "long"),
-    'long long':  ('L', None, "longlong", "long long"),
-    'unsigned long long':  ('L', None, "longlong", "long long"),
-    'unsigned char *':  ('z', None, "charPtr", "char *"),
-    'char *':  ('z', None, "charPtr", "char *"),
-    'const char *':  ('z', None, "constcharPtr", "const char *"),
-    'size_t': ('n', None, "size_t", "size_t"),
-
-    'virDomainPtr':  ('O', "virDomain", "virDomainPtr", "virDomainPtr"),
-    'virDomain *':  ('O', "virDomain", "virDomainPtr", "virDomainPtr"),
-    'const virDomain *':  ('O', "virDomain", "virDomainPtr", "virDomainPtr"),
-
-    'virNetworkPtr':  ('O', "virNetwork", "virNetworkPtr", "virNetworkPtr"),
-    'virNetwork *':  ('O', "virNetwork", "virNetworkPtr", "virNetworkPtr"),
-    'const virNetwork *':  ('O', "virNetwork", "virNetworkPtr", "virNetworkPtr"),
-
-    'virInterfacePtr':  ('O', "virInterface", "virInterfacePtr", "virInterfacePtr"),
-    'virInterface *':  ('O', "virInterface", "virInterfacePtr", "virInterfacePtr"),
-    'const virInterface *':  ('O', "virInterface", "virInterfacePtr", "virInterfacePtr"),
-
-    'virStoragePoolPtr':  ('O', "virStoragePool", "virStoragePoolPtr", "virStoragePoolPtr"),
-    'virStoragePool *':  ('O', "virStoragePool", "virStoragePoolPtr", "virStoragePoolPtr"),
-    'const virStoragePool *':  ('O', "virStoragePool", "virStoragePoolPtr", "virStoragePoolPtr"),
-
-    'virStorageVolPtr':  ('O', "virStorageVol", "virStorageVolPtr", "virStorageVolPtr"),
-    'virStorageVol *':  ('O', "virStorageVol", "virStorageVolPtr", "virStorageVolPtr"),
-    'const virStorageVol *':  ('O', "virStorageVol", "virStorageVolPtr", "virStorageVolPtr"),
-
-    'virConnectPtr':  ('O', "virConnect", "virConnectPtr", "virConnectPtr"),
-    'virConnect *':  ('O', "virConnect", "virConnectPtr", "virConnectPtr"),
-    'const virConnect *':  ('O', "virConnect", "virConnectPtr", "virConnectPtr"),
-
-    'virNodeDevicePtr':  ('O', "virNodeDevice", "virNodeDevicePtr", "virNodeDevicePtr"),
-    'virNodeDevice *':  ('O', "virNodeDevice", "virNodeDevicePtr", "virNodeDevicePtr"),
-    'const virNodeDevice *':  ('O', "virNodeDevice", "virNodeDevicePtr", "virNodeDevicePtr"),
-
-    'virSecretPtr':  ('O', "virSecret", "virSecretPtr", "virSecretPtr"),
-    'virSecret *':  ('O', "virSecret", "virSecretPtr", "virSecretPtr"),
-    'const virSecret *':  ('O', "virSecret", "virSecretPtr", "virSecretPtr"),
-
-    'virNWFilterPtr':  ('O', "virNWFilter", "virNWFilterPtr", "virNWFilterPtr"),
-    'virNWFilter *':  ('O', "virNWFilter", "virNWFilterPtr", "virNWFilterPtr"),
-    'const virNWFilter *':  ('O', "virNWFilter", "virNWFilterPtr", "virNWFilterPtr"),
-
-    'virStreamPtr':  ('O', "virStream", "virStreamPtr", "virStreamPtr"),
-    'virStream *':  ('O', "virStream", "virStreamPtr", "virStreamPtr"),
-    'const virStream *':  ('O', "virStream", "virStreamPtr", "virStreamPtr"),
-
-    'virDomainSnapshotPtr':  ('O', "virDomainSnapshot", "virDomainSnapshotPtr", "virDomainSnapshotPtr"),
-    'virDomainSnapshot *':  ('O', "virDomainSnapshot", "virDomainSnapshotPtr", "virDomainSnapshotPtr"),
-    'const virDomainSnapshot *':  ('O', "virDomainSnapshot", "virDomainSnapshotPtr", "virDomainSnapshotPtr"),
-}
-
-py_return_types = {
-}
-
-unknown_types = {}
-
-foreign_encoding_args = (
-)
-
-#######################################################################
-#
-#  This part writes the C <-> Python stubs libvirt.[ch] and
-#  the table libvirt-export.c to add when registrering the Python module
-#
-#######################################################################
-
-# Class methods which are written by hand in libvirt.c but the Python-level
-# code is still automatically generated (so they are not in skip_function()).
-skip_impl = (
-    'virConnectGetVersion',
-    'virConnectGetLibVersion',
-    'virConnectListDomainsID',
-    'virConnectListDefinedDomains',
-    'virConnectListNetworks',
-    'virConnectListDefinedNetworks',
-    'virConnectListSecrets',
-    'virConnectListInterfaces',
-    'virConnectListStoragePools',
-    'virConnectListDefinedStoragePools',
-    'virConnectListStorageVols',
-    'virConnectListDefinedStorageVols',
-    'virConnectListDefinedInterfaces',
-    'virConnectListNWFilters',
-    'virDomainSnapshotListNames',
-    'virDomainSnapshotListChildrenNames',
-    'virConnGetLastError',
-    'virGetLastError',
-    'virDomainGetInfo',
-    'virDomainGetState',
-    'virDomainGetControlInfo',
-    'virDomainGetBlockInfo',
-    'virDomainGetJobInfo',
-    'virDomainGetJobStats',
-    'virNodeGetInfo',
-    'virDomainGetUUID',
-    'virDomainGetUUIDString',
-    'virDomainLookupByUUID',
-    'virNetworkGetUUID',
-    'virNetworkGetUUIDString',
-    'virNetworkLookupByUUID',
-    'virDomainGetAutostart',
-    'virNetworkGetAutostart',
-    'virDomainBlockStats',
-    'virDomainInterfaceStats',
-    'virDomainMemoryStats',
-    'virNodeGetCellsFreeMemory',
-    'virDomainGetSchedulerType',
-    'virDomainGetSchedulerParameters',
-    'virDomainGetSchedulerParametersFlags',
-    'virDomainSetSchedulerParameters',
-    'virDomainSetSchedulerParametersFlags',
-    'virDomainSetBlkioParameters',
-    'virDomainGetBlkioParameters',
-    'virDomainSetMemoryParameters',
-    'virDomainGetMemoryParameters',
-    'virDomainSetNumaParameters',
-    'virDomainGetNumaParameters',
-    'virDomainGetVcpus',
-    'virDomainPinVcpu',
-    'virDomainPinVcpuFlags',
-    'virDomainGetVcpuPinInfo',
-    'virDomainGetEmulatorPinInfo',
-    'virDomainPinEmulator',
-    'virSecretGetValue',
-    'virSecretSetValue',
-    'virSecretGetUUID',
-    'virSecretGetUUIDString',
-    'virSecretLookupByUUID',
-    'virNWFilterGetUUID',
-    'virNWFilterGetUUIDString',
-    'virNWFilterLookupByUUID',
-    'virStoragePoolGetUUID',
-    'virStoragePoolGetUUIDString',
-    'virStoragePoolLookupByUUID',
-    'virStoragePoolGetInfo',
-    'virStorageVolGetInfo',
-    'virStoragePoolGetAutostart',
-    'virStoragePoolListVolumes',
-    'virDomainBlockPeek',
-    'virDomainMemoryPeek',
-    'virEventRegisterImpl',
-    'virNodeListDevices',
-    'virNodeDeviceListCaps',
-    'virConnectBaselineCPU',
-    'virDomainRevertToSnapshot',
-    'virDomainSendKey',
-    'virNodeGetCPUStats',
-    'virNodeGetMemoryStats',
-    'virDomainGetBlockJobInfo',
-    'virDomainMigrateGetCompressionCache',
-    'virDomainMigrateGetMaxSpeed',
-    'virDomainBlockStatsFlags',
-    'virDomainSetBlockIoTune',
-    'virDomainGetBlockIoTune',
-    'virDomainSetInterfaceParameters',
-    'virDomainGetInterfaceParameters',
-    'virDomainGetCPUStats',
-    'virDomainGetDiskErrors',
-    'virNodeGetMemoryParameters',
-    'virNodeSetMemoryParameters',
-    'virNodeGetCPUMap',
-    'virDomainMigrate3',
-    'virDomainMigrateToURI3',
-    'virConnectGetCPUModelNames',
-)
-
-lxc_skip_impl = (
-    'virDomainLxcOpenNamespace',
-)
-
-qemu_skip_impl = (
-    'virDomainQemuMonitorCommand',
-    'virDomainQemuAgentCommand',
-)
-
-
-# These are functions which the generator skips completly - no python
-# or C code is generated. Generally should not be used for any more
-# functions than those already listed
-skip_function = (
-    'virConnectListDomains', # Python API is called virConectListDomainsID for unknown reasons
-    'virConnSetErrorFunc', # Not used in Python API  XXX is this a bug ?
-    'virResetError', # Not used in Python API  XXX is this a bug ?
-    'virGetVersion', # Python C code is manually written
-    'virSetErrorFunc', # Python API is called virRegisterErrorHandler for unknown reasons
-    'virConnCopyLastError', # Python API is called virConnGetLastError instead
-    'virCopyLastError', # Python API is called virGetLastError instead
-    'virConnectOpenAuth', # Python C code is manually written
-    'virDefaultErrorFunc', # Python virErrorFuncHandler impl calls this from C
-    'virDomainGetSecurityLabel', # Needs investigation...
-    'virDomainGetSecurityLabelList', # Needs investigation...
-    'virNodeGetSecurityModel', # Needs investigation...
-    'virConnectDomainEventRegister',   # overridden in virConnect.py
-    'virConnectDomainEventDeregister', # overridden in virConnect.py
-    'virConnectDomainEventRegisterAny',   # overridden in virConnect.py
-    'virConnectDomainEventDeregisterAny', # overridden in virConnect.py
-    'virSaveLastError', # We have our own python error wrapper
-    'virFreeError', # Only needed if we use virSaveLastError
-    'virConnectListAllDomains', # overridden in virConnect.py
-    'virDomainListAllSnapshots', # overridden in virDomain.py
-    'virDomainSnapshotListAllChildren', # overridden in virDomainSnapshot.py
-    'virConnectListAllStoragePools', # overridden in virConnect.py
-    'virStoragePoolListAllVolumes', # overridden in virStoragePool.py
-    'virConnectListAllNetworks', # overridden in virConnect.py
-    'virConnectListAllInterfaces', # overridden in virConnect.py
-    'virConnectListAllNodeDevices', # overridden in virConnect.py
-    'virConnectListAllNWFilters', # overridden in virConnect.py
-    'virConnectListAllSecrets', # overridden in virConnect.py
-
-    'virStreamRecvAll', # Pure python libvirt-override-virStream.py
-    'virStreamSendAll', # Pure python libvirt-override-virStream.py
-    'virStreamRecv', # overridden in libvirt-override-virStream.py
-    'virStreamSend', # overridden in libvirt-override-virStream.py
-
-    'virConnectUnregisterCloseCallback', # overridden in virConnect.py
-    'virConnectRegisterCloseCallback', # overridden in virConnect.py
-
-    'virDomainCreateXMLWithFiles', # overridden in virConnect.py
-    'virDomainCreateWithFiles', # overridden in virDomain.py
-
-    # 'Ref' functions have no use for bindings users.
-    "virConnectRef",
-    "virDomainRef",
-    "virInterfaceRef",
-    "virNetworkRef",
-    "virNodeDeviceRef",
-    "virSecretRef",
-    "virNWFilterRef",
-    "virStoragePoolRef",
-    "virStorageVolRef",
-    'virStreamRef',
-
-    # This functions shouldn't be called via the bindings (and even the docs
-    # contain an explicit warning to that effect). The equivalent should be
-    # implemented in pure python for each class
-    "virDomainGetConnect",
-    "virInterfaceGetConnect",
-    "virNetworkGetConnect",
-    "virSecretGetConnect",
-    "virNWFilterGetConnect",
-    "virStoragePoolGetConnect",
-    "virStorageVolGetConnect",
-    "virDomainSnapshotGetConnect",
-    "virDomainSnapshotGetDomain",
-
-    # only useful in C code, python code uses dict for typed parameters
-    "virTypedParamsAddBoolean",
-    "virTypedParamsAddDouble",
-    "virTypedParamsAddFromString",
-    "virTypedParamsAddInt",
-    "virTypedParamsAddLLong",
-    "virTypedParamsAddString",
-    "virTypedParamsAddUInt",
-    "virTypedParamsAddULLong",
-    "virTypedParamsClear",
-    "virTypedParamsFree",
-    "virTypedParamsGet",
-    "virTypedParamsGetBoolean",
-    "virTypedParamsGetDouble",
-    "virTypedParamsGetInt",
-    "virTypedParamsGetLLong",
-    "virTypedParamsGetString",
-    "virTypedParamsGetUInt",
-    "virTypedParamsGetULLong",
-)
-
-lxc_skip_function = (
-  "virDomainLxcEnterNamespace",
-  "virDomainLxcEnterSecurityLabel",
-)
-qemu_skip_function = (
-    #"virDomainQemuAttach",
-)
-
-# Generate C code, but skip python impl
-function_skip_python_impl = (
-    "virStreamFree", # Needed in custom virStream __del__, but free shouldn't
-                     # be exposed in bindings
-)
-
-lxc_function_skip_python_impl = ()
-qemu_function_skip_python_impl = ()
-
-function_skip_index_one = (
-    "virDomainRevertToSnapshot",
-)
-
-def print_function_wrapper(module, name, output, export, include):
-    global py_types
-    global unknown_types
-    global functions
-    global lxc_functions
-    global qemu_functions
-    global skipped_modules
-    global function_skip_python_impl
-
-    try:
-        if module == "libvirt":
-            (desc, ret, args, file, mod, cond) = functions[name]
-        if module == "libvirt-lxc":
-            (desc, ret, args, file, mod, cond) = lxc_functions[name]
-        if module == "libvirt-qemu":
-            (desc, ret, args, file, mod, cond) = qemu_functions[name]
-    except:
-        print "failed to get function %s infos" % name
-        return
-
-    if skipped_modules.has_key(module):
-        return 0
-
-    if module == "libvirt":
-        if name in skip_function:
-            return 0
-        if name in skip_impl:
-            # Don't delete the function entry in the caller.
-            return 1
-    elif module == "libvirt-lxc":
-        if name in lxc_skip_function:
-            return 0
-        if name in lxc_skip_impl:
-            # Don't delete the function entry in the caller.
-            return 1
-    elif module == "libvirt-qemu":
-        if name in qemu_skip_function:
-            return 0
-        if name in qemu_skip_impl:
-            # Don't delete the function entry in the caller.
-            return 1
-
-    c_call = ""
-    format=""
-    format_args=""
-    c_args=""
-    c_return=""
-    c_convert=""
-    num_bufs=0
-    for arg in args:
-        # This should be correct
-        if arg[1][0:6] == "const ":
-            arg[1] = arg[1][6:]
-        c_args = c_args + "    %s %s;\n" % (arg[1], arg[0])
-        if py_types.has_key(arg[1]):
-            (f, t, n, c) = py_types[arg[1]]
-            if (f == 'z') and (name in foreign_encoding_args) and (num_bufs == 0):
-                f = 't#'
-            if f is not None:
-                format = format + f
-            if t is not None:
-                format_args = format_args + ", &pyobj_%s" % (arg[0])
-                c_args = c_args + "    PyObject *pyobj_%s;\n" % (arg[0])
-                c_convert = c_convert + \
-                   "    %s = (%s) Py%s_Get(pyobj_%s);\n" % (arg[0],
-                   arg[1], t, arg[0])
-            else:
-                format_args = format_args + ", &%s" % (arg[0])
-            if f == 't#':
-                format_args = format_args + ", &py_buffsize%d" % num_bufs
-                c_args = c_args + "    int py_buffsize%d;\n" % num_bufs
-                num_bufs = num_bufs + 1
-            if c_call != "":
-                c_call = c_call + ", "
-            c_call = c_call + "%s" % (arg[0])
-        else:
-            if skipped_types.has_key(arg[1]):
-                return 0
-            if unknown_types.has_key(arg[1]):
-                lst = unknown_types[arg[1]]
-                lst.append(name)
-            else:
-                unknown_types[arg[1]] = [name]
-            return -1
-    if format != "":
-        format = format + ":%s" % (name)
-
-    if ret[0] == 'void':
-        if file == "python_accessor":
-            if args[1][1] == "char *":
-                c_call = "\n    VIR_FREE(%s->%s);\n" % (
-                                 args[0][0], args[1][0], args[0][0], args[1][0])
-                c_call = c_call + "    %s->%s = (%s)strdup((const xmlChar *)%s);\n" % (args[0][0],
-                                 args[1][0], args[1][1], args[1][0])
-            else:
-                c_call = "\n    %s->%s = %s;\n" % (args[0][0], args[1][0],
-                                                   args[1][0])
-        else:
-            c_call = "\n    %s(%s);\n" % (name, c_call)
-        ret_convert = "    Py_INCREF(Py_None);\n    return Py_None;\n"
-    elif py_types.has_key(ret[0]):
-        (f, t, n, c) = py_types[ret[0]]
-        c_return = "    %s c_retval;\n" % (ret[0])
-        if file == "python_accessor" and ret[2] is not None:
-            c_call = "\n    c_retval = %s->%s;\n" % (args[0][0], ret[2])
-        else:
-            c_call = "\n    c_retval = %s(%s);\n" % (name, c_call)
-        ret_convert = "    py_retval = libvirt_%sWrap((%s) c_retval);\n" % (n,c)
-        ret_convert = ret_convert + "    return py_retval;\n"
-    elif py_return_types.has_key(ret[0]):
-        (f, t, n, c) = py_return_types[ret[0]]
-        c_return = "    %s c_retval;\n" % (ret[0])
-        c_call = "\n    c_retval = %s(%s);\n" % (name, c_call)
-        ret_convert = "    py_retval = libvirt_%sWrap((%s) c_retval);\n" % (n,c)
-        ret_convert = ret_convert + "    return py_retval;\n"
-    else:
-        if skipped_types.has_key(ret[0]):
-            return 0
-        if unknown_types.has_key(ret[0]):
-            lst = unknown_types[ret[0]]
-            lst.append(name)
-        else:
-            unknown_types[ret[0]] = [name]
-        return -1
-
-    if cond is not None and cond != "":
-        include.write("#if %s\n" % cond)
-        export.write("#if %s\n" % cond)
-        output.write("#if %s\n" % cond)
-
-    include.write("PyObject * ")
-    if module == "libvirt":
-        include.write("libvirt_%s(PyObject *self, PyObject *args);\n" % (name))
-        export.write("    { (char *)\"%s\", libvirt_%s, METH_VARARGS, NULL },\n" %
-                     (name, name))
-    elif module == "libvirt-lxc":
-        include.write("libvirt_lxc_%s(PyObject *self, PyObject *args);\n" % (name))
-        export.write("    { (char *)\"%s\", libvirt_lxc_%s, METH_VARARGS, NULL },\n" %
-                     (name, name))
-    elif module == "libvirt-qemu":
-        include.write("libvirt_qemu_%s(PyObject *self, PyObject *args);\n" % (name))
-        export.write("    { (char *)\"%s\", libvirt_qemu_%s, METH_VARARGS, NULL },\n" %
-                     (name, name))
-
-    if file == "python":
-        # Those have been manually generated
-        if cond is not None and cond != "":
-            include.write("#endif\n")
-            export.write("#endif\n")
-            output.write("#endif\n")
-        return 1
-    if file == "python_accessor" and ret[0] != "void" and ret[2] is None:
-        # Those have been manually generated
-        if cond is not None and cond != "":
-            include.write("#endif\n")
-            export.write("#endif\n")
-            output.write("#endif\n")
-        return 1
-
-    output.write("PyObject *\n")
-    if module == "libvirt":
-        output.write("libvirt_%s(PyObject *self ATTRIBUTE_UNUSED," % (name))
-    elif module == "libvirt-lxc":
-        output.write("libvirt_lxc_%s(PyObject *self ATTRIBUTE_UNUSED," % (name))
-    elif module == "libvirt-qemu":
-        output.write("libvirt_qemu_%s(PyObject *self ATTRIBUTE_UNUSED," % (name))
-    output.write(" PyObject *args")
-    if format == "":
-        output.write(" ATTRIBUTE_UNUSED")
-    output.write(") {\n")
-    if ret[0] != 'void':
-        output.write("    PyObject *py_retval;\n")
-    if c_return != "":
-        output.write(c_return)
-    if c_args != "":
-        output.write(c_args)
-    if format != "":
-        output.write("\n    if (!PyArg_ParseTuple(args, (char *)\"%s\"%s))\n" %
-                     (format, format_args))
-        output.write("        return NULL;\n")
-    if c_convert != "":
-        output.write(c_convert + "\n")
-
-    output.write("    LIBVIRT_BEGIN_ALLOW_THREADS;")
-    output.write(c_call)
-    output.write("    LIBVIRT_END_ALLOW_THREADS;\n")
-    output.write(ret_convert)
-    output.write("}\n\n")
-    if cond is not None and cond != "":
-        include.write("#endif /* %s */\n" % cond)
-        export.write("#endif /* %s */\n" % cond)
-        output.write("#endif /* %s */\n" % cond)
-
-    if module == "libvirt":
-        if name in function_skip_python_impl:
-            return 0
-    elif module == "libvirt-lxc":
-        if name in lxc_function_skip_python_impl:
-            return 0
-    elif module == "libvirt-qemu":
-        if name in qemu_function_skip_python_impl:
-            return 0
-    return 1
-
-def buildStubs(module):
-    global py_types
-    global py_return_types
-    global unknown_types
-
-    if module not in ["libvirt", "libvirt-qemu", "libvirt-lxc"]:
-        print "ERROR: Unknown module type: %s" % module
-        return None
-
-    if module == "libvirt":
-        funcs = functions
-        funcs_failed = functions_failed
-        funcs_skipped = functions_skipped
-    elif module == "libvirt-lxc":
-        funcs = lxc_functions
-        funcs_failed = lxc_functions_failed
-        funcs_skipped = lxc_functions_skipped
-    elif module == "libvirt-qemu":
-        funcs = qemu_functions
-        funcs_failed = qemu_functions_failed
-        funcs_skipped = qemu_functions_skipped
-
-    api_xml = "%s-api.xml" % module
-
-    try:
-        f = open(os.path.join(srcPref,api_xml))
-        data = f.read()
-        f.close()
-        (parser, target)  = getparser()
-        parser.feed(data)
-        parser.close()
-    except IOError, msg:
-        try:
-            f = open(os.path.join(srcPref,"..","docs",api_xml))
-            data = f.read()
-            f.close()
-            (parser, target)  = getparser()
-            parser.feed(data)
-            parser.close()
-        except IOError, msg:
-            print file, ":", msg
-            sys.exit(1)
-
-    n = len(funcs.keys())
-    if not quiet:
-        print "Found %d functions in %s" % ((n), api_xml)
-
-    override_api_xml = "%s-override-api.xml" % module
-    py_types['pythonObject'] = ('O', "pythonObject", "pythonObject", "pythonObject")
-
-    try:
-        f = open(os.path.join(srcPref, override_api_xml))
-        data = f.read()
-        f.close()
-        (parser, target)  = getparser()
-        parser.feed(data)
-        parser.close()
-    except IOError, msg:
-        print file, ":", msg
-
-    if not quiet:
-        # XXX: This is not right, same function already in @functions
-        # will be overwritten.
-        print "Found %d functions in %s" % ((len(funcs.keys()) - n), override_api_xml)
-    nb_wrap = 0
-    failed = 0
-    skipped = 0
-
-    header_file = "%s.h" % module
-    export_file = "%s-export.c" % module
-    wrapper_file = "%s.c" % module
-
-    include = open(header_file, "w")
-    include.write("/* Generated */\n\n")
-
-    export = open(export_file, "w")
-    export.write("/* Generated */\n\n")
-
-    wrapper = open(wrapper_file, "w")
-    wrapper.write("/* Generated by generator.py */\n\n")
-    wrapper.write("#include <config.h>\n")
-    wrapper.write("#include <Python.h>\n")
-    wrapper.write("#include <libvirt/" + module + ".h>\n")
-    wrapper.write("#include \"typewrappers.h\"\n")
-    wrapper.write("#include \"" + module + ".h\"\n\n")
-
-    for function in funcs.keys():
-        # Skip the functions which are not for the module
-        ret = print_function_wrapper(module, function, wrapper, export, include)
-        if ret < 0:
-            failed = failed + 1
-            funcs_failed.append(function)
-            del funcs[function]
-        if ret == 0:
-            skipped = skipped + 1
-            funcs_skipped.append(function)
-            del funcs[function]
-        if ret == 1:
-            nb_wrap = nb_wrap + 1
-    include.close()
-    export.close()
-    wrapper.close()
-
-    if not quiet:
-        print "Generated %d wrapper functions" % nb_wrap
-
-    if unknown_types:
-        print "Missing type converters: "
-        for type in unknown_types.keys():
-            print "%s:%d " % (type, len(unknown_types[type])),
-
-    for f in funcs_failed:
-        print "ERROR: failed %s" % f
-
-    if failed > 0:
-        return -1
-    if len(unknown_types) > 0:
-        return -1
-    return 0
-
-#######################################################################
-#
-#  This part writes part of the Python front-end classes based on
-#  mapping rules between types and classes and also based on function
-#  renaming to get consistent function names at the Python level
-#
-#######################################################################
-
-#
-# The type automatically remapped to generated classes
-#
-classes_type = {
-    "virDomainPtr": ("._o", "virDomain(self,_obj=%s)", "virDomain"),
-    "virDomain *": ("._o", "virDomain(self, _obj=%s)", "virDomain"),
-    "virNetworkPtr": ("._o", "virNetwork(self, _obj=%s)", "virNetwork"),
-    "virNetwork *": ("._o", "virNetwork(self, _obj=%s)", "virNetwork"),
-    "virInterfacePtr": ("._o", "virInterface(self, _obj=%s)", "virInterface"),
-    "virInterface *": ("._o", "virInterface(self, _obj=%s)", "virInterface"),
-    "virStoragePoolPtr": ("._o", "virStoragePool(self, _obj=%s)", "virStoragePool"),
-    "virStoragePool *": ("._o", "virStoragePool(self, _obj=%s)", "virStoragePool"),
-    "virStorageVolPtr": ("._o", "virStorageVol(self, _obj=%s)", "virStorageVol"),
-    "virStorageVol *": ("._o", "virStorageVol(self, _obj=%s)", "virStorageVol"),
-    "virNodeDevicePtr": ("._o", "virNodeDevice(self, _obj=%s)", "virNodeDevice"),
-    "virNodeDevice *": ("._o", "virNodeDevice(self, _obj=%s)", "virNodeDevice"),
-    "virSecretPtr": ("._o", "virSecret(self, _obj=%s)", "virSecret"),
-    "virSecret *": ("._o", "virSecret(self, _obj=%s)", "virSecret"),
-    "virNWFilterPtr": ("._o", "virNWFilter(self, _obj=%s)", "virNWFilter"),
-    "virNWFilter *": ("._o", "virNWFilter(self, _obj=%s)", "virNWFilter"),
-    "virStreamPtr": ("._o", "virStream(self, _obj=%s)", "virStream"),
-    "virStream *": ("._o", "virStream(self, _obj=%s)", "virStream"),
-    "virConnectPtr": ("._o", "virConnect(_obj=%s)", "virConnect"),
-    "virConnect *": ("._o", "virConnect(_obj=%s)", "virConnect"),
-    "virDomainSnapshotPtr": ("._o", "virDomainSnapshot(self,_obj=%s)", "virDomainSnapshot"),
-    "virDomainSnapshot *": ("._o", "virDomainSnapshot(self, _obj=%s)", "virDomainSnapshot"),
-}
-
-converter_type = {
-}
-
-primary_classes = ["virDomain", "virNetwork", "virInterface",
-                   "virStoragePool", "virStorageVol",
-                   "virConnect", "virNodeDevice", "virSecret",
-                   "virNWFilter", "virStream", "virDomainSnapshot"]
-
-classes_ancestor = {
-}
-
-classes_destructors = {
-    "virDomain": "virDomainFree",
-    "virNetwork": "virNetworkFree",
-    "virInterface": "virInterfaceFree",
-    "virStoragePool": "virStoragePoolFree",
-    "virStorageVol": "virStorageVolFree",
-    "virNodeDevice" : "virNodeDeviceFree",
-    "virSecret": "virSecretFree",
-    "virNWFilter": "virNWFilterFree",
-    "virDomainSnapshot": "virDomainSnapshotFree",
-    # We hand-craft __del__ for this one
-    #"virStream": "virStreamFree",
-}
-
-class_skip_connect_impl = {
-    "virConnect" : True,
-}
-
-class_domain_impl = {
-    "virDomainSnapshot": True,
-}
-
-functions_noexcept = {
-    'virDomainGetID': True,
-    'virDomainGetName': True,
-    'virNetworkGetName': True,
-    'virInterfaceGetName': True,
-    'virStoragePoolGetName': True,
-    'virStorageVolGetName': True,
-    'virStorageVolGetkey': True,
-    'virNodeDeviceGetName': True,
-    'virNodeDeviceGetParent': True,
-    'virSecretGetUsageType': True,
-    'virSecretGetUsageID': True,
-    'virNWFilterGetName': True,
-}
-
-reference_keepers = {
-}
-
-function_classes = {}
-
-function_classes["None"] = []
-
-function_post = {}
-
-# Functions returning an integral type which need special rules to
-# check for errors and raise exceptions.
-functions_int_exception_test = {
-    'virDomainGetMaxMemory': "%s == 0",
-}
-functions_int_default_test = "%s == -1"
-
-def is_integral_type (name):
-    return not re.search ("^(unsigned)? ?(int|long)$", name) is None
-
-def is_optional_arg(info):
-    return re.search("^\(?\optional\)?", info) is not None
-# Functions returning lists which need special rules to check for errors
-# and raise exceptions.
-functions_list_exception_test = {
-}
-functions_list_default_test = "%s is None"
-
-def is_python_noninteger_type (name):
-
-    return name[-1:] == "*"
-
-def nameFixup(name, classe, type, file):
-    # avoid a desastrous clash
-    listname = classe + "List"
-    ll = len(listname)
-    l = len(classe)
-    if name[0:l] == listname:
-        func = name[l:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:16] == "virNetworkDefine":
-        func = name[3:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:19] == "virNetworkCreateXML":
-        func = name[3:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:16] == "virNetworkLookup":
-        func = name[3:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:18] == "virInterfaceDefine":
-        func = name[3:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:21] == "virInterfaceCreateXML":
-        func = name[3:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:18] == "virInterfaceLookup":
-        func = name[3:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:15] == "virSecretDefine":
-        func = name[3:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:15] == "virSecretLookup":
-        func = name[3:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:17] == "virNWFilterDefine":
-        func = name[3:]
-        func = string.lower(func[0:3]) + func[3:]
-    elif name[0:17] == "virNWFilterLookup":
-        func = name[3:]
-        func = string.lower(func[0:3]) + func[3:]
-    elif name[0:20] == "virStoragePoolDefine":
-        func = name[3:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:23] == "virStoragePoolCreateXML":
-        func = name[3:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:20] == "virStoragePoolLookup":
-        func = name[3:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:19] == "virStorageVolDefine":
-        func = name[3:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:19] == "virStorageVolLookup":
-        func = name[3:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:20] == "virDomainGetCPUStats":
-        func = name[9:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:12] == "virDomainGet":
-        func = name[12:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:29] == "virDomainSnapshotLookupByName":
-        func = name[9:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:26] == "virDomainSnapshotListNames":
-        func = name[9:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:28] == "virDomainSnapshotNumChildren":
-        func = name[17:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:20] == "virDomainSnapshotNum":
-        func = name[9:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:26] == "virDomainSnapshotCreateXML":
-        func = name[9:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:24] == "virDomainSnapshotCurrent":
-        func = name[9:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:17] == "virDomainSnapshot":
-        func = name[17:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:9] == "virDomain":
-        func = name[9:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:13] == "virNetworkGet":
-        func = name[13:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:10] == "virNetwork":
-        func = name[10:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:15] == "virInterfaceGet":
-        func = name[15:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:12] == "virInterface":
-        func = name[12:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:12] == 'virSecretGet':
-        func = name[12:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:9] == 'virSecret':
-        func = name[9:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:14] == 'virNWFilterGet':
-        func = name[14:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:11] == 'virNWFilter':
-        func = name[11:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:12] == 'virStreamNew':
-        func = "newStream"
-    elif name[0:9] == 'virStream':
-        func = name[9:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:17] == "virStoragePoolGet":
-        func = name[17:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:14] == "virStoragePool":
-        func = name[14:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:16] == "virStorageVolGet":
-        func = name[16:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:13] == "virStorageVol":
-        func = name[13:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:13] == "virNodeDevice":
-        if name[13:16] == "Get":
-            func = string.lower(name[16]) + name[17:]
-        elif name[13:19] == "Lookup" or name[13:19] == "Create":
-            func = string.lower(name[3]) + name[4:]
-        else:
-            func = string.lower(name[13]) + name[14:]
-    elif name[0:7] == "virNode":
-        func = name[7:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:10] == "virConnect":
-        func = name[10:]
-        func = string.lower(func[0:1]) + func[1:]
-    elif name[0:3] == "xml":
-        func = name[3:]
-        func = string.lower(func[0:1]) + func[1:]
-    else:
-        func = name
-    if func == "iD":
-        func = "ID"
-    if func == "uUID":
-        func = "UUID"
-    if func == "uUIDString":
-        func = "UUIDString"
-    if func == "oSType":
-        func = "OSType"
-    if func == "xMLDesc":
-        func = "XMLDesc"
-    if func == "mACString":
-        func = "MACString"
-
-    return func
-
-
-def functionCompare(info1, info2):
-    (index1, func1, name1, ret1, args1, file1, mod1) = info1
-    (index2, func2, name2, ret2, args2, file2, mod2) = info2
-    if file1 == file2:
-        if func1 < func2:
-            return -1
-        if func1 > func2:
-            return 1
-    if file1 == "python_accessor":
-        return -1
-    if file2 == "python_accessor":
-        return 1
-    if file1 < file2:
-        return -1
-    if file1 > file2:
-        return 1
-    return 0
-
-def writeDoc(module, name, args, indent, output):
-     if module == "libvirt":
-         funcs = functions
-     elif module == "libvirt-lxc":
-         funcs = lxc_functions
-     elif module == "libvirt-qemu":
-         funcs = qemu_functions
-     if funcs[name][0] is None or funcs[name][0] == "":
-         return
-     val = funcs[name][0]
-     val = string.replace(val, "NULL", "None")
-     output.write(indent)
-     output.write('"""')
-     i = string.find(val, "\n")
-     while i >= 0:
-         str = val[0:i+1]
-         val = val[i+1:]
-         output.write(str)
-         i = string.find(val, "\n")
-         output.write(indent)
-     output.write(val)
-     output.write(' """\n')
-
-def buildWrappers(module):
-    global ctypes
-    global py_types
-    global py_return_types
-    global unknown_types
-    global functions
-    global function_classes
-    global classes_type
-    global classes_list
-    global primary_classes
-    global classes_ancestor
-    global converter_type
-    global classes_destructors
-    global functions_noexcept
-
-    if not module == "libvirt":
-        print "ERROR: Unknown module type: %s" % module
-        return None
-
-    for type in classes_type.keys():
-        function_classes[classes_type[type][2]] = []
-
-    #
-    # Build the list of C types to look for ordered to start
-    # with primary classes
-    #
-    ctypes = []
-    classes_list = []
-    ctypes_processed = {}
-    classes_processed = {}
-    for classe in primary_classes:
-        classes_list.append(classe)
-        classes_processed[classe] = ()
-        for type in classes_type.keys():
-            tinfo = classes_type[type]
-            if tinfo[2] == classe:
-                ctypes.append(type)
-                ctypes_processed[type] = ()
-    for type in classes_type.keys():
-        if ctypes_processed.has_key(type):
-            continue
-        tinfo = classes_type[type]
-        if not classes_processed.has_key(tinfo[2]):
-            classes_list.append(tinfo[2])
-            classes_processed[tinfo[2]] = ()
-
-        ctypes.append(type)
-        ctypes_processed[type] = ()
-
-    for name in functions.keys():
-        found = 0
-        (desc, ret, args, file, mod, cond) = functions[name]
-        for type in ctypes:
-            classe = classes_type[type][2]
-
-            if name[0:3] == "vir" and len(args) >= 1 and args[0][1] == type:
-                found = 1
-                func = nameFixup(name, classe, type, file)
-                info = (0, func, name, ret, args, file, mod)
-                function_classes[classe].append(info)
-            elif name[0:3] == "vir" and len(args) >= 2 and args[1][1] == type \
-                and file != "python_accessor" and not name in function_skip_index_one:
-                found = 1
-                func = nameFixup(name, classe, type, file)
-                info = (1, func, name, ret, args, file, mod)
-                function_classes[classe].append(info)
-        if found == 1:
-            continue
-        func = nameFixup(name, "None", file, file)
-        info = (0, func, name, ret, args, file, mod)
-        function_classes['None'].append(info)
-
-    classes_file = "%s.py" % module
-    extra_file = os.path.join(srcPref, "%s-override.py" % module)
-    extra = None
-
-    classes = open(classes_file, "w")
-
-    if os.path.exists(extra_file):
-        extra = open(extra_file, "r")
-    classes.write("#! " + python + " -i\n")
-    classes.write("#\n")
-    classes.write("# WARNING WARNING WARNING WARNING\n")
-    classes.write("#\n")
-    classes.write("# This file is automatically written by generator.py. Any changes\n")
-    classes.write("# made here will be lost.\n")
-    classes.write("#\n")
-    classes.write("# To change the manually written methods edit " + module + "-override.py\n")
-    classes.write("# To change the automatically written methods edit generator.py\n")
-    classes.write("#\n")
-    classes.write("# WARNING WARNING WARNING WARNING\n")
-    classes.write("#\n")
-    if extra is not None:
-        classes.writelines(extra.readlines())
-    classes.write("#\n")
-    classes.write("# WARNING WARNING WARNING WARNING\n")
-    classes.write("#\n")
-    classes.write("# Automatically written part of python bindings for libvirt\n")
-    classes.write("#\n")
-    classes.write("# WARNING WARNING WARNING WARNING\n")
-    if extra is not None:
-        extra.close()
-
-    if function_classes.has_key("None"):
-        flist = function_classes["None"]
-        flist.sort(functionCompare)
-        oldfile = ""
-        for info in flist:
-            (index, func, name, ret, args, file, mod) = info
-            if file != oldfile:
-                classes.write("#\n# Functions from module %s\n#\n\n" % file)
-                oldfile = file
-            classes.write("def %s(" % func)
-            n = 0
-            for arg in args:
-                if n != 0:
-                    classes.write(", ")
-                classes.write("%s" % arg[0])
-                if arg[0] == "flags" or is_optional_arg(arg[2]):
-                    if is_integral_type(arg[1]):
-                        classes.write("=0")
-                    else:
-                        classes.write("=None")
-                n = n + 1
-            classes.write("):\n")
-            writeDoc(module, name, args, '    ', classes)
-
-            for arg in args:
-                if classes_type.has_key(arg[1]):
-                    classes.write("    if %s is None: %s__o = None\n" %
-                                  (arg[0], arg[0]))
-                    classes.write("    else: %s__o = %s%s\n" %
-                                  (arg[0], arg[0], classes_type[arg[1]][0]))
-            if ret[0] != "void":
-                classes.write("    ret = ")
-            else:
-                classes.write("    ")
-            classes.write("libvirtmod.%s(" % name)
-            n = 0
-            for arg in args:
-                if n != 0:
-                    classes.write(", ")
-                classes.write("%s" % arg[0])
-                if classes_type.has_key(arg[1]):
-                    classes.write("__o")
-                n = n + 1
-            classes.write(")\n")
-
-            if ret[0] != "void":
-                if classes_type.has_key(ret[0]):
-                    #
-                    # Raise an exception
-                    #
-                    if functions_noexcept.has_key(name):
-                        classes.write("    if ret is None:return None\n")
-                    else:
-                        classes.write(
-                     "    if ret is None:raise libvirtError('%s() failed')\n" %
-                                      (name))
-
-                    classes.write("    return ")
-                    classes.write(classes_type[ret[0]][1] % ("ret"))
-                    classes.write("\n")
-
-                # For functions returning an integral type there are
-                # several things that we can do, depending on the
-                # contents of functions_int_*:
-                elif is_integral_type (ret[0]):
-                    if not functions_noexcept.has_key (name):
-                        if functions_int_exception_test.has_key (name):
-                            test = functions_int_exception_test[name]
-                        else:
-                            test = functions_int_default_test
-                        classes.write (("    if " + test +
-                                        ": raise libvirtError ('%s() failed')\n") %
-                                       ("ret", name))
-                    classes.write("    return ret\n")
-
-                elif is_python_noninteger_type (ret[0]):
-                    if not functions_noexcept.has_key (name):
-                        if functions_list_exception_test.has_key (name):
-                            test = functions_list_exception_test[name]
-                        else:
-                            test = functions_list_default_test
-                        classes.write (("    if " + test +
-                                        ": raise libvirtError ('%s() failed')\n") %
-                                       ("ret", name))
-                    classes.write("    return ret\n")
-
-                else:
-                    classes.write("    return ret\n")
-
-            classes.write("\n")
-
-    for classname in classes_list:
-        if classname == "None":
-            pass
-        else:
-            if classes_ancestor.has_key(classname):
-                classes.write("class %s(%s):\n" % (classname,
-                              classes_ancestor[classname]))
-                classes.write("    def __init__(self, _obj=None):\n")
-                if reference_keepers.has_key(classname):
-                    rlist = reference_keepers[classname]
-                    for ref in rlist:
-                        classes.write("        self.%s = None\n" % ref[1])
-                classes.write("        self._o = _obj\n")
-                classes.write("        %s.__init__(self, _obj=_obj)\n\n" % (
-                              classes_ancestor[classname]))
-            else:
-                classes.write("class %s(object):\n" % (classname))
-                if classname in [ "virDomain", "virNetwork", "virInterface", "virStoragePool",
-                                  "virStorageVol", "virNodeDevice", "virSecret","virStream",
-                                  "virNWFilter" ]:
-                    classes.write("    def __init__(self, conn, _obj=None):\n")
-                elif classname in [ 'virDomainSnapshot' ]:
-                    classes.write("    def __init__(self, dom, _obj=None):\n")
-                else:
-                    classes.write("    def __init__(self, _obj=None):\n")
-                if reference_keepers.has_key(classname):
-                    list = reference_keepers[classname]
-                    for ref in list:
-                        classes.write("        self.%s = None\n" % ref[1])
-                if classname in [ "virDomain", "virNetwork", "virInterface",
-                                  "virNodeDevice", "virSecret", "virStream",
-                                  "virNWFilter" ]:
-                    classes.write("        self._conn = conn\n")
-                elif classname in [ "virStorageVol", "virStoragePool" ]:
-                    classes.write("        self._conn = conn\n" + \
-                                  "        if not isinstance(conn, virConnect):\n" + \
-                                  "            self._conn = conn._conn\n")
-                elif classname in [ "virDomainSnapshot" ]:
-                    classes.write("        self._dom = dom\n")
-                    classes.write("        self._conn = dom.connect()\n")
-                classes.write("        self._o = _obj\n\n")
-            destruct=None
-            if classes_destructors.has_key(classname):
-                classes.write("    def __del__(self):\n")
-                classes.write("        if self._o is not None:\n")
-                classes.write("            libvirtmod.%s(self._o)\n" %
-                              classes_destructors[classname])
-                classes.write("        self._o = None\n\n")
-                destruct=classes_destructors[classname]
-
-            if not class_skip_connect_impl.has_key(classname):
-                # Build python safe 'connect' method
-                classes.write("    def connect(self):\n")
-                classes.write("        return self._conn\n\n")
-
-            if class_domain_impl.has_key(classname):
-                classes.write("    def domain(self):\n")
-                classes.write("        return self._dom\n\n")
-
-            flist = function_classes[classname]
-            flist.sort(functionCompare)
-            oldfile = ""
-            for info in flist:
-                (index, func, name, ret, args, file, mod) = info
-                #
-                # Do not provide as method the destructors for the class
-                # to avoid double free
-                #
-                if name == destruct:
-                    continue
-                if file != oldfile:
-                    if file == "python_accessor":
-                        classes.write("    # accessors for %s\n" % (classname))
-                    else:
-                        classes.write("    #\n")
-                        classes.write("    # %s functions from module %s\n" % (
-                                      classname, file))
-                        classes.write("    #\n\n")
-                oldfile = file
-                classes.write("    def %s(self" % func)
-                n = 0
-                for arg in args:
-                    if n != index:
-                        classes.write(", %s" % arg[0])
-                    if arg[0] == "flags" or is_optional_arg(arg[2]):
-                        if is_integral_type(arg[1]):
-                           classes.write("=0")
-                        else:
-                           classes.write("=None")
-                    n = n + 1
-                classes.write("):\n")
-                writeDoc(module, name, args, '        ', classes)
-                n = 0
-                for arg in args:
-                    if classes_type.has_key(arg[1]):
-                        if n != index:
-                            classes.write("        if %s is None: %s__o = None\n" %
-                                          (arg[0], arg[0]))
-                            classes.write("        else: %s__o = %s%s\n" %
-                                          (arg[0], arg[0], classes_type[arg[1]][0]))
-                    n = n + 1
-                if ret[0] != "void":
-                    classes.write("        ret = ")
-                else:
-                    classes.write("        ")
-                n = 0
-                classes.write("libvirtmod.%s(" % name)
-                for arg in args:
-                    if n != 0:
-                        classes.write(", ")
-                    if n != index:
-                        classes.write("%s" % arg[0])
-                        if classes_type.has_key(arg[1]):
-                            classes.write("__o")
-                    else:
-                        classes.write("self")
-                        if classes_type.has_key(arg[1]):
-                            classes.write(classes_type[arg[1]][0])
-                    n = n + 1
-                classes.write(")\n")
-
-                if name == "virConnectClose":
-                    classes.write("        self._o = None\n")
-
-                # For functions returning object types:
-                if ret[0] != "void":
-                    if classes_type.has_key(ret[0]):
-                        #
-                        # Raise an exception
-                        #
-                        if functions_noexcept.has_key(name):
-                            classes.write(
-                                "        if ret is None:return None\n")
-                        else:
-                            if classname == "virConnect":
-                                classes.write(
-                     "        if ret is None:raise libvirtError('%s() failed', conn=self)\n" %
-                                              (name))
-                            elif classname == "virDomain":
-                                classes.write(
-                     "        if ret is None:raise libvirtError('%s() failed', dom=self)\n" %
-                                              (name))
-                            elif classname == "virNetwork":
-                                classes.write(
-                     "        if ret is None:raise libvirtError('%s() failed', net=self)\n" %
-                                              (name))
-                            elif classname == "virInterface":
-                                classes.write(
-                     "        if ret is None:raise libvirtError('%s() failed', net=self)\n" %
-                                              (name))
-                            elif classname == "virStoragePool":
-                                classes.write(
-                     "        if ret is None:raise libvirtError('%s() failed', pool=self)\n" %
-                                              (name))
-                            elif classname == "virStorageVol":
-                                classes.write(
-                     "        if ret is None:raise libvirtError('%s() failed', vol=self)\n" %
-                                              (name))
-                            elif classname == "virDomainSnapshot":
-                                classes.write(
-                     "        if ret is None:raise libvirtError('%s() failed', dom=self._dom)\n" %
-                                              (name))
-                            else:
-                                classes.write(
-                     "        if ret is None:raise libvirtError('%s() failed')\n" %
-                                              (name))
-
-                        #
-                        # generate the returned class wrapper for the object
-                        #
-                        classes.write("        __tmp = ")
-                        classes.write(classes_type[ret[0]][1] % ("ret"))
-                        classes.write("\n")
-
-                        #
-                        # Sometime one need to keep references of the source
-                        # class in the returned class object.
-                        # See reference_keepers for the list
-                        #
-                        tclass = classes_type[ret[0]][2]
-                        if reference_keepers.has_key(tclass):
-                            list = reference_keepers[tclass]
-                            for pref in list:
-                                if pref[0] == classname:
-                                    classes.write("        __tmp.%s = self\n" %
-                                                  pref[1])
-
-                        # Post-processing - just before we return.
-                        if function_post.has_key(name):
-                            classes.write("        %s\n" %
-                                          (function_post[name]))
-
-                        #
-                        # return the class
-                        #
-                        classes.write("        return __tmp\n")
-                    elif converter_type.has_key(ret[0]):
-                        #
-                        # Raise an exception
-                        #
-                        if functions_noexcept.has_key(name):
-                            classes.write(
-                                "        if ret is None:return None")
-
-                        # Post-processing - just before we return.
-                        if function_post.has_key(name):
-                            classes.write("        %s\n" %
-                                          (function_post[name]))
-
-                        classes.write("        return ")
-                        classes.write(converter_type[ret[0]] % ("ret"))
-                        classes.write("\n")
-
-                    # For functions returning an integral type there
-                    # are several things that we can do, depending on
-                    # the contents of functions_int_*:
-                    elif is_integral_type (ret[0]):
-                        if not functions_noexcept.has_key (name):
-                            if functions_int_exception_test.has_key (name):
-                                test = functions_int_exception_test[name]
-                            else:
-                                test = functions_int_default_test
-                            if classname == "virConnect":
-                                classes.write (("        if " + test +
-                                                ": raise libvirtError ('%s() failed', conn=self)\n") %
-                                               ("ret", name))
-                            elif classname == "virDomain":
-                                classes.write (("        if " + test +
-                                                ": raise libvirtError ('%s() failed', dom=self)\n") %
-                                               ("ret", name))
-                            elif classname == "virNetwork":
-                                classes.write (("        if " + test +
-                                                ": raise libvirtError ('%s() failed', net=self)\n") %
-                                               ("ret", name))
-                            elif classname == "virInterface":
-                                classes.write (("        if " + test +
-                                                ": raise libvirtError ('%s() failed', net=self)\n") %
-                                               ("ret", name))
-                            elif classname == "virStoragePool":
-                                classes.write (("        if " + test +
-                                                ": raise libvirtError ('%s() failed', pool=self)\n") %
-                                               ("ret", name))
-                            elif classname == "virStorageVol":
-                                classes.write (("        if " + test +
-                                                ": raise libvirtError ('%s() failed', vol=self)\n") %
-                                               ("ret", name))
-                            else:
-                                classes.write (("        if " + test +
-                                                ": raise libvirtError ('%s() failed')\n") %
-                                               ("ret", name))
-
-                        # Post-processing - just before we return.
-                        if function_post.has_key(name):
-                            classes.write("        %s\n" %
-                                          (function_post[name]))
-
-                        classes.write ("        return ret\n")
-
-                    elif is_python_noninteger_type (ret[0]):
-                        if not functions_noexcept.has_key (name):
-                            if functions_list_exception_test.has_key (name):
-                                test = functions_list_exception_test[name]
-                            else:
-                                test = functions_list_default_test
-                            if classname == "virConnect":
-                                classes.write (("        if " + test +
-                                                ": raise libvirtError ('%s() failed', conn=self)\n") %
-                                               ("ret", name))
-                            elif classname == "virDomain":
-                                classes.write (("        if " + test +
-                                                ": raise libvirtError ('%s() failed', dom=self)\n") %
-                                               ("ret", name))
-                            elif classname == "virNetwork":
-                                classes.write (("        if " + test +
-                                                ": raise libvirtError ('%s() failed', net=self)\n") %
-                                               ("ret", name))
-                            elif classname == "virInterface":
-                                classes.write (("        if " + test +
-                                                ": raise libvirtError ('%s() failed', net=self)\n") %
-                                               ("ret", name))
-                            elif classname == "virStoragePool":
-                                classes.write (("        if " + test +
-                                                ": raise libvirtError ('%s() failed', pool=self)\n") %
-                                               ("ret", name))
-                            elif classname == "virStorageVol":
-                                classes.write (("        if " + test +
-                                                ": raise libvirtError ('%s() failed', vol=self)\n") %
-                                               ("ret", name))
-                            else:
-                                classes.write (("        if " + test +
-                                                ": raise libvirtError ('%s() failed')\n") %
-                                               ("ret", name))
-
-                        # Post-processing - just before we return.
-                        if function_post.has_key(name):
-                            classes.write("        %s\n" %
-                                          (function_post[name]))
-
-                        classes.write ("        return ret\n")
-
-                    else:
-                        # Post-processing - just before we return.
-                        if function_post.has_key(name):
-                            classes.write("        %s\n" %
-                                          (function_post[name]))
-
-                        classes.write("        return ret\n")
-
-                classes.write("\n")
-            # Append "<classname>.py" to class def, iff it exists
-            try:
-                extra = open(os.path.join(srcPref,"libvirt-override-" + classname + ".py"), "r")
-                classes.write ("    #\n")
-                classes.write ("    # %s methods from %s.py (hand coded)\n" % (classname,classname))
-                classes.write ("    #\n")
-                classes.writelines(extra.readlines())
-                classes.write("\n")
-                extra.close()
-            except:
-                pass
-
-    #
-    # Generate enum constants
-    #
-    for type,enum in enums.items():
-        classes.write("# %s\n" % type)
-        items = enum.items()
-        items.sort(lambda i1,i2: cmp(long(i1[1]),long(i2[1])))
-        for name,value in items:
-            classes.write("%s = %s\n" % (name,value))
-        classes.write("\n")
-
-    classes.close()
-
-def qemuBuildWrappers(module):
-    global qemu_functions
-
-    if not module == "libvirt-qemu":
-        print "ERROR: only libvirt-qemu is supported"
-        return None
-
-    extra_file = os.path.join(srcPref, "%s-override.py" % module)
-    extra = None
-
-    fd = open("libvirt_qemu.py", "w")
-
-    if os.path.exists(extra_file):
-        extra = open(extra_file, "r")
-    fd.write("#! " + python + " -i\n")
-    fd.write("#\n")
-    fd.write("# WARNING WARNING WARNING WARNING\n")
-    fd.write("#\n")
-    fd.write("# This file is automatically written by generator.py. Any changes\n")
-    fd.write("# made here will be lost.\n")
-    fd.write("#\n")
-    fd.write("# To change the manually written methods edit " + module + "-override.py\n")
-    fd.write("# To change the automatically written methods edit generator.py\n")
-    fd.write("#\n")
-    fd.write("# WARNING WARNING WARNING WARNING\n")
-    fd.write("#\n")
-    if extra is not None:
-        fd.writelines(extra.readlines())
-    fd.write("#\n")
-    fd.write("# WARNING WARNING WARNING WARNING\n")
-    fd.write("#\n")
-    fd.write("# Automatically written part of python bindings for libvirt\n")
-    fd.write("#\n")
-    fd.write("# WARNING WARNING WARNING WARNING\n")
-    if extra is not None:
-        extra.close()
-
-    fd.write("try:\n")
-    fd.write("    import libvirtmod_qemu\n")
-    fd.write("except ImportError, lib_e:\n")
-    fd.write("    try:\n")
-    fd.write("        import cygvirtmod_qemu as libvirtmod_qemu\n")
-    fd.write("    except ImportError, cyg_e:\n")
-    fd.write("        if str(cyg_e).count(\"No module named\"):\n")
-    fd.write("            raise lib_e\n\n")
-
-    fd.write("import libvirt\n\n")
-    fd.write("#\n# Functions from module %s\n#\n\n" % module)
-    #
-    # Generate functions directly, no classes
-    #
-    for name in qemu_functions.keys():
-        func = nameFixup(name, 'None', None, None)
-        (desc, ret, args, file, mod, cond) = qemu_functions[name]
-        fd.write("def %s(" % func)
-        n = 0
-        for arg in args:
-            if n != 0:
-                fd.write(", ")
-            fd.write("%s" % arg[0])
-            n = n + 1
-        fd.write("):\n")
-        writeDoc(module, name, args, '    ', fd)
-
-        if ret[0] != "void":
-            fd.write("    ret = ")
-        else:
-            fd.write("    ")
-        fd.write("libvirtmod_qemu.%s(" % name)
-        n = 0
-
-        conn = None
-
-        for arg in args:
-            if arg[1] == "virConnectPtr":
-                conn = arg[0]
-
-            if n != 0:
-                fd.write(", ")
-            if arg[1] in ["virDomainPtr", "virConnectPtr"]:
-                # FIXME: This might have problem if the function
-                # has multiple args which are objects.
-                fd.write("%s.%s" % (arg[0], "_o"))
-            else:
-                fd.write("%s" % arg[0])
-            n = n + 1
-        fd.write(")\n")
-
-        if ret[0] != "void":
-            fd.write("    if ret is None: raise libvirt.libvirtError('" + name + "() failed')\n")
-            if ret[0] == "virDomainPtr":
-                fd.write("    __tmp = virDomain(" + conn + ",_obj=ret)\n")
-                fd.write("    return __tmp\n")
-            else:
-                fd.write("    return ret\n")
-
-        fd.write("\n")
-
-    #
-    # Generate enum constants
-    #
-    for type,enum in qemu_enums.items():
-        fd.write("# %s\n" % type)
-        items = enum.items()
-        items.sort(lambda i1,i2: cmp(long(i1[1]),long(i2[1])))
-        for name,value in items:
-            fd.write("%s = %s\n" % (name,value))
-        fd.write("\n")
-
-    fd.close()
-
-
-def lxcBuildWrappers(module):
-    global lxc_functions
-
-    if not module == "libvirt-lxc":
-        print "ERROR: only libvirt-lxc is supported"
-        return None
-
-    extra_file = os.path.join(srcPref, "%s-override.py" % module)
-    extra = None
-
-    fd = open("libvirt_lxc.py", "w")
-
-    if os.path.exists(extra_file):
-        extra = open(extra_file, "r")
-    fd.write("#! " + python + " -i\n")
-    fd.write("#\n")
-    fd.write("# WARNING WARNING WARNING WARNING\n")
-    fd.write("#\n")
-    fd.write("# This file is automatically written by generator.py. Any changes\n")
-    fd.write("# made here will be lost.\n")
-    fd.write("#\n")
-    fd.write("# To change the manually written methods edit " + module + "-override.py\n")
-    fd.write("# To change the automatically written methods edit generator.py\n")
-    fd.write("#\n")
-    fd.write("# WARNING WARNING WARNING WARNING\n")
-    fd.write("#\n")
-    if extra is not None:
-        fd.writelines(extra.readlines())
-    fd.write("#\n")
-    fd.write("# WARNING WARNING WARNING WARNING\n")
-    fd.write("#\n")
-    fd.write("# Automatically written part of python bindings for libvirt\n")
-    fd.write("#\n")
-    fd.write("# WARNING WARNING WARNING WARNING\n")
-    if extra is not None:
-        extra.close()
-
-    fd.write("try:\n")
-    fd.write("    import libvirtmod_lxc\n")
-    fd.write("except ImportError, lib_e:\n")
-    fd.write("    try:\n")
-    fd.write("        import cygvirtmod_lxc as libvirtmod_lxc\n")
-    fd.write("    except ImportError, cyg_e:\n")
-    fd.write("        if str(cyg_e).count(\"No module named\"):\n")
-    fd.write("            raise lib_e\n\n")
-
-    fd.write("import libvirt\n\n")
-    fd.write("#\n# Functions from module %s\n#\n\n" % module)
-    #
-    # Generate functions directly, no classes
-    #
-    for name in lxc_functions.keys():
-        func = nameFixup(name, 'None', None, None)
-        (desc, ret, args, file, mod, cond) = lxc_functions[name]
-        fd.write("def %s(" % func)
-        n = 0
-        for arg in args:
-            if n != 0:
-                fd.write(", ")
-            fd.write("%s" % arg[0])
-            n = n + 1
-        fd.write("):\n")
-        writeDoc(module, name, args, '    ', fd)
-
-        if ret[0] != "void":
-            fd.write("    ret = ")
-        else:
-            fd.write("    ")
-        fd.write("libvirtmod_lxc.%s(" % name)
-        n = 0
-
-        conn = None
-
-        for arg in args:
-            if arg[1] == "virConnectPtr":
-                conn = arg[0]
-
-            if n != 0:
-                fd.write(", ")
-            if arg[1] in ["virDomainPtr", "virConnectPtr"]:
-                # FIXME: This might have problem if the function
-                # has multiple args which are objects.
-                fd.write("%s.%s" % (arg[0], "_o"))
-            else:
-                fd.write("%s" % arg[0])
-            n = n + 1
-        fd.write(")\n")
-
-        if ret[0] != "void":
-            fd.write("    if ret is None: raise libvirt.libvirtError('" + name + "() failed')\n")
-            if ret[0] == "virDomainPtr":
-                fd.write("    __tmp = virDomain(" + conn + ",_obj=ret)\n")
-                fd.write("    return __tmp\n")
-            else:
-                fd.write("    return ret\n")
-
-        fd.write("\n")
-
-    #
-    # Generate enum constants
-    #
-    for type,enum in lxc_enums.items():
-        fd.write("# %s\n" % type)
-        items = enum.items()
-        items.sort(lambda i1,i2: cmp(long(i1[1]),long(i2[1])))
-        for name,value in items:
-            fd.write("%s = %s\n" % (name,value))
-        fd.write("\n")
-
-    fd.close()
-
-
-quiet = 0
-if buildStubs("libvirt") < 0:
-    sys.exit(1)
-if buildStubs("libvirt-lxc") < 0:
-    sys.exit(1)
-if buildStubs("libvirt-qemu") < 0:
-    sys.exit(1)
-buildWrappers("libvirt")
-lxcBuildWrappers("libvirt-lxc")
-qemuBuildWrappers("libvirt-qemu")
-sys.exit(0)
diff --git a/python/libvirt-lxc-override-api.xml b/python/libvirt-lxc-override-api.xml
deleted file mode 100644
index db0d45d..0000000
--- a/python/libvirt-lxc-override-api.xml
+++ /dev/null
@@ -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>
diff --git a/python/libvirt-lxc-override.c b/python/libvirt-lxc-override.c
deleted file mode 100644
index f76ff4b..0000000
--- a/python/libvirt-lxc-override.c
+++ /dev/null
@@ -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 at 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;
-}
diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml
deleted file mode 100644
index 337d0a0..0000000
--- a/python/libvirt-override-api.xml
+++ /dev/null
@@ -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>
diff --git a/python/libvirt-override-virConnect.py b/python/libvirt-override-virConnect.py
deleted file mode 100644
index 4ba3d30..0000000
--- a/python/libvirt-override-virConnect.py
+++ /dev/null
@@ -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
diff --git a/python/libvirt-override-virDomain.py b/python/libvirt-override-virDomain.py
deleted file mode 100644
index c96cc5e..0000000
--- a/python/libvirt-override-virDomain.py
+++ /dev/null
@@ -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
diff --git a/python/libvirt-override-virDomainSnapshot.py b/python/libvirt-override-virDomainSnapshot.py
deleted file mode 100644
index ec53358..0000000
--- a/python/libvirt-override-virDomainSnapshot.py
+++ /dev/null
@@ -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
diff --git a/python/libvirt-override-virStoragePool.py b/python/libvirt-override-virStoragePool.py
deleted file mode 100644
index 325e403..0000000
--- a/python/libvirt-override-virStoragePool.py
+++ /dev/null
@@ -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
diff --git a/python/libvirt-override-virStream.py b/python/libvirt-override-virStream.py
deleted file mode 100644
index 53000da..0000000
--- a/python/libvirt-override-virStream.py
+++ /dev/null
@@ -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
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
deleted file mode 100644
index c60747d..0000000
--- a/python/libvirt-override.c
+++ /dev/null
@@ -1,7379 +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) 2005, 2007-2013 Red Hat, Inc.
- *
- * Daniel Veillard <veillard at 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
-
-/* We want to see *_LAST enums.  */
-#define VIR_ENUM_SENTINELS
-
-#include <Python.h>
-#include <libvirt/libvirt.h>
-#include <libvirt/virterror.h>
-#include "typewrappers.h"
-#include "libvirt.h"
-#include "viralloc.h"
-#include "virtypedparam.h"
-#include "ignore-value.h"
-#include "virutil.h"
-#include "virstring.h"
-
-#ifndef __CYGWIN__
-extern void initlibvirtmod(void);
-#else
-extern void initcygvirtmod(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))
-
-/* We don't want to free() returned value. As written in doc:
- * PyString_AsString returns pointer to 'internal buffer of string,
- * not a copy' and 'It must not be deallocated'. */
-static char *py_str(PyObject *obj)
-{
-    PyObject *str = PyObject_Str(obj);
-    if (!str) {
-        PyErr_Print();
-        PyErr_Clear();
-        return NULL;
-    };
-    return PyString_AsString(str);
-}
-
-/* Helper function to convert a virTypedParameter output array into a
- * Python dictionary for return to the user.  Return NULL on failure,
- * after raising a python exception.  */
-static PyObject *
-getPyVirTypedParameter(const virTypedParameter *params, int nparams)
-{
-    PyObject *key, *val, *info;
-    size_t i;
-
-    if ((info = PyDict_New()) == NULL)
-        return NULL;
-
-    for (i = 0; i < nparams; i++) {
-        switch (params[i].type) {
-        case VIR_TYPED_PARAM_INT:
-            val = PyInt_FromLong(params[i].value.i);
-            break;
-
-        case VIR_TYPED_PARAM_UINT:
-            val = PyInt_FromLong(params[i].value.ui);
-            break;
-
-        case VIR_TYPED_PARAM_LLONG:
-            val = PyLong_FromLongLong(params[i].value.l);
-            break;
-
-        case VIR_TYPED_PARAM_ULLONG:
-            val = PyLong_FromUnsignedLongLong(params[i].value.ul);
-            break;
-
-        case VIR_TYPED_PARAM_DOUBLE:
-            val = PyFloat_FromDouble(params[i].value.d);
-            break;
-
-        case VIR_TYPED_PARAM_BOOLEAN:
-            val = PyBool_FromLong(params[i].value.b);
-            break;
-
-        case VIR_TYPED_PARAM_STRING:
-            val = libvirt_constcharPtrWrap(params[i].value.s);
-            break;
-
-        default:
-            /* Possible if a newer server has a bug and sent stuff we
-             * don't recognize.  */
-            PyErr_Format(PyExc_LookupError,
-                         "Type value \"%d\" not recognized",
-                         params[i].type);
-            val = NULL;
-            break;
-        }
-
-        key = libvirt_constcharPtrWrap(params[i].field);
-        if (!key || !val)
-            goto cleanup;
-
-        if (PyDict_SetItem(info, key, val) < 0) {
-            Py_DECREF(info);
-            goto cleanup;
-        }
-
-        Py_DECREF(key);
-        Py_DECREF(val);
-    }
-    return info;
-
-cleanup:
-    Py_XDECREF(key);
-    Py_XDECREF(val);
-    return NULL;
-}
-
-/* Allocate a new typed parameter array with the same contents and
- * length as info, and using the array params of length nparams as
- * hints on what types to use when creating the new array. The caller
- * must NOT clear the array before freeing it, as it points into info
- * rather than allocated strings.  Return NULL on failure, after
- * raising a python exception.  */
-static virTypedParameterPtr ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
-setPyVirTypedParameter(PyObject *info,
-                       const virTypedParameter *params, int nparams)
-{
-    PyObject *key, *value;
-#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 4
-    int pos = 0;
-#else
-    Py_ssize_t pos = 0;
-#endif
-    virTypedParameterPtr temp = NULL, ret = NULL;
-    Py_ssize_t size;
-    size_t i;
-
-    if ((size = PyDict_Size(info)) < 0)
-        return NULL;
-
-    /* Libvirt APIs use NULL array and 0 size as a special case;
-     * setting should have at least one parameter.  */
-    if (size == 0) {
-        PyErr_Format(PyExc_LookupError, "Dictionary must not be empty");
-        return NULL;
-    }
-
-    if (VIR_ALLOC_N_QUIET(ret, size) < 0) {
-        PyErr_NoMemory();
-        return NULL;
-    }
-
-    temp = &ret[0];
-    while (PyDict_Next(info, &pos, &key, &value)) {
-        char *keystr = NULL;
-
-        if ((keystr = PyString_AsString(key)) == NULL)
-            goto cleanup;
-
-        for (i = 0; i < nparams; i++) {
-            if (STREQ(params[i].field, keystr))
-                break;
-        }
-        if (i == nparams) {
-            PyErr_Format(PyExc_LookupError,
-                         "Attribute name \"%s\" could not be recognized",
-                         keystr);
-            goto cleanup;
-        }
-
-        ignore_value(virStrcpyStatic(temp->field, keystr));
-        temp->type = params[i].type;
-
-        switch (params[i].type) {
-        case VIR_TYPED_PARAM_INT:
-            if (libvirt_intUnwrap(value, &temp->value.i) < 0)
-                goto cleanup;
-            break;
-
-        case VIR_TYPED_PARAM_UINT:
-            if (libvirt_uintUnwrap(value, &temp->value.ui) < 0)
-                goto cleanup;
-            break;
-
-        case VIR_TYPED_PARAM_LLONG:
-            if (libvirt_longlongUnwrap(value, &temp->value.l) < 0)
-                goto cleanup;
-            break;
-
-        case VIR_TYPED_PARAM_ULLONG:
-            if (libvirt_ulonglongUnwrap(value, &temp->value.ul) < 0)
-                goto cleanup;
-            break;
-
-        case VIR_TYPED_PARAM_DOUBLE:
-            if (libvirt_doubleUnwrap(value, &temp->value.d) < 0)
-                goto cleanup;
-            break;
-
-        case VIR_TYPED_PARAM_BOOLEAN:
-        {
-            bool b;
-            if (libvirt_boolUnwrap(value, &b) < 0)
-                goto cleanup;
-            temp->value.b = b;
-            break;
-        }
-        case VIR_TYPED_PARAM_STRING:
-        {
-            char *string_val = PyString_AsString(value);
-            if (!string_val)
-                goto cleanup;
-            temp->value.s = string_val;
-            break;
-        }
-
-        default:
-            /* Possible if a newer server has a bug and sent stuff we
-             * don't recognize.  */
-            PyErr_Format(PyExc_LookupError,
-                         "Type value \"%d\" not recognized",
-                         params[i].type);
-            goto cleanup;
-        }
-
-        temp++;
-    }
-    return ret;
-
-cleanup:
-    VIR_FREE(ret);
-    return NULL;
-}
-
-
-typedef struct {
-    const char *name;
-    int type;
-} virPyTypedParamsHint;
-typedef virPyTypedParamsHint *virPyTypedParamsHintPtr;
-
-/* Automatically convert dict into type parameters based on types reported
- * by python. All integer types are converted into LLONG (in case of a negative
- * value) or ULLONG (in case of a positive value). If you need different
- * handling, use @hints to explicitly specify what types should be used for
- * specific parameters.
- */
-static int
-ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
-virPyDictToTypedParams(PyObject *dict,
-                       virTypedParameterPtr *ret_params,
-                       int *ret_nparams,
-                       virPyTypedParamsHintPtr hints,
-                       int nhints)
-{
-    PyObject *key;
-    PyObject *value;
-#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 4
-    int pos = 0;
-#else
-    Py_ssize_t pos = 0;
-#endif
-    virTypedParameterPtr params = NULL;
-    size_t i;
-    int n = 0;
-    int max = 0;
-    int ret = -1;
-
-    *ret_params = NULL;
-    *ret_nparams = 0;
-
-    if (PyDict_Size(dict) < 0)
-        return -1;
-
-    while (PyDict_Next(dict, &pos, &key, &value)) {
-        char *keystr;
-        int type = -1;
-
-        if (!(keystr = PyString_AsString(key)))
-            goto cleanup;
-
-        for (i = 0; i < nhints; i++) {
-            if (STREQ(hints[i].name, keystr)) {
-                type = hints[i].type;
-                break;
-            }
-        }
-
-        if (type == -1) {
-            if (PyString_Check(value)) {
-                type = VIR_TYPED_PARAM_STRING;
-            } else if (PyBool_Check(value)) {
-                type = VIR_TYPED_PARAM_BOOLEAN;
-            } else if (PyLong_Check(value)) {
-                unsigned long long ull = PyLong_AsUnsignedLongLong(value);
-                if (ull == (unsigned long long) -1 && PyErr_Occurred())
-                    type = VIR_TYPED_PARAM_LLONG;
-                else
-                    type = VIR_TYPED_PARAM_ULLONG;
-            } else if (PyInt_Check(value)) {
-                if (PyInt_AS_LONG(value) < 0)
-                    type = VIR_TYPED_PARAM_LLONG;
-                else
-                    type = VIR_TYPED_PARAM_ULLONG;
-            } else if (PyFloat_Check(value)) {
-                type = VIR_TYPED_PARAM_DOUBLE;
-            }
-        }
-
-        if (type == -1) {
-            PyErr_Format(PyExc_TypeError,
-                         "Unknown type of \"%s\" field", keystr);
-            goto cleanup;
-        }
-
-        switch ((virTypedParameterType) type) {
-        case VIR_TYPED_PARAM_INT:
-        {
-            int val;
-            if (libvirt_intUnwrap(value, &val) < 0 ||
-                virTypedParamsAddInt(&params, &n, &max, keystr, val) < 0)
-                goto cleanup;
-            break;
-        }
-        case VIR_TYPED_PARAM_UINT:
-        {
-            unsigned int val;
-            if (libvirt_uintUnwrap(value, &val) < 0 ||
-                virTypedParamsAddUInt(&params, &n, &max, keystr, val) < 0)
-                goto cleanup;
-            break;
-        }
-        case VIR_TYPED_PARAM_LLONG:
-        {
-            long long val;
-            if (libvirt_longlongUnwrap(value, &val) < 0 ||
-                virTypedParamsAddLLong(&params, &n, &max, keystr, val) < 0)
-                goto cleanup;
-            break;
-        }
-        case VIR_TYPED_PARAM_ULLONG:
-        {
-            unsigned long long val;
-            if (libvirt_ulonglongUnwrap(value, &val) < 0 ||
-                virTypedParamsAddULLong(&params, &n, &max, keystr, val) < 0)
-                goto cleanup;
-            break;
-        }
-        case VIR_TYPED_PARAM_DOUBLE:
-        {
-            double val;
-            if (libvirt_doubleUnwrap(value, &val) < 0 ||
-                virTypedParamsAddDouble(&params, &n, &max, keystr, val) < 0)
-                goto cleanup;
-            break;
-        }
-        case VIR_TYPED_PARAM_BOOLEAN:
-        {
-            bool val;
-            if (libvirt_boolUnwrap(value, &val) < 0 ||
-                virTypedParamsAddBoolean(&params, &n, &max, keystr, val) < 0)
-                goto cleanup;
-            break;
-        }
-        case VIR_TYPED_PARAM_STRING:
-        {
-            char *val = PyString_AsString(value);
-            if (!val ||
-                virTypedParamsAddString(&params, &n, &max, keystr, val) < 0)
-                goto cleanup;
-            break;
-        }
-        case VIR_TYPED_PARAM_LAST:
-            break; /* unreachable */
-        }
-    }
-
-    *ret_params = params;
-    *ret_nparams = n;
-    params = NULL;
-    ret = 0;
-
-cleanup:
-    virTypedParamsFree(params, n);
-    return ret;
-}
-
-
-/*
- * Utility function to retrieve the number of node CPUs present.
- * It first tries virGetNodeCPUMap, which will return the
- * number reliably, if available.
- * As a fallback and for compatibility with backlevel libvirt
- * versions virGetNodeInfo will be called to calculate the
- * CPU number, which has the potential to return a too small
- * number if some host CPUs are offline.
- */
-static int
-getPyNodeCPUCount(virConnectPtr conn) {
-    int i_retval;
-    virNodeInfo nodeinfo;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virNodeGetCPUMap(conn, NULL, NULL, 0);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        /* fallback: use nodeinfo */
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        i_retval = virNodeGetInfo(conn, &nodeinfo);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (i_retval < 0)
-            goto cleanup;
-
-        i_retval = VIR_NODEINFO_MAXCPUS(nodeinfo);
-    }
-
-cleanup:
-    return i_retval;
-}
-
-/************************************************************************
- *									*
- *		Statistics						*
- *									*
- ************************************************************************/
-
-static PyObject *
-libvirt_virDomainBlockStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    char * path;
-    int c_retval;
-    virDomainBlockStatsStruct stats;
-    PyObject *info;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oz:virDomainBlockStats",
-        &pyobj_domain, &path))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainBlockStats(domain, path, &stats, sizeof(stats));
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    /* convert to a Python tuple of long objects */
-    if ((info = PyTuple_New(5)) == NULL)
-        return VIR_PY_NONE;
-    PyTuple_SetItem(info, 0, PyLong_FromLongLong(stats.rd_req));
-    PyTuple_SetItem(info, 1, PyLong_FromLongLong(stats.rd_bytes));
-    PyTuple_SetItem(info, 2, PyLong_FromLongLong(stats.wr_req));
-    PyTuple_SetItem(info, 3, PyLong_FromLongLong(stats.wr_bytes));
-    PyTuple_SetItem(info, 4, PyLong_FromLongLong(stats.errs));
-    return info;
-}
-
-static PyObject *
-libvirt_virDomainBlockStatsFlags(PyObject *self ATTRIBUTE_UNUSED,
-                                 PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    PyObject *ret = NULL;
-    int i_retval;
-    int nparams = 0;
-    unsigned int flags;
-    virTypedParameterPtr params;
-    const char *path;
-
-    if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainBlockStatsFlags",
-                          &pyobj_domain, &path, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainBlockStatsFlags(domain, path, NULL, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0)
-        return VIR_PY_NONE;
-
-    if (!nparams)
-        return PyDict_New();
-
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainBlockStatsFlags(domain, path, params, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_NONE;
-        goto cleanup;
-    }
-
-    ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetCPUStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain, *totalbool;
-    PyObject *cpu, *total;
-    PyObject *ret = NULL;
-    PyObject *error = NULL;
-    int ncpus = -1, start_cpu = 0;
-    int sumparams = 0, nparams = -1;
-    size_t i;
-    int i_retval;
-    unsigned int flags;
-    bool totalflag;
-    virTypedParameterPtr params = NULL, cpuparams;
-
-    if (!PyArg_ParseTuple(args, (char *)"OOi:virDomainGetCPUStats",
-                          &pyobj_domain, &totalbool, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if (libvirt_boolUnwrap(totalbool, &totalflag) < 0)
-        return NULL;
-
-    if ((ret = PyList_New(0)) == NULL)
-        return NULL;
-
-    if (!totalflag) {
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        ncpus = virDomainGetCPUStats(domain, NULL, 0, 0, 0, flags);
-        LIBVIRT_END_ALLOW_THREADS;
-
-        if (ncpus < 0) {
-            error = VIR_PY_NONE;
-            goto error;
-        }
-
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        nparams = virDomainGetCPUStats(domain, NULL, 0, 0, 1, flags);
-        LIBVIRT_END_ALLOW_THREADS;
-
-        if (nparams < 0) {
-            error = VIR_PY_NONE;
-            goto error;
-        }
-
-        sumparams = nparams * MIN(ncpus, 128);
-
-        if (VIR_ALLOC_N_QUIET(params, sumparams) < 0) {
-            error = PyErr_NoMemory();
-            goto error;
-        }
-
-        while (ncpus) {
-            int queried_ncpus = MIN(ncpus, 128);
-            if (nparams) {
-
-                LIBVIRT_BEGIN_ALLOW_THREADS;
-                i_retval = virDomainGetCPUStats(domain, params,
-                                                nparams, start_cpu, queried_ncpus, flags);
-                LIBVIRT_END_ALLOW_THREADS;
-
-                if (i_retval < 0) {
-                    error = VIR_PY_NONE;
-                    goto error;
-                }
-            } else {
-                i_retval = 0;
-            }
-
-            for (i = 0; i < queried_ncpus; i++) {
-                cpuparams = &params[i * nparams];
-                if ((cpu = getPyVirTypedParameter(cpuparams, i_retval)) == NULL) {
-                    goto error;
-                }
-
-                if (PyList_Append(ret, cpu) < 0) {
-                    Py_DECREF(cpu);
-                    goto error;
-                }
-                Py_DECREF(cpu);
-            }
-
-            start_cpu += queried_ncpus;
-            ncpus -= queried_ncpus;
-            virTypedParamsClear(params, sumparams);
-        }
-    } else {
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        nparams = virDomainGetCPUStats(domain, NULL, 0, -1, 1, flags);
-        LIBVIRT_END_ALLOW_THREADS;
-
-        if (nparams < 0) {
-            error = VIR_PY_NONE;
-            goto error;
-        }
-
-        if (nparams) {
-            sumparams = nparams;
-
-            if (VIR_ALLOC_N_QUIET(params, nparams) < 0) {
-                error = PyErr_NoMemory();
-                goto error;
-            }
-
-            LIBVIRT_BEGIN_ALLOW_THREADS;
-            i_retval = virDomainGetCPUStats(domain, params, nparams, -1, 1, flags);
-            LIBVIRT_END_ALLOW_THREADS;
-
-            if (i_retval < 0) {
-                error = VIR_PY_NONE;
-                goto error;
-            }
-        } else {
-            i_retval = 0;
-        }
-
-        if ((total = getPyVirTypedParameter(params, i_retval)) == NULL) {
-            goto error;
-        }
-        if (PyList_Append(ret, total) < 0) {
-            Py_DECREF(total);
-            goto error;
-        }
-        Py_DECREF(total);
-    }
-
-    virTypedParamsFree(params, sumparams);
-    return ret;
-
-error:
-    virTypedParamsFree(params, sumparams);
-    Py_DECREF(ret);
-    return error;
-}
-
-static PyObject *
-libvirt_virDomainInterfaceStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    char * path;
-    int c_retval;
-    virDomainInterfaceStatsStruct stats;
-    PyObject *info;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oz:virDomainInterfaceStats",
-        &pyobj_domain, &path))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainInterfaceStats(domain, path, &stats, sizeof(stats));
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    /* convert to a Python tuple of long objects */
-    if ((info = PyTuple_New(8)) == NULL)
-        return VIR_PY_NONE;
-    PyTuple_SetItem(info, 0, PyLong_FromLongLong(stats.rx_bytes));
-    PyTuple_SetItem(info, 1, PyLong_FromLongLong(stats.rx_packets));
-    PyTuple_SetItem(info, 2, PyLong_FromLongLong(stats.rx_errs));
-    PyTuple_SetItem(info, 3, PyLong_FromLongLong(stats.rx_drop));
-    PyTuple_SetItem(info, 4, PyLong_FromLongLong(stats.tx_bytes));
-    PyTuple_SetItem(info, 5, PyLong_FromLongLong(stats.tx_packets));
-    PyTuple_SetItem(info, 6, PyLong_FromLongLong(stats.tx_errs));
-    PyTuple_SetItem(info, 7, PyLong_FromLongLong(stats.tx_drop));
-    return info;
-}
-
-static PyObject *
-libvirt_virDomainMemoryStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    unsigned int nr_stats;
-    size_t i;
-    virDomainMemoryStatStruct stats[VIR_DOMAIN_MEMORY_STAT_NR];
-    PyObject *info;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virDomainMemoryStats", &pyobj_domain))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    nr_stats = virDomainMemoryStats(domain, stats,
-                                    VIR_DOMAIN_MEMORY_STAT_NR, 0);
-    if (nr_stats == -1)
-        return VIR_PY_NONE;
-
-    /* convert to a Python dictionary */
-    if ((info = PyDict_New()) == NULL)
-        return VIR_PY_NONE;
-
-    for (i = 0; i < nr_stats; i++) {
-        if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_SWAP_IN)
-            PyDict_SetItem(info, libvirt_constcharPtrWrap("swap_in"),
-                           PyLong_FromUnsignedLongLong(stats[i].val));
-        else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_SWAP_OUT)
-            PyDict_SetItem(info, libvirt_constcharPtrWrap("swap_out"),
-                           PyLong_FromUnsignedLongLong(stats[i].val));
-        else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT)
-            PyDict_SetItem(info, libvirt_constcharPtrWrap("major_fault"),
-                           PyLong_FromUnsignedLongLong(stats[i].val));
-        else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT)
-            PyDict_SetItem(info, libvirt_constcharPtrWrap("minor_fault"),
-                           PyLong_FromUnsignedLongLong(stats[i].val));
-        else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_UNUSED)
-            PyDict_SetItem(info, libvirt_constcharPtrWrap("unused"),
-                           PyLong_FromUnsignedLongLong(stats[i].val));
-        else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_AVAILABLE)
-            PyDict_SetItem(info, libvirt_constcharPtrWrap("available"),
-                           PyLong_FromUnsignedLongLong(stats[i].val));
-        else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON)
-            PyDict_SetItem(info, libvirt_constcharPtrWrap("actual"),
-                           PyLong_FromUnsignedLongLong(stats[i].val));
-        else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_RSS)
-            PyDict_SetItem(info, libvirt_constcharPtrWrap("rss"),
-                           PyLong_FromUnsignedLongLong(stats[i].val));
-    }
-    return info;
-}
-
-static PyObject *
-libvirt_virDomainGetSchedulerType(PyObject *self ATTRIBUTE_UNUSED,
-                                  PyObject *args) {
-    virDomainPtr domain;
-    PyObject *pyobj_domain, *info;
-    char *c_retval;
-    int nparams;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetScedulerType",
-                          &pyobj_domain))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainGetSchedulerType(domain, &nparams);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval == NULL)
-        return VIR_PY_NONE;
-
-    /* convert to a Python tuple of long objects */
-    if ((info = PyTuple_New(2)) == NULL) {
-        VIR_FREE(c_retval);
-        return VIR_PY_NONE;
-    }
-
-    PyTuple_SetItem(info, 0, libvirt_constcharPtrWrap(c_retval));
-    PyTuple_SetItem(info, 1, PyInt_FromLong((long)nparams));
-    VIR_FREE(c_retval);
-    return info;
-}
-
-static PyObject *
-libvirt_virDomainGetSchedulerParameters(PyObject *self ATTRIBUTE_UNUSED,
-                                        PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    PyObject *ret = NULL;
-    char *c_retval;
-    int i_retval;
-    int nparams = 0;
-    virTypedParameterPtr params;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetScedulerParameters",
-                          &pyobj_domain))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainGetSchedulerType(domain, &nparams);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval == NULL)
-        return VIR_PY_NONE;
-    VIR_FREE(c_retval);
-
-    if (!nparams)
-        return PyDict_New();
-
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetSchedulerParameters(domain, params, &nparams);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_NONE;
-        goto cleanup;
-    }
-
-    ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetSchedulerParametersFlags(PyObject *self ATTRIBUTE_UNUSED,
-                                        PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    PyObject *ret = NULL;
-    char *c_retval;
-    int i_retval;
-    int nparams = 0;
-    unsigned int flags;
-    virTypedParameterPtr params;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetScedulerParametersFlags",
-                          &pyobj_domain, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainGetSchedulerType(domain, &nparams);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval == NULL)
-        return VIR_PY_NONE;
-    VIR_FREE(c_retval);
-
-    if (!nparams)
-        return PyDict_New();
-
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetSchedulerParametersFlags(domain, params, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_NONE;
-        goto cleanup;
-    }
-
-    ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    return ret;
-}
-
-static PyObject *
-libvirt_virDomainSetSchedulerParameters(PyObject *self ATTRIBUTE_UNUSED,
-                                        PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain, *info;
-    PyObject *ret = NULL;
-    char *c_retval;
-    int i_retval;
-    int nparams = 0;
-    Py_ssize_t size = 0;
-    virTypedParameterPtr params, new_params = NULL;
-
-    if (!PyArg_ParseTuple(args, (char *)"OO:virDomainSetScedulerParameters",
-                          &pyobj_domain, &info))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if ((size = PyDict_Size(info)) < 0)
-        return NULL;
-
-    if (size == 0) {
-        PyErr_Format(PyExc_LookupError,
-                     "Need non-empty dictionary to set attributes");
-        return NULL;
-    }
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainGetSchedulerType(domain, &nparams);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval == NULL)
-        return VIR_PY_INT_FAIL;
-    VIR_FREE(c_retval);
-
-    if (nparams == 0) {
-        PyErr_Format(PyExc_LookupError,
-                     "Domain has no settable attributes");
-        return NULL;
-    }
-
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetSchedulerParameters(domain, params, &nparams);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-
-    new_params = setPyVirTypedParameter(info, params, nparams);
-    if (!new_params)
-        goto cleanup;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainSetSchedulerParameters(domain, new_params, size);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-
-    ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    VIR_FREE(new_params);
-    return ret;
-}
-
-static PyObject *
-libvirt_virDomainSetSchedulerParametersFlags(PyObject *self ATTRIBUTE_UNUSED,
-                                             PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain, *info;
-    PyObject *ret = NULL;
-    char *c_retval;
-    int i_retval;
-    int nparams = 0;
-    Py_ssize_t size = 0;
-    unsigned int flags;
-    virTypedParameterPtr params, new_params = NULL;
-
-    if (!PyArg_ParseTuple(args,
-                          (char *)"OOi:virDomainSetScedulerParametersFlags",
-                          &pyobj_domain, &info, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if ((size = PyDict_Size(info)) < 0)
-        return NULL;
-
-    if (size == 0) {
-        PyErr_Format(PyExc_LookupError,
-                     "Need non-empty dictionary to set attributes");
-        return NULL;
-    }
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainGetSchedulerType(domain, &nparams);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval == NULL)
-        return VIR_PY_INT_FAIL;
-    VIR_FREE(c_retval);
-
-    if (nparams == 0) {
-        PyErr_Format(PyExc_LookupError,
-                     "Domain has no settable attributes");
-        return NULL;
-    }
-
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetSchedulerParametersFlags(domain, params, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-
-    new_params = setPyVirTypedParameter(info, params, nparams);
-    if (!new_params)
-        goto cleanup;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainSetSchedulerParametersFlags(domain, new_params, size, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-
-    ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    VIR_FREE(new_params);
-    return ret;
-}
-
-static PyObject *
-libvirt_virDomainSetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
-                                    PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain, *info;
-    PyObject *ret = NULL;
-    int i_retval;
-    int nparams = 0;
-    Py_ssize_t size = 0;
-    unsigned int flags;
-    virTypedParameterPtr params, new_params = NULL;
-
-    if (!PyArg_ParseTuple(args,
-                          (char *)"OOi:virDomainSetBlkioParameters",
-                          &pyobj_domain, &info, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if ((size = PyDict_Size(info)) < 0)
-        return NULL;
-
-    if (size == 0) {
-        PyErr_Format(PyExc_LookupError,
-                     "Need non-empty dictionary to set attributes");
-        return NULL;
-    }
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetBlkioParameters(domain, NULL, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0)
-        return VIR_PY_INT_FAIL;
-
-    if (nparams == 0) {
-        PyErr_Format(PyExc_LookupError,
-                     "Domain has no settable attributes");
-        return NULL;
-    }
-
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetBlkioParameters(domain, params, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-
-    new_params = setPyVirTypedParameter(info, params, nparams);
-    if (!new_params)
-        goto cleanup;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainSetBlkioParameters(domain, new_params, size, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-
-    ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    VIR_FREE(new_params);
-    return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
-                                    PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    PyObject *ret = NULL;
-    int i_retval;
-    int nparams = 0;
-    unsigned int flags;
-    virTypedParameterPtr params;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetBlkioParameters",
-                          &pyobj_domain, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetBlkioParameters(domain, NULL, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0)
-        return VIR_PY_NONE;
-
-    if (!nparams)
-        return PyDict_New();
-
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetBlkioParameters(domain, params, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_NONE;
-        goto cleanup;
-    }
-
-    ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    return ret;
-}
-
-static PyObject *
-libvirt_virDomainSetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED,
-                                     PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain, *info;
-    PyObject *ret = NULL;
-    int i_retval;
-    int nparams = 0;
-    Py_ssize_t size = 0;
-    unsigned int flags;
-    virTypedParameterPtr params, new_params = NULL;
-
-    if (!PyArg_ParseTuple(args,
-                          (char *)"OOi:virDomainSetMemoryParameters",
-                          &pyobj_domain, &info, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if ((size = PyDict_Size(info)) < 0)
-        return NULL;
-
-    if (size == 0) {
-        PyErr_Format(PyExc_LookupError,
-                     "Need non-empty dictionary to set attributes");
-        return NULL;
-    }
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetMemoryParameters(domain, NULL, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0)
-        return VIR_PY_INT_FAIL;
-
-    if (nparams == 0) {
-        PyErr_Format(PyExc_LookupError,
-                     "Domain has no settable attributes");
-        return NULL;
-    }
-
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetMemoryParameters(domain, params, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-
-    new_params = setPyVirTypedParameter(info, params, nparams);
-    if (!new_params)
-        goto cleanup;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainSetMemoryParameters(domain, new_params, size, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-
-    ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    VIR_FREE(new_params);
-    return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED,
-                                     PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    PyObject *ret = NULL;
-    int i_retval;
-    int nparams = 0;
-    unsigned int flags;
-    virTypedParameterPtr params;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetMemoryParameters",
-                          &pyobj_domain, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetMemoryParameters(domain, NULL, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0)
-        return VIR_PY_NONE;
-
-    if (!nparams)
-        return PyDict_New();
-
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetMemoryParameters(domain, params, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_NONE;
-        goto cleanup;
-    }
-
-    ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    return ret;
-}
-
-static PyObject *
-libvirt_virDomainSetNumaParameters(PyObject *self ATTRIBUTE_UNUSED,
-                                   PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain, *info;
-    PyObject *ret = NULL;
-    int i_retval;
-    int nparams = 0;
-    Py_ssize_t size = 0;
-    unsigned int flags;
-    virTypedParameterPtr params, new_params = NULL;
-
-    if (!PyArg_ParseTuple(args,
-                          (char *)"OOi:virDomainSetNumaParameters",
-                          &pyobj_domain, &info, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if ((size = PyDict_Size(info)) < 0)
-        return NULL;
-
-    if (size == 0) {
-        PyErr_Format(PyExc_LookupError,
-                     "Need non-empty dictionary to set attributes");
-        return NULL;
-    }
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetNumaParameters(domain, NULL, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0)
-        return VIR_PY_INT_FAIL;
-
-    if (nparams == 0) {
-        PyErr_Format(PyExc_LookupError,
-                     "Domain has no settable attributes");
-        return NULL;
-    }
-
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetNumaParameters(domain, params, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-
-    new_params = setPyVirTypedParameter(info, params, nparams);
-    if (!new_params)
-        goto cleanup;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainSetNumaParameters(domain, new_params, size, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-
-    ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    VIR_FREE(new_params);
-    return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetNumaParameters(PyObject *self ATTRIBUTE_UNUSED,
-                                   PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    PyObject *ret = NULL;
-    int i_retval;
-    int nparams = 0;
-    unsigned int flags;
-    virTypedParameterPtr params;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetNumaParameters",
-                          &pyobj_domain, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetNumaParameters(domain, NULL, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0)
-        return VIR_PY_NONE;
-
-    if (!nparams)
-        return PyDict_New();
-
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetNumaParameters(domain, params, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_NONE;
-        goto cleanup;
-    }
-
-    ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    return ret;
-}
-
-static PyObject *
-libvirt_virDomainSetInterfaceParameters(PyObject *self ATTRIBUTE_UNUSED,
-                                        PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain, *info;
-    PyObject *ret = NULL;
-    int i_retval;
-    int nparams = 0;
-    Py_ssize_t size = 0;
-    unsigned int flags;
-    const char *device = NULL;
-    virTypedParameterPtr params, new_params = NULL;
-
-    if (!PyArg_ParseTuple(args,
-                          (char *)"OzOi:virDomainSetInterfaceParameters",
-                          &pyobj_domain, &device, &info, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if ((size = PyDict_Size(info)) < 0)
-        return NULL;
-
-    if (size == 0) {
-        PyErr_Format(PyExc_LookupError,
-                     "Need non-empty dictionary to set attributes");
-        return NULL;
-    }
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetInterfaceParameters(domain, device, NULL, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0)
-        return VIR_PY_INT_FAIL;
-
-    if (nparams == 0) {
-        PyErr_Format(PyExc_LookupError,
-                     "Domain has no settable attributes");
-        return NULL;
-    }
-
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetInterfaceParameters(domain, device, params, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-
-    new_params = setPyVirTypedParameter(info, params, nparams);
-    if (!new_params)
-        goto cleanup;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainSetInterfaceParameters(domain, device, new_params, size, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-
-    ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    VIR_FREE(new_params);
-    return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetInterfaceParameters(PyObject *self ATTRIBUTE_UNUSED,
-                                        PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    PyObject *ret = NULL;
-    int i_retval;
-    int nparams = 0;
-    unsigned int flags;
-    const char *device = NULL;
-    virTypedParameterPtr params;
-
-    if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainGetInterfaceParameters",
-                          &pyobj_domain, &device, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetInterfaceParameters(domain, device, NULL, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0)
-        return VIR_PY_NONE;
-
-    if (!nparams)
-        return PyDict_New();
-
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetInterfaceParameters(domain, device, params, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_NONE;
-        goto cleanup;
-    }
-
-    ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetVcpus(PyObject *self ATTRIBUTE_UNUSED,
-                          PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain, *pyretval = NULL, *pycpuinfo = NULL, *pycpumap = NULL;
-    PyObject *error = NULL;
-    virDomainInfo dominfo;
-    virVcpuInfoPtr cpuinfo = NULL;
-    unsigned char *cpumap = NULL;
-    size_t cpumaplen, i;
-    int i_retval, cpunum;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetVcpus",
-                          &pyobj_domain))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if ((cpunum = getPyNodeCPUCount(virDomainGetConnect(domain))) < 0)
-        return VIR_PY_INT_FAIL;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetInfo(domain, &dominfo);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (i_retval < 0)
-        return VIR_PY_INT_FAIL;
-
-    if (VIR_ALLOC_N_QUIET(cpuinfo, dominfo.nrVirtCpu) < 0)
-        return PyErr_NoMemory();
-
-    cpumaplen = VIR_CPU_MAPLEN(cpunum);
-    if (xalloc_oversized(dominfo.nrVirtCpu, cpumaplen) ||
-        VIR_ALLOC_N_QUIET(cpumap, dominfo.nrVirtCpu * cpumaplen) < 0) {
-        error = PyErr_NoMemory();
-        goto cleanup;
-    }
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetVcpus(domain,
-                                 cpuinfo, dominfo.nrVirtCpu,
-                                 cpumap, cpumaplen);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (i_retval < 0) {
-        error = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-
-    /* convert to a Python tuple of long objects */
-    if ((pyretval = PyTuple_New(2)) == NULL)
-        goto cleanup;
-    if ((pycpuinfo = PyList_New(dominfo.nrVirtCpu)) == NULL)
-        goto cleanup;
-    if ((pycpumap = PyList_New(dominfo.nrVirtCpu)) == NULL)
-        goto cleanup;
-
-    for (i = 0; i < dominfo.nrVirtCpu; i++) {
-        PyObject *info = PyTuple_New(4);
-        PyObject *item = NULL;
-
-        if (info == NULL)
-            goto cleanup;
-
-        if ((item = PyInt_FromLong((long)cpuinfo[i].number)) == NULL ||
-            PyTuple_SetItem(info, 0, item) < 0)
-            goto itemError;
-
-        if ((item = PyInt_FromLong((long)cpuinfo[i].state)) == NULL ||
-            PyTuple_SetItem(info, 1, item) < 0)
-            goto itemError;
-
-        if ((item = PyLong_FromLongLong((long long)cpuinfo[i].cpuTime)) == NULL ||
-            PyTuple_SetItem(info, 2, item) < 0)
-            goto itemError;
-
-        if ((item = PyInt_FromLong((long)cpuinfo[i].cpu)) == NULL ||
-            PyTuple_SetItem(info, 3, item) < 0)
-            goto itemError;
-
-        if (PyList_SetItem(pycpuinfo, i, info) < 0)
-            goto itemError;
-
-        continue;
-        itemError:
-            Py_DECREF(info);
-            Py_XDECREF(item);
-            goto cleanup;
-    }
-    for (i = 0; i < dominfo.nrVirtCpu; i++) {
-        PyObject *info = PyTuple_New(cpunum);
-        size_t j;
-        if (info == NULL)
-            goto cleanup;
-        for (j = 0; j < cpunum; j++) {
-            PyObject *item = NULL;
-            if ((item = PyBool_FromLong(VIR_CPU_USABLE(cpumap, cpumaplen, i, j))) == NULL ||
-                PyTuple_SetItem(info, j, item) < 0) {
-                Py_DECREF(info);
-                Py_XDECREF(item);
-                goto cleanup;
-            }
-        }
-        if (PyList_SetItem(pycpumap, i, info) < 0) {
-            Py_DECREF(info);
-            goto cleanup;
-        }
-    }
-    if (PyTuple_SetItem(pyretval, 0, pycpuinfo) < 0 ||
-        PyTuple_SetItem(pyretval, 1, pycpumap) < 0)
-        goto cleanup;
-
-    VIR_FREE(cpuinfo);
-    VIR_FREE(cpumap);
-
-    return pyretval;
-
-cleanup:
-    VIR_FREE(cpuinfo);
-    VIR_FREE(cpumap);
-    Py_XDECREF(pyretval);
-    Py_XDECREF(pycpuinfo);
-    Py_XDECREF(pycpumap);
-    return error;
-}
-
-
-static PyObject *
-libvirt_virDomainPinVcpu(PyObject *self ATTRIBUTE_UNUSED,
-                         PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain, *pycpumap;
-    PyObject *ret = NULL;
-    unsigned char *cpumap;
-    int cpumaplen, vcpu, tuple_size, cpunum;
-    size_t i;
-    int i_retval;
-
-    if (!PyArg_ParseTuple(args, (char *)"OiO:virDomainPinVcpu",
-                          &pyobj_domain, &vcpu, &pycpumap))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if ((cpunum = getPyNodeCPUCount(virDomainGetConnect(domain))) < 0)
-        return VIR_PY_INT_FAIL;
-
-    if (PyTuple_Check(pycpumap)) {
-        tuple_size = PyTuple_Size(pycpumap);
-        if (tuple_size == -1)
-            return ret;
-    } else {
-       PyErr_SetString(PyExc_TypeError, "Unexpected type, tuple is required");
-       return ret;
-    }
-
-    cpumaplen = VIR_CPU_MAPLEN(cpunum);
-    if (VIR_ALLOC_N_QUIET(cpumap, cpumaplen) < 0)
-        return PyErr_NoMemory();
-
-    for (i = 0; i < tuple_size; i++) {
-        PyObject *flag = PyTuple_GetItem(pycpumap, i);
-        bool b;
-
-        if (!flag || libvirt_boolUnwrap(flag, &b) < 0)
-            goto cleanup;
-
-        if (b)
-            VIR_USE_CPU(cpumap, i);
-        else
-            VIR_UNUSE_CPU(cpumap, i);
-    }
-
-    for (; i < cpunum; i++)
-        VIR_UNUSE_CPU(cpumap, i);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainPinVcpu(domain, vcpu, cpumap, cpumaplen);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-    ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
-    VIR_FREE(cpumap);
-    return ret;
-}
-
-static PyObject *
-libvirt_virDomainPinVcpuFlags(PyObject *self ATTRIBUTE_UNUSED,
-                              PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain, *pycpumap;
-    PyObject *ret = NULL;
-    unsigned char *cpumap;
-    int cpumaplen, vcpu, tuple_size, cpunum;
-    size_t i;
-    unsigned int flags;
-    int i_retval;
-
-    if (!PyArg_ParseTuple(args, (char *)"OiOi:virDomainPinVcpuFlags",
-                          &pyobj_domain, &vcpu, &pycpumap, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if ((cpunum = getPyNodeCPUCount(virDomainGetConnect(domain))) < 0)
-        return VIR_PY_INT_FAIL;
-
-    if (PyTuple_Check(pycpumap)) {
-        tuple_size = PyTuple_Size(pycpumap);
-        if (tuple_size == -1)
-            return ret;
-    } else {
-       PyErr_SetString(PyExc_TypeError, "Unexpected type, tuple is required");
-       return ret;
-    }
-
-    cpumaplen = VIR_CPU_MAPLEN(cpunum);
-    if (VIR_ALLOC_N_QUIET(cpumap, cpumaplen) < 0)
-        return PyErr_NoMemory();
-
-    for (i = 0; i < tuple_size; i++) {
-        PyObject *flag = PyTuple_GetItem(pycpumap, i);
-        bool b;
-
-        if (!flag || libvirt_boolUnwrap(flag, &b) < 0)
-            goto cleanup;
-
-        if (b)
-            VIR_USE_CPU(cpumap, i);
-        else
-            VIR_UNUSE_CPU(cpumap, i);
-    }
-
-    for (; i < cpunum; i++)
-        VIR_UNUSE_CPU(cpumap, i);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainPinVcpuFlags(domain, vcpu, cpumap, cpumaplen, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-    ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
-    VIR_FREE(cpumap);
-    return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetVcpuPinInfo(PyObject *self ATTRIBUTE_UNUSED,
-                                PyObject *args) {
-    virDomainPtr domain;
-    PyObject *pyobj_domain, *pycpumaps = NULL;
-    virDomainInfo dominfo;
-    unsigned char *cpumaps = NULL;
-    size_t cpumaplen, vcpu, pcpu;
-    unsigned int flags;
-    int i_retval, cpunum;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetVcpuPinInfo",
-                          &pyobj_domain, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if ((cpunum = getPyNodeCPUCount(virDomainGetConnect(domain))) < 0)
-        return VIR_PY_INT_FAIL;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetInfo(domain, &dominfo);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (i_retval < 0)
-        return VIR_PY_NONE;
-
-    cpumaplen = VIR_CPU_MAPLEN(cpunum);
-    if (xalloc_oversized(dominfo.nrVirtCpu, cpumaplen) ||
-        VIR_ALLOC_N_QUIET(cpumaps, dominfo.nrVirtCpu * cpumaplen) < 0)
-        goto cleanup;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetVcpuPinInfo(domain, dominfo.nrVirtCpu,
-                                       cpumaps, cpumaplen, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (i_retval < 0)
-        goto cleanup;
-
-    if ((pycpumaps = PyList_New(dominfo.nrVirtCpu)) == NULL)
-        goto cleanup;
-
-    for (vcpu = 0; vcpu < dominfo.nrVirtCpu; vcpu++) {
-        PyObject *mapinfo = PyTuple_New(cpunum);
-        if (mapinfo == NULL)
-            goto cleanup;
-
-        for (pcpu = 0; pcpu < cpunum; pcpu++) {
-            PyTuple_SetItem(mapinfo, pcpu,
-                            PyBool_FromLong(VIR_CPU_USABLE(cpumaps, cpumaplen, vcpu, pcpu)));
-        }
-        PyList_SetItem(pycpumaps, vcpu, mapinfo);
-    }
-
-    VIR_FREE(cpumaps);
-
-    return pycpumaps;
-
-cleanup:
-    VIR_FREE(cpumaps);
-
-    Py_XDECREF(pycpumaps);
-
-    return VIR_PY_NONE;
-}
-
-
-static PyObject *
-libvirt_virDomainPinEmulator(PyObject *self ATTRIBUTE_UNUSED,
-                             PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain, *pycpumap;
-    unsigned char *cpumap = NULL;
-    int cpumaplen, tuple_size, cpunum;
-    size_t i;
-    int i_retval;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"OOi:virDomainPinVcpu",
-                          &pyobj_domain, &pycpumap, &flags))
-        return NULL;
-
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if ((cpunum = getPyNodeCPUCount(virDomainGetConnect(domain))) < 0)
-        return VIR_PY_INT_FAIL;
-
-    cpumaplen = VIR_CPU_MAPLEN(cpunum);
-
-    if (!PyTuple_Check(pycpumap)) {
-       PyErr_SetString(PyExc_TypeError, "Unexpected type, tuple is required");
-       return NULL;
-    }
-
-    if ((tuple_size = PyTuple_Size(pycpumap)) == -1)
-        return NULL;
-
-    if (VIR_ALLOC_N_QUIET(cpumap, cpumaplen) < 0)
-        return PyErr_NoMemory();
-
-    for (i = 0; i < tuple_size; i++) {
-        PyObject *flag = PyTuple_GetItem(pycpumap, i);
-        bool b;
-
-        if (!flag || libvirt_boolUnwrap(flag, &b) < 0) {
-            VIR_FREE(cpumap);
-            return VIR_PY_INT_FAIL;
-        }
-
-        if (b)
-            VIR_USE_CPU(cpumap, i);
-        else
-            VIR_UNUSE_CPU(cpumap, i);
-    }
-
-    for (; i < cpunum; i++)
-        VIR_UNUSE_CPU(cpumap, i);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainPinEmulator(domain, cpumap, cpumaplen, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    VIR_FREE(cpumap);
-
-    if (i_retval < 0)
-        return VIR_PY_INT_FAIL;
-
-    return VIR_PY_INT_SUCCESS;
-}
-
-
-static PyObject *
-libvirt_virDomainGetEmulatorPinInfo(PyObject *self ATTRIBUTE_UNUSED,
-                                    PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    PyObject *pycpumap;
-    unsigned char *cpumap;
-    size_t cpumaplen;
-    size_t pcpu;
-    unsigned int flags;
-    int ret;
-    int cpunum;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainEmulatorPinInfo",
-                          &pyobj_domain, &flags))
-        return NULL;
-
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if ((cpunum = getPyNodeCPUCount(virDomainGetConnect(domain))) < 0)
-        return VIR_PY_NONE;
-
-    cpumaplen = VIR_CPU_MAPLEN(cpunum);
-
-    if (VIR_ALLOC_N_QUIET(cpumap, cpumaplen) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    ret = virDomainGetEmulatorPinInfo(domain, cpumap, cpumaplen, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (ret < 0) {
-        VIR_FREE(cpumap);
-        return VIR_PY_NONE;
-    }
-
-    if (!(pycpumap = PyTuple_New(cpunum))) {
-        VIR_FREE(cpumap);
-        return NULL;
-    }
-
-    for (pcpu = 0; pcpu < cpunum; pcpu++)
-        PyTuple_SET_ITEM(pycpumap, pcpu,
-                         PyBool_FromLong(VIR_CPU_USABLE(cpumap, cpumaplen,
-                                                        0, pcpu)));
-
-    VIR_FREE(cpumap);
-    return pycpumap;
-}
-
-
-/************************************************************************
- *									*
- *		Global error handler at the Python level		*
- *									*
- ************************************************************************/
-
-static PyObject *libvirt_virPythonErrorFuncHandler = NULL;
-static PyObject *libvirt_virPythonErrorFuncCtxt = NULL;
-
-static PyObject *
-libvirt_virGetLastError(PyObject *self ATTRIBUTE_UNUSED, PyObject *args ATTRIBUTE_UNUSED)
-{
-    virError *err;
-    PyObject *info;
-
-    if ((err = virGetLastError()) == NULL)
-        return VIR_PY_NONE;
-
-    if ((info = PyTuple_New(9)) == NULL)
-        return VIR_PY_NONE;
-    PyTuple_SetItem(info, 0, PyInt_FromLong((long) err->code));
-    PyTuple_SetItem(info, 1, PyInt_FromLong((long) err->domain));
-    PyTuple_SetItem(info, 2, libvirt_constcharPtrWrap(err->message));
-    PyTuple_SetItem(info, 3, PyInt_FromLong((long) err->level));
-    PyTuple_SetItem(info, 4, libvirt_constcharPtrWrap(err->str1));
-    PyTuple_SetItem(info, 5, libvirt_constcharPtrWrap(err->str2));
-    PyTuple_SetItem(info, 6, libvirt_constcharPtrWrap(err->str3));
-    PyTuple_SetItem(info, 7, PyInt_FromLong((long) err->int1));
-    PyTuple_SetItem(info, 8, PyInt_FromLong((long) err->int2));
-
-    return info;
-}
-
-static PyObject *
-libvirt_virConnGetLastError(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
-{
-    virError *err;
-    PyObject *info;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virConGetLastError", &pyobj_conn))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    err = virConnGetLastError(conn);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (err == NULL)
-        return VIR_PY_NONE;
-
-    if ((info = PyTuple_New(9)) == NULL)
-        return VIR_PY_NONE;
-    PyTuple_SetItem(info, 0, PyInt_FromLong((long) err->code));
-    PyTuple_SetItem(info, 1, PyInt_FromLong((long) err->domain));
-    PyTuple_SetItem(info, 2, libvirt_constcharPtrWrap(err->message));
-    PyTuple_SetItem(info, 3, PyInt_FromLong((long) err->level));
-    PyTuple_SetItem(info, 4, libvirt_constcharPtrWrap(err->str1));
-    PyTuple_SetItem(info, 5, libvirt_constcharPtrWrap(err->str2));
-    PyTuple_SetItem(info, 6, libvirt_constcharPtrWrap(err->str3));
-    PyTuple_SetItem(info, 7, PyInt_FromLong((long) err->int1));
-    PyTuple_SetItem(info, 8, PyInt_FromLong((long) err->int2));
-
-    return info;
-}
-
-static void
-libvirt_virErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, virErrorPtr err)
-{
-    PyObject *list, *info;
-    PyObject *result;
-
-    DEBUG("libvirt_virErrorFuncHandler(%p, %s, ...) called\n", ctx,
-          err->message);
-
-    if ((err == NULL) || (err->code == VIR_ERR_OK))
-        return;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    if ((libvirt_virPythonErrorFuncHandler == NULL) ||
-        (libvirt_virPythonErrorFuncHandler == Py_None)) {
-        virDefaultErrorFunc(err);
-    } else {
-        list = PyTuple_New(2);
-        info = PyTuple_New(9);
-        PyTuple_SetItem(list, 0, libvirt_virPythonErrorFuncCtxt);
-        PyTuple_SetItem(list, 1, info);
-        Py_XINCREF(libvirt_virPythonErrorFuncCtxt);
-        PyTuple_SetItem(info, 0, PyInt_FromLong((long) err->code));
-        PyTuple_SetItem(info, 1, PyInt_FromLong((long) err->domain));
-        PyTuple_SetItem(info, 2, libvirt_constcharPtrWrap(err->message));
-        PyTuple_SetItem(info, 3, PyInt_FromLong((long) err->level));
-        PyTuple_SetItem(info, 4, libvirt_constcharPtrWrap(err->str1));
-        PyTuple_SetItem(info, 5, libvirt_constcharPtrWrap(err->str2));
-        PyTuple_SetItem(info, 6, libvirt_constcharPtrWrap(err->str3));
-        PyTuple_SetItem(info, 7, PyInt_FromLong((long) err->int1));
-        PyTuple_SetItem(info, 8, PyInt_FromLong((long) err->int2));
-        /* TODO pass conn and dom if available */
-        result = PyEval_CallObject(libvirt_virPythonErrorFuncHandler, list);
-        Py_XDECREF(list);
-        Py_XDECREF(result);
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-static PyObject *
-libvirt_virRegisterErrorHandler(ATTRIBUTE_UNUSED PyObject * self,
-                               PyObject * args)
-{
-    PyObject *py_retval;
-    PyObject *pyobj_f;
-    PyObject *pyobj_ctx;
-
-    if (!PyArg_ParseTuple
-        (args, (char *) "OO:xmlRegisterErrorHandler", &pyobj_f,
-         &pyobj_ctx))
-        return NULL;
-
-    DEBUG("libvirt_virRegisterErrorHandler(%p, %p) called\n", pyobj_ctx,
-          pyobj_f);
-
-    virSetErrorFunc(NULL, libvirt_virErrorFuncHandler);
-    if (libvirt_virPythonErrorFuncHandler != NULL) {
-        Py_XDECREF(libvirt_virPythonErrorFuncHandler);
-    }
-    if (libvirt_virPythonErrorFuncCtxt != NULL) {
-        Py_XDECREF(libvirt_virPythonErrorFuncCtxt);
-    }
-
-    if ((pyobj_f == Py_None) && (pyobj_ctx == Py_None)) {
-        libvirt_virPythonErrorFuncHandler = NULL;
-        libvirt_virPythonErrorFuncCtxt = NULL;
-    } else {
-        Py_XINCREF(pyobj_ctx);
-        Py_XINCREF(pyobj_f);
-
-        /* TODO: check f is a function ! */
-        libvirt_virPythonErrorFuncHandler = pyobj_f;
-        libvirt_virPythonErrorFuncCtxt = pyobj_ctx;
-    }
-
-    py_retval = libvirt_intWrap(1);
-    return py_retval;
-}
-
-static int virConnectCredCallbackWrapper(virConnectCredentialPtr cred,
-                                         unsigned int ncred,
-                                         void *cbdata) {
-    PyObject *list;
-    PyObject *pycred;
-    PyObject *pyauth = (PyObject *)cbdata;
-    PyObject *pycbdata;
-    PyObject *pycb;
-    PyObject *pyret;
-    int ret = -1;
-    size_t i;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    pycb = PyList_GetItem(pyauth, 1);
-    pycbdata = PyList_GetItem(pyauth, 2);
-
-    list = PyTuple_New(2);
-    pycred = PyTuple_New(ncred);
-    for (i = 0; i < ncred; i++) {
-        PyObject *pycreditem;
-        pycreditem = PyList_New(5);
-        Py_INCREF(Py_None);
-        PyTuple_SetItem(pycred, i, pycreditem);
-        PyList_SetItem(pycreditem, 0, PyInt_FromLong((long) cred[i].type));
-        PyList_SetItem(pycreditem, 1, PyString_FromString(cred[i].prompt));
-        if (cred[i].challenge) {
-            PyList_SetItem(pycreditem, 2, PyString_FromString(cred[i].challenge));
-        } else {
-            Py_INCREF(Py_None);
-            PyList_SetItem(pycreditem, 2, Py_None);
-        }
-        if (cred[i].defresult) {
-            PyList_SetItem(pycreditem, 3, PyString_FromString(cred[i].defresult));
-        } else {
-            Py_INCREF(Py_None);
-            PyList_SetItem(pycreditem, 3, Py_None);
-        }
-        PyList_SetItem(pycreditem, 4, Py_None);
-    }
-
-    PyTuple_SetItem(list, 0, pycred);
-    Py_XINCREF(pycbdata);
-    PyTuple_SetItem(list, 1, pycbdata);
-
-    PyErr_Clear();
-    pyret = PyEval_CallObject(pycb, list);
-    if (PyErr_Occurred()) {
-        PyErr_Print();
-        goto cleanup;
-    }
-
-    ret = PyLong_AsLong(pyret);
-    if (ret == 0) {
-        for (i = 0; i < ncred; i++) {
-            PyObject *pycreditem;
-            PyObject *pyresult;
-            char *result = NULL;
-            pycreditem = PyTuple_GetItem(pycred, i);
-            pyresult = PyList_GetItem(pycreditem, 4);
-            if (pyresult != Py_None)
-                result = PyString_AsString(pyresult);
-            if (result != NULL) {
-                cred[i].result = strdup(result);
-                cred[i].resultlen = strlen(result);
-            } else {
-                cred[i].result = NULL;
-                cred[i].resultlen = 0;
-            }
-        }
-    }
-
- cleanup:
-    Py_XDECREF(list);
-    Py_XDECREF(pyret);
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-
-    return ret;
-}
-
-
-static PyObject *
-libvirt_virConnectOpenAuth(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    virConnectPtr c_retval;
-    char * name;
-    unsigned int flags;
-    PyObject *pyauth;
-    PyObject *pycredcb;
-    PyObject *pycredtype;
-    virConnectAuth auth;
-
-    memset(&auth, 0, sizeof(auth));
-    if (!PyArg_ParseTuple(args, (char *)"zOi:virConnectOpenAuth", &name, &pyauth, &flags))
-        return NULL;
-
-    pycredtype = PyList_GetItem(pyauth, 0);
-    pycredcb = PyList_GetItem(pyauth, 1);
-
-    auth.ncredtype = PyList_Size(pycredtype);
-    if (auth.ncredtype) {
-        size_t i;
-        if (VIR_ALLOC_N_QUIET(auth.credtype, auth.ncredtype) < 0)
-            return VIR_PY_NONE;
-        for (i = 0; i < auth.ncredtype; i++) {
-            PyObject *val;
-            val = PyList_GetItem(pycredtype, i);
-            auth.credtype[i] = (int)PyLong_AsLong(val);
-        }
-    }
-    if (pycredcb && pycredcb != Py_None)
-        auth.cb = virConnectCredCallbackWrapper;
-    auth.cbdata = pyauth;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-
-    c_retval = virConnectOpenAuth(name, &auth, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    VIR_FREE(auth.credtype);
-    py_retval = libvirt_virConnectPtrWrap((virConnectPtr) c_retval);
-    return py_retval;
-}
-
-
-/************************************************************************
- *									*
- *		Wrappers for functions where generator fails		*
- *									*
- ************************************************************************/
-
-static PyObject *
-libvirt_virGetVersion(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
-{
-    char *type = NULL;
-    unsigned long libVer, typeVer = 0;
-    int c_retval;
-
-    if (!PyArg_ParseTuple(args, (char *) "|s", &type))
-        return NULL;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-
-    if (type == NULL)
-        c_retval = virGetVersion(&libVer, NULL, NULL);
-    else
-        c_retval = virGetVersion(&libVer, type, &typeVer);
-
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval == -1)
-        return VIR_PY_NONE;
-
-    if (type == NULL)
-        return PyInt_FromLong(libVer);
-    else
-        return Py_BuildValue((char *) "kk", libVer, typeVer);
-}
-
-static PyObject *
-libvirt_virConnectGetVersion(PyObject *self ATTRIBUTE_UNUSED,
-                             PyObject *args)
-{
-    unsigned long hvVersion;
-    int c_retval;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virConnectGetVersion",
-                          &pyobj_conn))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-
-    c_retval = virConnectGetVersion(conn, &hvVersion);
-
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval == -1)
-        return VIR_PY_INT_FAIL;
-
-    return PyInt_FromLong(hvVersion);
-}
-
-static PyObject *
-libvirt_virConnectGetCPUModelNames(PyObject *self ATTRIBUTE_UNUSED,
-                                   PyObject *args)
-{
-    int c_retval;
-    virConnectPtr conn;
-    PyObject *rv = NULL, *pyobj_conn;
-    char **models = NULL;
-    size_t i;
-    int flags = 0;
-    const char *arch = NULL;
-
-    if (!PyArg_ParseTuple(args, (char *)"Osi:virConnectGetCPUModelNames",
-                          &pyobj_conn, &arch, &flags))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-
-    c_retval = virConnectGetCPUModelNames(conn, arch, &models, flags);
-
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval == -1)
-        return VIR_PY_INT_FAIL;
-
-    if ((rv = PyList_New(c_retval)) == NULL)
-        goto error;
-
-    for (i = 0; i < c_retval; i++) {
-        PyObject *str;
-        if ((str = PyString_FromString(models[i])) == NULL)
-            goto error;
-
-        PyList_SET_ITEM(rv, i, str);
-    }
-
-done:
-    if (models) {
-        for (i = 0; i < c_retval; i++)
-            VIR_FREE(models[i]);
-        VIR_FREE(models);
-    }
-
-    return rv;
-
-error:
-    Py_XDECREF(rv);
-    rv = VIR_PY_INT_FAIL;
-    goto done;
-}
-
-static PyObject *
-libvirt_virConnectGetLibVersion(PyObject *self ATTRIBUTE_UNUSED,
-                                PyObject *args)
-{
-    unsigned long libVer;
-    int c_retval;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virConnectGetLibVersion",
-                          &pyobj_conn))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-
-    c_retval = virConnectGetLibVersion(conn, &libVer);
-
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval == -1)
-        return VIR_PY_INT_FAIL;
-
-    return PyInt_FromLong(libVer);
-}
-
-static PyObject *
-libvirt_virConnectListDomainsID(PyObject *self ATTRIBUTE_UNUSED,
-                                PyObject *args) {
-    PyObject *py_retval;
-    int *ids = NULL, c_retval;
-    size_t i;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virConnectListDomains", &pyobj_conn))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virConnectNumOfDomains(conn);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(ids, c_retval) < 0)
-            return VIR_PY_NONE;
-
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        c_retval = virConnectListDomains(conn, ids, c_retval);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (c_retval < 0) {
-            VIR_FREE(ids);
-            return VIR_PY_NONE;
-        }
-    }
-    py_retval = PyList_New(c_retval);
-
-    if (ids) {
-        for (i = 0; i < c_retval; i++) {
-            PyList_SetItem(py_retval, i, libvirt_intWrap(ids[i]));
-        }
-        VIR_FREE(ids);
-    }
-
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectListAllDomains(PyObject *self ATTRIBUTE_UNUSED,
-                                 PyObject *args)
-{
-    PyObject *pyobj_conn;
-    PyObject *py_retval = NULL;
-    PyObject *tmp = NULL;
-    virConnectPtr conn;
-    virDomainPtr *doms = NULL;
-    int c_retval = 0;
-    size_t i;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllDomains",
-                          &pyobj_conn, &flags))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virConnectListAllDomains(conn, &doms, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (!(py_retval = PyList_New(c_retval)))
-        goto cleanup;
-
-    for (i = 0; i < c_retval; i++) {
-        if (!(tmp = libvirt_virDomainPtrWrap(doms[i])) ||
-            PyList_SetItem(py_retval, i, tmp) < 0) {
-            Py_XDECREF(tmp);
-            Py_DECREF(py_retval);
-            py_retval = NULL;
-            goto cleanup;
-        }
-        /* python steals the pointer */
-        doms[i] = NULL;
-    }
-
-cleanup:
-    for (i = 0; i < c_retval; i++)
-        if (doms[i])
-            virDomainFree(doms[i]);
-    VIR_FREE(doms);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectListDefinedDomains(PyObject *self ATTRIBUTE_UNUSED,
-                                     PyObject *args) {
-    PyObject *py_retval;
-    char **names = NULL;
-    int c_retval;
-    size_t i;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virConnectListDefinedDomains", &pyobj_conn))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virConnectNumOfDefinedDomains(conn);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
-            return VIR_PY_NONE;
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        c_retval = virConnectListDefinedDomains(conn, names, c_retval);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (c_retval < 0) {
-            VIR_FREE(names);
-            return VIR_PY_NONE;
-        }
-    }
-    py_retval = PyList_New(c_retval);
-
-    if (names) {
-        for (i = 0; i < c_retval; i++) {
-            PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
-            VIR_FREE(names[i]);
-        }
-        VIR_FREE(names);
-    }
-
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainSnapshotListNames(PyObject *self ATTRIBUTE_UNUSED,
-                                   PyObject *args)
-{
-    PyObject *py_retval;
-    char **names = NULL;
-    int c_retval;
-    size_t i;
-    virDomainPtr dom;
-    PyObject *pyobj_dom;
-    PyObject *pyobj_snap;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainSnapshotListNames",
-                          &pyobj_dom, &flags))
-        return NULL;
-    dom = (virDomainPtr) PyvirDomain_Get(pyobj_dom);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainSnapshotNum(dom, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
-            return PyErr_NoMemory();
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        c_retval = virDomainSnapshotListNames(dom, names, c_retval, flags);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (c_retval < 0) {
-            VIR_FREE(names);
-            return VIR_PY_NONE;
-        }
-    }
-    py_retval = PyList_New(c_retval);
-    if (!py_retval)
-        goto cleanup;
-
-    for (i = 0; i < c_retval; i++) {
-        if ((pyobj_snap = libvirt_constcharPtrWrap(names[i])) == NULL ||
-            PyList_SetItem(py_retval, i, pyobj_snap) < 0) {
-            Py_XDECREF(pyobj_snap);
-            Py_DECREF(py_retval);
-            py_retval = NULL;
-            goto cleanup;
-        }
-        VIR_FREE(names[i]);
-    }
-
-cleanup:
-    for (i = 0; i < c_retval; i++)
-        VIR_FREE(names[i]);
-    VIR_FREE(names);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainListAllSnapshots(PyObject *self ATTRIBUTE_UNUSED,
-                                  PyObject *args)
-{
-    PyObject *py_retval = NULL;
-    virDomainSnapshotPtr *snaps = NULL;
-    int c_retval;
-    size_t i;
-    virDomainPtr dom;
-    PyObject *pyobj_dom;
-    unsigned int flags;
-    PyObject *pyobj_snap;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainListAllSnapshots",
-                          &pyobj_dom, &flags))
-        return NULL;
-    dom = (virDomainPtr) PyvirDomain_Get(pyobj_dom);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainListAllSnapshots(dom, &snaps, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (!(py_retval = PyList_New(c_retval)))
-        goto cleanup;
-
-    for (i = 0; i < c_retval; i++) {
-        if ((pyobj_snap = libvirt_virDomainSnapshotPtrWrap(snaps[i])) == NULL ||
-            PyList_SetItem(py_retval, i, pyobj_snap) < 0) {
-            Py_XDECREF(pyobj_snap);
-            Py_DECREF(py_retval);
-            py_retval = NULL;
-            goto cleanup;
-        }
-        snaps[i] = NULL;
-    }
-
-cleanup:
-    for (i = 0; i < c_retval; i++)
-        if (snaps[i])
-            virDomainSnapshotFree(snaps[i]);
-    VIR_FREE(snaps);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainSnapshotListChildrenNames(PyObject *self ATTRIBUTE_UNUSED,
-                                           PyObject *args)
-{
-    PyObject *py_retval;
-    char **names = NULL;
-    int c_retval;
-    size_t i;
-    virDomainSnapshotPtr snap;
-    PyObject *pyobj_snap;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainSnapshotListChildrenNames",
-                          &pyobj_snap, &flags))
-        return NULL;
-    snap = (virDomainSnapshotPtr) PyvirDomainSnapshot_Get(pyobj_snap);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainSnapshotNumChildren(snap, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
-            return PyErr_NoMemory();
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        c_retval = virDomainSnapshotListChildrenNames(snap, names, c_retval,
-                                                      flags);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (c_retval < 0) {
-            VIR_FREE(names);
-            return VIR_PY_NONE;
-        }
-    }
-    py_retval = PyList_New(c_retval);
-
-    for (i = 0; i < c_retval; i++) {
-        if ((pyobj_snap = libvirt_constcharPtrWrap(names[i])) == NULL ||
-            PyList_SetItem(py_retval, i, pyobj_snap) < 0) {
-            Py_XDECREF(pyobj_snap);
-            Py_DECREF(py_retval);
-            py_retval = NULL;
-            goto cleanup;
-        }
-        VIR_FREE(names[i]);
-    }
-
-cleanup:
-    for (i = 0; i < c_retval; i++)
-        VIR_FREE(names[i]);
-    VIR_FREE(names);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainSnapshotListAllChildren(PyObject *self ATTRIBUTE_UNUSED,
-                                         PyObject *args)
-{
-    PyObject *py_retval = NULL;
-    virDomainSnapshotPtr *snaps = NULL;
-    int c_retval;
-    size_t i;
-    virDomainSnapshotPtr parent;
-    PyObject *pyobj_parent;
-    unsigned int flags;
-    PyObject *pyobj_snap;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainSnapshotListAllChildren",
-                          &pyobj_parent, &flags))
-        return NULL;
-    parent = (virDomainSnapshotPtr) PyvirDomainSnapshot_Get(pyobj_parent);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainSnapshotListAllChildren(parent, &snaps, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (!(py_retval = PyList_New(c_retval)))
-        goto cleanup;
-
-    for (i = 0; i < c_retval; i++) {
-        if ((pyobj_snap = libvirt_virDomainSnapshotPtrWrap(snaps[i])) == NULL ||
-            PyList_SetItem(py_retval, i, pyobj_snap) < 0) {
-            Py_XDECREF(pyobj_snap);
-            Py_DECREF(py_retval);
-            py_retval = NULL;
-            goto cleanup;
-        }
-        snaps[i] = NULL;
-    }
-
-cleanup:
-    for (i = 0; i < c_retval; i++)
-        if (snaps[i])
-            virDomainSnapshotFree(snaps[i]);
-    VIR_FREE(snaps);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainRevertToSnapshot(PyObject *self ATTRIBUTE_UNUSED,
-                                  PyObject *args) {
-    int c_retval;
-    virDomainSnapshotPtr snap;
-    PyObject *pyobj_snap;
-    PyObject *pyobj_dom;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"OOi:virDomainRevertToSnapshot", &pyobj_dom, &pyobj_snap, &flags))
-        return NULL;
-    snap = (virDomainSnapshotPtr) PyvirDomainSnapshot_Get(pyobj_snap);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainRevertToSnapshot(snap, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_INT_FAIL;
-
-    return PyInt_FromLong(c_retval);
-}
-
-static PyObject *
-libvirt_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    int c_retval;
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    virDomainInfo info;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetInfo", &pyobj_domain))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainGetInfo(domain, &info);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-    py_retval = PyList_New(5);
-    PyList_SetItem(py_retval, 0, libvirt_intWrap((int) info.state));
-    PyList_SetItem(py_retval, 1, libvirt_ulongWrap(info.maxMem));
-    PyList_SetItem(py_retval, 2, libvirt_ulongWrap(info.memory));
-    PyList_SetItem(py_retval, 3, libvirt_intWrap((int) info.nrVirtCpu));
-    PyList_SetItem(py_retval, 4,
-                   libvirt_longlongWrap((unsigned long long) info.cpuTime));
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainGetState(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
-{
-    PyObject *py_retval;
-    int c_retval;
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    int state;
-    int reason;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetState",
-                          &pyobj_domain, &flags))
-        return NULL;
-
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainGetState(domain, &state, &reason, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    py_retval = PyList_New(2);
-    PyList_SetItem(py_retval, 0, libvirt_intWrap(state));
-    PyList_SetItem(py_retval, 1, libvirt_intWrap(reason));
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainGetControlInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    int c_retval;
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    virDomainControlInfo info;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetControlInfo",
-                          &pyobj_domain, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainGetControlInfo(domain, &info, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-    py_retval = PyList_New(3);
-    PyList_SetItem(py_retval, 0, libvirt_intWrap(info.state));
-    PyList_SetItem(py_retval, 1, libvirt_intWrap(info.details));
-    PyList_SetItem(py_retval, 2, libvirt_longlongWrap(info.stateTime));
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainGetBlockInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    int c_retval;
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    virDomainBlockInfo info;
-    const char *path;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainGetInfo", &pyobj_domain, &path, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainGetBlockInfo(domain, path, &info, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-    py_retval = PyList_New(3);
-    PyList_SetItem(py_retval, 0, libvirt_ulonglongWrap(info.capacity));
-    PyList_SetItem(py_retval, 1, libvirt_ulonglongWrap(info.allocation));
-    PyList_SetItem(py_retval, 2, libvirt_ulonglongWrap(info.physical));
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virNodeGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    int c_retval;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-    virNodeInfo info;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetInfo", &pyobj_conn))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virNodeGetInfo(conn, &info);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-    py_retval = PyList_New(8);
-    PyList_SetItem(py_retval, 0, libvirt_constcharPtrWrap(&info.model[0]));
-    PyList_SetItem(py_retval, 1, libvirt_longWrap((long) info.memory >> 10));
-    PyList_SetItem(py_retval, 2, libvirt_intWrap((int) info.cpus));
-    PyList_SetItem(py_retval, 3, libvirt_intWrap((int) info.mhz));
-    PyList_SetItem(py_retval, 4, libvirt_intWrap((int) info.nodes));
-    PyList_SetItem(py_retval, 5, libvirt_intWrap((int) info.sockets));
-    PyList_SetItem(py_retval, 6, libvirt_intWrap((int) info.cores));
-    PyList_SetItem(py_retval, 7, libvirt_intWrap((int) info.threads));
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    unsigned char uuid[VIR_UUID_BUFLEN];
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    int c_retval;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetUUID", &pyobj_domain))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if (domain == NULL)
-        return VIR_PY_NONE;
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainGetUUID(domain, &uuid[0]);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-    py_retval = PyString_FromStringAndSize((char *) &uuid[0], VIR_UUID_BUFLEN);
-
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainGetUUIDString(PyObject *self ATTRIBUTE_UNUSED,
-                               PyObject *args) {
-    PyObject *py_retval;
-    char uuidstr[VIR_UUID_STRING_BUFLEN];
-    virDomainPtr dom;
-    PyObject *pyobj_dom;
-    int c_retval;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetUUIDString",
-                          &pyobj_dom))
-        return NULL;
-    dom = (virDomainPtr) PyvirDomain_Get(pyobj_dom);
-
-    if (dom == NULL)
-        return VIR_PY_NONE;
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainGetUUIDString(dom, &uuidstr[0]);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    py_retval = PyString_FromString((char *) &uuidstr[0]);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainLookupByUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    virDomainPtr c_retval;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-    unsigned char * uuid;
-    int len;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oz#:virDomainLookupByUUID", &pyobj_conn, &uuid, &len))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    if ((uuid == NULL) || (len != VIR_UUID_BUFLEN))
-        return VIR_PY_NONE;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainLookupByUUID(conn, uuid);
-    LIBVIRT_END_ALLOW_THREADS;
-    py_retval = libvirt_virDomainPtrWrap((virDomainPtr) c_retval);
-    return py_retval;
-}
-
-
-static PyObject *
-libvirt_virConnectListNetworks(PyObject *self ATTRIBUTE_UNUSED,
-                               PyObject *args) {
-    PyObject *py_retval;
-    char **names = NULL;
-    int c_retval;
-    size_t i;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virConnectListNetworks", &pyobj_conn))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virConnectNumOfNetworks(conn);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
-            return VIR_PY_NONE;
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        c_retval = virConnectListNetworks(conn, names, c_retval);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (c_retval < 0) {
-            VIR_FREE(names);
-            return VIR_PY_NONE;
-        }
-    }
-    py_retval = PyList_New(c_retval);
-
-    if (names) {
-        for (i = 0; i < c_retval; i++) {
-            PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
-            VIR_FREE(names[i]);
-        }
-        VIR_FREE(names);
-    }
-
-    return py_retval;
-}
-
-
-static PyObject *
-libvirt_virConnectListDefinedNetworks(PyObject *self ATTRIBUTE_UNUSED,
-                                      PyObject *args) {
-    PyObject *py_retval;
-    char **names = NULL;
-    int c_retval;
-    size_t i;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virConnectListDefinedNetworks", &pyobj_conn))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virConnectNumOfDefinedNetworks(conn);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
-            return VIR_PY_NONE;
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        c_retval = virConnectListDefinedNetworks(conn, names, c_retval);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (c_retval < 0) {
-            VIR_FREE(names);
-            return VIR_PY_NONE;
-        }
-    }
-    py_retval = PyList_New(c_retval);
-
-    if (names) {
-        for (i = 0; i < c_retval; i++) {
-            PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
-            VIR_FREE(names[i]);
-        }
-        VIR_FREE(names);
-    }
-
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectListAllNetworks(PyObject *self ATTRIBUTE_UNUSED,
-                                  PyObject *args)
-{
-    PyObject *pyobj_conn;
-    PyObject *py_retval = NULL;
-    PyObject *tmp = NULL;
-    virConnectPtr conn;
-    virNetworkPtr *nets = NULL;
-    int c_retval = 0;
-    size_t i;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllNetworks",
-                          &pyobj_conn, &flags))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virConnectListAllNetworks(conn, &nets, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (!(py_retval = PyList_New(c_retval)))
-        goto cleanup;
-
-    for (i = 0; i < c_retval; i++) {
-        if (!(tmp = libvirt_virNetworkPtrWrap(nets[i])) ||
-            PyList_SetItem(py_retval, i, tmp) < 0) {
-            Py_XDECREF(tmp);
-            Py_DECREF(py_retval);
-            py_retval = NULL;
-            goto cleanup;
-        }
-        /* python steals the pointer */
-        nets[i] = NULL;
-    }
-
-cleanup:
-    for (i = 0; i < c_retval; i++)
-        if (nets[i])
-            virNetworkFree(nets[i]);
-    VIR_FREE(nets);
-    return py_retval;
-}
-
-
-static PyObject *
-libvirt_virNetworkGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    unsigned char uuid[VIR_UUID_BUFLEN];
-    virNetworkPtr domain;
-    PyObject *pyobj_domain;
-    int c_retval;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virNetworkGetUUID", &pyobj_domain))
-        return NULL;
-    domain = (virNetworkPtr) PyvirNetwork_Get(pyobj_domain);
-
-    if (domain == NULL)
-        return VIR_PY_NONE;
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virNetworkGetUUID(domain, &uuid[0]);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-    py_retval = PyString_FromStringAndSize((char *) &uuid[0], VIR_UUID_BUFLEN);
-
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virNetworkGetUUIDString(PyObject *self ATTRIBUTE_UNUSED,
-                                PyObject *args) {
-    PyObject *py_retval;
-    char uuidstr[VIR_UUID_STRING_BUFLEN];
-    virNetworkPtr net;
-    PyObject *pyobj_net;
-    int c_retval;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virNetworkGetUUIDString",
-                          &pyobj_net))
-        return NULL;
-    net = (virNetworkPtr) PyvirNetwork_Get(pyobj_net);
-
-    if (net == NULL)
-        return VIR_PY_NONE;
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virNetworkGetUUIDString(net, &uuidstr[0]);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    py_retval = PyString_FromString((char *) &uuidstr[0]);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virNetworkLookupByUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    virNetworkPtr c_retval;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-    unsigned char * uuid;
-    int len;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oz#:virNetworkLookupByUUID", &pyobj_conn, &uuid, &len))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    if ((uuid == NULL) || (len != VIR_UUID_BUFLEN))
-        return VIR_PY_NONE;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virNetworkLookupByUUID(conn, uuid);
-    LIBVIRT_END_ALLOW_THREADS;
-    py_retval = libvirt_virNetworkPtrWrap((virNetworkPtr) c_retval);
-    return py_retval;
-}
-
-
-static PyObject *
-libvirt_virDomainGetAutostart(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    int c_retval, autostart;
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetAutostart", &pyobj_domain))
-        return NULL;
-
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainGetAutostart(domain, &autostart);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0)
-        return VIR_PY_INT_FAIL;
-    py_retval = libvirt_intWrap(autostart);
-    return py_retval;
-}
-
-
-static PyObject *
-libvirt_virNetworkGetAutostart(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    int c_retval, autostart;
-    virNetworkPtr network;
-    PyObject *pyobj_network;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virNetworkGetAutostart", &pyobj_network))
-        return NULL;
-
-    network = (virNetworkPtr) PyvirNetwork_Get(pyobj_network);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virNetworkGetAutostart(network, &autostart);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0)
-        return VIR_PY_INT_FAIL;
-    py_retval = libvirt_intWrap(autostart);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virNodeGetCellsFreeMemory(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
-{
-    PyObject *py_retval;
-    PyObject *pyobj_conn;
-    int startCell, maxCells, c_retval;
-    size_t i;
-    virConnectPtr conn;
-    unsigned long long *freeMems;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oii:virNodeGetCellsFreeMemory", &pyobj_conn, &startCell, &maxCells))
-        return NULL;
-
-    if ((startCell < 0) || (maxCells <= 0) || (startCell + maxCells > 10000))
-        return VIR_PY_NONE;
-
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-    if (VIR_ALLOC_N_QUIET(freeMems, maxCells) < 0)
-        return VIR_PY_NONE;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virNodeGetCellsFreeMemory(conn, freeMems, startCell, maxCells);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0) {
-        VIR_FREE(freeMems);
-        return VIR_PY_NONE;
-    }
-    py_retval = PyList_New(c_retval);
-    for (i = 0; i < c_retval; i++) {
-        PyList_SetItem(py_retval, i,
-                libvirt_longlongWrap((long long) freeMems[i]));
-    }
-    VIR_FREE(freeMems);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virNodeGetCPUStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
-{
-    PyObject *ret = NULL;
-    PyObject *key = NULL;
-    PyObject *val = NULL;
-    PyObject *pyobj_conn;
-    virConnectPtr conn;
-    unsigned int flags;
-    int cpuNum, c_retval;
-    size_t i;
-    int nparams = 0;
-    virNodeCPUStatsPtr stats = NULL;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oii:virNodeGetCPUStats", &pyobj_conn, &cpuNum, &flags))
-        return ret;
-    conn = (virConnectPtr)(PyvirConnect_Get(pyobj_conn));
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virNodeGetCPUStats(conn, cpuNum, NULL, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (nparams) {
-        if (VIR_ALLOC_N_QUIET(stats, nparams) < 0)
-            return PyErr_NoMemory();
-
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        c_retval = virNodeGetCPUStats(conn, cpuNum, stats, &nparams, flags);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (c_retval < 0) {
-            VIR_FREE(stats);
-            return VIR_PY_NONE;
-        }
-    }
-
-    if (!(ret = PyDict_New()))
-        goto error;
-
-    for (i = 0; i < nparams; i++) {
-        key = libvirt_constcharPtrWrap(stats[i].field);
-        val = libvirt_ulonglongWrap(stats[i].value);
-
-        if (!key || !val || PyDict_SetItem(ret, key, val) < 0) {
-            Py_DECREF(ret);
-            ret = NULL;
-            goto error;
-        }
-
-        Py_DECREF(key);
-        Py_DECREF(val);
-    }
-
-    VIR_FREE(stats);
-    return ret;
-
-error:
-    VIR_FREE(stats);
-    Py_XDECREF(key);
-    Py_XDECREF(val);
-    return ret;
-}
-
-static PyObject *
-libvirt_virNodeGetMemoryStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
-{
-    PyObject *ret = NULL;
-    PyObject *key = NULL;
-    PyObject *val = NULL;
-    PyObject *pyobj_conn;
-    virConnectPtr conn;
-    unsigned int flags;
-    int cellNum, c_retval;
-    size_t i;
-    int nparams = 0;
-    virNodeMemoryStatsPtr stats = NULL;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oii:virNodeGetMemoryStats", &pyobj_conn, &cellNum, &flags))
-        return ret;
-    conn = (virConnectPtr)(PyvirConnect_Get(pyobj_conn));
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virNodeGetMemoryStats(conn, cellNum, NULL, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (nparams) {
-        if (VIR_ALLOC_N_QUIET(stats, nparams) < 0)
-            return PyErr_NoMemory();
-
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        c_retval = virNodeGetMemoryStats(conn, cellNum, stats, &nparams, flags);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (c_retval < 0) {
-            VIR_FREE(stats);
-            return VIR_PY_NONE;
-        }
-    }
-
-    if (!(ret = PyDict_New()))
-        goto error;
-
-    for (i = 0; i < nparams; i++) {
-        key = libvirt_constcharPtrWrap(stats[i].field);
-        val = libvirt_ulonglongWrap(stats[i].value);
-
-        if (!key || !val || PyDict_SetItem(ret, key, val) < 0) {
-            Py_DECREF(ret);
-            ret = NULL;
-            goto error;
-        }
-
-        Py_DECREF(key);
-        Py_DECREF(val);
-    }
-
-    VIR_FREE(stats);
-    return ret;
-
-error:
-    VIR_FREE(stats);
-    Py_XDECREF(key);
-    Py_XDECREF(val);
-    return ret;
-}
-
-static PyObject *
-libvirt_virConnectListStoragePools(PyObject *self ATTRIBUTE_UNUSED,
-                                   PyObject *args) {
-    PyObject *py_retval;
-    char **names = NULL;
-    int c_retval;
-    size_t i;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virConnectListStoragePools", &pyobj_conn))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virConnectNumOfStoragePools(conn);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
-            return VIR_PY_NONE;
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        c_retval = virConnectListStoragePools(conn, names, c_retval);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (c_retval < 0) {
-            VIR_FREE(names);
-            return VIR_PY_NONE;
-        }
-    }
-    py_retval = PyList_New(c_retval);
-    if (py_retval == NULL) {
-        if (names) {
-            for (i = 0; i < c_retval; i++)
-                VIR_FREE(names[i]);
-            VIR_FREE(names);
-        }
-        return VIR_PY_NONE;
-    }
-
-    if (names) {
-        for (i = 0; i < c_retval; i++) {
-            PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
-            VIR_FREE(names[i]);
-        }
-        VIR_FREE(names);
-    }
-
-    return py_retval;
-}
-
-
-static PyObject *
-libvirt_virConnectListDefinedStoragePools(PyObject *self ATTRIBUTE_UNUSED,
-                                          PyObject *args) {
-    PyObject *py_retval;
-    char **names = NULL;
-    int c_retval;
-    size_t i;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virConnectListDefinedStoragePools", &pyobj_conn))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virConnectNumOfDefinedStoragePools(conn);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
-            return VIR_PY_NONE;
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        c_retval = virConnectListDefinedStoragePools(conn, names, c_retval);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (c_retval < 0) {
-            VIR_FREE(names);
-            return VIR_PY_NONE;
-        }
-    }
-    py_retval = PyList_New(c_retval);
-    if (py_retval == NULL) {
-        if (names) {
-            for (i = 0; i < c_retval; i++)
-                VIR_FREE(names[i]);
-            VIR_FREE(names);
-        }
-        return VIR_PY_NONE;
-    }
-
-    if (names) {
-        for (i = 0; i < c_retval; i++) {
-            PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
-            VIR_FREE(names[i]);
-        }
-        VIR_FREE(names);
-    }
-
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectListAllStoragePools(PyObject *self ATTRIBUTE_UNUSED,
-                                      PyObject *args)
-{
-    PyObject *pyobj_conn;
-    PyObject *py_retval = NULL;
-    PyObject *tmp = NULL;
-    virConnectPtr conn;
-    virStoragePoolPtr *pools = NULL;
-    int c_retval = 0;
-    size_t i;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllStoragePools",
-                          &pyobj_conn, &flags))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virConnectListAllStoragePools(conn, &pools, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (!(py_retval = PyList_New(c_retval)))
-        goto cleanup;
-
-    for (i = 0; i < c_retval; i++) {
-        if (!(tmp = libvirt_virStoragePoolPtrWrap(pools[i])) ||
-            PyList_SetItem(py_retval, i, tmp) < 0) {
-            Py_XDECREF(tmp);
-            Py_DECREF(py_retval);
-            py_retval = NULL;
-            goto cleanup;
-        }
-        /* python steals the pointer */
-        pools[i] = NULL;
-    }
-
-cleanup:
-    for (i = 0; i < c_retval; i++)
-        if (pools[i])
-            virStoragePoolFree(pools[i]);
-    VIR_FREE(pools);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virStoragePoolListVolumes(PyObject *self ATTRIBUTE_UNUSED,
-                                  PyObject *args) {
-    PyObject *py_retval;
-    char **names = NULL;
-    int c_retval;
-    size_t i;
-    virStoragePoolPtr pool;
-    PyObject *pyobj_pool;
-
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virStoragePoolListVolumes", &pyobj_pool))
-        return NULL;
-    pool = (virStoragePoolPtr) PyvirStoragePool_Get(pyobj_pool);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virStoragePoolNumOfVolumes(pool);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
-            return VIR_PY_NONE;
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        c_retval = virStoragePoolListVolumes(pool, names, c_retval);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (c_retval < 0) {
-            VIR_FREE(names);
-            return VIR_PY_NONE;
-        }
-    }
-    py_retval = PyList_New(c_retval);
-    if (py_retval == NULL) {
-        if (names) {
-            for (i = 0; i < c_retval; i++)
-                VIR_FREE(names[i]);
-            VIR_FREE(names);
-        }
-        return VIR_PY_NONE;
-    }
-
-    if (names) {
-        for (i = 0; i < c_retval; i++) {
-            PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
-            VIR_FREE(names[i]);
-        }
-        VIR_FREE(names);
-    }
-
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virStoragePoolListAllVolumes(PyObject *self ATTRIBUTE_UNUSED,
-                                     PyObject *args)
-{
-    PyObject *py_retval = NULL;
-    PyObject *tmp = NULL;
-    virStoragePoolPtr pool;
-    virStorageVolPtr *vols = NULL;
-    int c_retval = 0;
-    size_t i;
-    unsigned int flags;
-    PyObject *pyobj_pool;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virStoragePoolListAllVolumes",
-                          &pyobj_pool, &flags))
-        return NULL;
-
-    pool = (virStoragePoolPtr) PyvirStoragePool_Get(pyobj_pool);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virStoragePoolListAllVolumes(pool, &vols, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (!(py_retval = PyList_New(c_retval)))
-        goto cleanup;
-
-    for (i = 0; i < c_retval; i++) {
-        if (!(tmp = libvirt_virStorageVolPtrWrap(vols[i])) ||
-            PyList_SetItem(py_retval, i, tmp) < 0) {
-            Py_XDECREF(tmp);
-            Py_DECREF(py_retval);
-            py_retval = NULL;
-            goto cleanup;
-        }
-        /* python steals the pointer */
-        vols[i] = NULL;
-    }
-
-cleanup:
-    for (i = 0; i < c_retval; i++)
-        if (vols[i])
-            virStorageVolFree(vols[i]);
-    VIR_FREE(vols);
-    return py_retval;
-}
-
-
-static PyObject *
-libvirt_virStoragePoolGetAutostart(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    int c_retval, autostart;
-    virStoragePoolPtr pool;
-    PyObject *pyobj_pool;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virStoragePoolGetAutostart", &pyobj_pool))
-        return NULL;
-
-    pool = (virStoragePoolPtr) PyvirStoragePool_Get(pyobj_pool);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virStoragePoolGetAutostart(pool, &autostart);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    py_retval = libvirt_intWrap(autostart);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virStoragePoolGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    int c_retval;
-    virStoragePoolPtr pool;
-    PyObject *pyobj_pool;
-    virStoragePoolInfo info;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virStoragePoolGetInfo", &pyobj_pool))
-        return NULL;
-    pool = (virStoragePoolPtr) PyvirStoragePool_Get(pyobj_pool);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virStoragePoolGetInfo(pool, &info);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if ((py_retval = PyList_New(4)) == NULL)
-        return VIR_PY_NONE;
-
-    PyList_SetItem(py_retval, 0, libvirt_intWrap((int) info.state));
-    PyList_SetItem(py_retval, 1,
-                   libvirt_longlongWrap((unsigned long long) info.capacity));
-    PyList_SetItem(py_retval, 2,
-                   libvirt_longlongWrap((unsigned long long) info.allocation));
-    PyList_SetItem(py_retval, 3,
-                   libvirt_longlongWrap((unsigned long long) info.available));
-    return py_retval;
-}
-
-
-static PyObject *
-libvirt_virStorageVolGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    int c_retval;
-    virStorageVolPtr pool;
-    PyObject *pyobj_pool;
-    virStorageVolInfo info;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virStorageVolGetInfo", &pyobj_pool))
-        return NULL;
-    pool = (virStorageVolPtr) PyvirStorageVol_Get(pyobj_pool);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virStorageVolGetInfo(pool, &info);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if ((py_retval = PyList_New(3)) == NULL)
-        return VIR_PY_NONE;
-    PyList_SetItem(py_retval, 0, libvirt_intWrap((int) info.type));
-    PyList_SetItem(py_retval, 1,
-                   libvirt_longlongWrap((unsigned long long) info.capacity));
-    PyList_SetItem(py_retval, 2,
-                   libvirt_longlongWrap((unsigned long long) info.allocation));
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virStoragePoolGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    unsigned char uuid[VIR_UUID_BUFLEN];
-    virStoragePoolPtr pool;
-    PyObject *pyobj_pool;
-    int c_retval;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virStoragePoolGetUUID", &pyobj_pool))
-        return NULL;
-    pool = (virStoragePoolPtr) PyvirStoragePool_Get(pyobj_pool);
-
-    if (pool == NULL)
-        return VIR_PY_NONE;
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virStoragePoolGetUUID(pool, &uuid[0]);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    py_retval = PyString_FromStringAndSize((char *) &uuid[0], VIR_UUID_BUFLEN);
-
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virStoragePoolGetUUIDString(PyObject *self ATTRIBUTE_UNUSED,
-                                    PyObject *args) {
-    PyObject *py_retval;
-    char uuidstr[VIR_UUID_STRING_BUFLEN];
-    virStoragePoolPtr pool;
-    PyObject *pyobj_pool;
-    int c_retval;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virStoragePoolGetUUIDString", &pyobj_pool))
-        return NULL;
-    pool = (virStoragePoolPtr) PyvirStoragePool_Get(pyobj_pool);
-
-    if (pool == NULL)
-        return VIR_PY_NONE;
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virStoragePoolGetUUIDString(pool, &uuidstr[0]);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    py_retval = PyString_FromString((char *) &uuidstr[0]);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virStoragePoolLookupByUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    virStoragePoolPtr c_retval;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-    unsigned char * uuid;
-    int len;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oz#:virStoragePoolLookupByUUID", &pyobj_conn, &uuid, &len))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    if ((uuid == NULL) || (len != VIR_UUID_BUFLEN))
-        return VIR_PY_NONE;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virStoragePoolLookupByUUID(conn, uuid);
-    LIBVIRT_END_ALLOW_THREADS;
-    py_retval = libvirt_virStoragePoolPtrWrap((virStoragePoolPtr) c_retval);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virNodeListDevices(PyObject *self ATTRIBUTE_UNUSED,
-                           PyObject *args) {
-    PyObject *py_retval;
-    char **names = NULL;
-    int c_retval;
-    size_t i;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-    char *cap;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"Ozi:virNodeListDevices",
-                          &pyobj_conn, &cap, &flags))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virNodeNumOfDevices(conn, cap, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
-            return VIR_PY_NONE;
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        c_retval = virNodeListDevices(conn, cap, names, c_retval, flags);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (c_retval < 0) {
-            VIR_FREE(names);
-            return VIR_PY_NONE;
-        }
-    }
-    py_retval = PyList_New(c_retval);
-
-    if (names) {
-        for (i = 0; i < c_retval; i++) {
-            PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
-            VIR_FREE(names[i]);
-        }
-        VIR_FREE(names);
-    }
-
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectListAllNodeDevices(PyObject *self ATTRIBUTE_UNUSED,
-                                     PyObject *args)
-{
-    PyObject *pyobj_conn;
-    PyObject *py_retval = NULL;
-    PyObject *tmp = NULL;
-    virConnectPtr conn;
-    virNodeDevicePtr *devices = NULL;
-    int c_retval = 0;
-    size_t i;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllNodeDevices",
-                          &pyobj_conn, &flags))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virConnectListAllNodeDevices(conn, &devices, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (!(py_retval = PyList_New(c_retval)))
-        goto cleanup;
-
-    for (i = 0; i < c_retval; i++) {
-        if (!(tmp = libvirt_virNodeDevicePtrWrap(devices[i])) ||
-            PyList_SetItem(py_retval, i, tmp) < 0) {
-            Py_XDECREF(tmp);
-            Py_DECREF(py_retval);
-            py_retval = NULL;
-            goto cleanup;
-        }
-        /* python steals the pointer */
-        devices[i] = NULL;
-    }
-
-cleanup:
-    for (i = 0; i < c_retval; i++)
-        if (devices[i])
-            virNodeDeviceFree(devices[i]);
-    VIR_FREE(devices);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virNodeDeviceListCaps(PyObject *self ATTRIBUTE_UNUSED,
-                              PyObject *args) {
-    PyObject *py_retval;
-    char **names = NULL;
-    int c_retval;
-    size_t i;
-    virNodeDevicePtr dev;
-    PyObject *pyobj_dev;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virNodeDeviceListCaps", &pyobj_dev))
-        return NULL;
-    dev = (virNodeDevicePtr) PyvirNodeDevice_Get(pyobj_dev);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virNodeDeviceNumOfCaps(dev);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
-            return VIR_PY_NONE;
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        c_retval = virNodeDeviceListCaps(dev, names, c_retval);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (c_retval < 0) {
-            VIR_FREE(names);
-            return VIR_PY_NONE;
-        }
-    }
-    py_retval = PyList_New(c_retval);
-
-    if (names) {
-        for (i = 0; i < c_retval; i++) {
-            PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
-            VIR_FREE(names[i]);
-        }
-        VIR_FREE(names);
-    }
-
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virSecretGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    unsigned char uuid[VIR_UUID_BUFLEN];
-    virSecretPtr secret;
-    PyObject *pyobj_secret;
-    int c_retval;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virSecretGetUUID", &pyobj_secret))
-        return NULL;
-    secret = (virSecretPtr) PyvirSecret_Get(pyobj_secret);
-
-    if (secret == NULL)
-        return VIR_PY_NONE;
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virSecretGetUUID(secret, &uuid[0]);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-    py_retval = PyString_FromStringAndSize((char *) &uuid[0], VIR_UUID_BUFLEN);
-
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virSecretGetUUIDString(PyObject *self ATTRIBUTE_UNUSED,
-                               PyObject *args) {
-    PyObject *py_retval;
-    char uuidstr[VIR_UUID_STRING_BUFLEN];
-    virSecretPtr dom;
-    PyObject *pyobj_dom;
-    int c_retval;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virSecretGetUUIDString",
-                          &pyobj_dom))
-        return NULL;
-    dom = (virSecretPtr) PyvirSecret_Get(pyobj_dom);
-
-    if (dom == NULL)
-        return VIR_PY_NONE;
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virSecretGetUUIDString(dom, &uuidstr[0]);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    py_retval = PyString_FromString((char *) &uuidstr[0]);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virSecretLookupByUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    virSecretPtr c_retval;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-    unsigned char * uuid;
-    int len;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oz#:virSecretLookupByUUID", &pyobj_conn, &uuid, &len))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    if ((uuid == NULL) || (len != VIR_UUID_BUFLEN))
-        return VIR_PY_NONE;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virSecretLookupByUUID(conn, uuid);
-    LIBVIRT_END_ALLOW_THREADS;
-    py_retval = libvirt_virSecretPtrWrap((virSecretPtr) c_retval);
-    return py_retval;
-}
-
-
-static PyObject *
-libvirt_virConnectListSecrets(PyObject *self ATTRIBUTE_UNUSED,
-                              PyObject *args) {
-    PyObject *py_retval;
-    char **uuids = NULL;
-    virConnectPtr conn;
-    int c_retval;
-    size_t i;
-    PyObject *pyobj_conn;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virConnectListSecrets", &pyobj_conn))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virConnectNumOfSecrets(conn);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(uuids, c_retval) < 0)
-            return VIR_PY_NONE;
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        c_retval = virConnectListSecrets(conn, uuids, c_retval);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (c_retval < 0) {
-            VIR_FREE(uuids);
-            return VIR_PY_NONE;
-        }
-    }
-    py_retval = PyList_New(c_retval);
-
-    if (uuids) {
-        for (i = 0; i < c_retval; i++) {
-            PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(uuids[i]));
-            VIR_FREE(uuids[i]);
-        }
-        VIR_FREE(uuids);
-    }
-
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectListAllSecrets(PyObject *self ATTRIBUTE_UNUSED,
-                                 PyObject *args)
-{
-    PyObject *pyobj_conn;
-    PyObject *py_retval = NULL;
-    PyObject *tmp = NULL;
-    virConnectPtr conn;
-    virSecretPtr *secrets = NULL;
-    int c_retval = 0;
-    size_t i;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllSecrets",
-                          &pyobj_conn, &flags))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virConnectListAllSecrets(conn, &secrets, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (!(py_retval = PyList_New(c_retval)))
-        goto cleanup;
-
-    for (i = 0; i < c_retval; i++) {
-        if (!(tmp = libvirt_virSecretPtrWrap(secrets[i])) ||
-            PyList_SetItem(py_retval, i, tmp) < 0) {
-            Py_XDECREF(tmp);
-            Py_DECREF(py_retval);
-            py_retval = NULL;
-            goto cleanup;
-        }
-        /* python steals the pointer */
-        secrets[i] = NULL;
-    }
-
-cleanup:
-    for (i = 0; i < c_retval; i++)
-        if (secrets[i])
-            virSecretFree(secrets[i]);
-    VIR_FREE(secrets);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virSecretGetValue(PyObject *self ATTRIBUTE_UNUSED,
-                          PyObject *args) {
-    PyObject *py_retval;
-    unsigned char *c_retval;
-    size_t size;
-    virSecretPtr secret;
-    PyObject *pyobj_secret;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virSecretGetValue", &pyobj_secret,
-                          &flags))
-        return NULL;
-    secret = (virSecretPtr) PyvirSecret_Get(pyobj_secret);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virSecretGetValue(secret, &size, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval == NULL)
-        return VIR_PY_NONE;
-
-    py_retval = PyString_FromStringAndSize((const char *)c_retval, size);
-    VIR_FREE(c_retval);
-
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virSecretSetValue(PyObject *self ATTRIBUTE_UNUSED,
-                          PyObject *args) {
-    PyObject *py_retval;
-    int c_retval;
-    virSecretPtr secret;
-    PyObject *pyobj_secret;
-    const char *value;
-    int size;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oz#i:virSecretSetValue", &pyobj_secret,
-                          &value, &size, &flags))
-        return NULL;
-    secret = (virSecretPtr) PyvirSecret_Get(pyobj_secret);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virSecretSetValue(secret, (const unsigned char *)value, size,
-                                 flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    py_retval = libvirt_intWrap(c_retval);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virNWFilterGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    unsigned char uuid[VIR_UUID_BUFLEN];
-    virNWFilterPtr nwfilter;
-    PyObject *pyobj_nwfilter;
-    int c_retval;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virNWFilterGetUUID", &pyobj_nwfilter))
-        return NULL;
-    nwfilter = (virNWFilterPtr) PyvirNWFilter_Get(pyobj_nwfilter);
-
-    if (nwfilter == NULL)
-        return VIR_PY_NONE;
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virNWFilterGetUUID(nwfilter, &uuid[0]);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-    py_retval = PyString_FromStringAndSize((char *) &uuid[0], VIR_UUID_BUFLEN);
-
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virNWFilterGetUUIDString(PyObject *self ATTRIBUTE_UNUSED,
-                                 PyObject *args) {
-    PyObject *py_retval;
-    char uuidstr[VIR_UUID_STRING_BUFLEN];
-    virNWFilterPtr nwfilter;
-    PyObject *pyobj_nwfilter;
-    int c_retval;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virNWFilterGetUUIDString",
-                          &pyobj_nwfilter))
-        return NULL;
-    nwfilter = (virNWFilterPtr) PyvirNWFilter_Get(pyobj_nwfilter);
-
-    if (nwfilter == NULL)
-        return VIR_PY_NONE;
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virNWFilterGetUUIDString(nwfilter, &uuidstr[0]);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    py_retval = PyString_FromString((char *) &uuidstr[0]);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virNWFilterLookupByUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    virNWFilterPtr c_retval;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-    unsigned char * uuid;
-    int len;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oz#:virNWFilterLookupByUUID", &pyobj_conn, &uuid, &len))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    if ((uuid == NULL) || (len != VIR_UUID_BUFLEN))
-        return VIR_PY_NONE;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virNWFilterLookupByUUID(conn, uuid);
-    LIBVIRT_END_ALLOW_THREADS;
-    py_retval = libvirt_virNWFilterPtrWrap((virNWFilterPtr) c_retval);
-    return py_retval;
-}
-
-
-static PyObject *
-libvirt_virConnectListNWFilters(PyObject *self ATTRIBUTE_UNUSED,
-                                PyObject *args) {
-    PyObject *py_retval;
-    char **uuids = NULL;
-    virConnectPtr conn;
-    int c_retval;
-    size_t i;
-    PyObject *pyobj_conn;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virConnectListNWFilters", &pyobj_conn))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virConnectNumOfNWFilters(conn);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(uuids, c_retval) < 0)
-            return VIR_PY_NONE;
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        c_retval = virConnectListNWFilters(conn, uuids, c_retval);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (c_retval < 0) {
-            VIR_FREE(uuids);
-            return VIR_PY_NONE;
-        }
-    }
-    py_retval = PyList_New(c_retval);
-
-    if (uuids) {
-        for (i = 0; i < c_retval; i++) {
-            PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(uuids[i]));
-            VIR_FREE(uuids[i]);
-        }
-        VIR_FREE(uuids);
-    }
-
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectListAllNWFilters(PyObject *self ATTRIBUTE_UNUSED,
-                                   PyObject *args)
-{
-    PyObject *pyobj_conn;
-    PyObject *py_retval = NULL;
-    PyObject *tmp = NULL;
-    virConnectPtr conn;
-    virNWFilterPtr *filters = NULL;
-    int c_retval = 0;
-    size_t i;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllNWFilters",
-                          &pyobj_conn, &flags))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virConnectListAllNWFilters(conn, &filters, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (!(py_retval = PyList_New(c_retval)))
-        goto cleanup;
-
-    for (i = 0; i < c_retval; i++) {
-        if (!(tmp = libvirt_virNWFilterPtrWrap(filters[i])) ||
-            PyList_SetItem(py_retval, i, tmp) < 0) {
-            Py_XDECREF(tmp);
-            Py_DECREF(py_retval);
-            py_retval = NULL;
-            goto cleanup;
-        }
-        /* python steals the pointer */
-        filters[i] = NULL;
-    }
-
-cleanup:
-    for (i = 0; i < c_retval; i++)
-        if (filters[i])
-            virNWFilterFree(filters[i]);
-    VIR_FREE(filters);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectListInterfaces(PyObject *self ATTRIBUTE_UNUSED,
-                                 PyObject *args) {
-    PyObject *py_retval;
-    char **names = NULL;
-    int c_retval;
-    size_t i;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virConnectListInterfaces", &pyobj_conn))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virConnectNumOfInterfaces(conn);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
-            return VIR_PY_NONE;
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        c_retval = virConnectListInterfaces(conn, names, c_retval);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (c_retval < 0) {
-            VIR_FREE(names);
-            return VIR_PY_NONE;
-        }
-    }
-    py_retval = PyList_New(c_retval);
-    if (py_retval == NULL) {
-        if (names) {
-            for (i = 0; i < c_retval; i++)
-                VIR_FREE(names[i]);
-            VIR_FREE(names);
-        }
-        return VIR_PY_NONE;
-    }
-
-    if (names) {
-        for (i = 0; i < c_retval; i++) {
-            PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
-            VIR_FREE(names[i]);
-        }
-        VIR_FREE(names);
-    }
-
-    return py_retval;
-}
-
-
-static PyObject *
-libvirt_virConnectListDefinedInterfaces(PyObject *self ATTRIBUTE_UNUSED,
-                                        PyObject *args) {
-    PyObject *py_retval;
-    char **names = NULL;
-    int c_retval;
-    size_t i;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virConnectListDefinedInterfaces",
-                          &pyobj_conn))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virConnectNumOfDefinedInterfaces(conn);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
-            return VIR_PY_NONE;
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        c_retval = virConnectListDefinedInterfaces(conn, names, c_retval);
-        LIBVIRT_END_ALLOW_THREADS;
-        if (c_retval < 0) {
-            VIR_FREE(names);
-            return VIR_PY_NONE;
-        }
-    }
-    py_retval = PyList_New(c_retval);
-    if (py_retval == NULL) {
-        if (names) {
-            for (i = 0; i < c_retval; i++)
-                VIR_FREE(names[i]);
-            VIR_FREE(names);
-        }
-        return VIR_PY_NONE;
-    }
-
-    if (names) {
-        for (i = 0; i < c_retval; i++) {
-            PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
-            VIR_FREE(names[i]);
-        }
-        VIR_FREE(names);
-    }
-
-    return py_retval;
-}
-
-
-static PyObject *
-libvirt_virConnectListAllInterfaces(PyObject *self ATTRIBUTE_UNUSED,
-                                    PyObject *args)
-{
-    PyObject *pyobj_conn;
-    PyObject *py_retval = NULL;
-    PyObject *tmp = NULL;
-    virConnectPtr conn;
-    virInterfacePtr *ifaces = NULL;
-    int c_retval = 0;
-    size_t i;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllInterfaces",
-                          &pyobj_conn, &flags))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virConnectListAllInterfaces(conn, &ifaces, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-
-    if (!(py_retval = PyList_New(c_retval)))
-        goto cleanup;
-
-    for (i = 0; i < c_retval; i++) {
-        if (!(tmp = libvirt_virInterfacePtrWrap(ifaces[i])) ||
-            PyList_SetItem(py_retval, i, tmp) < 0) {
-            Py_XDECREF(tmp);
-            Py_DECREF(py_retval);
-            py_retval = NULL;
-            goto cleanup;
-        }
-        /* python steals the pointer */
-        ifaces[i] = NULL;
-    }
-
-cleanup:
-    for (i = 0; i < c_retval; i++)
-        if (ifaces[i])
-            virInterfaceFree(ifaces[i]);
-    VIR_FREE(ifaces);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectBaselineCPU(PyObject *self ATTRIBUTE_UNUSED,
-                              PyObject *args) {
-    PyObject *pyobj_conn;
-    PyObject *list;
-    virConnectPtr conn;
-    unsigned int flags;
-    const char **xmlcpus = NULL;
-    int ncpus = 0;
-    char *base_cpu;
-    PyObject *pybase_cpu;
-
-    if (!PyArg_ParseTuple(args, (char *)"OOi:virConnectBaselineCPU",
-                          &pyobj_conn, &list, &flags))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    if (PyList_Check(list)) {
-        size_t i;
-
-        ncpus = PyList_Size(list);
-        if (VIR_ALLOC_N_QUIET(xmlcpus, ncpus) < 0)
-            return VIR_PY_INT_FAIL;
-
-        for (i = 0; i < ncpus; i++) {
-            xmlcpus[i] = PyString_AsString(PyList_GetItem(list, i));
-            if (xmlcpus[i] == NULL) {
-                VIR_FREE(xmlcpus);
-                return VIR_PY_INT_FAIL;
-            }
-        }
-    }
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    base_cpu = virConnectBaselineCPU(conn, xmlcpus, ncpus, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    VIR_FREE(xmlcpus);
-
-    if (base_cpu == NULL)
-        return VIR_PY_INT_FAIL;
-
-    pybase_cpu = PyString_FromString(base_cpu);
-    VIR_FREE(base_cpu);
-
-    if (pybase_cpu == NULL)
-        return VIR_PY_INT_FAIL;
-
-    return pybase_cpu;
-}
-
-
-static PyObject *
-libvirt_virDomainGetJobInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    int c_retval;
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    virDomainJobInfo info;
-
-    if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetJobInfo", &pyobj_domain))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainGetJobInfo(domain, &info);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (c_retval < 0)
-        return VIR_PY_NONE;
-    py_retval = PyList_New(12);
-    PyList_SetItem(py_retval, 0, libvirt_intWrap((int) info.type));
-    PyList_SetItem(py_retval, 1, libvirt_ulonglongWrap(info.timeElapsed));
-    PyList_SetItem(py_retval, 2, libvirt_ulonglongWrap(info.timeRemaining));
-    PyList_SetItem(py_retval, 3, libvirt_ulonglongWrap(info.dataTotal));
-    PyList_SetItem(py_retval, 4, libvirt_ulonglongWrap(info.dataProcessed));
-    PyList_SetItem(py_retval, 5, libvirt_ulonglongWrap(info.dataRemaining));
-    PyList_SetItem(py_retval, 6, libvirt_ulonglongWrap(info.memTotal));
-    PyList_SetItem(py_retval, 7, libvirt_ulonglongWrap(info.memProcessed));
-    PyList_SetItem(py_retval, 8, libvirt_ulonglongWrap(info.memRemaining));
-    PyList_SetItem(py_retval, 9, libvirt_ulonglongWrap(info.fileTotal));
-    PyList_SetItem(py_retval, 10, libvirt_ulonglongWrap(info.fileProcessed));
-    PyList_SetItem(py_retval, 11, libvirt_ulonglongWrap(info.fileRemaining));
-
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainGetJobStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
-{
-    PyObject *pyobj_domain;
-    virDomainPtr domain;
-    unsigned int flags;
-    virTypedParameterPtr params = NULL;
-    int nparams = 0;
-    int type;
-    PyObject *dict = NULL;
-    int rc;
-
-    if (!PyArg_ParseTuple(args, (char *) "Oi:virDomainGetJobStats",
-                          &pyobj_domain, &flags))
-        goto cleanup;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    rc = virDomainGetJobStats(domain, &type, &params, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    if (rc < 0)
-        goto cleanup;
-
-    if (!(dict = getPyVirTypedParameter(params, nparams)))
-        goto cleanup;
-
-    if (PyDict_SetItem(dict, libvirt_constcharPtrWrap("type"),
-                       libvirt_intWrap(type)) < 0) {
-        Py_DECREF(dict);
-        dict = NULL;
-        goto cleanup;
-    }
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    if (dict)
-        return dict;
-    else
-        return VIR_PY_NONE;
-}
-
-static PyObject *
-libvirt_virDomainGetBlockJobInfo(PyObject *self ATTRIBUTE_UNUSED,
-                                 PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    const char *path;
-    unsigned int flags;
-    virDomainBlockJobInfo info;
-    int c_ret;
-    PyObject *type = NULL, *bandwidth = NULL, *cur = NULL, *end = NULL;
-    PyObject *dict;
-
-    if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainGetBlockJobInfo",
-                          &pyobj_domain, &path, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if ((dict = PyDict_New()) == NULL)
-        return NULL;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_ret = virDomainGetBlockJobInfo(domain, path, &info, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_ret == 0) {
-        return dict;
-    } else if (c_ret < 0) {
-        Py_DECREF(dict);
-        return VIR_PY_NONE;
-    }
-
-    if ((type = libvirt_intWrap(info.type)) == NULL ||
-        PyDict_SetItemString(dict, "type", type) < 0)
-        goto error;
-    Py_DECREF(type);
-
-    if ((bandwidth = libvirt_ulongWrap(info.bandwidth)) == NULL ||
-        PyDict_SetItemString(dict, "bandwidth", bandwidth) < 0)
-        goto error;
-    Py_DECREF(bandwidth);
-
-    if ((cur = libvirt_ulonglongWrap(info.cur)) == NULL ||
-        PyDict_SetItemString(dict, "cur", cur) < 0)
-        goto error;
-    Py_DECREF(cur);
-
-    if ((end = libvirt_ulonglongWrap(info.end)) == NULL ||
-        PyDict_SetItemString(dict, "end", end) < 0)
-        goto error;
-    Py_DECREF(end);
-
-    return dict;
-
-error:
-    Py_DECREF(dict);
-    Py_XDECREF(type);
-    Py_XDECREF(bandwidth);
-    Py_XDECREF(cur);
-    Py_XDECREF(end);
-    return NULL;
-}
-
-static PyObject *
-libvirt_virDomainSetBlockIoTune(PyObject *self ATTRIBUTE_UNUSED,
-                                PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain, *info;
-    PyObject *ret = NULL;
-    int i_retval;
-    int nparams = 0;
-    Py_ssize_t size = 0;
-    const char *disk;
-    unsigned int flags;
-    virTypedParameterPtr params, new_params = NULL;
-
-    if (!PyArg_ParseTuple(args, (char *)"OzOi:virDomainSetBlockIoTune",
-                          &pyobj_domain, &disk, &info, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if ((size = PyDict_Size(info)) < 0)
-        return NULL;
-
-    if (size == 0) {
-        PyErr_Format(PyExc_LookupError,
-                     "Need non-empty dictionary to set attributes");
-        return NULL;
-    }
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetBlockIoTune(domain, disk, NULL, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0)
-        return VIR_PY_INT_FAIL;
-
-    if (nparams == 0) {
-        PyErr_Format(PyExc_LookupError,
-                     "Domain has no settable attributes");
-        return NULL;
-    }
-
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetBlockIoTune(domain, disk, params, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-
-    new_params = setPyVirTypedParameter(info, params, nparams);
-    if (!new_params)
-        goto cleanup;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainSetBlockIoTune(domain, disk, new_params, size, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-
-    ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    VIR_FREE(new_params);
-    return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetBlockIoTune(PyObject *self ATTRIBUTE_UNUSED,
-                                PyObject *args)
-{
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    PyObject *ret = NULL;
-    int i_retval;
-    int nparams = 0;
-    const char *disk;
-    unsigned int flags;
-    virTypedParameterPtr params;
-
-    if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainGetBlockIoTune",
-                          &pyobj_domain, &disk, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetBlockIoTune(domain, disk, NULL, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0)
-        return VIR_PY_NONE;
-
-    if (!nparams)
-        return PyDict_New();
-
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virDomainGetBlockIoTune(domain, disk, params, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_NONE;
-        goto cleanup;
-    }
-
-    ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetDiskErrors(PyObject *self ATTRIBUTE_UNUSED,
-                               PyObject *args)
-{
-    PyObject *py_retval = VIR_PY_NONE;
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    unsigned int flags;
-    virDomainDiskErrorPtr disks = NULL;
-    unsigned int ndisks;
-    int count;
-    size_t i;
-
-    if (!PyArg_ParseTuple(args, (char *) "Oi:virDomainGetDiskErrors",
-                          &pyobj_domain, &flags))
-        return NULL;
-
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if ((count = virDomainGetDiskErrors(domain, NULL, 0, 0)) < 0)
-        return VIR_PY_NONE;
-    ndisks = count;
-
-    if (ndisks) {
-        if (VIR_ALLOC_N_QUIET(disks, ndisks) < 0)
-            return VIR_PY_NONE;
-
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        count = virDomainGetDiskErrors(domain, disks, ndisks, 0);
-        LIBVIRT_END_ALLOW_THREADS;
-
-        if (count < 0)
-            goto cleanup;
-    }
-
-    if (!(py_retval = PyDict_New()))
-        goto cleanup;
-
-    for (i = 0; i < count; i++) {
-        PyDict_SetItem(py_retval,
-                       libvirt_constcharPtrWrap(disks[i].disk),
-                       libvirt_intWrap(disks[i].error));
-    }
-
-cleanup:
-    if (disks) {
-        for (i = 0; i < count; i++)
-            VIR_FREE(disks[i].disk);
-        VIR_FREE(disks);
-    }
-    return py_retval;
-}
-
-/*******************************************
- * Helper functions to avoid importing modules
- * for every callback
- *******************************************/
-static PyObject *libvirt_module    = NULL;
-static PyObject *libvirt_dict      = NULL;
-static PyObject *libvirt_dom_class = NULL;
-
-static PyObject *
-getLibvirtModuleObject(void) {
-    if (libvirt_module)
-        return libvirt_module;
-
-    // PyImport_ImportModule returns a new reference
-    /* Bogus (char *) cast for RHEL-5 python API brokenness */
-    libvirt_module = PyImport_ImportModule((char *)"libvirt");
-    if (!libvirt_module) {
-        DEBUG("%s Error importing libvirt module\n", __FUNCTION__);
-        PyErr_Print();
-        return NULL;
-    }
-
-    return libvirt_module;
-}
-
-static PyObject *
-getLibvirtDictObject(void) {
-    if (libvirt_dict)
-        return libvirt_dict;
-
-    // PyModule_GetDict returns a borrowed reference
-    libvirt_dict = PyModule_GetDict(getLibvirtModuleObject());
-    if (!libvirt_dict) {
-        DEBUG("%s Error importing libvirt dictionary\n", __FUNCTION__);
-        PyErr_Print();
-        return NULL;
-    }
-
-    Py_INCREF(libvirt_dict);
-    return libvirt_dict;
-}
-
-static PyObject *
-getLibvirtDomainClassObject(void) {
-    if (libvirt_dom_class)
-        return libvirt_dom_class;
-
-    // PyDict_GetItemString returns a borrowed reference
-    libvirt_dom_class = PyDict_GetItemString(getLibvirtDictObject(),
-                                             "virDomain");
-    if (!libvirt_dom_class) {
-        DEBUG("%s Error importing virDomain class\n", __FUNCTION__);
-        PyErr_Print();
-        return NULL;
-    }
-
-    Py_INCREF(libvirt_dom_class);
-    return libvirt_dom_class;
-}
-
-static PyObject *
-libvirt_lookupPythonFunc(const char *funcname)
-{
-    PyObject *python_cb;
-
-    /* Lookup the python callback */
-    python_cb = PyDict_GetItemString(getLibvirtDictObject(), funcname);
-
-    if (!python_cb) {
-        DEBUG("%s: Error finding %s\n", __FUNCTION__, funcname);
-        PyErr_Print();
-        PyErr_Clear();
-        return NULL;
-    }
-
-    if (!PyCallable_Check(python_cb)) {
-        DEBUG("%s: %s is not callable\n", __FUNCTION__, funcname);
-        return NULL;
-    }
-
-    return python_cb;
-}
-
-/*******************************************
- * Domain Events
- *******************************************/
-
-static int
-libvirt_virConnectDomainEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                      virDomainPtr dom,
-                                      int event,
-                                      int detail,
-                                      void *opaque)
-{
-    PyObject *pyobj_ret;
-
-    PyObject *pyobj_conn_inst = (PyObject*)opaque;
-    PyObject *pyobj_dom;
-
-    PyObject *pyobj_dom_args;
-    PyObject *pyobj_dom_inst;
-
-    PyObject *dom_class;
-    int ret = -1;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    /* Create a python instance of this virDomainPtr */
-    virDomainRef(dom);
-    pyobj_dom = libvirt_virDomainPtrWrap(dom);
-    pyobj_dom_args = PyTuple_New(2);
-    if (PyTuple_SetItem(pyobj_dom_args, 0, pyobj_conn_inst) != 0) {
-        DEBUG("%s error creating tuple", __FUNCTION__);
-        goto cleanup;
-    }
-    if (PyTuple_SetItem(pyobj_dom_args, 1, pyobj_dom) != 0) {
-        DEBUG("%s error creating tuple", __FUNCTION__);
-        goto cleanup;
-    }
-    Py_INCREF(pyobj_conn_inst);
-
-    dom_class = getLibvirtDomainClassObject();
-    if (!PyClass_Check(dom_class)) {
-        DEBUG("%s dom_class is not a class!\n", __FUNCTION__);
-        goto cleanup;
-    }
-
-    pyobj_dom_inst = PyInstance_New(dom_class,
-                                    pyobj_dom_args,
-                                    NULL);
-
-    Py_DECREF(pyobj_dom_args);
-
-    if (!pyobj_dom_inst) {
-        DEBUG("%s Error creating a python instance of virDomain\n",
-              __FUNCTION__);
-        PyErr_Print();
-        goto cleanup;
-    }
-
-    /* Call the Callback Dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_conn_inst,
-                                    (char*)"_dispatchDomainEventCallbacks",
-                                    (char*)"Oii",
-                                    pyobj_dom_inst,
-                                    event,
-                                    detail);
-
-    Py_DECREF(pyobj_dom_inst);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-        ret = 0;
-    }
-
-
-cleanup:
-    LIBVIRT_RELEASE_THREAD_STATE;
-    return ret;
-}
-
-static PyObject *
-libvirt_virConnectDomainEventRegister(ATTRIBUTE_UNUSED PyObject * self,
-                                      PyObject * args)
-{
-    PyObject *py_retval;        /* return value */
-    PyObject *pyobj_conn;       /* virConnectPtr */
-    PyObject *pyobj_conn_inst;  /* virConnect Python object */
-
-    virConnectPtr conn;
-    int ret = 0;
-
-    if (!PyArg_ParseTuple
-        (args, (char *) "OO:virConnectDomainEventRegister",
-                        &pyobj_conn, &pyobj_conn_inst)) {
-        DEBUG("%s failed parsing tuple\n", __FUNCTION__);
-        return VIR_PY_INT_FAIL;
-    }
-
-    DEBUG("libvirt_virConnectDomainEventRegister(%p %p) called\n",
-          pyobj_conn, pyobj_conn_inst);
-    conn   = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    Py_INCREF(pyobj_conn_inst);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-
-    ret = virConnectDomainEventRegister(conn,
-                                        libvirt_virConnectDomainEventCallback,
-                                        (void *)pyobj_conn_inst, NULL);
-
-    LIBVIRT_END_ALLOW_THREADS;
-
-    py_retval = libvirt_intWrap(ret);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectDomainEventDeregister(ATTRIBUTE_UNUSED PyObject * self,
-                                        PyObject * args)
-{
-    PyObject *py_retval;
-    PyObject *pyobj_conn;
-    PyObject *pyobj_conn_inst;
-
-    virConnectPtr conn;
-    int ret = 0;
-
-    if (!PyArg_ParseTuple
-        (args, (char *) "OO:virConnectDomainEventDeregister",
-         &pyobj_conn, &pyobj_conn_inst))
-        return NULL;
-
-    DEBUG("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn);
-
-    conn   = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-
-    ret = virConnectDomainEventDeregister(conn, libvirt_virConnectDomainEventCallback);
-
-    LIBVIRT_END_ALLOW_THREADS;
-
-    Py_DECREF(pyobj_conn_inst);
-    py_retval = libvirt_intWrap(ret);
-    return py_retval;
-}
-
-/*******************************************
- * Event Impl
- *******************************************/
-static PyObject *addHandleObj     = NULL;
-static char *addHandleName        = NULL;
-static PyObject *updateHandleObj  = NULL;
-static char *updateHandleName     = NULL;
-static PyObject *removeHandleObj  = NULL;
-static char *removeHandleName     = NULL;
-static PyObject *addTimeoutObj    = NULL;
-static char *addTimeoutName       = NULL;
-static PyObject *updateTimeoutObj = NULL;
-static char *updateTimeoutName    = NULL;
-static PyObject *removeTimeoutObj = NULL;
-static char *removeTimeoutName    = NULL;
-
-#define NAME(fn) ( fn ## Name ? fn ## Name : # fn )
-
-static int
-libvirt_virEventAddHandleFunc  (int fd,
-                                int event,
-                                virEventHandleCallback cb,
-                                void *opaque,
-                                virFreeCallback ff)
-{
-    PyObject *result;
-    PyObject *python_cb;
-    PyObject *cb_obj;
-    PyObject *ff_obj;
-    PyObject *opaque_obj;
-    PyObject *cb_args;
-    PyObject *pyobj_args;
-    int retval = -1;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    /* Lookup the python callback */
-    python_cb = libvirt_lookupPythonFunc("_eventInvokeHandleCallback");
-    if (!python_cb) {
-        goto cleanup;
-    }
-    Py_INCREF(python_cb);
-
-    /* create tuple for cb */
-    cb_obj = libvirt_virEventHandleCallbackWrap(cb);
-    ff_obj = libvirt_virFreeCallbackWrap(ff);
-    opaque_obj = libvirt_virVoidPtrWrap(opaque);
-
-    cb_args = PyTuple_New(3);
-    PyTuple_SetItem(cb_args, 0, cb_obj);
-    PyTuple_SetItem(cb_args, 1, opaque_obj);
-    PyTuple_SetItem(cb_args, 2, ff_obj);
-
-    pyobj_args = PyTuple_New(4);
-    PyTuple_SetItem(pyobj_args, 0, libvirt_intWrap(fd));
-    PyTuple_SetItem(pyobj_args, 1, libvirt_intWrap(event));
-    PyTuple_SetItem(pyobj_args, 2, python_cb);
-    PyTuple_SetItem(pyobj_args, 3, cb_args);
-
-    result = PyEval_CallObject(addHandleObj, pyobj_args);
-    if (!result) {
-        PyErr_Print();
-        PyErr_Clear();
-    } else if (!PyInt_Check(result)) {
-        DEBUG("%s: %s should return an int\n", __FUNCTION__, NAME(addHandle));
-    } else {
-        retval = (int)PyInt_AsLong(result);
-    }
-
-    Py_XDECREF(result);
-    Py_DECREF(pyobj_args);
-
-cleanup:
-    LIBVIRT_RELEASE_THREAD_STATE;
-
-    return retval;
-}
-
-static void
-libvirt_virEventUpdateHandleFunc(int watch, int event)
-{
-    PyObject *result;
-    PyObject *pyobj_args;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    pyobj_args = PyTuple_New(2);
-    PyTuple_SetItem(pyobj_args, 0, libvirt_intWrap(watch));
-    PyTuple_SetItem(pyobj_args, 1, libvirt_intWrap(event));
-
-    result = PyEval_CallObject(updateHandleObj, pyobj_args);
-    if (!result) {
-        PyErr_Print();
-        PyErr_Clear();
-    }
-
-    Py_XDECREF(result);
-    Py_DECREF(pyobj_args);
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-
-static int
-libvirt_virEventRemoveHandleFunc(int watch)
-{
-    PyObject *result;
-    PyObject *pyobj_args;
-    PyObject *opaque;
-    PyObject *ff;
-    int retval = -1;
-    virFreeCallback cff;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    pyobj_args = PyTuple_New(1);
-    PyTuple_SetItem(pyobj_args, 0, libvirt_intWrap(watch));
-
-    result = PyEval_CallObject(removeHandleObj, pyobj_args);
-    if (!result) {
-        PyErr_Print();
-        PyErr_Clear();
-    } else if (!PyTuple_Check(result) || PyTuple_Size(result) != 3) {
-        DEBUG("%s: %s must return opaque obj registered with %s"
-              "to avoid leaking libvirt memory\n",
-              __FUNCTION__, NAME(removeHandle), NAME(addHandle));
-    } else {
-        opaque = PyTuple_GetItem(result, 1);
-        ff = PyTuple_GetItem(result, 2);
-        cff = PyvirFreeCallback_Get(ff);
-        if (cff)
-            (*cff)(PyvirVoidPtr_Get(opaque));
-        retval = 0;
-    }
-
-    Py_XDECREF(result);
-    Py_DECREF(pyobj_args);
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-
-    return retval;
-}
-
-
-static int
-libvirt_virEventAddTimeoutFunc(int timeout,
-                               virEventTimeoutCallback cb,
-                               void *opaque,
-                               virFreeCallback ff)
-{
-    PyObject *result;
-
-    PyObject *python_cb;
-
-    PyObject *cb_obj;
-    PyObject *ff_obj;
-    PyObject *opaque_obj;
-    PyObject *cb_args;
-    PyObject *pyobj_args;
-    int retval = -1;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    /* Lookup the python callback */
-    python_cb = libvirt_lookupPythonFunc("_eventInvokeTimeoutCallback");
-    if (!python_cb) {
-        goto cleanup;
-    }
-    Py_INCREF(python_cb);
-
-    /* create tuple for cb */
-    cb_obj = libvirt_virEventTimeoutCallbackWrap(cb);
-    ff_obj = libvirt_virFreeCallbackWrap(ff);
-    opaque_obj = libvirt_virVoidPtrWrap(opaque);
-
-    cb_args = PyTuple_New(3);
-    PyTuple_SetItem(cb_args, 0, cb_obj);
-    PyTuple_SetItem(cb_args, 1, opaque_obj);
-    PyTuple_SetItem(cb_args, 2, ff_obj);
-
-    pyobj_args = PyTuple_New(3);
-
-    PyTuple_SetItem(pyobj_args, 0, libvirt_intWrap(timeout));
-    PyTuple_SetItem(pyobj_args, 1, python_cb);
-    PyTuple_SetItem(pyobj_args, 2, cb_args);
-
-    result = PyEval_CallObject(addTimeoutObj, pyobj_args);
-    if (!result) {
-        PyErr_Print();
-        PyErr_Clear();
-    } else if (!PyInt_Check(result)) {
-        DEBUG("%s: %s should return an int\n", __FUNCTION__, NAME(addTimeout));
-    } else {
-        retval = (int)PyInt_AsLong(result);
-    }
-
-    Py_XDECREF(result);
-    Py_DECREF(pyobj_args);
-
-cleanup:
-    LIBVIRT_RELEASE_THREAD_STATE;
-    return retval;
-}
-
-static void
-libvirt_virEventUpdateTimeoutFunc(int timer, int timeout)
-{
-    PyObject *result = NULL;
-    PyObject *pyobj_args;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    pyobj_args = PyTuple_New(2);
-    PyTuple_SetItem(pyobj_args, 0, libvirt_intWrap(timer));
-    PyTuple_SetItem(pyobj_args, 1, libvirt_intWrap(timeout));
-
-    result = PyEval_CallObject(updateTimeoutObj, pyobj_args);
-    if (!result) {
-        PyErr_Print();
-        PyErr_Clear();
-    }
-
-    Py_XDECREF(result);
-    Py_DECREF(pyobj_args);
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-static int
-libvirt_virEventRemoveTimeoutFunc(int timer)
-{
-    PyObject *result = NULL;
-    PyObject *pyobj_args;
-    PyObject *opaque;
-    PyObject *ff;
-    int retval = -1;
-    virFreeCallback cff;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    pyobj_args = PyTuple_New(1);
-    PyTuple_SetItem(pyobj_args, 0, libvirt_intWrap(timer));
-
-    result = PyEval_CallObject(removeTimeoutObj, pyobj_args);
-    if (!result) {
-        PyErr_Print();
-        PyErr_Clear();
-    } else if (!PyTuple_Check(result) || PyTuple_Size(result) != 3) {
-        DEBUG("%s: %s must return opaque obj registered with %s"
-              "to avoid leaking libvirt memory\n",
-              __FUNCTION__, NAME(removeTimeout), NAME(addTimeout));
-    } else {
-        opaque = PyTuple_GetItem(result, 1);
-        ff = PyTuple_GetItem(result, 2);
-        cff = PyvirFreeCallback_Get(ff);
-        if (cff)
-            (*cff)(PyvirVoidPtr_Get(opaque));
-        retval = 0;
-    }
-
-    Py_XDECREF(result);
-    Py_DECREF(pyobj_args);
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-
-    return retval;
-}
-
-static PyObject *
-libvirt_virEventRegisterImpl(ATTRIBUTE_UNUSED PyObject * self,
-                             PyObject * args)
-{
-    /* Unref the previously-registered impl (if any) */
-    Py_XDECREF(addHandleObj);
-    Py_XDECREF(updateHandleObj);
-    Py_XDECREF(removeHandleObj);
-    Py_XDECREF(addTimeoutObj);
-    Py_XDECREF(updateTimeoutObj);
-    Py_XDECREF(removeTimeoutObj);
-
-    /* Parse and check arguments */
-    if (!PyArg_ParseTuple(args, (char *) "OOOOOO:virEventRegisterImpl",
-                          &addHandleObj, &updateHandleObj,
-                          &removeHandleObj, &addTimeoutObj,
-                          &updateTimeoutObj, &removeTimeoutObj) ||
-        !PyCallable_Check(addHandleObj) ||
-        !PyCallable_Check(updateHandleObj) ||
-        !PyCallable_Check(removeHandleObj) ||
-        !PyCallable_Check(addTimeoutObj) ||
-        !PyCallable_Check(updateTimeoutObj) ||
-        !PyCallable_Check(removeTimeoutObj))
-        return VIR_PY_INT_FAIL;
-
-    /* Get argument string representations (for error reporting) */
-    addHandleName = py_str(addHandleObj);
-    updateHandleName = py_str(updateHandleObj);
-    removeHandleName = py_str(removeHandleObj);
-    addTimeoutName = py_str(addTimeoutObj);
-    updateTimeoutName = py_str(updateTimeoutObj);
-    removeTimeoutName = py_str(removeTimeoutObj);
-
-    /* Inc refs since we're holding on to these objects until
-     * the next call (if any) to this function.
-     */
-    Py_INCREF(addHandleObj);
-    Py_INCREF(updateHandleObj);
-    Py_INCREF(removeHandleObj);
-    Py_INCREF(addTimeoutObj);
-    Py_INCREF(updateTimeoutObj);
-    Py_INCREF(removeTimeoutObj);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-
-    /* Now register our C EventImpl, which will dispatch
-     * to the Python callbacks passed in as args.
-     */
-    virEventRegisterImpl(libvirt_virEventAddHandleFunc,
-                         libvirt_virEventUpdateHandleFunc,
-                         libvirt_virEventRemoveHandleFunc,
-                         libvirt_virEventAddTimeoutFunc,
-                         libvirt_virEventUpdateTimeoutFunc,
-                         libvirt_virEventRemoveTimeoutFunc);
-
-    LIBVIRT_END_ALLOW_THREADS;
-
-    return VIR_PY_INT_SUCCESS;
-}
-
-static PyObject *
-libvirt_virEventInvokeHandleCallback(PyObject *self ATTRIBUTE_UNUSED,
-                                     PyObject *args)
-{
-    int watch, fd, event;
-    PyObject *py_f;
-    PyObject *py_opaque;
-    virEventHandleCallback cb;
-    void *opaque;
-
-    if (!PyArg_ParseTuple
-        (args, (char *) "iiiOO:virEventInvokeHandleCallback",
-         &watch, &fd, &event, &py_f, &py_opaque
-        ))
-        return VIR_PY_INT_FAIL;
-
-    cb     = (virEventHandleCallback) PyvirEventHandleCallback_Get(py_f);
-    opaque = (void *) PyvirVoidPtr_Get(py_opaque);
-
-    if (cb) {
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        cb(watch, fd, event, opaque);
-        LIBVIRT_END_ALLOW_THREADS;
-    }
-
-    return VIR_PY_INT_SUCCESS;
-}
-
-static PyObject *
-libvirt_virEventInvokeTimeoutCallback(PyObject *self ATTRIBUTE_UNUSED,
-                                      PyObject *args)
-{
-    int timer;
-    PyObject *py_f;
-    PyObject *py_opaque;
-    virEventTimeoutCallback cb;
-    void *opaque;
-
-    if (!PyArg_ParseTuple
-        (args, (char *) "iOO:virEventInvokeTimeoutCallback",
-                        &timer, &py_f, &py_opaque
-        ))
-        return VIR_PY_INT_FAIL;
-
-    cb     = (virEventTimeoutCallback) PyvirEventTimeoutCallback_Get(py_f);
-    opaque = (void *) PyvirVoidPtr_Get(py_opaque);
-    if (cb) {
-        LIBVIRT_BEGIN_ALLOW_THREADS;
-        cb(timer, opaque);
-        LIBVIRT_END_ALLOW_THREADS;
-    }
-
-    return VIR_PY_INT_SUCCESS;
-}
-
-static void
-libvirt_virEventHandleCallback(int watch,
-                               int fd,
-                               int events,
-                               void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject *)opaque;
-    PyObject *pyobj_ret;
-    PyObject *python_cb;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    /* Lookup the python callback */
-    python_cb = libvirt_lookupPythonFunc("_dispatchEventHandleCallback");
-    if (!python_cb) {
-        goto cleanup;
-    }
-
-    Py_INCREF(pyobj_cbData);
-
-    /* Call the pure python dispatcher */
-    pyobj_ret = PyObject_CallFunction(python_cb,
-                                      (char *)"iiiO",
-                                      watch, fd, events, pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-    }
-
-cleanup:
-    LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-static PyObject *
-libvirt_virEventAddHandle(PyObject *self ATTRIBUTE_UNUSED,
-                          PyObject *args)
-{
-    PyObject *py_retval;
-    PyObject *pyobj_cbData;
-    virEventHandleCallback cb = libvirt_virEventHandleCallback;
-    int events;
-    int fd;
-    int ret;
-
-    if (!PyArg_ParseTuple(args, (char *) "iiO:virEventAddHandle",
-                          &fd, &events, &pyobj_cbData)) {
-        DEBUG("%s failed to parse tuple\n", __FUNCTION__);
-        return VIR_PY_INT_FAIL;
-    }
-
-    Py_INCREF(pyobj_cbData);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    ret = virEventAddHandle(fd, events, cb, pyobj_cbData, NULL);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (ret < 0) {
-        Py_DECREF(pyobj_cbData);
-    }
-
-    py_retval = libvirt_intWrap(ret);
-    return py_retval;
-}
-
-static void
-libvirt_virEventTimeoutCallback(int timer,
-                                void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject *)opaque;
-    PyObject *pyobj_ret;
-    PyObject *python_cb;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    /* Lookup the python callback */
-    python_cb = libvirt_lookupPythonFunc("_dispatchEventTimeoutCallback");
-    if (!python_cb) {
-        goto cleanup;
-    }
-
-    Py_INCREF(pyobj_cbData);
-
-    /* Call the pure python dispatcher */
-    pyobj_ret = PyObject_CallFunction(python_cb,
-                                      (char *)"iO",
-                                      timer, pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-    }
-
-cleanup:
-    LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-static PyObject *
-libvirt_virEventAddTimeout(PyObject *self ATTRIBUTE_UNUSED,
-                           PyObject *args)
-{
-    PyObject *py_retval;
-    PyObject *pyobj_cbData;
-    virEventTimeoutCallback cb = libvirt_virEventTimeoutCallback;
-    int timeout;
-    int ret;
-
-    if (!PyArg_ParseTuple(args, (char *) "iO:virEventAddTimeout",
-                          &timeout, &pyobj_cbData)) {
-        DEBUG("%s failed to parse tuple\n", __FUNCTION__);
-        return VIR_PY_INT_FAIL;
-    }
-
-    Py_INCREF(pyobj_cbData);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    ret = virEventAddTimeout(timeout, cb, pyobj_cbData, NULL);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (ret < 0) {
-        Py_DECREF(pyobj_cbData);
-    }
-
-    py_retval = libvirt_intWrap(ret);
-    return py_retval;
-}
-
-static void
-libvirt_virConnectDomainEventFreeFunc(void *opaque)
-{
-    PyObject *pyobj_conn = (PyObject*)opaque;
-    LIBVIRT_ENSURE_THREAD_STATE;
-    Py_DECREF(pyobj_conn);
-    LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-static int
-libvirt_virConnectDomainEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                               virDomainPtr dom,
-                                               int event,
-                                               int detail,
-                                               void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject*)opaque;
-    PyObject *pyobj_dom;
-    PyObject *pyobj_ret;
-    PyObject *pyobj_conn;
-    PyObject *dictKey;
-    int ret = -1;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    /* Create a python instance of this virDomainPtr */
-    virDomainRef(dom);
-    pyobj_dom = libvirt_virDomainPtrWrap(dom);
-    Py_INCREF(pyobj_cbData);
-
-    dictKey = libvirt_constcharPtrWrap("conn");
-    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
-    Py_DECREF(dictKey);
-
-    /* Call the Callback Dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"_dispatchDomainEventLifecycleCallback",
-                                    (char*)"OiiO",
-                                    pyobj_dom,
-                                    event, detail,
-                                    pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-    Py_DECREF(pyobj_dom);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-        ret = 0;
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-    return ret;
-}
-
-static int
-libvirt_virConnectDomainEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                             virDomainPtr dom,
-                                             void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject*)opaque;
-    PyObject *pyobj_dom;
-    PyObject *pyobj_ret;
-    PyObject *pyobj_conn;
-    PyObject *dictKey;
-    int ret = -1;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    /* Create a python instance of this virDomainPtr */
-    virDomainRef(dom);
-    pyobj_dom = libvirt_virDomainPtrWrap(dom);
-    Py_INCREF(pyobj_cbData);
-
-    dictKey = libvirt_constcharPtrWrap("conn");
-    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
-    Py_DECREF(dictKey);
-
-    /* Call the Callback Dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"_dispatchDomainEventGenericCallback",
-                                    (char*)"OO",
-                                    pyobj_dom, pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-    Py_DECREF(pyobj_dom);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-        ret = 0;
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-    return ret;
-}
-
-static int
-libvirt_virConnectDomainEventRTCChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                               virDomainPtr dom,
-                                               long long utcoffset,
-                                               void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject*)opaque;
-    PyObject *pyobj_dom;
-    PyObject *pyobj_ret;
-    PyObject *pyobj_conn;
-    PyObject *dictKey;
-    int ret = -1;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    /* Create a python instance of this virDomainPtr */
-    virDomainRef(dom);
-    pyobj_dom = libvirt_virDomainPtrWrap(dom);
-    Py_INCREF(pyobj_cbData);
-
-    dictKey = libvirt_constcharPtrWrap("conn");
-    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
-    Py_DECREF(dictKey);
-
-    /* Call the Callback Dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"_dispatchDomainEventRTCChangeCallback",
-                                    (char*)"OLO",
-                                    pyobj_dom,
-                                    (PY_LONG_LONG)utcoffset,
-                                    pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-    Py_DECREF(pyobj_dom);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-        ret = 0;
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-    return ret;
-}
-
-static int
-libvirt_virConnectDomainEventWatchdogCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                              virDomainPtr dom,
-                                              int action,
-                                              void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject*)opaque;
-    PyObject *pyobj_dom;
-    PyObject *pyobj_ret;
-    PyObject *pyobj_conn;
-    PyObject *dictKey;
-    int ret = -1;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    /* Create a python instance of this virDomainPtr */
-    virDomainRef(dom);
-    pyobj_dom = libvirt_virDomainPtrWrap(dom);
-    Py_INCREF(pyobj_cbData);
-
-    dictKey = libvirt_constcharPtrWrap("conn");
-    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
-    Py_DECREF(dictKey);
-
-    /* Call the Callback Dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"_dispatchDomainEventWatchdogCallback",
-                                    (char*)"OiO",
-                                    pyobj_dom,
-                                    action,
-                                    pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-    Py_DECREF(pyobj_dom);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-        ret = 0;
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-    return ret;
-}
-
-static int
-libvirt_virConnectDomainEventIOErrorCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                             virDomainPtr dom,
-                                             const char *srcPath,
-                                             const char *devAlias,
-                                             int action,
-                                             void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject*)opaque;
-    PyObject *pyobj_dom;
-    PyObject *pyobj_ret;
-    PyObject *pyobj_conn;
-    PyObject *dictKey;
-    int ret = -1;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    /* Create a python instance of this virDomainPtr */
-    virDomainRef(dom);
-    pyobj_dom = libvirt_virDomainPtrWrap(dom);
-    Py_INCREF(pyobj_cbData);
-
-    dictKey = libvirt_constcharPtrWrap("conn");
-    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
-    Py_DECREF(dictKey);
-
-    /* Call the Callback Dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"_dispatchDomainEventIOErrorCallback",
-                                    (char*)"OssiO",
-                                    pyobj_dom,
-                                    srcPath, devAlias, action,
-                                    pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-    Py_DECREF(pyobj_dom);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-        ret = 0;
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-    return ret;
-}
-
-static int
-libvirt_virConnectDomainEventIOErrorReasonCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                                   virDomainPtr dom,
-                                                   const char *srcPath,
-                                                   const char *devAlias,
-                                                   int action,
-                                                   const char *reason,
-                                                   void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject*)opaque;
-    PyObject *pyobj_dom;
-    PyObject *pyobj_ret;
-    PyObject *pyobj_conn;
-    PyObject *dictKey;
-    int ret = -1;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    /* Create a python instance of this virDomainPtr */
-    virDomainRef(dom);
-    pyobj_dom = libvirt_virDomainPtrWrap(dom);
-    Py_INCREF(pyobj_cbData);
-
-    dictKey = libvirt_constcharPtrWrap("conn");
-    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
-    Py_DECREF(dictKey);
-
-    /* Call the Callback Dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"_dispatchDomainEventIOErrorReasonCallback",
-                                    (char*)"OssisO",
-                                    pyobj_dom,
-                                    srcPath, devAlias, action, reason,
-                                    pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-    Py_DECREF(pyobj_dom);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-        ret = 0;
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-    return ret;
-}
-
-static int
-libvirt_virConnectDomainEventGraphicsCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                              virDomainPtr dom,
-                                              int phase,
-                                              virDomainEventGraphicsAddressPtr local,
-                                              virDomainEventGraphicsAddressPtr remote,
-                                              const char *authScheme,
-                                              virDomainEventGraphicsSubjectPtr subject,
-                                              void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject*)opaque;
-    PyObject *pyobj_dom;
-    PyObject *pyobj_ret;
-    PyObject *pyobj_conn;
-    PyObject *dictKey;
-    PyObject *pyobj_local;
-    PyObject *pyobj_remote;
-    PyObject *pyobj_subject;
-    int ret = -1;
-    size_t i;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    /* Create a python instance of this virDomainPtr */
-    virDomainRef(dom);
-    pyobj_dom = libvirt_virDomainPtrWrap(dom);
-    Py_INCREF(pyobj_cbData);
-
-    dictKey = libvirt_constcharPtrWrap("conn");
-    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
-    Py_DECREF(dictKey);
-
-    pyobj_local = PyDict_New();
-    PyDict_SetItem(pyobj_local,
-                   libvirt_constcharPtrWrap("family"),
-                   libvirt_intWrap(local->family));
-    PyDict_SetItem(pyobj_local,
-                   libvirt_constcharPtrWrap("node"),
-                   libvirt_constcharPtrWrap(local->node));
-    PyDict_SetItem(pyobj_local,
-                   libvirt_constcharPtrWrap("service"),
-                   libvirt_constcharPtrWrap(local->service));
-
-    pyobj_remote = PyDict_New();
-    PyDict_SetItem(pyobj_remote,
-                   libvirt_constcharPtrWrap("family"),
-                   libvirt_intWrap(remote->family));
-    PyDict_SetItem(pyobj_remote,
-                   libvirt_constcharPtrWrap("node"),
-                   libvirt_constcharPtrWrap(remote->node));
-    PyDict_SetItem(pyobj_remote,
-                   libvirt_constcharPtrWrap("service"),
-                   libvirt_constcharPtrWrap(remote->service));
-
-    pyobj_subject = PyList_New(subject->nidentity);
-    for (i = 0; i < subject->nidentity; i++) {
-        PyObject *pair = PyTuple_New(2);
-        PyTuple_SetItem(pair, 0, libvirt_constcharPtrWrap(subject->identities[i].type));
-        PyTuple_SetItem(pair, 1, libvirt_constcharPtrWrap(subject->identities[i].name));
-
-        PyList_SetItem(pyobj_subject, i, pair);
-    }
-
-    /* Call the Callback Dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"_dispatchDomainEventGraphicsCallback",
-                                    (char*)"OiOOsOO",
-                                    pyobj_dom,
-                                    phase, pyobj_local, pyobj_remote,
-                                    authScheme, pyobj_subject,
-                                    pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-    Py_DECREF(pyobj_dom);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-        ret = 0;
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-    return ret;
-}
-
-static int
-libvirt_virConnectDomainEventBlockJobCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                              virDomainPtr dom,
-                                              const char *path,
-                                              int type,
-                                              int status,
-                                              void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject*)opaque;
-    PyObject *pyobj_dom;
-    PyObject *pyobj_ret;
-    PyObject *pyobj_conn;
-    PyObject *dictKey;
-    int ret = -1;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    /* Create a python instance of this virDomainPtr */
-    virDomainRef(dom);
-    pyobj_dom = libvirt_virDomainPtrWrap(dom);
-    Py_INCREF(pyobj_cbData);
-
-    dictKey = libvirt_constcharPtrWrap("conn");
-    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
-    Py_DECREF(dictKey);
-
-    /* Call the Callback Dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"dispatchDomainEventBlockPullCallback",
-                                    (char*)"OsiiO",
-                                    pyobj_dom, path, type, status, pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-    Py_DECREF(pyobj_dom);
-
-    if (!pyobj_ret) {
-#if DEBUG_ERROR
-        printf("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-#endif
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-        ret = 0;
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-    return ret;
-}
-
-static int
-libvirt_virConnectDomainEventDiskChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                                virDomainPtr dom,
-                                                const char *oldSrcPath,
-                                                const char *newSrcPath,
-                                                const char *devAlias,
-                                                int reason,
-                                                void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject*)opaque;
-    PyObject *pyobj_dom;
-    PyObject *pyobj_ret;
-    PyObject *pyobj_conn;
-    PyObject *dictKey;
-    int ret = -1;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-    /* Create a python instance of this virDomainPtr */
-    virDomainRef(dom);
-
-    pyobj_dom = libvirt_virDomainPtrWrap(dom);
-    Py_INCREF(pyobj_cbData);
-
-    dictKey = libvirt_constcharPtrWrap("conn");
-    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
-    Py_DECREF(dictKey);
-
-    /* Call the Callback Dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"_dispatchDomainEventDiskChangeCallback",
-                                    (char*)"OsssiO",
-                                    pyobj_dom,
-                                    oldSrcPath, newSrcPath,
-                                    devAlias, reason, pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-    Py_DECREF(pyobj_dom);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-        ret = 0;
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-    return ret;
-}
-
-static int
-libvirt_virConnectDomainEventTrayChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                                virDomainPtr dom,
-                                                const char *devAlias,
-                                                int reason,
-                                                void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject*)opaque;
-    PyObject *pyobj_dom;
-    PyObject *pyobj_ret;
-    PyObject *pyobj_conn;
-    PyObject *dictKey;
-    int ret = -1;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-    /* Create a python instance of this virDomainPtr */
-    virDomainRef(dom);
-
-    pyobj_dom = libvirt_virDomainPtrWrap(dom);
-    Py_INCREF(pyobj_cbData);
-
-    dictKey = libvirt_constcharPtrWrap("conn");
-    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
-    Py_DECREF(dictKey);
-
-    /* Call the Callback Dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"_dispatchDomainEventTrayChangeCallback",
-                                    (char*)"OsiO",
-                                    pyobj_dom,
-                                    devAlias, reason, pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-    Py_DECREF(pyobj_dom);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-        ret = 0;
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-    return ret;
-}
-
-static int
-libvirt_virConnectDomainEventPMWakeupCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                              virDomainPtr dom,
-                                              int reason,
-                                              void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject*)opaque;
-    PyObject *pyobj_dom;
-    PyObject *pyobj_ret;
-    PyObject *pyobj_conn;
-    PyObject *dictKey;
-    int ret = -1;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-    /* Create a python instance of this virDomainPtr */
-    virDomainRef(dom);
-
-    pyobj_dom = libvirt_virDomainPtrWrap(dom);
-    Py_INCREF(pyobj_cbData);
-
-    dictKey = libvirt_constcharPtrWrap("conn");
-    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
-    Py_DECREF(dictKey);
-
-    /* Call the Callback Dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"_dispatchDomainEventPMWakeupCallback",
-                                    (char*)"OiO",
-                                    pyobj_dom,
-                                    reason,
-                                    pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-    Py_DECREF(pyobj_dom);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-        ret = 0;
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-    return ret;
-}
-
-static int
-libvirt_virConnectDomainEventPMSuspendCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                               virDomainPtr dom,
-                                               int reason,
-                                               void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject*)opaque;
-    PyObject *pyobj_dom;
-    PyObject *pyobj_ret;
-    PyObject *pyobj_conn;
-    PyObject *dictKey;
-    int ret = -1;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-    /* Create a python instance of this virDomainPtr */
-    virDomainRef(dom);
-
-    pyobj_dom = libvirt_virDomainPtrWrap(dom);
-    Py_INCREF(pyobj_cbData);
-
-    dictKey = libvirt_constcharPtrWrap("conn");
-    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
-    Py_DECREF(dictKey);
-
-    /* Call the Callback Dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"_dispatchDomainEventPMSuspendCallback",
-                                    (char*)"OiO",
-                                    pyobj_dom,
-                                    reason,
-                                    pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-    Py_DECREF(pyobj_dom);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-        ret = 0;
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-    return ret;
-}
-
-static int
-libvirt_virConnectDomainEventBalloonChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                                   virDomainPtr dom,
-                                                   unsigned long long actual,
-                                                   void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject*)opaque;
-    PyObject *pyobj_dom;
-    PyObject *pyobj_ret;
-    PyObject *pyobj_conn;
-    PyObject *dictKey;
-    int ret = -1;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    /* Create a python instance of this virDomainPtr */
-    virDomainRef(dom);
-    pyobj_dom = libvirt_virDomainPtrWrap(dom);
-    Py_INCREF(pyobj_cbData);
-
-    dictKey = libvirt_constcharPtrWrap("conn");
-    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
-    Py_DECREF(dictKey);
-
-    /* Call the Callback Dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"_dispatchDomainEventBalloonChangeCallback",
-                                    (char*)"OLO",
-                                    pyobj_dom,
-                                    (PY_LONG_LONG)actual,
-                                    pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-    Py_DECREF(pyobj_dom);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-        ret = 0;
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-    return ret;
-}
-
-static int
-libvirt_virConnectDomainEventPMSuspendDiskCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                                   virDomainPtr dom,
-                                                   int reason,
-                                                   void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject*)opaque;
-    PyObject *pyobj_dom;
-    PyObject *pyobj_ret;
-    PyObject *pyobj_conn;
-    PyObject *dictKey;
-    int ret = -1;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-    /* Create a python instance of this virDomainPtr */
-    virDomainRef(dom);
-
-    pyobj_dom = libvirt_virDomainPtrWrap(dom);
-    Py_INCREF(pyobj_cbData);
-
-    dictKey = libvirt_constcharPtrWrap("conn");
-    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
-    Py_DECREF(dictKey);
-
-    /* Call the Callback Dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"_dispatchDomainEventPMSuspendDiskCallback",
-                                    (char*)"OiO",
-                                    pyobj_dom,
-                                    reason,
-                                    pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-    Py_DECREF(pyobj_dom);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-        ret = 0;
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-    return ret;
-}
-
-static int
-libvirt_virConnectDomainEventDeviceRemovedCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                                   virDomainPtr dom,
-                                                   const char *devAlias,
-                                                   void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject*)opaque;
-    PyObject *pyobj_dom;
-    PyObject *pyobj_ret;
-    PyObject *pyobj_conn;
-    PyObject *dictKey;
-    int ret = -1;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-    /* Create a python instance of this virDomainPtr */
-    virDomainRef(dom);
-
-    pyobj_dom = libvirt_virDomainPtrWrap(dom);
-    Py_INCREF(pyobj_cbData);
-
-    dictKey = libvirt_constcharPtrWrap("conn");
-    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
-    Py_DECREF(dictKey);
-
-    /* Call the Callback Dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"_dispatchDomainEventDeviceRemovedCallback",
-                                    (char*)"OsO",
-                                    pyobj_dom, devAlias, pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-    Py_DECREF(pyobj_dom);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-        ret = 0;
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-    return ret;
-}
-
-static PyObject *
-libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self,
-                                         PyObject * args)
-{
-    PyObject *py_retval;        /* return value */
-    PyObject *pyobj_conn;       /* virConnectPtr */
-    PyObject *pyobj_dom;
-    PyObject *pyobj_cbData;     /* hash of callback data */
-    int eventID;
-    virConnectPtr conn;
-    int ret = 0;
-    virConnectDomainEventGenericCallback cb = NULL;
-    virDomainPtr dom;
-
-    if (!PyArg_ParseTuple
-        (args, (char *) "OOiO:virConnectDomainEventRegisterAny",
-         &pyobj_conn, &pyobj_dom, &eventID, &pyobj_cbData)) {
-        DEBUG("%s failed parsing tuple\n", __FUNCTION__);
-        return VIR_PY_INT_FAIL;
-    }
-
-    DEBUG("libvirt_virConnectDomainEventRegister(%p %p %d %p) called\n",
-           pyobj_conn, pyobj_dom, eventID, pyobj_cbData);
-    conn = PyvirConnect_Get(pyobj_conn);
-    if (pyobj_dom == Py_None)
-        dom = NULL;
-    else
-        dom = PyvirDomain_Get(pyobj_dom);
-
-    switch ((virDomainEventID) eventID) {
-    case VIR_DOMAIN_EVENT_ID_LIFECYCLE:
-        cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventLifecycleCallback);
-        break;
-    case VIR_DOMAIN_EVENT_ID_REBOOT:
-        cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGenericCallback);
-        break;
-    case VIR_DOMAIN_EVENT_ID_RTC_CHANGE:
-        cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventRTCChangeCallback);
-        break;
-    case VIR_DOMAIN_EVENT_ID_WATCHDOG:
-        cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventWatchdogCallback);
-        break;
-    case VIR_DOMAIN_EVENT_ID_IO_ERROR:
-        cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventIOErrorCallback);
-        break;
-    case VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON:
-        cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventIOErrorReasonCallback);
-        break;
-    case VIR_DOMAIN_EVENT_ID_GRAPHICS:
-        cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGraphicsCallback);
-        break;
-    case VIR_DOMAIN_EVENT_ID_CONTROL_ERROR:
-        cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGenericCallback);
-        break;
-    case VIR_DOMAIN_EVENT_ID_BLOCK_JOB:
-        cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBlockJobCallback);
-        break;
-    case VIR_DOMAIN_EVENT_ID_DISK_CHANGE:
-        cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDiskChangeCallback);
-        break;
-    case VIR_DOMAIN_EVENT_ID_TRAY_CHANGE:
-        cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventTrayChangeCallback);
-        break;
-    case VIR_DOMAIN_EVENT_ID_PMWAKEUP:
-        cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMWakeupCallback);
-        break;
-    case VIR_DOMAIN_EVENT_ID_PMSUSPEND:
-        cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendCallback);
-        break;
-    case VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE:
-        cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBalloonChangeCallback);
-        break;
-    case VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK:
-        cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendDiskCallback);
-        break;
-    case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED:
-        cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovedCallback);
-        break;
-
-    case VIR_DOMAIN_EVENT_ID_LAST:
-        break;
-    }
-
-    if (!cb) {
-        return VIR_PY_INT_FAIL;
-    }
-
-    Py_INCREF(pyobj_cbData);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    ret = virConnectDomainEventRegisterAny(conn, dom, eventID,
-                                           cb, pyobj_cbData,
-                                           libvirt_virConnectDomainEventFreeFunc);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (ret < 0) {
-        Py_DECREF(pyobj_cbData);
-    }
-
-    py_retval = libvirt_intWrap(ret);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectDomainEventDeregisterAny(ATTRIBUTE_UNUSED PyObject * self,
-                                           PyObject * args)
-{
-    PyObject *py_retval;
-    PyObject *pyobj_conn;
-    int callbackID;
-    virConnectPtr conn;
-    int ret = 0;
-
-    if (!PyArg_ParseTuple
-        (args, (char *) "Oi:virConnectDomainEventDeregister",
-         &pyobj_conn, &callbackID))
-        return NULL;
-
-    DEBUG("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn);
-
-    conn   = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-
-    ret = virConnectDomainEventDeregisterAny(conn, callbackID);
-
-    LIBVIRT_END_ALLOW_THREADS;
-    py_retval = libvirt_intWrap(ret);
-    return py_retval;
-}
-
-
-static void
-libvirt_virConnectCloseCallbackDispatch(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                        int reason,
-                                        void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject*)opaque;
-    PyObject *pyobj_ret;
-    PyObject *pyobj_conn;
-    PyObject *dictKey;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    Py_INCREF(pyobj_cbData);
-
-    dictKey = libvirt_constcharPtrWrap("conn");
-    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
-    Py_DECREF(dictKey);
-
-    /* Call the Callback Dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"_dispatchCloseCallback",
-                                    (char*)"iO",
-                                    reason,
-                                    pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-static PyObject *
-libvirt_virConnectRegisterCloseCallback(ATTRIBUTE_UNUSED PyObject * self,
-                                        PyObject * args)
-{
-    PyObject *py_retval;        /* return value */
-    PyObject *pyobj_conn;       /* virConnectPtr */
-    PyObject *pyobj_cbData;     /* hash of callback data */
-    virConnectPtr conn;
-    int ret = 0;
-
-    if (!PyArg_ParseTuple
-        (args, (char *) "OO:virConnectRegisterCloseCallback",
-         &pyobj_conn, &pyobj_cbData)) {
-        DEBUG("%s failed parsing tuple\n", __FUNCTION__);
-        return VIR_PY_INT_FAIL;
-    }
-
-    DEBUG("libvirt_virConnectRegisterCloseCallback(%p %p) called\n",
-           pyobj_conn, pyobj_cbData);
-    conn = PyvirConnect_Get(pyobj_conn);
-
-    Py_INCREF(pyobj_cbData);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    ret = virConnectRegisterCloseCallback(conn,
-                                          libvirt_virConnectCloseCallbackDispatch,
-                                          pyobj_cbData,
-                                          libvirt_virConnectDomainEventFreeFunc);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (ret < 0) {
-        Py_DECREF(pyobj_cbData);
-    }
-
-    py_retval = libvirt_intWrap(ret);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectUnregisterCloseCallback(ATTRIBUTE_UNUSED PyObject * self,
-                                          PyObject * args)
-{
-    PyObject *py_retval;
-    PyObject *pyobj_conn;
-    virConnectPtr conn;
-    int ret = 0;
-
-    if (!PyArg_ParseTuple
-        (args, (char *) "O:virConnectDomainEventUnregister",
-         &pyobj_conn))
-        return NULL;
-
-    DEBUG("libvirt_virConnectDomainEventUnregister(%p) called\n",
-          pyobj_conn);
-
-    conn = PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-
-    ret = virConnectUnregisterCloseCallback(conn,
-                                            libvirt_virConnectCloseCallbackDispatch);
-
-    LIBVIRT_END_ALLOW_THREADS;
-    py_retval = libvirt_intWrap(ret);
-    return py_retval;
-}
-
-static void
-libvirt_virStreamEventFreeFunc(void *opaque)
-{
-    PyObject *pyobj_stream = (PyObject*)opaque;
-    LIBVIRT_ENSURE_THREAD_STATE;
-    Py_DECREF(pyobj_stream);
-    LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-static void
-libvirt_virStreamEventCallback(virStreamPtr st ATTRIBUTE_UNUSED,
-                               int events,
-                               void *opaque)
-{
-    PyObject *pyobj_cbData = (PyObject *)opaque;
-    PyObject *pyobj_stream;
-    PyObject *pyobj_ret;
-    PyObject *dictKey;
-
-    LIBVIRT_ENSURE_THREAD_STATE;
-
-    Py_INCREF(pyobj_cbData);
-    dictKey = libvirt_constcharPtrWrap("stream");
-    pyobj_stream = PyDict_GetItem(pyobj_cbData, dictKey);
-    Py_DECREF(dictKey);
-
-    /* Call the pure python dispatcher */
-    pyobj_ret = PyObject_CallMethod(pyobj_stream,
-                                    (char *)"_dispatchStreamEventCallback",
-                                    (char *)"iO",
-                                    events, pyobj_cbData);
-
-    Py_DECREF(pyobj_cbData);
-
-    if (!pyobj_ret) {
-        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-        PyErr_Print();
-    } else {
-        Py_DECREF(pyobj_ret);
-    }
-
-    LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-static PyObject *
-libvirt_virStreamEventAddCallback(PyObject *self ATTRIBUTE_UNUSED,
-                                  PyObject *args)
-{
-    PyObject *py_retval;
-    PyObject *pyobj_stream;
-    PyObject *pyobj_cbData;
-    virStreamPtr stream;
-    virStreamEventCallback cb = libvirt_virStreamEventCallback;
-    int ret;
-    int events;
-
-    if (!PyArg_ParseTuple(args, (char *) "OiO:virStreamEventAddCallback",
-                          &pyobj_stream, &events, &pyobj_cbData)) {
-        DEBUG("%s failed to parse tuple\n", __FUNCTION__);
-        return VIR_PY_INT_FAIL;
-    }
-
-    DEBUG("libvirt_virStreamEventAddCallback(%p, %d, %p) called\n",
-          pyobj_stream, events, pyobj_cbData);
-    stream = PyvirStream_Get(pyobj_stream);
-
-    Py_INCREF(pyobj_cbData);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    ret = virStreamEventAddCallback(stream, events, cb, pyobj_cbData,
-                                    libvirt_virStreamEventFreeFunc);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (ret < 0) {
-        Py_DECREF(pyobj_cbData);
-    }
-
-    py_retval = libvirt_intWrap(ret);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virStreamRecv(PyObject *self ATTRIBUTE_UNUSED,
-                      PyObject *args)
-{
-    PyObject *pyobj_stream;
-    virStreamPtr stream;
-    char *buf = NULL;
-    int ret;
-    int nbytes;
-
-    if (!PyArg_ParseTuple(args, (char *) "Oi:virStreamRecv",
-                          &pyobj_stream, &nbytes)) {
-        DEBUG("%s failed to parse tuple\n", __FUNCTION__);
-        return VIR_PY_NONE;
-    }
-    stream = PyvirStream_Get(pyobj_stream);
-
-    if (VIR_ALLOC_N_QUIET(buf, nbytes+1 > 0 ? nbytes+1 : 1) < 0)
-        return VIR_PY_NONE;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    ret = virStreamRecv(stream, buf, nbytes);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    buf[ret > -1 ? ret : 0] = '\0';
-    DEBUG("StreamRecv ret=%d strlen=%d\n", ret, (int) strlen(buf));
-
-    if (ret == -2)
-        return libvirt_intWrap(ret);
-    if (ret < 0)
-        return VIR_PY_NONE;
-    return libvirt_charPtrSizeWrap((char *) buf, (Py_ssize_t) ret);
-}
-
-static PyObject *
-libvirt_virStreamSend(PyObject *self ATTRIBUTE_UNUSED,
-                      PyObject *args)
-{
-    PyObject *py_retval;
-    PyObject *pyobj_stream;
-    virStreamPtr stream;
-    char *data;
-    int datalen;
-    int ret;
-    int nbytes;
-
-    if (!PyArg_ParseTuple(args, (char *) "Oz#i:virStreamRecv",
-                          &pyobj_stream, &data, &datalen, &nbytes)) {
-        DEBUG("%s failed to parse tuple\n", __FUNCTION__);
-        return VIR_PY_INT_FAIL;
-    }
-    stream = PyvirStream_Get(pyobj_stream);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    ret = virStreamSend(stream, data, nbytes);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    DEBUG("StreamSend ret=%d\n", ret);
-
-    py_retval = libvirt_intWrap(ret);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainSendKey(PyObject *self ATTRIBUTE_UNUSED,
-                         PyObject *args)
-{
-    PyObject *py_retval;
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    PyObject *pyobj_list;
-    int codeset;
-    int holdtime;
-    unsigned int flags;
-    int ret;
-    size_t i;
-    unsigned int keycodes[VIR_DOMAIN_SEND_KEY_MAX_KEYS];
-    unsigned int nkeycodes;
-
-    if (!PyArg_ParseTuple(args, (char *)"OiiOii:virDomainSendKey",
-                          &pyobj_domain, &codeset, &holdtime, &pyobj_list,
-                          &nkeycodes, &flags)) {
-        DEBUG("%s failed to parse tuple\n", __FUNCTION__);
-        return VIR_PY_INT_FAIL;
-    }
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if (!PyList_Check(pyobj_list)) {
-        return VIR_PY_INT_FAIL;
-    }
-
-    if (nkeycodes != PyList_Size(pyobj_list) ||
-        nkeycodes > VIR_DOMAIN_SEND_KEY_MAX_KEYS) {
-        return VIR_PY_INT_FAIL;
-    }
-
-    for (i = 0; i < nkeycodes; i++) {
-        keycodes[i] = (int)PyInt_AsLong(PyList_GetItem(pyobj_list, i));
-    }
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    ret = virDomainSendKey(domain, codeset, holdtime, keycodes, nkeycodes, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    DEBUG("virDomainSendKey ret=%d\n", ret);
-
-    py_retval = libvirt_intWrap(ret);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainMigrateGetCompressionCache(PyObject *self ATTRIBUTE_UNUSED,
-                                            PyObject *args)
-{
-    PyObject *pyobj_domain;
-    virDomainPtr domain;
-    unsigned int flags;
-    unsigned long long cacheSize;
-    int rc;
-
-    if (!PyArg_ParseTuple(args,
-                          (char *) "Oi:virDomainMigrateGetCompressionCache",
-                          &pyobj_domain, &flags))
-        return VIR_PY_NONE;
-
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    rc = virDomainMigrateGetCompressionCache(domain, &cacheSize, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (rc < 0)
-        return VIR_PY_NONE;
-
-    return libvirt_ulonglongWrap(cacheSize);
-}
-
-static PyObject *
-libvirt_virDomainMigrateGetMaxSpeed(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval;
-    int c_retval;
-    unsigned long bandwidth;
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    unsigned int flags = 0;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainMigrateGetMaxSpeed",
-                          &pyobj_domain, &flags))
-        return NULL;
-
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainMigrateGetMaxSpeed(domain, &bandwidth, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0)
-        return VIR_PY_INT_FAIL;
-    py_retval = libvirt_ulongWrap(bandwidth);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainMigrate3(PyObject *self ATTRIBUTE_UNUSED,
-                          PyObject *args)
-{
-    PyObject *pyobj_domain;
-    virDomainPtr domain;
-    PyObject *pyobj_dconn;
-    virConnectPtr dconn;
-    PyObject *dict;
-    unsigned int flags;
-    virTypedParameterPtr params;
-    int nparams;
-    virDomainPtr ddom = NULL;
-
-    if (!PyArg_ParseTuple(args, (char *) "OOOi:virDomainMigrate3",
-                          &pyobj_domain, &pyobj_dconn, &dict, &flags))
-        return NULL;
-
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-    dconn = (virConnectPtr) PyvirConnect_Get(pyobj_dconn);
-
-    if (virPyDictToTypedParams(dict, &params, &nparams, NULL, 0) < 0)
-        return NULL;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    ddom = virDomainMigrate3(domain, dconn, params, nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    virTypedParamsFree(params, nparams);
-    return libvirt_virDomainPtrWrap(ddom);
-}
-
-static PyObject *
-libvirt_virDomainMigrateToURI3(PyObject *self ATTRIBUTE_UNUSED,
-                               PyObject *args)
-{
-    PyObject *pyobj_domain;
-    virDomainPtr domain;
-    char *dconnuri;
-    PyObject *dict;
-    unsigned int flags;
-    virTypedParameterPtr params;
-    int nparams;
-    int ret = -1;
-
-    if (!PyArg_ParseTuple(args, (char *) "OzOi:virDomainMigrate3",
-                          &pyobj_domain, &dconnuri, &dict, &flags))
-        return NULL;
-
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if (virPyDictToTypedParams(dict, &params, &nparams, NULL, 0) < 0)
-        return NULL;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    ret = virDomainMigrateToURI3(domain, dconnuri, params, nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    virTypedParamsFree(params, nparams);
-    return libvirt_intWrap(ret);
-}
-
-static PyObject *
-libvirt_virDomainBlockPeek(PyObject *self ATTRIBUTE_UNUSED,
-                           PyObject *args) {
-    PyObject *py_retval = NULL;
-    int c_retval;
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    const char *disk;
-    unsigned long long offset;
-    size_t size;
-    char *buf;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"OzLni:virDomainBlockPeek", &pyobj_domain,
-                          &disk, &offset, &size, &flags))
-        return NULL;
-
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if (VIR_ALLOC_N_QUIET(buf, size) < 0)
-        return VIR_PY_NONE;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainBlockPeek(domain, disk, offset, size, buf, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0) {
-        py_retval = VIR_PY_NONE;
-        goto cleanup;
-    }
-
-    py_retval = PyString_FromStringAndSize(buf, size);
-
-cleanup:
-    VIR_FREE(buf);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainMemoryPeek(PyObject *self ATTRIBUTE_UNUSED,
-                            PyObject *args) {
-    PyObject *py_retval = NULL;
-    int c_retval;
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    unsigned long long start;
-    size_t size;
-    char *buf;
-    unsigned int flags;
-
-    if (!PyArg_ParseTuple(args, (char *)"OLni:virDomainMemoryPeek", &pyobj_domain,
-                          &start, &size, &flags))
-        return NULL;
-
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    if (VIR_ALLOC_N_QUIET(buf, size) < 0)
-        return VIR_PY_NONE;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainMemoryPeek(domain, start, size, buf, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (c_retval < 0) {
-        py_retval = VIR_PY_NONE;
-        goto cleanup;
-    }
-
-    py_retval = PyString_FromStringAndSize(buf, size);
-
-cleanup:
-    VIR_FREE(buf);
-    return py_retval;
-}
-
-static PyObject *
-libvirt_virNodeSetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED,
-                                   PyObject *args)
-{
-    virConnectPtr conn;
-    PyObject *pyobj_conn, *info;
-    PyObject *ret = NULL;
-    int i_retval;
-    int nparams = 0;
-    Py_ssize_t size = 0;
-    unsigned int flags;
-    virTypedParameterPtr params, new_params = NULL;
-
-    if (!PyArg_ParseTuple(args,
-                          (char *)"OOi:virNodeSetMemoryParameters",
-                          &pyobj_conn, &info, &flags))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    if ((size = PyDict_Size(info)) < 0)
-        return NULL;
-
-    if (size == 0) {
-        PyErr_Format(PyExc_LookupError,
-                     "Need non-empty dictionary to set attributes");
-        return NULL;
-    }
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virNodeGetMemoryParameters(conn, NULL, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0)
-        return VIR_PY_INT_FAIL;
-
-    if (nparams == 0) {
-        PyErr_Format(PyExc_LookupError,
-                     "no settable attributes");
-        return NULL;
-    }
-
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virNodeGetMemoryParameters(conn, params, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-
-    new_params = setPyVirTypedParameter(info, params, nparams);
-    if (!new_params)
-        goto cleanup;
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virNodeSetMemoryParameters(conn, new_params, size, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_INT_FAIL;
-        goto cleanup;
-    }
-
-    ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    VIR_FREE(new_params);
-    return ret;
-}
-
-static PyObject *
-libvirt_virNodeGetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED,
-                                   PyObject *args)
-{
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-    PyObject *ret = NULL;
-    int i_retval;
-    int nparams = 0;
-    unsigned int flags;
-    virTypedParameterPtr params;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virNodeGetMemoryParameters",
-                          &pyobj_conn, &flags))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virNodeGetMemoryParameters(conn, NULL, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0)
-        return VIR_PY_NONE;
-
-    if (!nparams)
-        return PyDict_New();
-
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
-        return PyErr_NoMemory();
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virNodeGetMemoryParameters(conn, params, &nparams, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0) {
-        ret = VIR_PY_NONE;
-        goto cleanup;
-    }
-
-    ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
-    virTypedParamsFree(params, nparams);
-    return ret;
-}
-
-static PyObject *
-libvirt_virNodeGetCPUMap(PyObject *self ATTRIBUTE_UNUSED,
-                         PyObject *args)
-{
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-    PyObject *ret = NULL;
-    PyObject *pycpumap = NULL;
-    PyObject *pyused = NULL;
-    PyObject *pycpunum = NULL;
-    PyObject *pyonline = NULL;
-    int i_retval;
-    unsigned char *cpumap = NULL;
-    unsigned int online = 0;
-    unsigned int flags;
-    size_t i;
-
-    if (!PyArg_ParseTuple(args, (char *)"Oi:virNodeGetCPUMap",
-                          &pyobj_conn, &flags))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    i_retval = virNodeGetCPUMap(conn, &cpumap, &online, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-
-    if (i_retval < 0)
-        return VIR_PY_NONE;
-
-    if ((ret = PyTuple_New(3)) == NULL)
-        goto error;
-
-    /* 0: number of CPUs */
-    if ((pycpunum = PyLong_FromLong(i_retval)) == NULL ||
-        PyTuple_SetItem(ret, 0, pycpunum) < 0)
-        goto error;
-
-    /* 1: CPU map */
-    if ((pycpumap = PyList_New(i_retval)) == NULL)
-        goto error;
-
-    for (i = 0; i < i_retval; i++) {
-        if ((pyused = PyBool_FromLong(VIR_CPU_USED(cpumap, i))) == NULL)
-            goto error;
-        if (PyList_SetItem(pycpumap, i, pyused) < 0)
-            goto error;
-    }
-
-    if (PyTuple_SetItem(ret, 1, pycpumap) < 0)
-        goto error;
-
-    /* 2: number of online CPUs */
-    if ((pyonline = PyLong_FromLong(online)) == NULL ||
-        PyTuple_SetItem(ret, 2, pyonline) < 0)
-        goto error;
-
-cleanup:
-    VIR_FREE(cpumap);
-    return ret;
-error:
-    Py_XDECREF(ret);
-    Py_XDECREF(pycpumap);
-    Py_XDECREF(pyused);
-    Py_XDECREF(pycpunum);
-    Py_XDECREF(pyonline);
-    ret = NULL;
-    goto cleanup;
-}
-
-
-static PyObject *
-libvirt_virDomainCreateWithFiles(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval = NULL;
-    int c_retval;
-    virDomainPtr domain;
-    PyObject *pyobj_domain;
-    PyObject *pyobj_files;
-    unsigned int flags;
-    unsigned int nfiles;
-    int *files = NULL;
-    size_t i;
-
-    if (!PyArg_ParseTuple(args, (char *)"OOi:virDomainCreateWithFiles",
-                          &pyobj_domain, &pyobj_files, &flags))
-        return NULL;
-    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
-    nfiles = PyList_Size(pyobj_files);
-
-    if (VIR_ALLOC_N_QUIET(files, nfiles) < 0)
-        return PyErr_NoMemory();
-
-    for (i = 0; i < nfiles; i++) {
-        PyObject *pyfd;
-        int fd;
-
-        pyfd = PyList_GetItem(pyobj_files, i);
-
-        if (libvirt_intUnwrap(pyfd, &fd) < 0)
-            goto cleanup;
-
-        files[i] = fd;
-    }
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainCreateWithFiles(domain, nfiles, files, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    py_retval = libvirt_intWrap((int) c_retval);
-
-cleanup:
-    VIR_FREE(files);
-    return py_retval;
-}
-
-
-static PyObject *
-libvirt_virDomainCreateXMLWithFiles(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
-    PyObject *py_retval = NULL;
-    virDomainPtr c_retval;
-    virConnectPtr conn;
-    PyObject *pyobj_conn;
-    char * xmlDesc;
-    PyObject *pyobj_files;
-    unsigned int flags;
-    unsigned int nfiles;
-    int *files = NULL;
-    size_t i;
-
-    if (!PyArg_ParseTuple(args, (char *)"OzOi:virDomainCreateXMLWithFiles",
-                          &pyobj_conn, &xmlDesc, &pyobj_files, &flags))
-        return NULL;
-    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
-    nfiles = PyList_Size(pyobj_files);
-
-    if (VIR_ALLOC_N_QUIET(files, nfiles) < 0)
-        return PyErr_NoMemory();
-
-    for (i = 0; i < nfiles; i++) {
-        PyObject *pyfd;
-        int fd;
-
-        pyfd = PyList_GetItem(pyobj_files, i);
-
-        if (libvirt_intUnwrap(pyfd, &fd) < 0)
-            goto cleanup;
-
-        files[i] = fd;
-    }
-
-    LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_retval = virDomainCreateXMLWithFiles(conn, xmlDesc, nfiles, files, flags);
-    LIBVIRT_END_ALLOW_THREADS;
-    py_retval = libvirt_virDomainPtrWrap((virDomainPtr) c_retval);
-
-cleanup:
-    VIR_FREE(files);
-    return py_retval;
-}
-
-
-/************************************************************************
- *									*
- *			The registration stuff				*
- *									*
- ************************************************************************/
-static PyMethodDef libvirtMethods[] = {
-#include "libvirt-export.c"
-    {(char *) "virGetVersion", libvirt_virGetVersion, METH_VARARGS, NULL},
-    {(char *) "virConnectGetVersion", libvirt_virConnectGetVersion, METH_VARARGS, NULL},
-    {(char *) "virConnectGetCPUModelNames", libvirt_virConnectGetCPUModelNames, METH_VARARGS, NULL},
-    {(char *) "virConnectGetLibVersion", libvirt_virConnectGetLibVersion, METH_VARARGS, NULL},
-    {(char *) "virConnectOpenAuth", libvirt_virConnectOpenAuth, METH_VARARGS, NULL},
-    {(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID, METH_VARARGS, NULL},
-    {(char *) "virConnectListDefinedDomains", libvirt_virConnectListDefinedDomains, METH_VARARGS, NULL},
-    {(char *) "virConnectListAllDomains", libvirt_virConnectListAllDomains, METH_VARARGS, NULL},
-    {(char *) "virConnectDomainEventRegister", libvirt_virConnectDomainEventRegister, METH_VARARGS, NULL},
-    {(char *) "virConnectDomainEventDeregister", libvirt_virConnectDomainEventDeregister, METH_VARARGS, NULL},
-    {(char *) "virConnectDomainEventRegisterAny", libvirt_virConnectDomainEventRegisterAny, METH_VARARGS, NULL},
-    {(char *) "virConnectDomainEventDeregisterAny", libvirt_virConnectDomainEventDeregisterAny, METH_VARARGS, NULL},
-    {(char *) "virConnectRegisterCloseCallback", libvirt_virConnectRegisterCloseCallback, METH_VARARGS, NULL},
-    {(char *) "virConnectUnregisterCloseCallback", libvirt_virConnectUnregisterCloseCallback, METH_VARARGS, NULL},
-    {(char *) "virStreamEventAddCallback", libvirt_virStreamEventAddCallback, METH_VARARGS, NULL},
-    {(char *) "virStreamRecv", libvirt_virStreamRecv, METH_VARARGS, NULL},
-    {(char *) "virStreamSend", libvirt_virStreamSend, METH_VARARGS, NULL},
-    {(char *) "virDomainGetInfo", libvirt_virDomainGetInfo, METH_VARARGS, NULL},
-    {(char *) "virDomainGetState", libvirt_virDomainGetState, METH_VARARGS, NULL},
-    {(char *) "virDomainGetControlInfo", libvirt_virDomainGetControlInfo, METH_VARARGS, NULL},
-    {(char *) "virDomainGetBlockInfo", libvirt_virDomainGetBlockInfo, METH_VARARGS, NULL},
-    {(char *) "virNodeGetInfo", libvirt_virNodeGetInfo, METH_VARARGS, NULL},
-    {(char *) "virNodeGetCPUStats", libvirt_virNodeGetCPUStats, METH_VARARGS, NULL},
-    {(char *) "virNodeGetMemoryStats", libvirt_virNodeGetMemoryStats, METH_VARARGS, NULL},
-    {(char *) "virDomainGetUUID", libvirt_virDomainGetUUID, METH_VARARGS, NULL},
-    {(char *) "virDomainGetUUIDString", libvirt_virDomainGetUUIDString, METH_VARARGS, NULL},
-    {(char *) "virDomainLookupByUUID", libvirt_virDomainLookupByUUID, METH_VARARGS, NULL},
-    {(char *) "virRegisterErrorHandler", libvirt_virRegisterErrorHandler, METH_VARARGS, NULL},
-    {(char *) "virGetLastError", libvirt_virGetLastError, METH_VARARGS, NULL},
-    {(char *) "virConnGetLastError", libvirt_virConnGetLastError, METH_VARARGS, NULL},
-    {(char *) "virConnectListNetworks", libvirt_virConnectListNetworks, METH_VARARGS, NULL},
-    {(char *) "virConnectListDefinedNetworks", libvirt_virConnectListDefinedNetworks, METH_VARARGS, NULL},
-    {(char *) "virConnectListAllNetworks", libvirt_virConnectListAllNetworks, METH_VARARGS, NULL},
-    {(char *) "virNetworkGetUUID", libvirt_virNetworkGetUUID, METH_VARARGS, NULL},
-    {(char *) "virNetworkGetUUIDString", libvirt_virNetworkGetUUIDString, METH_VARARGS, NULL},
-    {(char *) "virNetworkLookupByUUID", libvirt_virNetworkLookupByUUID, METH_VARARGS, NULL},
-    {(char *) "virDomainGetAutostart", libvirt_virDomainGetAutostart, METH_VARARGS, NULL},
-    {(char *) "virNetworkGetAutostart", libvirt_virNetworkGetAutostart, METH_VARARGS, NULL},
-    {(char *) "virDomainBlockStats", libvirt_virDomainBlockStats, METH_VARARGS, NULL},
-    {(char *) "virDomainBlockStatsFlags", libvirt_virDomainBlockStatsFlags, METH_VARARGS, NULL},
-    {(char *) "virDomainGetCPUStats", libvirt_virDomainGetCPUStats, METH_VARARGS, NULL},
-    {(char *) "virDomainInterfaceStats", libvirt_virDomainInterfaceStats, METH_VARARGS, NULL},
-    {(char *) "virDomainMemoryStats", libvirt_virDomainMemoryStats, METH_VARARGS, NULL},
-    {(char *) "virNodeGetCellsFreeMemory", libvirt_virNodeGetCellsFreeMemory, METH_VARARGS, NULL},
-    {(char *) "virDomainGetSchedulerType", libvirt_virDomainGetSchedulerType, METH_VARARGS, NULL},
-    {(char *) "virDomainGetSchedulerParameters", libvirt_virDomainGetSchedulerParameters, METH_VARARGS, NULL},
-    {(char *) "virDomainGetSchedulerParametersFlags", libvirt_virDomainGetSchedulerParametersFlags, METH_VARARGS, NULL},
-    {(char *) "virDomainSetSchedulerParameters", libvirt_virDomainSetSchedulerParameters, METH_VARARGS, NULL},
-    {(char *) "virDomainSetSchedulerParametersFlags", libvirt_virDomainSetSchedulerParametersFlags, METH_VARARGS, NULL},
-    {(char *) "virDomainSetBlkioParameters", libvirt_virDomainSetBlkioParameters, METH_VARARGS, NULL},
-    {(char *) "virDomainGetBlkioParameters", libvirt_virDomainGetBlkioParameters, METH_VARARGS, NULL},
-    {(char *) "virDomainSetMemoryParameters", libvirt_virDomainSetMemoryParameters, METH_VARARGS, NULL},
-    {(char *) "virDomainGetMemoryParameters", libvirt_virDomainGetMemoryParameters, METH_VARARGS, NULL},
-    {(char *) "virDomainSetNumaParameters", libvirt_virDomainSetNumaParameters, METH_VARARGS, NULL},
-    {(char *) "virDomainGetNumaParameters", libvirt_virDomainGetNumaParameters, METH_VARARGS, NULL},
-    {(char *) "virDomainSetInterfaceParameters", libvirt_virDomainSetInterfaceParameters, METH_VARARGS, NULL},
-    {(char *) "virDomainGetInterfaceParameters", libvirt_virDomainGetInterfaceParameters, METH_VARARGS, NULL},
-    {(char *) "virDomainGetVcpus", libvirt_virDomainGetVcpus, METH_VARARGS, NULL},
-    {(char *) "virDomainPinVcpu", libvirt_virDomainPinVcpu, METH_VARARGS, NULL},
-    {(char *) "virDomainPinVcpuFlags", libvirt_virDomainPinVcpuFlags, METH_VARARGS, NULL},
-    {(char *) "virDomainGetVcpuPinInfo", libvirt_virDomainGetVcpuPinInfo, METH_VARARGS, NULL},
-    {(char *) "virDomainGetEmulatorPinInfo", libvirt_virDomainGetEmulatorPinInfo, METH_VARARGS, NULL},
-    {(char *) "virDomainPinEmulator", libvirt_virDomainPinEmulator, METH_VARARGS, NULL},
-    {(char *) "virConnectListStoragePools", libvirt_virConnectListStoragePools, METH_VARARGS, NULL},
-    {(char *) "virConnectListDefinedStoragePools", libvirt_virConnectListDefinedStoragePools, METH_VARARGS, NULL},
-    {(char *) "virConnectListAllStoragePools", libvirt_virConnectListAllStoragePools, METH_VARARGS, NULL},
-    {(char *) "virStoragePoolGetAutostart", libvirt_virStoragePoolGetAutostart, METH_VARARGS, NULL},
-    {(char *) "virStoragePoolListVolumes", libvirt_virStoragePoolListVolumes, METH_VARARGS, NULL},
-    {(char *) "virStoragePoolListAllVolumes", libvirt_virStoragePoolListAllVolumes, METH_VARARGS, NULL},
-    {(char *) "virStoragePoolGetInfo", libvirt_virStoragePoolGetInfo, METH_VARARGS, NULL},
-    {(char *) "virStorageVolGetInfo", libvirt_virStorageVolGetInfo, METH_VARARGS, NULL},
-    {(char *) "virStoragePoolGetUUID", libvirt_virStoragePoolGetUUID, METH_VARARGS, NULL},
-    {(char *) "virStoragePoolGetUUIDString", libvirt_virStoragePoolGetUUIDString, METH_VARARGS, NULL},
-    {(char *) "virStoragePoolLookupByUUID", libvirt_virStoragePoolLookupByUUID, METH_VARARGS, NULL},
-    {(char *) "virEventRegisterImpl", libvirt_virEventRegisterImpl, METH_VARARGS, NULL},
-    {(char *) "virEventAddHandle", libvirt_virEventAddHandle, METH_VARARGS, NULL},
-    {(char *) "virEventAddTimeout", libvirt_virEventAddTimeout, METH_VARARGS, NULL},
-    {(char *) "virEventInvokeHandleCallback", libvirt_virEventInvokeHandleCallback, METH_VARARGS, NULL},
-    {(char *) "virEventInvokeTimeoutCallback", libvirt_virEventInvokeTimeoutCallback, METH_VARARGS, NULL},
-    {(char *) "virNodeListDevices", libvirt_virNodeListDevices, METH_VARARGS, NULL},
-    {(char *) "virConnectListAllNodeDevices", libvirt_virConnectListAllNodeDevices, METH_VARARGS, NULL},
-    {(char *) "virNodeDeviceListCaps", libvirt_virNodeDeviceListCaps, METH_VARARGS, NULL},
-    {(char *) "virSecretGetUUID", libvirt_virSecretGetUUID, METH_VARARGS, NULL},
-    {(char *) "virSecretGetUUIDString", libvirt_virSecretGetUUIDString, METH_VARARGS, NULL},
-    {(char *) "virSecretLookupByUUID", libvirt_virSecretLookupByUUID, METH_VARARGS, NULL},
-    {(char *) "virConnectListSecrets", libvirt_virConnectListSecrets, METH_VARARGS, NULL},
-    {(char *) "virConnectListAllSecrets", libvirt_virConnectListAllSecrets, METH_VARARGS, NULL},
-    {(char *) "virSecretGetValue", libvirt_virSecretGetValue, METH_VARARGS, NULL},
-    {(char *) "virSecretSetValue", libvirt_virSecretSetValue, METH_VARARGS, NULL},
-    {(char *) "virNWFilterGetUUID", libvirt_virNWFilterGetUUID, METH_VARARGS, NULL},
-    {(char *) "virNWFilterGetUUIDString", libvirt_virNWFilterGetUUIDString, METH_VARARGS, NULL},
-    {(char *) "virNWFilterLookupByUUID", libvirt_virNWFilterLookupByUUID, METH_VARARGS, NULL},
-    {(char *) "virConnectListNWFilters", libvirt_virConnectListNWFilters, METH_VARARGS, NULL},
-    {(char *) "virConnectListAllNWFilters", libvirt_virConnectListAllNWFilters, METH_VARARGS, NULL},
-    {(char *) "virConnectListInterfaces", libvirt_virConnectListInterfaces, METH_VARARGS, NULL},
-    {(char *) "virConnectListDefinedInterfaces", libvirt_virConnectListDefinedInterfaces, METH_VARARGS, NULL},
-    {(char *) "virConnectListAllInterfaces", libvirt_virConnectListAllInterfaces, METH_VARARGS, NULL},
-    {(char *) "virConnectBaselineCPU", libvirt_virConnectBaselineCPU, METH_VARARGS, NULL},
-    {(char *) "virDomainGetJobInfo", libvirt_virDomainGetJobInfo, METH_VARARGS, NULL},
-    {(char *) "virDomainGetJobStats", libvirt_virDomainGetJobStats, METH_VARARGS, NULL},
-    {(char *) "virDomainSnapshotListNames", libvirt_virDomainSnapshotListNames, METH_VARARGS, NULL},
-    {(char *) "virDomainListAllSnapshots", libvirt_virDomainListAllSnapshots, METH_VARARGS, NULL},
-    {(char *) "virDomainSnapshotListChildrenNames", libvirt_virDomainSnapshotListChildrenNames, METH_VARARGS, NULL},
-    {(char *) "virDomainSnapshotListAllChildren", libvirt_virDomainSnapshotListAllChildren, METH_VARARGS, NULL},
-    {(char *) "virDomainRevertToSnapshot", libvirt_virDomainRevertToSnapshot, METH_VARARGS, NULL},
-    {(char *) "virDomainGetBlockJobInfo", libvirt_virDomainGetBlockJobInfo, METH_VARARGS, NULL},
-    {(char *) "virDomainSetBlockIoTune", libvirt_virDomainSetBlockIoTune, METH_VARARGS, NULL},
-    {(char *) "virDomainGetBlockIoTune", libvirt_virDomainGetBlockIoTune, METH_VARARGS, NULL},
-    {(char *) "virDomainSendKey", libvirt_virDomainSendKey, METH_VARARGS, NULL},
-    {(char *) "virDomainMigrateGetCompressionCache", libvirt_virDomainMigrateGetCompressionCache, METH_VARARGS, NULL},
-    {(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed, METH_VARARGS, NULL},
-    {(char *) "virDomainMigrate3", libvirt_virDomainMigrate3, METH_VARARGS, NULL},
-    {(char *) "virDomainMigrateToURI3", libvirt_virDomainMigrateToURI3, METH_VARARGS, NULL},
-    {(char *) "virDomainBlockPeek", libvirt_virDomainBlockPeek, METH_VARARGS, NULL},
-    {(char *) "virDomainMemoryPeek", libvirt_virDomainMemoryPeek, METH_VARARGS, NULL},
-    {(char *) "virDomainGetDiskErrors", libvirt_virDomainGetDiskErrors, METH_VARARGS, NULL},
-    {(char *) "virNodeGetMemoryParameters", libvirt_virNodeGetMemoryParameters, METH_VARARGS, NULL},
-    {(char *) "virNodeSetMemoryParameters", libvirt_virNodeSetMemoryParameters, METH_VARARGS, NULL},
-    {(char *) "virNodeGetCPUMap", libvirt_virNodeGetCPUMap, METH_VARARGS, NULL},
-    {(char *) "virDomainCreateXMLWithFiles", libvirt_virDomainCreateXMLWithFiles, METH_VARARGS, NULL},
-    {(char *) "virDomainCreateWithFiles", libvirt_virDomainCreateWithFiles, METH_VARARGS, NULL},
-    {NULL, NULL, 0, NULL}
-};
-
-void
-#ifndef __CYGWIN__
-initlibvirtmod
-#else
-initcygvirtmod
-#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"
-#else
-                  "cygvirtmod"
-#endif
-                  , libvirtMethods);
-
-    initialized = 1;
-}
diff --git a/python/libvirt-override.py b/python/libvirt-override.py
deleted file mode 100644
index ccfec48..0000000
--- a/python/libvirt-override.py
+++ /dev/null
@@ -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
diff --git a/python/libvirt-qemu-override-api.xml b/python/libvirt-qemu-override-api.xml
deleted file mode 100644
index ca0dae9..0000000
--- a/python/libvirt-qemu-override-api.xml
+++ /dev/null
@@ -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>
diff --git a/python/libvirt-qemu-override.c b/python/libvirt-qemu-override.c
deleted file mode 100644
index 6249031..0000000
--- a/python/libvirt-qemu-override.c
+++ /dev/null
@@ -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 at 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;
-}
diff --git a/python/sanitytest.py b/python/sanitytest.py
deleted file mode 100644
index ace6792..0000000
--- a/python/sanitytest.py
+++ /dev/null
@@ -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)
diff --git a/python/typewrappers.c b/python/typewrappers.c
deleted file mode 100644
index 9ba8790..0000000
--- a/python/typewrappers.c
+++ /dev/null
@@ -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 at 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;
-}
diff --git a/python/typewrappers.h b/python/typewrappers.h
deleted file mode 100644
index d871d3f..0000000
--- a/python/typewrappers.h
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * libvirt_wrap.h: type wrappers for libvir python bindings
- *
- * Copyright (C) 2005, 2011-2012 Red Hat, Inc.
- *
- * Daniel Veillard <veillard at 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
diff --git a/run.in b/run.in
index 5d4a04c..2211f24 100644
--- a/run.in
+++ b/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)"
-- 
1.8.3.1




More information about the libvir-list mailing list