>From bd2f58d09e70ed6f537f69e4aa85405c228958b4 Mon Sep 17 00:00:00 2001
From: Arnaud <arnaud.champion@devatom.fr>
Date: Wed, 20 Oct 2010 13:35:43 +0200
Subject: [PATCH] Rename functions by creating more classes for each type of function.
 Use DllMap in Mono to ensure correct binary library using ofr each os.

---
 .gitignore                                         |    2 +
 Libvirt.cs                                         | 2161 --------------------
 LibvirtError.cs                                    |  810 ++------
 LibvirtTypes.cs                                    |  546 +++++-
 MarshalHelper.cs                                   |   36 +
 NativeFunctions.cs                                 |   23 +
 StringWithoutNativeCleanUpMarshaler.cs             |   10 +-
 .../MonoDevelop/virConnectOpenAuth/MainWindow.cs   |   16 +-
 examples/VisualStudio/virConnectOpenAuth/Form1.cs  |   16 +-
 projects/MonoDevelop/LibvirtBindings.csproj        |   47 +-
 projects/MonoDevelop/LibvirtBindings.dll.config    |   11 +
 projects/VisualStudio/LibvirtBindings.csproj       |   43 +-
 virConnect.cs                                      |  411 ++++
 virDomain.cs                                       |  608 ++++++
 virEvent.cs                                        |   32 +
 virInterface.cs                                    |   39 +
 virLibrary.cs                                      |   44 +
 virNetwork.cs                                      |  179 ++
 virNode.cs                                         |  163 ++
 virSecret.cs                                       |   43 +
 virStoragePool.cs                                  |  436 ++++
 virStorageVol.cs                                   |  235 +++
 virStream.cs                                       |   43 +
 23 files changed, 3086 insertions(+), 2868 deletions(-)
 delete mode 100644 Libvirt.cs
 rewrite LibvirtError.cs (79%)
 create mode 100644 MarshalHelper.cs
 create mode 100644 NativeFunctions.cs
 create mode 100644 projects/MonoDevelop/LibvirtBindings.dll.config
 create mode 100644 virConnect.cs
 create mode 100644 virDomain.cs
 create mode 100644 virEvent.cs
 create mode 100644 virInterface.cs
 create mode 100644 virLibrary.cs
 create mode 100644 virNetwork.cs
 create mode 100644 virNode.cs
 create mode 100644 virSecret.cs
 create mode 100644 virStoragePool.cs
 create mode 100644 virStorageVol.cs
 create mode 100644 virStream.cs

diff --git a/.gitignore b/.gitignore
index 96a9b41..e94b014 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
 
+*.userprefs
+*.user
 _ReSharper*
 *.obj
 *.pdb
diff --git a/Libvirt.cs b/Libvirt.cs
deleted file mode 100644
index dcba9b3..0000000
--- a/Libvirt.cs
+++ /dev/null
@@ -1,2161 +0,0 @@
-﻿/*
- * Copyright (C)
- *   Arnaud Champion <arnaud.champion@devatom.fr>
- *   Jaromír Červenka <cervajz@cervajz.com>
- *
- * See COPYING.LIB for the License of this software
- */
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace LibvirtBindings
-{
-    /// <summary>
-    /// Libvirt Binding class
-    /// </summary>
-    public class libVirt
-    {
-        private const int MaxStringLength = 1024;
-#if WINDOWS
-        private const string LibvirtDllImportName = "libvirt-0.dll";
-        private const string StrDupDllImportName = "msvcrt.dll";
-        private const string StrDupEntryPoint = "_strdup";
-#else
-        private const string LibvirtDllImportName = "libvirt.so.0";
-        private const string StrDupDllImportName = "libc.so.6";
-        private const string StrDupEntryPoint = "strdup";
-#endif
-        [DllImport(StrDupDllImportName, EntryPoint = StrDupEntryPoint, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr StrDup(IntPtr strSource);
-
-
-        #region Connect
-        /// <summary>
-        /// This function closes the connection to the Hypervisor. This should not be called if further interaction with the Hypervisor are needed especially if there is running domain which need further monitoring by the application.
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <returns>0 in case of success or -1 in case of error.</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virConnectClose(IntPtr conn);
-        /// <summary>
-        /// Provides capabilities of the hypervisor / driver.
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <returns>NULL in case of error, or an XML string defining the capabilities. The client must free the returned string after use.</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
-        public static extern string virConnectGetCapabilities(IntPtr conn);
-        /// <summary>
-        /// This returns the system hostname on which the hypervisor is running (the result of the gethostname system call). If we are connected to a remote system, then this returns the hostname of the remote system.
-        /// </summary>
-        /// <param name="conn">pointer to a hypervisor connection</param>
-        /// <returns>the hostname which must be freed by the caller, or NULL if there was an error.</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
-        public static extern string virConnectGetHostname(IntPtr conn);
-        /// <summary>
-        /// Provides @libVer, which is the version of libvirt used by the daemon running on the @conn host
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="libVer">returns the libvirt library version used on the connection (OUT)</param>
-        /// <returns>-1 in case of failure, 0 otherwise, and values for @libVer have the format major * 1,000,000 + minor * 1,000 + release.</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virConnectGetLibVersion(IntPtr conn, ref ulong libVer);
-        /// <summary>
-        /// Provides the maximum number of virtual CPUs supported for a guest VM of a specific type. The 'type' parameter here corresponds to the 'type' attribute in the domain element of the XML.
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="type">value of the 'type' attribute in the domain element</param>
-        /// <returns>the maximum of virtual CPU or -1 in case of error.</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virConnectGetMaxVcpus(IntPtr conn, string type);
-        /// <summary>
-        /// Get the name of the Hypervisor software used.
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <returns>NULL in case of error, a static zero terminated string otherwise. See also: http://www.redhat.com/archives/libvir-list/2007-February/msg00096.html</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
-        public static extern string virConnectGetType(IntPtr conn);
-        /// <summary>
-        /// This returns the Uri (name) of the hypervisor connection. Normally this is the same as or similar to the string passed to the virConnectOpen/virConnectOpenReadOnly call, but the driver may make the Uri canonical. If name == NULL was passed to virConnectOpen, then the driver will return a non-NULL Uri which can be used to connect to the same hypervisor later.
-        /// </summary>
-        /// <param name="conn">pointer to a hypervisor connection</param>
-        /// <returns>the Uri string which must be freed by the caller, or NULL if there was an error.</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
-        public static extern string virConnectGetURI(IntPtr conn);
-        /// <summary>
-        /// Get the version level of the Hypervisor running. This may work only with hypervisor call, i.e. with privileged access to the hypervisor, not with a Read-Only connection.
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="hvVer">return value for the version of the running hypervisor (OUT)</param>
-        /// <returns>-1 in case of error, 0 otherwise. if the version can't be extracted by lack of capacities returns 0 and @hvVer is 0, otherwise @hvVer value is major * 1,000,000 + minor * 1,000 + release</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virConnectGetVersion(IntPtr conn, ref ulong hvVer);
-        /// <summary>
-        /// Determine if the connection to the hypervisor is encrypted
-        /// </summary>
-        /// <param name="conn">pointer to the connection object</param>
-        /// <returns>1 if encrypted, 0 if not encrypted, -1 on error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virConnectIsEncrypted(IntPtr conn);
-        /// <summary>
-        /// Determine if the connection to the hypervisor is secure A connection will be classed as secure if it is either encrypted, or running over a channel which is not exposed to eavesdropping (eg a UNIX domain socket, or pipe)
-        /// </summary>
-        /// <param name="conn">pointer to the connection object</param>
-        /// <returns>1 if secure, 0 if secure, -1 on error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virConnectIsSecure(IntPtr conn);
-        /// <summary>
-        /// list the defined but inactive domains, stores the pointers to the names in @names
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="names">pointer to an array to store the names</param>
-        /// <param name="maxnames">size of the array</param>
-        /// <returns>the number of names provided in the array or -1 in case of error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        private static extern int virConnectListDefinedDomains(IntPtr conn, IntPtr names, int maxnames);
-        /// <summary>
-        /// list the defined but inactive domains, stores the pointers to the names in @names
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="names">pointer to an array to store the names</param>
-        /// <param name="maxnames">size of the array</param>
-        /// <returns>the number of names provided in the array or -1 in case of error</returns>
-        public static int virConnectListDefinedDomains(IntPtr conn, ref string[] names, int maxnames)
-        {
-            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
-            int count = virConnectListDefinedDomains(conn, namesPtr, maxnames);
-            if (count > 0)
-                names = ptrToStringArray(namesPtr, count);
-            Marshal.FreeHGlobal(namesPtr);
-            return count;
-        }
-        /// <summary>
-        /// Collect the list of defined (inactive) physical host interfaces, and store their names in @names.
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="names">array to collect the list of names of interfaces</param>
-        /// <param name="maxnames">size of @names</param>
-        /// <returns>the number of interfaces found or -1 in case of error </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        private static extern int virConnectListDefinedInterfaces(IntPtr conn, IntPtr names, int maxnames);
-        ///<summary>
-        /// Collect the list of defined (inactive) physical host interfaces, and store their names in @names.
-        ///</summary>
-        ///<param name="conn">pointer to the hypervisor connection</param>
-        ///<param name="names">array to collect the list of names of interfaces</param>
-        ///<param name="maxnames">size of @names</param>
-        ///<returns>the number of interfaces found or -1 in case of error </returns>
-        public static int virConnectListDefinedInterfaces(IntPtr conn, ref string[] names, int maxnames)
-        {
-            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
-            int count = virConnectListDefinedInterfaces(conn, namesPtr, maxnames);
-            if (count > 0)
-                names = ptrToStringArray(namesPtr, count);
-            Marshal.FreeHGlobal(namesPtr);
-            return count;
-        }
-        /// <summary>
-        /// list the inactive networks, stores the pointers to the names in @names
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="names">pointer to an array to store the names</param>
-        /// <param name="maxnames">size of the array</param>
-        /// <returns>the number of names provided in the array or -1 in case of error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        private static extern int virConnectListDefinedNetworks(IntPtr conn, IntPtr names, int maxnames);
-        /// <summary>
-        /// list the inactive networks, stores the pointers to the names in @names
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="names">pointer to an array to store the names</param>
-        /// <param name="maxnames">size of the array</param>
-        /// <returns>the number of names provided in the array or -1 in case of error</returns>
-        public static int virConnectListDefinedNetworks(IntPtr conn, ref string[] names, int maxnames)
-        {
-            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
-            int count = virConnectListDefinedNetworks(conn, namesPtr, maxnames);
-            if (count > 0)
-                names = ptrToStringArray(namesPtr, count);
-            Marshal.FreeHGlobal(namesPtr);
-            return count;
-        }
-        /// <summary>
-        /// Provides the list of names of inactive storage pools upto maxnames. If there are more than maxnames, the remaining names will be silently ignored.
-        /// </summary>
-        /// <param name="conn">pointer to hypervisor connection</param>
-        /// <param name="names">array of char * to fill with pool names (allocated by caller)</param>
-        /// <param name="maxnames">size of the names array</param>
-        /// <returns>0 on success, -1 on error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        private static extern int virConnectListDefinedStoragePools(IntPtr conn, IntPtr names, int maxnames);
-        /// <summary>
-        /// Provides the list of names of inactive storage pools upto maxnames. If there are more than maxnames, the remaining names will be silently ignored.
-        /// </summary>
-        /// <param name="conn">pointer to hypervisor connection</param>
-        /// <param name="names">array of char * to fill with pool names (allocated by caller)</param>
-        /// <param name="maxnames">size of the names array</param>
-        /// <returns>0 on success, -1 on error</returns>
-        public static int virConnectListDefinedStoragePools(IntPtr conn, ref string[] names, int maxnames)
-        {
-            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
-            int count = virConnectListDefinedStoragePools(conn, namesPtr, maxnames);
-            if (count > 0)
-                names = ptrToStringArray(namesPtr, count);
-            Marshal.FreeHGlobal(namesPtr);
-            return count;
-        }
-        /// <summary>
-        /// Collect the list of active domains, and store their ID in @maxids
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="ids">array to collect the list of IDs of active domains</param>
-        /// <param name="maxids">size of @ids</param>
-        /// <returns>the number of domain found or -1 in case of error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virConnectListDomains(IntPtr conn, int[] ids, int maxids);
-        /// <summary>
-        /// Collect the list of active physical host interfaces, and store their names in @names
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="names">array to collect the list of names of interfaces</param>
-        /// <param name="maxnames">size of @names</param>
-        /// <returns>the number of interfaces found or -1 in case of error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        private static extern int virConnectListInterfaces(IntPtr conn, IntPtr names, int maxnames);
-        /// <summary>
-        /// Collect the list of active physical host interfaces, and store their names in @names
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="names">array to collect the list of names of interfaces</param>
-        /// <param name="maxnames">size of @names</param>
-        /// <returns>the number of interfaces found or -1 in case of error</returns>
-        public static int virConnectListInterfaces(IntPtr conn, ref string[] names, int maxnames)
-        {
-            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
-            int count = virConnectListInterfaces(conn, namesPtr, maxnames);
-            if (count > 0)
-                names = ptrToStringArray(namesPtr, count);
-            Marshal.FreeHGlobal(namesPtr);
-            return count;
-        }
-        /// <summary>
-        /// Collect the list of active networks, and store their names in @names
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="names">array to collect the list of names of active networks</param>
-        /// <param name="maxnames">size of @names</param>
-        /// <returns>the number of networks found or -1 in case of error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        private static extern int virConnectListNetworks(IntPtr conn, IntPtr names, int maxnames);
-        /// <summary>
-        /// Collect the list of active networks, and store their names in @names
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="names">array to collect the list of names of active networks</param>
-        /// <param name="maxnames">size of @names</param>
-        /// <returns>the number of networks found or -1 in case of error</returns>
-        public static int virConnectListNetworks(IntPtr conn, ref string[] names, int maxnames)
-        {
-            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
-            int count = virConnectListNetworks(conn, namesPtr, maxnames);
-            if (count > 0)
-                names = ptrToStringArray(namesPtr, count);
-            Marshal.FreeHGlobal(namesPtr);
-            return count;
-        }
-        /// <summary>
-        /// List UUIDs of defined secrets, store pointers to names in uuids.
-        /// </summary>
-        /// <param name="conn">virConnect connection</param>
-        /// <param name="uuids">Pointer to an array to store the UUIDs</param>
-        /// <param name="maxuuids">size of the array.</param>
-        /// <returns>the number of UUIDs provided in the array, or -1 on failure.</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        private static extern int virConnectListSecrets(IntPtr conn, IntPtr uuids, int maxuuids);
-        /// <summary>
-        /// List UUIDs of defined secrets, store pointers to names in uuids.
-        /// </summary>
-        /// <param name="conn">virConnect connection</param>
-        /// <param name="uuids">Pointer to an array to store the UUIDs</param>
-        /// <param name="maxuuids">size of the array.</param>
-        /// <returns>the number of UUIDs provided in the array, or -1 on failure.</returns>
-        public static int virConnectListSecrets(IntPtr conn, ref string[] uuids, int maxuuids)
-        {
-            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
-            int count = virConnectListSecrets(conn, namesPtr, maxuuids);
-            if (count > 0)
-                uuids = ptrToStringArray(namesPtr, count);
-            Marshal.FreeHGlobal(namesPtr);
-            return count;
-        }
-        /// <summary>
-        /// Provides the list of names of active storage pools upto maxnames. If there are more than maxnames, the remaining names will be silently ignored.
-        /// </summary>
-        /// <param name="conn">pointer to hypervisor connection</param>
-        /// <param name="names">array of char * to fill with pool names (allocated by caller)</param>
-        /// <param name="maxnames">size of the names array</param>
-        /// <returns>0 on success, -1 on error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        private static extern int virConnectListStoragePools(IntPtr conn, IntPtr names, int maxnames);
-        /// <summary>
-        /// Provides the list of names of active storage pools upto maxnames. If there are more than maxnames, the remaining names will be silently ignored.
-        /// </summary>
-        /// <param name="conn">pointer to hypervisor connection</param>
-        /// <param name="names">array of char * to fill with pool names (allocated by caller)</param>
-        /// <param name="maxnames">size of the names array</param>
-        /// <returns>0 on success, -1 on error</returns>
-        public static int virConnectListStoragePools(IntPtr conn, ref string[] names, int maxnames)
-        {
-            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
-            int count = virConnectListStoragePools(conn, namesPtr, maxnames);
-            if (count > 0)
-                names = ptrToStringArray(namesPtr, count);
-            Marshal.FreeHGlobal(namesPtr);
-            return count;
-        }
-        /// <summary>
-        /// Provides the number of defined but inactive domains.
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <returns>the number of domain found or -1 in case of error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virConnectNumOfDefinedDomains(IntPtr conn);
-        /// <summary>
-        /// Provides the number of defined (inactive) interfaces on the physical host.
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <returns>the number of defined interface found or -1 in case of error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virConnectNumOfDefinedInterfaces(IntPtr conn);
-        /// <summary>
-        /// Provides the number of inactive networks.
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <returns>the number of networks found or -1 in case of error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virConnectNumOfDefinedNetworks(IntPtr conn);
-        /// <summary>
-        /// Provides the number of inactive storage pools
-        /// </summary>
-        /// <param name="conn">pointer to hypervisor connection</param>
-        /// <returns>the number of pools found, or -1 on error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virConnectNumOfDefinedStoragePools(IntPtr conn);
-        /// <summary>
-        /// Provides the number of active domains.
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <returns>the number of domain found or -1 in case of error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virConnectNumOfDomains(IntPtr conn);
-        /// <summary>
-        /// Provides the number of active interfaces on the physical host.
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <returns>the number of active interfaces found or -1 in case of error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virConnectNumOfInterfaces(IntPtr conn);
-        /// <summary>
-        /// Provides the number of active networks.
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <returns>the number of network found or -1 in case of error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virConnectNumOfNetworks(IntPtr conn);
-        /// <summary>
-        /// Fetch number of currently defined secrets.
-        /// </summary>
-        /// <param name="conn">virConnect connection</param>
-        /// <returns>the number currently defined secrets.</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virConnectNumOfSecrets(IntPtr conn);
-        /// <summary>
-        /// Provides the number of active storage pools
-        /// </summary>
-        /// <param name="conn">pointer to hypervisor connection</param>
-        /// <returns>the number of pools found, or -1 on error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virConnectNumOfStoragePools(IntPtr conn);
-        /// <summary>
-        /// This function should be called first to get a connection to the Hypervisor and xen store
-        /// </summary>
-        /// <param name="name">Uri of the hypervisor</param>
-        /// <returns>pointer to the connection</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virConnectOpen(string name);
-
-        ///<summary>
-        /// This function should be called first to get a connection to the Hypervisor. If necessary, authentication will be performed fetching credentials via the callback See virConnectOpen for notes about environment variables which can have an effect on opening drivers
-        ///</summary>
-        ///<param name="name">URI of the hypervisor</param>
-        ///<param name="auth">Authenticate callback parameters</param>
-        ///<param name="flags">Open flags</param>
-        ///<returns>a pointer to the hypervisor connection or NULL in case of error URIs are documented at http://libvirt.org/uri.html </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virConnectOpenAuth(string name, ref virConnectAuth auth, int flags);
-
-        /// <summary>
-        /// This function should be called first to get a restricted connection to the library functionalities. The set of APIs usable are then restricted on the available methods to control the domains. See virConnectOpen for notes about environment variables which can have an effect on opening drivers
-        /// </summary>
-        /// <param name="name">Uri of the hypervisor</param>
-        /// <returns>a pointer to the hypervisor connection or NULL in case of error URIs are documented at http://libvirt.org/uri.html </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virConnectOpenReadOnly(string name);
-        /// <summary>
-        /// Increment the reference count on the connection. For each additional call to this method, there shall be a corresponding call to virConnectClose to release the reference count, once the caller no longer needs the reference to this object. This method is typically useful for applications where multiple threads are using a connection, and it is required that the connection remain open until all threads have finished using it. ie, each new thread using a connection would increment the reference count.
-        /// </summary>
-        /// <param name="conn">the connection to hold a reference on</param>
-        /// <returns>0 in case of success, -1 in case of failure</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virConnectRef(IntPtr conn);
-        #endregion
-
-        #region Domain
-        /// <summary>
-        /// Create a virtual device attachment to backend. This function, having hotplug semantics, is only allowed on an active domain.
-        /// </summary>
-        /// <param name="domain">pointer to domain object</param>
-        /// <param name="xml">pointer to XML description of one device</param>
-        /// <returns>0 in case of success, -1 in case of failure.</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainAttachDevice(IntPtr domain, string xml);
-        /// <summary>
-        /// Attach a virtual device to a domain, using the flags parameter to control how the device is attached. VIR_DOMAIN_DEVICE_MODIFY_CURRENT specifies that the device allocation is made based on current domain state. VIR_DOMAIN_DEVICE_MODIFY_LIVE specifies that the device shall be allocated to the active domain instance only and is not added to the persisted domain configuration. VIR_DOMAIN_DEVICE_MODIFY_CONFIG specifies that the device shall be allocated to the persisted domain configuration only. Note that the target hypervisor must return an error if unable to satisfy flags. E.g. the hypervisor driver will return failure if LIVE is specified but it only supports modifying the persisted device allocation.
-        /// </summary>
-        /// <param name="domain">pointer to domain object</param>
-        /// <param name="xml">pointer to XML description of one device</param>
-        /// <param name="flags">an OR'ed set of virDomainDeviceModifyFlags</param>
-        /// <returns>0 in case of success, -1 in case of failure.</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainAttachDeviceFlags(IntPtr domain, string xml, uint flags);
-
-        // TODO virDomainBlockPeek
-
-        /// <summary>
-        /// This function returns block device (disk) stats for block devices attached to the domain. The path parameter is the name of the block device. Get this by calling virDomainGetXMLDesc and finding the target dev='...' attribute within //domain/devices/disk. (For example, "xvda"). Domains may have more than one block device. To get stats for each you should make multiple calls to this function. Individual fields within the stats structure may be returned as -1, which indicates that the hypervisor does not support that particular statistic.
-        /// </summary>
-        /// <param name="dom">pointer to the domain object</param>
-        /// <param name="path">path to the block device</param>
-        /// <param name="stats">block device stats (returned)</param>
-        /// <param name="size">size of stats structure</param>
-        /// <returns>0 in case of success or -1 in case of failure.</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainBlockStats(IntPtr dom, string path, virDomainBlockStatsStruct stats, int size);
-        /// <summary>
-        /// This method will dump the core of a domain on a given file for analysis. Note that for remote Xen Daemon the file path will be interpreted in the remote host.
-        /// </summary>
-        /// <param name="domain">a domain object</param>
-        /// <param name="to">path for the core file</param>
-        /// <param name="flags">extra flags, currently unused</param>
-        /// <returns>0 in case of success and -1 in case of failure.</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainCoreDump(IntPtr domain, string to, int flags);
-        /// <summary>
-        /// Launch a defined domain. If the call succeed the domain moves from the defined to the running domains pools.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/> pointer to a defined domain.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success, -1 in case of error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainCreate(IntPtr domain);
-        /// <summary>
-        /// Launch a new guest domain, based on an XML description similar to the one returned by virDomainGetXMLDesc().
-        /// This function may requires 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).
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/> pointer to the hypervisor connection.
-        /// </param>
-        /// <param name="xmlDesc">
-        /// A string containing an XML description of the domain.
-        /// </param>
-        /// <param name="flags">
-        /// Callers should always pass 0.
-        /// </param>
-        /// <returns>
-        /// A new domain object or NULL in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virDomainCreateXML(IntPtr conn, string xmlDesc, uint flags);
-        /// <summary>
-        /// Define a domain, but does not start it. This definition is persistent, until explicitly undefined with virDomainUndefine(). 
-        /// A previous definition for this domain would be overriden if it already exists.
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
-        /// </param>
-        /// <param name="xml">
-        /// The XML description for the domain, preferably in UTF-8.
-        /// </param>
-        /// <returns>
-        /// NULL in case of error, a pointer to the domain otherwise.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virDomainDefineXML(IntPtr conn, string xml);
-        /// <summary>
-        /// Destroy the domain object. The running instance is shutdown if not down already 
-        /// and all resources used by it are given back to the hypervisor. 
-        /// This does not free the associated virDomainPtr object. This function may require privileged access
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>domain object.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success and -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainDestroy(IntPtr domain);
-        /// <summary>
-        /// Destroy a virtual device attachment to backend.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>pointer to domain object.
-        /// </param>
-        /// <param name="xml">
-        /// Pointer to XML description of one device.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success, -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainDetachDevice(IntPtr domain, string xml);
-        /// <summary>
-        /// Detach a virtual device from a domain, using the flags parameter to control how the device is detached. VIR_DOMAIN_DEVICE_MODIFY_CURRENT specifies that the device allocation is removed based on current domain state. VIR_DOMAIN_DEVICE_MODIFY_LIVE specifies that the device shall be deallocated from the active domain instance only and is not from the persisted domain configuration. VIR_DOMAIN_DEVICE_MODIFY_CONFIG specifies that the device shall be deallocated from the persisted domain configuration only. Note that the target hypervisor must return an error if unable to satisfy flags. E.g. the hypervisor driver will return failure if LIVE is specified but it only supports removing the persisted device allocation.
-        /// </summary>
-        /// <param name="domain">pointer to domain object</param>
-        /// <param name="xml">pointer to XML description of one device</param>
-        /// <param name="flags">an OR'ed set of virDomainDeviceModifyFlags</param>
-        /// <returns>0 in case of success, -1 in case of failure.</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainDetachDeviceFlags(IntPtr domain, string xml, uint flags);
-        /// <summary>
-        /// Free the domain object. The running instance is kept alive. The data structure is freed and should not be used thereafter.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>domain object.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success and -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainFree(IntPtr domain);
-        /// <summary>
-        /// Provides a boolean value indicating whether the domain configured to be automatically started when the host machine boots.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>domain object.
-        /// </param>
-        /// <param name="autostart">
-        /// The value returned.
-        /// </param>
-        /// <returns>
-        /// -1 in case of error, 0 in case of success.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainGetAutostart(IntPtr domain, out int autostart);
-        /// <summary>
-        /// Provides the connection pointer associated with a domain. 
-        /// The reference counter on the connection is not increased by this call. 
-        /// WARNING: When writing libvirt bindings in other languages, do not use this function. 
-        /// Instead, store the connection and the domain object together.
-        /// </summary>
-        /// <param name="dom">
-        /// A <see cref="IntPtr"/>pointer to a domain.
-        /// </param>
-        /// <returns>
-        /// The <see cref="IntPtr"/>or NULL in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virDomainGetConnect(IntPtr dom);
-        /// <summary>
-        /// Get the hypervisor ID number for the domain.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>domain object.
-        /// </param>
-        /// <returns>
-        /// The domain ID number or (unsigned int) -1 in case of error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainGetID(IntPtr domain);
-        /// <summary>
-        /// 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.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>domain object.
-        /// </param>
-        /// <param name="info">
-        /// Pointer to a virDomainInfo structure allocated by the user.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success and -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainGetInfo(IntPtr domain, [Out] virDomainInfo info);
-        /// <summary>
-        /// Retrieve the maximum amount of physical memory allocated to a domain. 
-        /// If domain is NULL, then this get the amount of memory reserved to Domain0 i.e. the domain where the application runs.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>domain object or NULL.
-        /// </param>
-        /// <returns>
-        /// the memory size in kilobytes or 0 in case of error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern ulong virDomainGetMaxMemory(IntPtr domain);
-        /// <summary>
-        /// Provides the maximum number of virtual CPUs supported for the guest VM. 
-        /// If the guest is inactive, this is basically the same as virConnectGetMaxVcpus. 
-        /// If the guest is running this will reflect the maximum number of virtual CPUs the guest was booted with.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>pointer to domain object.
-        /// </param>
-        /// <returns>
-        /// The maximum of virtual CPU or -1 in case of error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainGetMaxVcpus(IntPtr domain);
-        /// <summary>
-        /// Get the public name for that domain.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>domain object.
-        /// </param>
-        /// <returns>
-        /// Pointer to the name or NULL, the string need not be deallocated its lifetime will be the same as the domain object.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
-        public static extern string virDomainGetName(IntPtr domain);
-        /// <summary>
-        /// Get the type of domain operation system.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>domain object.
-        /// </param>
-        /// <returns>
-        /// The new string or NULL in case of error, the string must be freed by the caller.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
-        public static extern string virDomainGetOSType(IntPtr domain);
-
-        // TODO virDomainGetSchedulerParameters
-
-        // TODO virDomainGetSchedulerType
-
-        // TODO virDomainGetSecurityLabel
-
-        /// <summary>
-        /// Get the UUID for a domain.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>a domain object.
-        /// </param>
-        /// <param name="uuid">
-        /// A <see cref="System.Char"/>pointer to a VIR_UUID_BUFLEN bytes array.
-        /// </param>
-        /// <returns>
-        /// A <see cref="System.Int32"/>-1 in case of error, 0 in case of success.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainGetUUID(IntPtr domain, [Out] char[] uuid);
-        /// <summary>
-        /// Get the UUID for a domain as string. For more information about UUID see RFC4122.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>domain object.
-        /// </param>
-        /// <param name="buf">
-        /// Pointer to a VIR_UUID_STRING_BUFLEN bytes array.
-        /// </param>
-        /// <returns>
-        /// -1 in case of error, 0 in case of success.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainGetUUIDString(IntPtr domain, [Out] IntPtr buf);
-
-        // TODO virDomainGetVcpus
-
-        /// <summary>
-        /// Provide an XML description of the domain. The description may be reused later to relaunch the domain with virDomainCreateXML().
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>a domain object.
-        /// </param>
-        /// <param name="flags">
-        /// An OR'ed set of virDomainXMLFlags.
-        /// </param>
-        /// <returns>
-        /// A 0 terminated UTF-8 encoded XML instance, or NULL in case of error. the caller must free() the returned value.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
-        public static extern string virDomainGetXMLDesc(IntPtr domain, int flags);
-        /// <summary>
-        /// This function returns network interface stats for interfaces attached to the domain. 
-        /// The path parameter is the name of the network interface. Domains may have more than one network interface. 
-        /// To get stats for each you should make multiple calls to this function. 
-        /// Individual fields within the stats structure may be returned as -1, 
-        /// which indicates that the hypervisor does not support that particular statistic.
-        /// </summary>
-        /// <param name="dom">
-        /// A <see cref="IntPtr"/>pointer to the domain object.
-        /// </param>
-        /// <param name="path">
-        /// Path to the interface.
-        /// </param>
-        /// <param name="stats">
-        /// A <see cref="virDomainInterfaceStatsStruct"/>network interface stats (returned).
-        /// </param>
-        /// <param name="size">
-        /// Size of stats structure.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success or -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainInterfaceStats(IntPtr dom, string path, virDomainInterfaceStatsStruct stats, int size);
-        /// <summary>
-        /// Determine if the domain is currently running.
-        /// </summary>
-        /// <param name="dom">
-        /// A <see cref="IntPtr"/>pointer to the domain object.
-        /// </param>
-        /// <returns>
-        /// 1 if running, 0 if inactive, -1 on error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainIsActive(IntPtr dom);
-
-        /// <summary>
-        /// Determine if the domain has a persistent configuration which means it will still exist after shutting down.
-        /// </summary>
-        /// <param name="dom">
-        /// A <see cref="IntPtr"/>pointer to the domain object.
-        /// </param>
-        /// <returns>
-        /// 1 if persistent, 0 if transient, -1 on error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainIsPersistent(IntPtr dom);
-
-        /// <summary>
-        /// Try to find a domain based on the hypervisor ID number.
-        /// Note that this won't work for inactive domains which have an ID of -1, 
-        /// in that case a lookup based on the Name or UUId need to be done instead.
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
-        /// </param>
-        /// <param name="id">
-        /// The domain ID number.
-        /// </param>
-        /// <returns>
-        /// A new domain object or NULL in case of failure. If the domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virDomainLookupByID(IntPtr conn, int id);
-
-        /// <summary>
-        /// Try to lookup a domain on the given hypervisor based on its name.
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
-        /// </param>
-        /// <param name="name">
-        /// A <see cref="System.String"/>name for the domain.
-        /// </param>
-        /// <returns>
-        /// A new domain object or NULL in case of failure. If the domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virDomainLookupByName(IntPtr conn, string name);
-
-        /// <summary>
-        /// Try to lookup a domain on the given hypervisor based on its UUID.
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
-        /// </param>
-        /// <param name="uuid">
-        /// A <see cref="System.Char"/>the raw UUID for the domain.
-        /// </param>
-        /// <returns>
-        /// A new domain object or NULL in case of failure. If the domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virDomainLookupByUUID(IntPtr conn, char[] uuid);
-
-        /// <summary>
-        /// Try to lookup a domain on the given hypervisor based on its UUID.
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
-        /// </param>
-        /// <param name="uuidstr">
-        /// The string UUID for the domain.
-        /// </param>
-        /// <returns>
-        /// A new domain object or NULL in case of failure. If the domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virDomainLookupByUUIDString(IntPtr conn, string uuidstr);
-
-        // TODO virDomainMemoryPeek
-
-        // TODO virDomainMigrate
-
-        // TODO virDomainMigrateToURI
-
-        // TODO virDomainPinVcpu
-
-        // TODO virDomainMemoryStats
-
-        /// <summary>
-        /// Reboot a domain, the domain object is still usable there after but the domain OS is being stopped for a restart. 
-        /// Note that the guest OS may ignore the request.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>domain object.
-        /// </param>
-        /// <param name="flags">
-        /// Extra flags for the reboot operation, not used yet.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success and -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainReboot(IntPtr domain, uint flags);
-
-        /// <summary>
-        /// Increment the reference count on the domain. For each additional call to this method, 
-        /// there shall be a corresponding call to virDomainFree to release the reference count, 
-        /// once the caller no longer needs the reference to this object. 
-        /// This method is typically useful for applications where multiple threads are using a connection, 
-        /// and it is required that the connection remain open until all threads have finished using it. ie, 
-        /// each new thread using a domain would increment the reference count.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>the domain to hold a reference on.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success and -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainRef(IntPtr domain);
-
-        /// <summary>
-        /// This method will restore a domain saved to disk by virDomainSave().
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
-        /// </param>
-        /// <param name="from">
-        /// Path to the file with saved domain.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success and -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainRestore(IntPtr conn, string from);
-
-        /// <summary>
-        /// Resume a suspended domain, the process is restarted from the state where it was frozen by calling virSuspendDomain(). 
-        /// This function may requires privileged access
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>domain object.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success and -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainResume(IntPtr domain);
-
-        /// <summary>
-        /// This method will suspend a domain and save its memory contents to a file on disk. After the call, if successful, 
-        /// the domain is not listed as running anymore (this may be a problem). Use virDomainRestore() to restore a domain after saving.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>domain object.
-        /// </param>
-        /// <param name="to">
-        /// Path for the output file.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success and -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainSave(IntPtr domain, string to);
-
-        /// <summary>
-        /// Configure the domain to be automatically started when the host machine boots.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>domain object.
-        /// </param>
-        /// <param name="autostart">
-        /// Whether the domain should be automatically started 0 or 1.
-        /// </param>
-        /// <returns>
-        /// -1 in case of error, 0 in case of success.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainSetAutostart(IntPtr domain, int autostart);
-
-        /// <summary>
-        /// Dynamically change the maximum amount of physical memory allocated to a domain. 
-        /// If domain is NULL, then this change the amount of memory reserved to Domain0 i.e. 
-        /// the domain where the application runs. This function requires privileged access to the hypervisor.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>domain object or NULL.
-        /// </param>
-        /// <param name="memory">
-        /// The memory size in kilobytes.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success and -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainSetMaxMemory(IntPtr domain, ulong memory);
-
-        /// <summary>
-        /// Dynamically change the target amount of physical memory allocated to a domain. 
-        /// If domain is NULL, then this change the amount of memory reserved to Domain0 i.e. 
-        /// the domain where the application runs. This function may requires privileged access to the hypervisor.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>domain object or NULL.
-        /// </param>
-        /// <param name="memory">
-        /// The memory size in kilobytes.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success and -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainSetMemory(IntPtr domain, ulong memory);
-
-        // TODO virDomainSetSchedulerParameters
-
-        /// <summary>
-        /// Dynamically change the number of virtual CPUs used by the domain. 
-        /// Note that this call may fail if the underlying virtualization hypervisor does not support it 
-        /// or if growing the number is arbitrary limited. This function requires privileged access to the hypervisor.
-        /// </summary>
-        /// <param name="domain">
-        /// Pointer to domain object, or NULL for Domain0
-        /// </param>
-        /// <param name="nvcpus">
-        /// The new number of virtual CPUs for this domain.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success, -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainSetVcpus(IntPtr domain, uint nvcpus);
-
-        /// <summary>
-        /// Shutdown a domain, the domain object is still usable there after but the domain OS is being stopped. 
-        /// Note that the guest OS may ignore the request. 
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>domain object.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success and -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainShutdown(IntPtr domain);
-
-        /// <summary>
-        /// Suspends an active domain, the process is frozen without further access to CPU resources and I/O 
-        /// but the memory used by the domain at the hypervisor level will stay allocated. 
-        /// Use virDomainResume() to reactivate the domain. This function may requires privileged access.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>domain object.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success and -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainSuspend(IntPtr domain);
-
-        /// <summary>
-        /// Undefine a domain but does not stop it if it is running.
-        /// </summary>
-        /// <param name="domain">
-        /// A <see cref="IntPtr"/>pointer to a defined domain.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success, -1 in case of error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virDomainUndefine(IntPtr domain);
-        #endregion
-
-        #region Events
-
-        ///<summary>
-        /// Function to install callbacks
-        ///</summary>
-        ///<param name="addHandle">the virEventAddHandleFunc which will be called (a delegate)</param>
-        ///<param name="updateHandle">the virEventUpdateHandleFunc which will be called (a delegate)</param>
-        ///<param name="removeHandle">the virEventRemoveHandleFunc which will be called (a delegate)</param>
-        ///<param name="addTimeout">the virEventAddTimeoutFunc which will be called (a delegate)</param>
-        ///<param name="updateTimeout">the virEventUpdateTimeoutFunc which will be called (a delegate)</param>
-        ///<param name="removeTimeout">the virEventRemoveTimeoutFunc which will be called (a delegate)</param>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern void virEventRegisterImpl([MarshalAs(UnmanagedType.FunctionPtr)]virEventAddHandleFunc addHandle,
-                                                       [MarshalAs(UnmanagedType.FunctionPtr)]virEventUpdateHandleFunc updateHandle,
-                                                       [MarshalAs(UnmanagedType.FunctionPtr)]virEventRemoveHandleFunc removeHandle,
-                                                       [MarshalAs(UnmanagedType.FunctionPtr)]virEventAddTimeoutFunc addTimeout,
-                                                       [MarshalAs(UnmanagedType.FunctionPtr)]virEventUpdateTimeoutFunc updateTimeout,
-                                                       [MarshalAs(UnmanagedType.FunctionPtr)]virEventRemoveTimeoutFunc removeTimeout);
-        #endregion
-
-        #region Library
-        /// <summary>
-        /// Provides two information back, @libVer is the version of the library while @typeVer will be the version of the hypervisor 
-        /// type @type against which the library was compiled. If @type is NULL, "Xen" is assumed, 
-        /// if @type is unknown or not available, an error code will be returned and @typeVer will be 0.
-        /// </summary>
-        /// <param name="libVer">
-        /// A <see cref="System.UInt64"/>return value for the library version (OUT).
-        /// </param>
-        /// <param name="type">
-        /// A <see cref="System.String"/>the type of connection/driver looked at.
-        /// </param>
-        /// <param name="typeVer">
-        /// A <see cref="System.UInt64"/>return value for the version of the hypervisor (OUT).
-        /// </param>
-        /// <returns>
-        /// -1 in case of failure, 0 otherwise, and values for @libVer and @typeVer have the format major * 1,000,000 + minor * 1,000 + release.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virGetVersion([Out] out ulong libVer, [In] string type, [Out] out ulong typeVer);
-        /// <summary>
-        /// Initialize the library. It's better to call this routine at startup in multithreaded applications to avoid 
-        /// potential race when initializing the library.
-        /// </summary>
-        /// <returns>
-        /// 0 in case of success, -1 in case of error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virInitialize();
-        #endregion
-
-        #region Interface
-
-        // TODO virInterfaceCreate
-
-        // TODO virInterfaceDefineXML
-
-        // TODO virInterfaceDestroy
-
-        // TODO virInterfaceFree
-
-        // TODO virInterfaceGetConnect
-
-        // TODO virInterfaceGetMACString
-
-        // TODO virInterfaceGetName
-
-        // TODO virInterfaceGetXMLDesc
-
-        // TODO virInterfaceIsActive
-
-        // TODO virInterfaceLookupByMACString
-
-        // TODO virInterfaceLookupByName
-
-        // TODO virInterfaceRef
-
-        // TODO virInterfaceUndefine
-
-        /// <summary>
-        /// Increment the reference count on the network. For each additional call to this method, 
-        /// there shall be a corresponding call to virNetworkFree to release the reference count, 
-        /// once the caller no longer needs the reference to this object. 
-        /// This method is typically useful for applications where multiple threads are using a connection, 
-        /// and it is required that the connection remain open until all threads have finished using it. ie, 
-        /// each new thread using a network would increment the reference count.
-        /// </summary>
-        /// <param name="network">
-        /// A <see cref="IntPtr"/>the network to hold a reference on.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success, -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virNetworkRef(IntPtr network);
-
-        // TODO virNetworkSetAutostart
-
-        // TODO virNetworkUndefine
-        #endregion
-
-        #region Node
-
-        // TODO virNodeDeviceCreateXML
-
-        // TODO virNodeDeviceDestroy
-
-        // TODO virNodeDeviceDettach
-
-        // TODO virNodeDeviceFree
-
-        // TODO virNodeDeviceGetName
-
-        // TODO virNodeDeviceGetParent
-
-        /// <summary>
-        /// Fetch an XML document describing all aspects of the device.
-        /// </summary>
-        /// <param name="dev">pointer to the node device</param>
-        /// <param name="flags">flags for XML generation (unused, pass 0)</param>
-        /// <returns>the XML document, or NULL on error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
-        public static extern string virNodeDeviceGetXMLDesc(IntPtr dev, uint flags);
-
-        // TODO virNodeDeviceListCaps
-
-        /// <summary>
-        /// Lookup a node device by its name.
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="name">unique device name</param>
-        /// <returns>a virNodeDevicePtr if found, NULL otherwise.</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virNodeDeviceLookupByName(IntPtr conn, string name);
-        // TODO virNodeDeviceNumOfCaps
-
-        // TODO virNodeDeviceReAttach
-
-        // TODO virNodeDeviceRef
-
-        // TODO virNodeDeviceReset
-
-        // TODO virNodeGetCellsFreeMemory
-
-        /// <summary>
-        /// Provides the free memory available on the Node Note: most libvirt APIs provide memory sizes in kilobytes, 
-        /// but in this function the returned value is in bytes. Divide by 1024 as necessary.
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
-        /// </param>
-        /// <returns>
-        /// The available free memory in bytes or 0 in case of error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern ulong virNodeGetFreeMemory(IntPtr conn);
-        /// <summary>
-        /// Extract hardware information about the node.
-        /// </summary>
-        /// <param name="h">
-        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
-        /// </param>
-        /// <param name="info">
-        /// Pointer to a virNodeInfo structure allocated by the user.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success and -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virNodeGetInfo(IntPtr h, [Out] virNodeInfo info);
-
-        // TODO virNodeGetSecurityModel
-
-        /// <summary>
-        /// Collect the list of node devices, and store their names in @names.
-        /// If the optional 'cap' argument is non-NULL, then the count will be restricted to devices with the specified capability.
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
-        /// </param>
-        /// <param name="cap">
-        /// Capability name.
-        /// </param>
-        /// <param name="names">
-        /// Array to collect the list of node device names.
-        /// </param>
-        /// <param name="maxnames">
-        /// Size of @names.
-        /// </param>
-        /// <param name="flags">
-        /// Flags (unused, pass 0).
-        /// </param>
-        /// <returns>
-        /// The number of node devices found or -1 in case of error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virNodeListDevices(IntPtr conn, string cap, IntPtr names, int maxnames, uint flags);
-        /// <summary>
-        /// Collect the list of node devices, and store their names in @names.
-        /// If the optional 'cap' argument is non-NULL, then the count will be restricted to devices with the specified capability.
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
-        /// </param>
-        /// <param name="cap">
-        /// Capability name.
-        /// </param>
-        /// <param name="names">
-        /// Array to collect the list of node device names.
-        /// </param>
-        /// <param name="maxnames">
-        /// Size of @names.
-        /// </param>
-        /// <param name="flags">
-        /// Flags (unused, pass 0).
-        /// </param>
-        /// <returns>
-        /// The number of node devices found or -1 in case of error.
-        /// </returns>
-        public static int virNodeListDevices(IntPtr conn, string cap, ref string[] names, int maxnames, uint flags)
-        {
-            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
-            int count = virNodeListDevices(conn, cap, namesPtr, maxnames, 0);
-            if (count > 0)
-                names = ptrToStringArray(namesPtr, count);
-            Marshal.FreeHGlobal(namesPtr);
-            return count;
-        }
-        /// <summary>
-        /// Provides the number of node devices. If the optional 'cap' argument is non-NULL, 
-        /// then the count will be restricted to devices with the specified capability.
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
-        /// </param>
-        /// <param name="cap">
-        /// A <see cref="System.String"/>capability name.
-        /// </param>
-        /// <param name="flags">
-        /// A <see cref="System.UInt32"/>flags (unused, pass 0).
-        /// </param>
-        /// <returns>
-        /// The number of node devices or -1 in case of error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virNodeNumOfDevices(IntPtr conn, string cap, uint flags);
-        #endregion
-
-        #region Secret
-
-        // TODO virSecretDefineXML
-
-        // TODO virSecretFree
-
-        // TODO virSecretGetConnect
-
-        // TODO virSecretGetUUID
-
-        // TODO virSecretGetUUIDString
-
-        // TODO virSecretGetUsageID
-
-        // TODO virSecretGetUsageType
-
-        // TODO virSecretGetValue
-
-        // TODO virSecretGetXMLDesc
-
-        // TODO virSecretLookupByUUID
-
-        // TODO virSecretLookupByUUIDString
-
-        // TODO virSecretLookupByUsage
-
-        // TODO virSecretRef
-
-        // TODO virSecretSetValue
-
-        // TODO virSecretUndefine
-        #endregion
-
-        #region Storage pool
-
-        /// <summary>
-        /// Build the underlying storage pool.
-        /// </summary>
-        /// <param name="pool">
-        /// A pointer to storage pool.
-        /// </param>
-        /// <param name="flags">
-        /// Future flags, use 0 for now.
-        /// </param>
-        /// <returns>
-        /// 0 on success, or -1 upon failure
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStoragePoolBuild(IntPtr pool, virStoragePoolBuildFlags flags);
-
-        /// <summary>
-        /// Starts an inactive storage pool.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        /// <param name="flags">
-        /// Future flags, use 0 for now.
-        /// </param>
-        /// <returns>
-        /// 0 on success, or -1 if it could not be started.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStoragePoolCreate(IntPtr pool, uint flags);
-
-        /// <summary>
-        /// Create a new storage based on its XML description. The pool is not persistent, 
-        /// so its definition will disappear when it is destroyed, or if the host is restarted
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to hypervisor connection.
-        /// </param>
-        /// <param name="xmlDesc">
-        /// A <see cref="System.String"/>XML description for new pool.
-        /// </param>
-        /// <param name="flags">
-        /// A <see cref="System.UInt32"/>future flags, use 0 for now.
-        /// </param>
-        /// <returns>
-        /// A virStoragePoolPtr object, or NULL if creation failed.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virStoragePoolCreateXML(IntPtr conn, string xmlDesc, uint flags);
-
-        /// <summary>
-        /// Define a new inactive storage pool based on its XML description. The pool is persistent, 
-        /// until explicitly undefined.
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to hypervisor connection.
-        /// </param>
-        /// <param name="xml">
-        /// A <see cref="System.String"/>XML description for new pool.
-        /// </param>
-        /// <param name="flags">
-        /// A <see cref="System.UInt32"/>future flags, use 0 for now.
-        /// </param>
-        /// <returns>
-        /// A virStoragePoolPtr object, or NULL if creation failed.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virStoragePoolDefineXML(IntPtr conn, string xml, uint flags);
-
-        /// <summary>
-        /// Delete the underlying pool resources. This is a non-recoverable operation. The virStoragePoolPtr object itself is not free'd.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        /// <param name="flags">
-        /// A <see cref="virStoragePoolDeleteFlags"/>flags for obliteration process.
-        /// </param>
-        /// <returns>
-        /// 0 on success, or -1 if it could not be obliterate.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStoragePoolDelete(IntPtr pool, virStoragePoolDeleteFlags flags);
-
-        /// <summary>
-        /// Destroy an active storage pool. This will deactivate the pool on the host, 
-        /// but keep any persistent config associated with it. 
-        /// If it has a persistent config it can later be restarted with virStoragePoolCreate(). 
-        /// This does not free the associated virStoragePoolPtr object.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        /// <returns>
-        /// 0 on success, or -1 if it could not be destroyed.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStoragePoolDestroy(IntPtr pool);
-
-        /// <summary>
-        /// Free a storage pool object, releasing all memory associated with it. Does not change the state of the pool on the host.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        /// <returns>
-        /// 0 on success, or -1 if it could not be free'd.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStoragePoolFree(IntPtr pool);
-
-        /// <summary>
-        /// Fetches the value of the autostart flag, which determines whether the pool is automatically started at boot time.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        /// <param name="autotart"></param>
-        /// <returns>
-        /// 0 on success, -1 on failure
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStoragePoolGetAutostart(IntPtr pool, out int autotart);
-
-        /// <summary>
-        /// Provides the connection pointer associated with a storage pool. The reference counter on the connection is not increased by this call. 
-        /// WARNING: When writing libvirt bindings in other languages, do not use this function. Instead, store the connection and the pool object together.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to a pool.
-        /// </param>
-        /// <returns>
-        /// A <see cref="IntPtr"/>the virConnectPtr or NULL in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virStoragePoolGetConnect(IntPtr pool);
-
-        /// <summary>
-        /// Get volatile information about the storage pool such as free space / usage summary.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        /// <param name="info">
-        /// Pointer at which to store info.
-        /// </param>
-        /// <returns>
-        /// 0 on success, or -1 on failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStoragePoolGetInfo(IntPtr pool, ref virStoragePoolInfo info);
-
-        /// <summary>
-        /// Fetch the locally unique name of the storage pool.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        /// <returns>
-        /// The name of the pool, or NULL on error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
-        public static extern string virStoragePoolGetName(IntPtr pool);
-
-        /// <summary>
-        /// Fetch the globally unique ID of the storage pool.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>Pointer to storage pool.
-        /// </param>
-        /// <param name="uuid">
-        /// Buffer of VIR_UUID_BUFLEN bytes in size.
-        /// </param>
-        /// <returns>
-        /// 0 on success, or -1 on error
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStoragePoolGetUUID(IntPtr pool, [Out] char[] uuid);
-
-        /// <summary>
-        /// Fetch the globally unique ID of the storage pool as a string.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        /// <param name="uuid">
-        /// A <see cref="IntPtr"/>buffer of VIR_UUID_STRING_BUFLEN bytes in size.
-        /// </param>
-        /// <returns>
-        /// 0 on success, or -1 on error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        private static extern int virStoragePoolGetUUIDString(IntPtr pool, [Out] char[] uuid);
-
-        ///<summary>
-        /// Fetch the globally unique ID of the storage pool as a string.
-        ///</summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        ///<returns>the storage pool UUID</returns>
-        public static string virStoragePoolGetUUIDString(IntPtr pool)
-        {
-            char[] uuidArray = new char[36];
-            virStoragePoolGetUUIDString(pool, uuidArray);
-            return new string(uuidArray);
-        }
-        /// <summary>
-        /// Fetch an XML document describing all aspects of the storage pool. 
-        /// This is suitable for later feeding back into the virStoragePoolCreateXML method.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        /// <param name="flags">
-        /// Flags for XML format options (set of virDomainXMLFlags).
-        /// </param>
-        /// <returns>
-        /// A XML document, or NULL on error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
-        public static extern string virStoragePoolGetXMLDesc(IntPtr pool, virDomainXMLFlags flags);
-
-        /// <summary>
-        /// Determine if the storage pool is currently running.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to the storage pool object.
-        /// </param>
-        /// <returns>
-        /// 1 if running, 0 if inactive, -1 on error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStoragePoolIsActive(IntPtr pool);
-
-        /// <summary>
-        /// Determine if the storage pool has a persistent configuration which means it will still exist after shutting down.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to the storage pool object.
-        /// </param>
-        /// <returns>
-        /// 1 if persistent, 0 if transient, -1 on error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStoragePoolIsPersistent(IntPtr pool);
-
-        /// <summary>
-        /// Fetch list of storage volume names, limiting to at most maxnames.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        /// <param name="names">
-        /// A <see cref="IntPtr"/>array in which to storage volume names.
-        /// </param>
-        /// <param name="maxnames">
-        /// A <see cref="System.Int32"/>size of names array.
-        /// </param>
-        /// <returns>
-        /// The number of names fetched, or -1 on error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        private static extern int virStoragePoolListVolumes(IntPtr pool, IntPtr names, int maxnames);
-        /// <summary>
-        /// Fetch list of storage volume names, limiting to at most maxnames.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        /// <param name="names">
-        /// A <see cref="IntPtr"/>array in which to storage volume names.
-        /// </param>
-        /// <param name="maxnames">
-        /// A <see cref="System.Int32"/>size of names array.
-        /// </param>
-        /// <returns>
-        /// The number of names fetched, or -1 on error.
-        /// </returns>
-        public static int virStoragePoolListVolumes(IntPtr pool, ref string[] names, int maxnames)
-        {
-            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
-            int count = virStoragePoolListVolumes(pool, namesPtr, maxnames);
-            if (count > 0)
-                names = ptrToStringArray(namesPtr, count);
-            Marshal.FreeHGlobal(namesPtr);
-            return count;
-        }
-        /// <summary>
-        /// Fetch a storage pool based on its unique name.
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to hypervisor connection.
-        /// </param>
-        /// <param name="name">
-        /// Name of pool to fetch.
-        /// </param>
-        /// <returns>
-        /// A <see cref="IntPtr"/>virStoragePoolPtr object, or NULL if no matching pool is found.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virStoragePoolLookupByName(IntPtr conn, string name);
-
-        /// <summary>
-        /// Fetch a storage pool based on its globally unique id.
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to hypervisor connection.
-        /// </param>
-        /// <param name="uuid">
-        /// Globally unique id of pool to fetch.
-        /// </param>
-        /// <returns>
-        /// A virStoragePoolPtr object, or NULL if no matching pool is found
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virStoragePoolLookupByUUID(IntPtr conn, char[] uuid);
-
-        /// <summary>
-        /// Fetch a storage pool based on its globally unique id.
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to hypervisor connection.
-        /// </param>
-        /// <param name="uuidstr">
-        /// A <see cref="System.String"/>globally unique id of pool to fetch.
-        /// </param>
-        /// <returns>
-        /// A <see cref="IntPtr"/>object, or NULL if no matching pool is found.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virStoragePoolLookupByUUIDString(IntPtr conn, string uuidstr);
-
-        /// <summary>
-        /// Fetch a storage pool which contains a particular volume.
-        /// </summary>
-        /// <param name="vol">
-        /// A <see cref="IntPtr"/>pointer to storage volume.
-        /// </param>
-        /// <returns>
-        /// A <see cref="IntPtr"/>object, or NULL if no matching pool is found.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virStoragePoolLookupByVolume(IntPtr vol);
-
-        /// <summary>
-        /// Fetch the number of storage volumes within a pool.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        /// <returns>
-        /// A <see cref="System.Int32"/>the number of storage pools, or -1 on failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStoragePoolNumOfVolumes(IntPtr pool);
-
-        /// <summary>
-        /// Increment the reference count on the pool. For each additional call to this method, 
-        /// there shall be a corresponding call to virStoragePoolFree to release the reference count, 
-        /// once the caller no longer needs the reference to this object. 
-        /// This method is typically useful for applications where multiple threads are using a connection, 
-        /// and it is required that the connection remain open until all threads have finished using it. ie, 
-        /// each new thread using a pool would increment the reference count.
-        /// </summary>
-        /// <param name="pool">
-        /// The pool to hold a reference on.
-        /// </param>
-        /// <returns>
-        /// 0 in case of success, -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStoragePoolRef(IntPtr pool);
-
-        /// <summary>
-        /// Request that the pool refresh its list of volumes. This may involve communicating with a remote server, 
-        /// and/or initializing new devices at the OS layer.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        /// <param name="flags">
-        /// A <see cref="System.UInt32"/>flags to control refresh behaviour (currently unused, use 0).
-        /// </param>
-        /// <returns>
-        /// 0 if the volume list was refreshed, -1 on failure.
-        /// </returns>
-        [DllImport("virtlib-0.dll")]
-        public static extern int virStoragePoolRefresh(IntPtr pool, uint flags);
-
-        /// <summary>
-        /// Sets the autostart flag.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        /// <param name="autostart">
-        /// A <see cref="System.Int32"/>new flag setting.
-        /// </param>
-        /// <returns>
-        /// 0 on success, -1 on failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStoragePoolSetAutostart(IntPtr pool, int autostart);
-
-        /// <summary>
-        /// Undefine an inactive storage pool.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        /// <returns>
-        /// 0 on success, -1 on failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStoragePoolUndefine(IntPtr pool);
-        #endregion
-
-        #region Volumes
-
-        /// <summary>
-        /// Create a storage volume within a pool based on an XML description. Not all pools support creation of volumes.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        /// <param name="xmldesc">
-        /// A <see cref="System.String"/>description of volume to create.
-        /// </param>
-        /// <param name="flags">
-        /// A <see cref="System.UInt32"/>flags for creation (unused, pass 0).
-        /// </param>
-        /// <returns>
-        /// The storage volume, or NULL on error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virStorageVolCreateXML(IntPtr pool, string xmldesc, uint flags);
-
-        /// <summary>
-        /// Create a storage volume in the parent pool, using the 'clonevol' volume as input. 
-        /// Information for the new volume (name, perms) are passed via a typical volume XML description.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to parent pool for the new volume.
-        /// </param>
-        /// <param name="xmldesc">
-        /// A <see cref="System.String"/>description of volume to create.
-        /// </param>
-        /// <param name="clonevol">
-        /// A <see cref="IntPtr"/>storage volume to use as input.
-        /// </param>
-        /// <param name="flags">
-        /// A <see cref="System.UInt32"/>flags for creation (unused, pass 0).
-        /// </param>
-        /// <returns>
-        /// A <see cref="IntPtr"/>the storage volume, or NULL on error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virStorageVolCreateXMLFrom(IntPtr pool, string xmldesc, IntPtr clonevol, uint flags);
-
-        /// <summary>
-        /// Delete the storage volume from the pool.
-        /// </summary>
-        /// <param name="vol">
-        /// A <see cref="IntPtr"/>pointer to storage volume.
-        /// </param>
-        /// <param name="flags">
-        /// A <see cref="System.UInt32"/>future flags, use 0 for now.
-        /// </param>
-        /// <returns>
-        /// 0 on success, or -1 on error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStorageVolDelete(IntPtr vol, uint flags);
-
-        /// <summary>
-        /// Release the storage volume handle. The underlying storage volume continues to exist.
-        /// </summary>
-        /// <param name="vol">
-        /// A <see cref="IntPtr"/>pointer to storage volume.
-        /// </param>
-        /// <returns>
-        /// 0 on success, or -1 on error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStorageVolFree(IntPtr vol);
-
-        /// <summary>
-        /// Provides the connection pointer associated with a storage volume. 
-        /// The reference counter on the connection is not increased by this call. 
-        /// WARNING: When writing libvirt bindings in other languages, do not use this function. 
-        /// Instead, store the connection and the volume object together.
-        /// </summary>
-        /// <param name="vol">
-        /// A <see cref="IntPtr"/>
-        /// </param>
-        /// <returns>
-        /// A <see cref="IntPtr"/>
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virStorageVolGetConnect(IntPtr vol);
-
-        /// <summary>
-        /// Fetches volatile information about the storage volume such as its current allocation.
-        /// </summary>
-        /// <param name="vol">
-        /// A <see cref="IntPtr"/>pointer to storage volume.
-        /// </param>
-        /// <param name="info">
-        /// A <see cref="virStorageVolInfo"/>pointer at which to store info.
-        /// </param>
-        /// <returns>
-        /// 0 on success, or -1 on failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStorageVolGetInfo(IntPtr vol, ref virStorageVolInfo info);
-
-        /// <summary>
-        /// Fetch the storage volume key. 
-        /// This is globally unique, so the same volume will have the same key no matter what host it is accessed from
-        /// </summary>
-        /// <param name="vol">
-        /// A <see cref="IntPtr"/>pointer to storage volume.
-        /// </param>
-        /// <returns>
-        /// The volume key, or NULL on error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
-        public static extern string virStorageVolGetKey(IntPtr vol);
-
-        /// <summary>
-        /// Fetch the storage volume name. This is unique within the scope of a pool.
-        /// </summary>
-        /// <param name="vol">
-        /// A <see cref="IntPtr"/>pointer to storage volume.
-        /// </param>
-        /// <returns>
-        /// The volume name, or NULL on error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
-        public static extern string virStorageVolGetName(IntPtr vol);
-
-        /// <summary>
-        /// Fetch the storage volume path. 
-        /// Depending on the pool configuration this is either persistent across hosts, 
-        /// or dynamically assigned at pool startup. 
-        /// Consult pool documentation for information on getting the persistent naming.
-        /// </summary>
-        /// <param name="vol">
-        /// A <see cref="IntPtr"/>pointer to storage volume.
-        /// </param>
-        /// <returns>
-        /// The storage volume path, or NULL on error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
-        public static extern string virStorageVolGetPath(IntPtr vol);
-
-        /// <summary>
-        /// Fetch an XML document describing all aspects of the storage volume.
-        /// </summary>
-        /// <param name="vol">
-        /// A <see cref="IntPtr"/>pointer to storage volume.
-        /// </param>
-        /// <param name="flags">
-        /// A <see cref="System.UInt32"/>flags for XML generation (unused, pass 0).
-        /// </param>
-        /// <returns>
-        /// The XML document, or NULL on error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
-        public static extern string virStorageVolGetXMLDesc(IntPtr vol, uint flags);
-
-        /// <summary>
-        /// Fetch a pointer to a storage volume based on its globally unique key.
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to hypervisor connection.
-        /// </param>
-        /// <param name="key">
-        /// A <see cref="System.String"/>globally unique key.
-        /// </param>
-        /// <returns>
-        /// A <see cref="IntPtr"/>storage volume, or NULL if not found / error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virStorageVolLookupByKey(IntPtr conn, string key);
-
-        /// <summary>
-        /// Fetch a pointer to a storage volume based on its name within a pool.
-        /// </summary>
-        /// <param name="pool">
-        /// A <see cref="IntPtr"/>pointer to storage pool.
-        /// </param>
-        /// <param name="name">
-        /// A <see cref="System.String"/>name of storage volume.
-        /// </param>
-        /// <returns>
-        /// A <see cref="IntPtr"/>storage volume, or NULL if not found / error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virStorageVolLookupByName(IntPtr pool, string name);
-
-        /// <summary>
-        /// Fetch a pointer to a storage volume based on its locally (host) unique path.
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to hypervisor connection.
-        /// </param>
-        /// <param name="path">
-        /// A <see cref="System.String"/>locally unique path.
-        /// </param>
-        /// <returns>
-        /// A <see cref="IntPtr"/>storage volume, or NULL if not found / error.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virStorageVolLookupByPath(IntPtr conn, string path);
-
-        /// <summary>
-        /// Increment the reference count on the vol. For each additional call to this method, 
-        /// there shall be a corresponding call to virStorageVolFree to release the reference count, 
-        /// once the caller no longer needs the reference to this object. 
-        /// This method is typically useful for applications where multiple threads are using a connection, 
-        /// and it is required that the connection remain open until all threads have finished using it. ie, 
-        /// each new thread using a vol would increment the reference count.
-        /// </summary>
-        /// <param name="vol">
-        /// A <see cref="IntPtr"/>the vol to hold a reference on.
-        /// </param>
-        /// <returns>
-        /// A <see cref="System.Int32"/>0 in case of success, -1 in case of failure.
-        /// </returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virStorageVolRef(IntPtr vol);
-
-        #endregion
-
-        #region Streams
-
-        // TODO virStreamAbort
-
-        // TODO virStreamEventAddCallback
-
-        // TODO virStreamEventCallback
-
-        // TODO virStreamEventRemoveCallback
-
-        // TODO virStreamEventUpdateCallback
-
-        // TODO virStreamFinish
-
-        // TODO virStreamFree
-
-        // TODO virStreamNew
-
-        // TODO virStreamRecv
-
-        // TODO virStreamRecvAll
-
-        // TODO virStreamRef
-
-        // TODO virStreamSend
-
-        // TODO virStreamSendAll
-
-        // TODO virStreamSinkFunc
-
-        // TODO virStreamSourceFunc
-
-        /// <summary>
-        /// A callback function to be registered, and called when a domain event occurs
-        /// </summary>
-        /// <param name="conn">virConnect connection </param>
-        /// <param name="dom">The domain on which the event occured</param>
-        /// <param name="evt">The specfic virDomainEventType which occured</param>
-        /// <param name="detail">event specific detail information</param>
-        /// <param name="opaque">opaque user data</param>
-        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-        public delegate void virConnectDomainEventCallback(IntPtr conn, IntPtr dom, virDomainEventType evt, int detail, IntPtr opaque);
-        /// <summary>
-        /// Adds a callback to receive notifications of domain lifecycle events occurring on a connection Use of this method is no longer recommended. Instead applications should try virConnectDomainEventRegisterAny which has a more flexible API contract The virDomainPtr object handle passed into the callback upon delivery of an event is only valid for the duration of execution of the callback. If the callback wishes to keep the domain object after the callback
-        /// </summary>
-        /// <param name="conn">pointer to the connection</param>
-        /// <param name="cb">callback to the function handling domain events</param>
-        /// <param name="opaque">opaque data to pass on to the callback</param>
-        /// <param name="ff">optional function to deallocate opaque when not used anymore</param>
-        /// <returns>t shall take a reference to it, by calling virDomainRef. The reference can be released once the object is no longer required by calling virDomainFree. Returns 0 on success, -1 on failure</returns>
-        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl)]
-        public static extern int virConnectDomainEventRegister(IntPtr conn, [MarshalAs(UnmanagedType.FunctionPtr)] virConnectDomainEventCallback cb,
-                                                                IntPtr opaque, [MarshalAs(UnmanagedType.FunctionPtr)] virFreeCallback ff);
-
-        #endregion
-
-        #region Network
-
-        /// <summary>
-        /// Create and start a defined network. If the call succeed the network moves from the defined to the running networks pools.
-        /// </summary>
-        /// <param name="network">pointer to a defined network</param>
-        /// <returns>0 in case of success, -1 in case of error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virNetworkCreate(IntPtr network);
-        /// <summary>
-        /// Create and start a new virtual network, based on an XML description similar to the one returned by virNetworkGetXMLDesc()
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="xmlDesc">an XML description of the network</param>
-        /// <returns>a new network object or NULL in case of failure</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virNetworkCreateXML(IntPtr conn, string xmlDesc);
-        /// <summary>
-        /// Define a network, but does not create it
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="xmlDesc">the XML description for the network, preferably in UTF-8</param>
-        /// <returns>NULL in case of error, a pointer to the network otherwise</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virNetworkDefineXML(IntPtr conn, string xmlDesc);
-        /// <summary>
-        /// Destroy the network object. The running instance is shutdown if not down already and all resources used by it are given back to the hypervisor. This does not free the associated virNetworkPtr object. This function may require privileged access
-        /// </summary>
-        /// <param name="network">a network object</param>
-        /// <returns>0 in case of success and -1 in case of failure.</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virNetworkDestroy(IntPtr network);
-        /// <summary>
-        /// Free the network object. The running instance is kept alive. The data structure is freed and should not be used thereafter.
-        /// </summary>
-        /// <param name="network">a network object</param>
-        /// <returns>0 in case of success and -1 in case of failure</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virNetworkFree(IntPtr network);
-        /// <summary>
-        /// Provides a boolean value indicating whether the network configured to be automatically started when the host machine boots.
-        /// </summary>
-        /// <param name="network">a network object</param>
-        /// <param name="autostart">the value returned</param>
-        /// <returns>-1 in case of error, 0 in case of success</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virNetworkGetAutostart(IntPtr network, int autostart);
-        /// <summary>
-        /// Provides a bridge interface name to which a domain may connect a network interface in order to join the network.
-        /// </summary>
-        /// <param name="network">a network object</param>
-        /// <returns>a 0 terminated interface name, or NULL in case of error. the caller must free() the returned value</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
-        public static extern string virNetworkGetBridgeName(IntPtr network);
-        /// <summary>
-        /// Provides the connection pointer associated with a network. The reference counter on the connection is not increased by this call. WARNING: When writing libvirt bindings in other languages, do not use this function. Instead, store the connection and the network object together
-        /// </summary>
-        /// <param name="network">pointer to a network</param>
-        /// <returns>the virConnectPtr or NULL in case of failure</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virNetworkGetConnect(IntPtr network);
-        /// <summary>
-        /// Get the public name for that network
-        /// </summary>
-        /// <param name="network">a network object</param>
-        /// <returns>a pointer to the name or NULL, the string need not be deallocated its lifetime will be the same as the network object</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
-        public static extern string virNetworkGetName(IntPtr network);
-        /// <summary>
-        /// Get the UUID for a network as string
-        /// </summary>
-        /// <param name="network">a network object</param>
-        /// <param name="uuid">string of the uuid</param>
-        /// <returns>-1 in case of error, 0 in case of success</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        private static extern int virNetworkGetUUIDString(IntPtr network, [Out] char[] uuid);
-
-        ///<summary>
-        /// Get the UUID for a network as string
-        ///</summary>
-        ///<param name="network">a network object, a netowrk IntPtr</param>
-        ///<returns>string of the uuid</returns>
-        public static string virNetworkGetUUIDString(IntPtr network)
-        {
-            char[] uuidArray = new char[36];
-            virNetworkGetUUIDString(network, uuidArray);
-            return new string(uuidArray);
-        }
-        /// <summary>
-        /// Provide an XML description of the network. The description may be reused later to relaunch the network with virNetworkCreateXML().
-        /// </summary>
-        /// <param name="network">a network object</param>
-        /// <param name="flags">an OR'ed set of extraction flags, not used yet</param>
-        /// <returns>a 0 terminated UTF-8 encoded XML instance, or NULL in case of error. the caller must free() the returned value</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
-        public static extern string virNetworkGetXMLDesc(IntPtr network, int flags);
-        /// <summary>
-        /// Determine if the network is currently running
-        /// </summary>
-        /// <param name="network">pointer to the network object</param>
-        /// <returns>1 if running, 0 if inactive, -1 on error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virNetworkIsActive(IntPtr network);
-        /// <summary>
-        /// Determine if the network has a persistent configuration which means it will still exist after shutting down
-        /// </summary>
-        /// <param name="network">pointer to the network object</param>
-        /// <returns>x1 if persistent, 0 if transient, -1 on error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virNetworkIsPersistent(IntPtr network);
-        /// <summary>
-        /// Try to lookup a network on the given hypervisor based on its name.
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="name">name for the network</param>
-        /// <returns>a new network object or NULL in case of failure. If the network cannot be found, then VIR_ERR_NO_NETWORK error is raised</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virNetworkLookupByName(IntPtr conn, string name);
-        /// <summary>
-        /// Try to lookup a network on the given hypervisor based on its UUID
-        /// </summary>
-        /// <param name="conn">pointer to the hypervisor connection</param>
-        /// <param name="uuidstr">the string UUID for the network</param>
-        /// <returns>a new network object or NULL in case of failure. If the network cannot be found, then VIR_ERR_NO_NETWORK error is raised</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern IntPtr virNetworkLookupByUUIDString(IntPtr conn, string uuidstr);
-        /// <summary>
-        /// Configure the network to be automatically started when the host machine boots
-        /// </summary>
-        /// <param name="network">a network object</param>
-        /// <param name="autostart">whether the network should be automatically started 0 or 1</param>
-        /// <returns>-1 in case of error, 0 in case of success</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virNetworkSetAutostart(IntPtr network, int autostart);
-        /// <summary>
-        /// Undefine a network but does not stop it if it is running
-        /// </summary>
-        /// <param name="network">pointer to a defined network</param>
-        /// <returns>0 in case of success, -1 in case of error</returns>
-        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
-        public static extern int virNetworkUndefine(IntPtr network);
-
-        #endregion
-
-        #region Helpers
-        
-        private static string[] ptrToStringArray(IntPtr stringPtr, int stringCount)
-        {
-            string[] members = new string[stringCount];
-            for (int i = 0; i < stringCount; ++i)
-            {
-                IntPtr s = Marshal.ReadIntPtr(stringPtr, i * IntPtr.Size);
-                members[i] = Marshal.PtrToStringAnsi(s);
-            }
-            return members;
-        }
-
-// ReSharper disable UnusedMember.Local
-        private static string ptrToString(IntPtr stringPtr)
-// ReSharper restore UnusedMember.Local
-        {
-            IntPtr s = Marshal.ReadIntPtr(stringPtr, IntPtr.Size);
-            return Marshal.PtrToStringAnsi(s);
-        }
-
-        #endregion
-    }
-}
diff --git a/LibvirtError.cs b/LibvirtError.cs
dissimilarity index 79%
index eaab401..0febfb5 100644
--- a/LibvirtError.cs
+++ b/LibvirtError.cs
@@ -1,683 +1,127 @@
-﻿/*
- * Copyright (C)
- *   Arnaud Champion <arnaud.champion@devatom.fr>
- *   Jaromír Červenka <cervajz@cervajz.com>
- *
- * See COPYING.LIB for the License of this software
- */
-
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace LibvirtBindings
-{
-    ///<summary>
-    /// class for libvirt errors binding
-    ///</summary>
-    public class libvirtError
-    {
-        ///<summary>
-        /// Signature of a function to use when there is an error raised by the library.
-        ///</summary>
-        ///<param name="userData">user provided data for the error callback</param>
-        ///<param name="error">the error being raised.</param>
-        public delegate void virErrorFunc(IntPtr userData, virError error);
-
-        ///<summary>
-        /// Enumerate errors
-        ///</summary>
-        public enum virErrorNumber
-        {
-            /// <summary>
-            /// No error
-            /// </summary>
-            VIR_ERR_OK = 0,
-            /// <summary>
-            /// Internal error
-            /// </summary>
-            VIR_ERR_INTERNAL_ERROR = 1,
-            /// <summary>
-            /// Memory allocation failure
-            /// </summary>
-            VIR_ERR_NO_MEMORY = 2,
-            /// <summary>
-            /// No support for this function
-            /// </summary>
-            VIR_ERR_NO_SUPPORT = 3,
-            /// <summary>
-            /// Could not resolve hostname
-            /// </summary>
-            VIR_ERR_UNKNOWN_HOST = 4,
-            /// <summary>
-            /// Can't connect to hypervisor
-            /// </summary>
-            VIR_ERR_NO_CONNECT = 5,
-            /// <summary>
-            /// Invalid connection object
-            /// </summary>
-            VIR_ERR_INVALID_CONN = 6,
-            /// <summary>
-            /// Invalid domain object
-            /// </summary>
-            VIR_ERR_INVALID_DOMAIN = 7,
-            /// <summary>
-            /// Invalid function argument
-            /// </summary>
-            VIR_ERR_INVALID_ARG = 8,
-            /// <summary>
-            ///  A command to hypervisor failed
-            /// </summary>
-            VIR_ERR_OPERATION_FAILED = 9,
-            /// <summary>
-            /// A HTTP GET command to failed
-            /// </summary>
-            VIR_ERR_GET_FAILED = 10,
-            /// <summary>
-            /// A HTTP POST command to failed
-            /// </summary>
-            VIR_ERR_POST_FAILED = 11,
-            /// <summary>
-            /// Unexpected HTTP error code
-            /// </summary>
-            VIR_ERR_HTTP_ERROR = 12,
-            /// <summary>
-            /// Failure to serialize an S-Expr
-            /// </summary>
-            VIR_ERR_SEXPR_SERIAL = 13,
-            /// <summary>
-            /// Could not open Xen hypervisor control
-            /// </summary>
-            VIR_ERR_NO_XEN = 14,
-            /// <summary>
-            /// Failure doing an hypervisor call
-            /// </summary>
-            VIR_ERR_XEN_CALL = 15,
-            /// <summary>
-            /// Unknown OS type
-            /// </summary>
-            VIR_ERR_OS_TYPE = 16,
-            /// <summary>
-            /// Missing kernel information
-            /// </summary>
-            VIR_ERR_NO_KERNEL = 17,
-            /// <summary>
-            /// Missing root device information
-            /// </summary>
-            VIR_ERR_NO_ROOT = 18,
-            /// <summary>
-            /// Missing source device information
-            /// </summary>
-            VIR_ERR_NO_SOURCE = 19,
-            /// <summary>
-            /// Missing target device information
-            /// </summary>
-            VIR_ERR_NO_TARGET = 20,
-            /// <summary>
-            /// Missing domain name information
-            /// </summary>
-            VIR_ERR_NO_NAME = 21,
-            /// <summary>
-            /// Missing domain OS information
-            /// </summary>
-            VIR_ERR_NO_OS = 22,
-            /// <summary>
-            /// Missing domain devices information
-            /// </summary>
-            VIR_ERR_NO_DEVICE = 23,
-            /// <summary>
-            /// Could not open Xen Store control
-            /// </summary>
-            VIR_ERR_NO_XENSTORE = 24,
-            /// <summary>
-            /// Too many drivers registered
-            /// </summary>
-            VIR_ERR_DRIVER_FULL = 25,
-            /// <summary>
-            /// Not supported by the drivers (DEPRECATED)
-            /// </summary>
-            VIR_ERR_CALL_FAILED = 26,
-            /// <summary>
-            /// An XML description is not well formed or broken
-            /// </summary>
-            VIR_ERR_XML_ERROR = 27,
-            /// <summary>
-            /// The domain already exist
-            /// </summary>
-            VIR_ERR_DOM_EXIST = 28,
-            /// <summary>
-            /// Operation forbidden on read-only connections
-            /// </summary>
-            VIR_ERR_OPERATION_DENIED = 29,
-            /// <summary>
-            /// Failed to open a conf file
-            /// </summary>
-            VIR_ERR_OPEN_FAILED = 30,
-            /// <summary>
-            /// Failed to read a conf file
-            /// </summary>
-            VIR_ERR_READ_FAILED = 31,
-            /// <summary>
-            /// Failed to parse a conf file
-            /// </summary>
-            VIR_ERR_PARSE_FAILED = 32,
-            /// <summary>
-            /// Failed to parse the syntax of a conf file
-            /// </summary>
-            VIR_ERR_CONF_SYNTAX = 33,
-            /// <summary>
-            /// Failed to write a conf file
-            /// </summary>
-            VIR_ERR_WRITE_FAILED = 34,
-            /// <summary>
-            /// Detail of an XML error
-            /// </summary>
-            VIR_ERR_XML_DETAIL = 35,
-            /// <summary>
-            /// Invalid network object
-            /// </summary>
-            VIR_ERR_INVALID_NETWORK = 36,
-            /// <summary>
-            /// The network already exist
-            /// </summary>
-            VIR_ERR_NETWORK_EXIST = 37,
-            /// <summary>
-            /// General system call failure
-            /// </summary>
-            VIR_ERR_SYSTEM_ERROR = 38,
-            /// <summary>
-            /// Some sort of RPC error
-            /// </summary>
-            VIR_ERR_RPC = 39,
-            /// <summary>
-            /// Error from a GNUTLS call
-            /// </summary>
-            VIR_ERR_GNUTLS_ERROR = 40,
-            /// <summary>
-            /// Failed to start network
-            /// </summary>
-            VIR_WAR_NO_NETWORK = 41,
-            /// <summary>
-            /// Domain not found or unexpectedly disappeared
-            /// </summary>
-            VIR_ERR_NO_DOMAIN = 42,
-            /// <summary>
-            /// Network not found
-            /// </summary>
-            VIR_ERR_NO_NETWORK = 43,
-            /// <summary>
-            /// Invalid MAC address
-            /// </summary>
-            VIR_ERR_INVALID_MAC = 44,
-            /// <summary>
-            /// Authentication failed
-            /// </summary>
-            VIR_ERR_AUTH_FAILED = 45,
-            /// <summary>
-            /// Invalid storage pool object
-            /// </summary>
-            VIR_ERR_INVALID_STORAGE_POOL = 46,
-            /// <summary>
-            /// Invalid storage vol object
-            /// </summary>
-            VIR_ERR_INVALID_STORAGE_VOL = 47,
-            /// <summary>
-            /// Failed to start storage
-            /// </summary>
-            VIR_WAR_NO_STORAGE = 48,
-            /// <summary>
-            /// Storage pool not found
-            /// </summary>
-            VIR_ERR_NO_STORAGE_POOL = 49,
-            /// <summary>
-            /// Storage pool not found
-            /// </summary>
-            VIR_ERR_NO_STORAGE_VOL = 50,
-            /// <summary>
-            /// Failed to start node driver
-            /// </summary>
-            VIR_WAR_NO_NODE = 51,
-            /// <summary>
-            /// Invalid node device object
-            /// </summary>
-            VIR_ERR_INVALID_NODE_DEVICE = 52,
-            /// <summary>
-            /// Node device not found
-            /// </summary>
-            VIR_ERR_NO_NODE_DEVICE = 53,
-            /// <summary>
-            /// Security model not found
-            /// </summary>
-            VIR_ERR_NO_SECURITY_MODEL = 54,
-            /// <summary>
-            /// Operation is not applicable at this time
-            /// </summary>
-            VIR_ERR_OPERATION_INVALID = 55,
-            /// <summary>
-            /// Failed to start interface driver
-            /// </summary>
-            VIR_WAR_NO_INTERFACE = 56,
-            /// <summary>
-            /// Interface driver not running
-            /// </summary>
-            VIR_ERR_NO_INTERFACE = 57,
-            /// <summary>
-            /// Invalid interface object
-            /// </summary>
-            VIR_ERR_INVALID_INTERFACE = 58,
-            /// <summary>
-            /// More than one matching interface found
-            /// </summary>
-            VIR_ERR_MULTIPLE_INTERFACES = 59,
-            /// <summary>
-            /// Failed to start secret storage
-            /// </summary>
-            VIR_WAR_NO_SECRET = 60,
-            /// <summary>
-            /// Invalid secret
-            /// </summary>
-            VIR_ERR_INVALID_SECRET = 61,
-            /// <summary>
-            /// Secret not found
-            /// </summary>
-            VIR_ERR_NO_SECRET = 62,
-            /// <summary>
-            /// Unsupported configuration construct
-            /// </summary>
-            VIR_ERR_CONFIG_UNSUPPORTED = 63,
-            /// <summary>
-            /// Timeout occurred during operation
-            /// </summary>
-            VIR_ERR_OPERATION_TIMEOUT = 64,
-            /// <summary>
-            /// A migration worked, but making the VM persist on the dest host failed
-            /// </summary>
-            VIR_ERR_MIGRATE_PERSIST_FAILED = 65,
-        }
-
-        /// <summary>
-        /// Enumrate types of domain errors
-        /// </summary>
-        public enum virErrorDomain
-        {
-            /// <summary>
-            /// None
-            /// </summary>
-            VIR_FROM_NONE = 0,
-            /// <summary>
-            /// Error at Xen hypervisor layer
-            /// </summary>
-            VIR_FROM_XEN = 1,
-            /// <summary>
-            /// Error at connection with xend daemon
-            /// </summary>
-            VIR_FROM_XEND = 2,
-            /// <summary>
-            /// Error at connection with xen store
-            /// </summary>
-            VIR_FROM_XENSTORE = 3,
-            /// <summary>
-            /// Error in the S-Expression code
-            /// </summary>
-            VIR_FROM_SEXPR = 4,
-            /// <summary>
-            /// Error in the XML code
-            /// </summary>
-            VIR_FROM_XML = 5,
-            /// <summary>
-            /// Error when operating on a domain
-            /// </summary>
-            VIR_FROM_DOM = 6,
-            /// <summary>
-            /// Error in the XML-RPC code
-            /// </summary>
-            VIR_FROM_RPC = 7,
-            /// <summary>
-            /// Error in the proxy code
-            /// </summary>
-            VIR_FROM_PROXY = 8,
-            /// <summary>
-            /// Error in the configuration file handling
-            /// </summary>
-            VIR_FROM_CONF = 9,
-            /// <summary>
-            /// Error at the QEMU daemon
-            /// </summary>
-            VIR_FROM_QEMU = 10,
-            /// <summary>
-            /// Error when operating on a network
-            /// </summary>
-            VIR_FROM_NET = 11,
-            /// <summary>
-            /// Error from test driver
-            /// </summary>
-            VIR_FROM_TEST = 12,
-            /// <summary>
-            /// Error from remote driver
-            /// </summary>
-            VIR_FROM_REMOTE = 13,
-            /// <summary>
-            /// Error from OpenVZ driver
-            /// </summary>
-            VIR_FROM_OPENVZ = 14,
-            /// <summary>
-            /// Error at Xen XM layer
-            /// </summary>
-            VIR_FROM_XENXM = 15,
-            /// <summary>
-            /// Error in the Linux Stats code
-            /// </summary>
-            VIR_FROM_STATS_LINUX = 16,
-            /// <summary>
-            /// Error from Linux Container driver
-            /// </summary>
-            VIR_FROM_LXC = 17,
-            /// <summary>
-            /// Error from storage driver
-            /// </summary>
-            VIR_FROM_STORAGE = 18,
-            /// <summary>
-            /// Error from network config
-            /// </summary>
-            VIR_FROM_NETWORK = 19,
-            /// <summary>
-            /// Error from domain config
-            /// </summary>
-            VIR_FROM_DOMAIN = 20,
-            /// <summary>
-            /// Error at the UML driver
-            /// </summary>
-            VIR_FROM_UML = 21,
-            /// <summary>
-            /// Error from node device monitor
-            /// </summary>
-            VIR_FROM_NODEDEV = 22,
-            /// <summary>
-            /// Error from xen inotify layer
-            /// </summary>
-            VIR_FROM_XEN_INOTIFY = 23,
-            /// <summary>
-            /// Error from security framework
-            /// </summary>
-            VIR_FROM_SECURITY = 24,
-            /// <summary>
-            /// Error from VirtualBox driver
-            /// </summary>
-            VIR_FROM_VBOX = 25,
-            /// <summary>
-            /// Error when operating on an interface
-            /// </summary>
-            VIR_FROM_INTERFACE = 26,
-            /// <summary>
-            /// Error from OpenNebula driver
-            /// </summary>
-            VIR_FROM_ONE = 27,
-            /// <summary>
-            /// Error from ESX driver
-            /// </summary>
-            VIR_FROM_ESX = 28,
-            /// <summary>
-            /// Error from IBM power hypervisor
-            /// </summary>
-            VIR_FROM_PHYP = 29,
-            /// <summary>
-            /// Error from secret storage
-            /// </summary>
-            VIR_FROM_SECRET = 30,
-            /// <summary>
-            /// Error from CPU driver
-            /// </summary>
-            VIR_FROM_CPU = 31,
-            /// <summary>
-            /// Error from XenAPI
-            /// </summary>
-            VIR_FROM_XENAPI	 =	32,
-            /// <summary>
-            /// Error from network filter driver
-            /// </summary>
-            VIR_FROM_NWFILTER	 =	33,
-            /// <summary>
-            /// Error from Synchronous hooks
-            /// </summary>
-            VIR_FROM_HOOK	 =	34,
-            /// <summary>
-            /// Error from domain snapshot
-            /// </summary>
-            VIR_FROM_DOMAIN_SNAPSHOT =	35
-        }
-
-        /// <summary>
-        /// Enumerate the error levels
-        /// </summary>
-        public enum virErrorLevel
-        {
-            /// <summary>
-            /// No error
-            /// </summary>
-            VIR_ERR_NONE = 0,
-            /// <summary>
-            /// A simple warning.
-            /// </summary>
-            VIR_ERR_WARNING = 1,
-            /// <summary>
-            /// An error.
-            /// </summary>
-            VIR_ERR_ERROR = 2,
-        }
-
-        /// <summary>
-        /// the virError object
-        /// </summary>
-        [StructLayout(LayoutKind.Sequential)]
-        public class virError
-        {
-            /// <summary>
-            /// The error code, a virErrorNumber.
-            /// </summary>
-            [MarshalAs(UnmanagedType.I4)]
-            public virErrorNumber code;
-            /// <summary>
-            /// What part of the library raised this error.
-            /// </summary>
-            [MarshalAs(UnmanagedType.I4)]
-            public int domain;
-            /// <summary>
-            /// Human-readable informative error message.
-            /// </summary>
-            [MarshalAs(UnmanagedType.SysInt)]
-#pragma warning disable 649
-            private IntPtr message;
-#pragma warning restore 649
-            /// <summary>
-            /// Human-readable informative error message.
-            /// </summary>
-// ReSharper disable InconsistentNaming
-            public string Message
-// ReSharper restore InconsistentNaming
-            {
-                get { return Marshal.PtrToStringAnsi(message); }
-            }
-
-            /// <summary>
-            /// How consequent is the error.
-            /// </summary>
-            [MarshalAs(UnmanagedType.I4)]
-            public virErrorLevel level;
-            /// <summary>
-            /// Connection if available, deprecated see note above.
-            /// </summary>
-            [MarshalAs(UnmanagedType.SysInt)]
-            public IntPtr conn;
-            /// <summary>
-            /// Domain if available, deprecated see note above.
-            /// </summary>
-            [MarshalAs(UnmanagedType.SysInt)]
-            public IntPtr dom;
-            /// <summary>
-            /// Extra string information.
-            /// </summary>
-            [MarshalAs(UnmanagedType.SysInt)]
-#pragma warning disable 649
-            private IntPtr str1;
-#pragma warning restore 649
-            /// <summary>
-            /// Extra string information.
-            /// </summary>
-// ReSharper disable InconsistentNaming
-            public string Str1 { get { return Marshal.PtrToStringAnsi(str1); } }
-// ReSharper restore InconsistentNaming
-            /// <summary>
-            /// Extra string information.
-            /// </summary>
-            [MarshalAs(UnmanagedType.SysInt)]
-#pragma warning disable 649
-            private IntPtr str2;
-#pragma warning restore 649
-            /// <summary>
-            /// Extra string information.
-            /// </summary>
-// ReSharper disable InconsistentNaming
-            public string Str2 { get { return Marshal.PtrToStringAnsi(str2); } }
-// ReSharper restore InconsistentNaming
-            /// <summary>
-            /// Extra string information.
-            /// </summary>
-            [MarshalAs(UnmanagedType.SysInt)]
-#pragma warning disable 649
-            private IntPtr str3;
-#pragma warning restore 649
-            /// <summary>
-            /// Extra string information.
-            /// </summary>
-// ReSharper disable InconsistentNaming
-            public string Str3 { get { return Marshal.PtrToStringAnsi(str3); } }
-// ReSharper restore InconsistentNaming
-            /// <summary>
-            /// Extra number information.
-            /// </summary>
-            [MarshalAs(UnmanagedType.I4)]
-            public int int1;
-            /// <summary>
-            /// Extra number information.
-            /// </summary>
-            [MarshalAs(UnmanagedType.I4)]
-            public int int2;
-            /// <summary>
-            /// Network if available, deprecated see note above.
-            /// </summary>     
-            [MarshalAs(UnmanagedType.SysInt)]
-            public IntPtr net;
-        }
-
-
-        // virConnCopyLastError - Deprecated
-        // virConnGetLastError - Deprecated
-
-        /// <summary>
-        /// The error object is kept in thread local storage, so separate threads can safely access this concurrently. 
-        /// Reset the last error caught on that connection.
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/> pointer to the hypervisor connection.
-        /// </param>
-        [DllImport("libvirt-0.dll")]
-        public static extern void virConnResetLastError(IntPtr conn);
-
-        /// <summary>
-        /// Set a connection error handling function, if @handler is NULL it will reset to default 
-        /// which is to pass error back to the global library handler.
-        /// </summary>
-        /// <param name="conn">
-        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
-        /// </param>
-        /// <param name="userData">
-        /// A <see cref="IntPtr"/>pointer to the user data provided in the handler callback.
-        /// </param>
-        /// <param name="handler">
-        /// A <see cref="virErrorFunc"/>function to get called in case of error or NULL
-        /// </param>
-        [DllImport("libvirt-0.dll")]
-        public static extern void virConnSetErrorFunc(IntPtr conn, IntPtr userData, [MarshalAs(UnmanagedType.FunctionPtr)]virErrorFunc handler);
-
-        /// <summary>
-        /// Copy the content of the last error caught at the library level. 
-        /// The error object is kept in thread local storage, so separate threads can safely access this concurrently. 
-        /// One will need to free the result with virResetError().
-        /// </summary>
-        /// <param name="to">
-        /// A <see cref="virError"/> target to receive the copy.
-        /// </param>
-        /// <returns>
-        /// 0 if no error was found and the error code otherwise and -1 in case of parameter error.
-        /// </returns>
-        [DllImport("libvirt-0.dll")]
-        public static extern int virCopyLastError([Out] virError to);
-
-        /// <summary>
-        /// Default routine reporting an error to stderr.
-        /// </summary>
-        /// <param name="err">
-        /// A <see cref="virError"/> pointer to the error.
-        /// </param>
-        [DllImport("libvirt-0.dll")]
-        public static extern void virDefaultErrorFunc([In] virError err);
-
-        /// <summary>
-        /// Resets and frees the given error.
-        /// </summary>
-        /// <param name="err">
-        /// A <see cref="virError"/> error to free.
-        /// </param>
-        [DllImport("libvirt-0.dll")]
-        public static extern void virFreeError(virError err); // Does not work, anybody know why?
-
-        /// <summary>
-        /// Provide a pointer to the last error caught at the library level. 
-        /// The error object is kept in thread local storage, so separate threads can safely access this concurrently.
-        /// </summary>
-        /// <returns>
-        /// A pointer to the last error or NULL if none occurred.
-        /// </returns>
-        [DllImport("libvirt-0.dll")]
-        public static extern int virGetLastError();
-
-        /// <summary>
-        /// Reset the error being pointed to.
-        /// </summary>
-        /// <param name="err">
-        /// A <see cref="virError"/> pointer to the to clean up.
-        /// </param>
-        [DllImport("libvirt-0.dll")]
-        public static extern void virResetError(virError err);
-
-        /// <summary>
-        /// Reset the last error caught at the library level. The error object is kept in thread local storage, 
-        /// so separate threads can safely access this concurrently, only resetting their own error object.
-        /// </summary>
-        [DllImport("libvirt-0.dll")]
-        public static extern void virResetLastError();
-
-        /// <summary>
-        /// Save the last error into a new error object.
-        /// </summary>
-        /// <returns>
-        /// A <see cref="virError"/> pointer to the copied error or NULL if allocation failed. 
-        /// It is the caller's responsibility to free the error with virFreeError().
-        /// </returns>
-        [DllImport("libvirt-0.dll")]
-        public static extern virError virSaveLastError();
-
-        /// <summary>
-        /// Set a library global error handling function, if @handler is NULL, it will reset to default printing on stderr. 
-        /// The error raised there are those for which no handler at the connection level could caught.
-        /// </summary>
-        /// <param name="userData">
-        /// A <see cref="IntPtr"/>pointer to the user data provided in the handler callback.
-        /// </param>
-        /// <param name="handler">
-        /// A <see cref="virErrorFunc"/>function to get called in case of error or NULL.
-        /// </param>
-        [DllImport("libvirt-0.dll")]
-        public static extern void virSetErrorFunc(IntPtr userData, [MarshalAs(UnmanagedType.FunctionPtr)]virErrorFunc handler);
-    }
-}
+﻿/*
+ * Copyright (C)
+ *   Arnaud Champion <arnaud.champion@devatom.fr>
+ *   Jaromír Červenka <cervajz@cervajz.com>
+ *
+ * See COPYING.LIB for the License of this software
+ */
+
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace LibvirtBindings
+{
+    ///<summary>
+    /// class for libvirt errors binding
+    ///</summary>
+    public class libvirtError
+    {
+        /// <summary>
+        /// The error object is kept in thread local storage, so separate threads can safely access this concurrently. 
+        /// Reset the last error caught on that connection.
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/> pointer to the hypervisor connection.
+        /// </param>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnResetLastError")]
+        public static extern void virConnResetLastError(IntPtr conn);
+
+        /// <summary>
+        /// Set a connection error handling function, if @handler is NULL it will reset to default 
+        /// which is to pass error back to the global library handler.
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
+        /// </param>
+        /// <param name="userData">
+        /// A <see cref="IntPtr"/>pointer to the user data provided in the handler callback.
+        /// </param>
+        /// <param name="handler">
+        /// A <see cref="virErrorFunc"/>function to get called in case of error or NULL
+        /// </param>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnSetErrorFunc")]
+        public static extern void virConnSetErrorFunc(IntPtr conn, IntPtr userData, [MarshalAs(UnmanagedType.FunctionPtr)]virErrorFunc handler);
+
+        /// <summary>
+        /// Copy the content of the last error caught at the library level. 
+        /// The error object is kept in thread local storage, so separate threads can safely access this concurrently. 
+        /// One will need to free the result with virResetError().
+        /// </summary>
+        /// <param name="to">
+        /// A <see cref="virError"/> target to receive the copy.
+        /// </param>
+        /// <returns>
+        /// 0 if no error was found and the error code otherwise and -1 in case of parameter error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virCopyLastError")]
+        public static extern int virCopyLastError([Out] virError to);
+
+        /// <summary>
+        /// Default routine reporting an error to stderr.
+        /// </summary>
+        /// <param name="err">
+        /// A <see cref="virError"/> pointer to the error.
+        /// </param>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDefaultErrorFunc")]
+        public static extern void virDefaultErrorFunc([In] virError err);
+
+        /// <summary>
+        /// Resets and frees the given error.
+        /// </summary>
+        /// <param name="err">
+        /// A <see cref="virError"/> error to free.
+        /// </param>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virFreeError")]
+        public static extern void virFreeError(virError err); // Does not work, anybody know why?
+
+        /// <summary>
+        /// Provide a pointer to the last error caught at the library level. 
+        /// The error object is kept in thread local storage, so separate threads can safely access this concurrently.
+        /// </summary>
+        /// <returns>
+        /// A pointer to the last error or NULL if none occurred.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virGetLastError")]
+        public static extern int virGetLastError();
+
+        /// <summary>
+        /// Reset the error being pointed to.
+        /// </summary>
+        /// <param name="err">
+        /// A <see cref="virError"/> pointer to the to clean up.
+        /// </param>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virResetError")]
+        public static extern void virResetError(virError err);
+
+        /// <summary>
+        /// Reset the last error caught at the library level. The error object is kept in thread local storage, 
+        /// so separate threads can safely access this concurrently, only resetting their own error object.
+        /// </summary>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virResetLastError")]
+        public static extern void virResetLastError();
+
+        /// <summary>
+        /// Save the last error into a new error object.
+        /// </summary>
+        /// <returns>
+        /// A <see cref="virError"/> pointer to the copied error or NULL if allocation failed. 
+        /// It is the caller's responsibility to free the error with virFreeError().
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virSaveLastError")]
+        public static extern virError virSaveLastError();
+
+        /// <summary>
+        /// Set a library global error handling function, if @handler is NULL, it will reset to default printing on stderr. 
+        /// The error raised there are those for which no handler at the connection level could caught.
+        /// </summary>
+        /// <param name="userData">
+        /// A <see cref="IntPtr"/>pointer to the user data provided in the handler callback.
+        /// </param>
+        /// <param name="handler">
+        /// A <see cref="virErrorFunc"/>function to get called in case of error or NULL.
+        /// </param>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virSetErrorFunc")]
+        public static extern void virSetErrorFunc(IntPtr userData, [MarshalAs(UnmanagedType.FunctionPtr)]virErrorFunc handler);
+    }
+}
diff --git a/LibvirtTypes.cs b/LibvirtTypes.cs
index de307dc..fa776e9 100644
--- a/LibvirtTypes.cs
+++ b/LibvirtTypes.cs
@@ -16,6 +16,22 @@ namespace LibvirtBindings
 
     #region delegates
     ///<summary>
+    /// Signature of a function to use when there is an error raised by the library.
+    ///</summary>
+    ///<param name="userData">user provided data for the error callback</param>
+    ///<param name="error">the error being raised.</param>
+    public delegate void virErrorFunc(IntPtr userData, virError error);
+    /// <summary>
+    /// A callback function to be registered, and called when a domain event occurs
+    /// </summary>
+    /// <param name="conn">virConnect connection </param>
+    /// <param name="dom">The domain on which the event occured</param>
+    /// <param name="evt">The specfic virDomainEventType which occured</param>
+    /// <param name="detail">event specific detail information</param>
+    /// <param name="opaque">opaque user data</param>
+    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+    public delegate void virConnectDomainEventCallback(IntPtr conn, IntPtr dom, virDomainEventType evt, int detail, IntPtr opaque);
+    ///<summary>
     /// Callback for receiving file handle events. The callback will be invoked once for each event which is pending.
     ///</summary>
     ///<param name="watch">watch on which the event occurred</param>
@@ -96,6 +112,94 @@ namespace LibvirtBindings
     #endregion
 
     #region structs
+    /// <summary>
+    /// the virError object
+    /// </summary>
+    [StructLayout(LayoutKind.Sequential)]
+    public class virError
+    {
+        /// <summary>
+        /// The error code, a virErrorNumber.
+        /// </summary>
+        [MarshalAs(UnmanagedType.I4)]
+        public virErrorNumber code;
+        /// <summary>
+        /// What part of the library raised this error.
+        /// </summary>
+        [MarshalAs(UnmanagedType.I4)]
+        public int domain;
+        /// <summary>
+        /// Human-readable informative error message.
+        /// </summary>
+        [MarshalAs(UnmanagedType.SysInt)]
+        private IntPtr message;
+        /// <summary>
+        /// Human-readable informative error message.
+        /// </summary>
+        public string Message
+        {
+            get { return Marshal.PtrToStringAnsi(message); }
+        }
+
+        /// <summary>
+        /// How consequent is the error.
+        /// </summary>
+        [MarshalAs(UnmanagedType.I4)]
+        public virErrorLevel level;
+        /// <summary>
+        /// Connection if available, deprecated see note above.
+        /// </summary>
+        [MarshalAs(UnmanagedType.SysInt)]
+        public IntPtr conn;
+        /// <summary>
+        /// Domain if available, deprecated see note above.
+        /// </summary>
+        [MarshalAs(UnmanagedType.SysInt)]
+        public IntPtr dom;
+        /// <summary>
+        /// Extra string information.
+        /// </summary>
+        [MarshalAs(UnmanagedType.SysInt)]
+        private IntPtr str1;
+        /// <summary>
+        /// Extra string information.
+        /// </summary>
+        public string Str1 { get { return Marshal.PtrToStringAnsi(str1); } }
+        /// <summary>
+        /// Extra string information.
+        /// </summary>
+        [MarshalAs(UnmanagedType.SysInt)]
+        private IntPtr str2;
+        /// <summary>
+        /// Extra string information.
+        /// </summary>
+        public string Str2 { get { return Marshal.PtrToStringAnsi(str2); } }
+        /// <summary>
+        /// Extra string information.
+        /// </summary>
+        [MarshalAs(UnmanagedType.SysInt)]
+        private IntPtr str3;
+        /// <summary>
+        /// Extra string information.
+        /// </summary>
+        public string Str3 { get { return Marshal.PtrToStringAnsi(str3); } }
+        /// <summary>
+        /// Extra number information.
+        /// </summary>
+        [MarshalAs(UnmanagedType.I4)]
+        public int int1;
+        /// <summary>
+        /// Extra number information.
+        /// </summary>
+        [MarshalAs(UnmanagedType.I4)]
+        public int int2;
+        /// <summary>
+        /// Network if available, deprecated see note above.
+        /// </summary>     
+        [MarshalAs(UnmanagedType.SysInt)]
+        public IntPtr net;
+    }
+
     ///<summary>
     /// Blocks domain statistics
     ///</summary>
@@ -310,7 +414,7 @@ namespace LibvirtBindings
             }
             set
             {
-                result = libVirt.StrDup(Marshal.StringToHGlobalAnsi(value));
+                result = NativeFunctions.StrDup(Marshal.StringToHGlobalAnsi(value));
             }
         }
     }
@@ -454,6 +558,446 @@ namespace LibvirtBindings
 
     #region enums
     ///<summary>
+    /// Enumerate errors
+    ///</summary>
+    public enum virErrorNumber
+    {
+        /// <summary>
+        /// No error
+        /// </summary>
+        VIR_ERR_OK = 0,
+        /// <summary>
+        /// Internal error
+        /// </summary>
+        VIR_ERR_INTERNAL_ERROR = 1,
+        /// <summary>
+        /// Memory allocation failure
+        /// </summary>
+        VIR_ERR_NO_MEMORY = 2,
+        /// <summary>
+        /// No support for this function
+        /// </summary>
+        VIR_ERR_NO_SUPPORT = 3,
+        /// <summary>
+        /// Could not resolve hostname
+        /// </summary>
+        VIR_ERR_UNKNOWN_HOST = 4,
+        /// <summary>
+        /// Can't connect to hypervisor
+        /// </summary>
+        VIR_ERR_NO_CONNECT = 5,
+        /// <summary>
+        /// Invalid connection object
+        /// </summary>
+        VIR_ERR_INVALID_CONN = 6,
+        /// <summary>
+        /// Invalid domain object
+        /// </summary>
+        VIR_ERR_INVALID_DOMAIN = 7,
+        /// <summary>
+        /// Invalid function argument
+        /// </summary>
+        VIR_ERR_INVALID_ARG = 8,
+        /// <summary>
+        ///  A command to hypervisor failed
+        /// </summary>
+        VIR_ERR_OPERATION_FAILED = 9,
+        /// <summary>
+        /// A HTTP GET command to failed
+        /// </summary>
+        VIR_ERR_GET_FAILED = 10,
+        /// <summary>
+        /// A HTTP POST command to failed
+        /// </summary>
+        VIR_ERR_POST_FAILED = 11,
+        /// <summary>
+        /// Unexpected HTTP error code
+        /// </summary>
+        VIR_ERR_HTTP_ERROR = 12,
+        /// <summary>
+        /// Failure to serialize an S-Expr
+        /// </summary>
+        VIR_ERR_SEXPR_SERIAL = 13,
+        /// <summary>
+        /// Could not open Xen hypervisor control
+        /// </summary>
+        VIR_ERR_NO_XEN = 14,
+        /// <summary>
+        /// Failure doing an hypervisor call
+        /// </summary>
+        VIR_ERR_XEN_CALL = 15,
+        /// <summary>
+        /// Unknown OS type
+        /// </summary>
+        VIR_ERR_OS_TYPE = 16,
+        /// <summary>
+        /// Missing kernel information
+        /// </summary>
+        VIR_ERR_NO_KERNEL = 17,
+        /// <summary>
+        /// Missing root device information
+        /// </summary>
+        VIR_ERR_NO_ROOT = 18,
+        /// <summary>
+        /// Missing source device information
+        /// </summary>
+        VIR_ERR_NO_SOURCE = 19,
+        /// <summary>
+        /// Missing target device information
+        /// </summary>
+        VIR_ERR_NO_TARGET = 20,
+        /// <summary>
+        /// Missing domain name information
+        /// </summary>
+        VIR_ERR_NO_NAME = 21,
+        /// <summary>
+        /// Missing domain OS information
+        /// </summary>
+        VIR_ERR_NO_OS = 22,
+        /// <summary>
+        /// Missing domain devices information
+        /// </summary>
+        VIR_ERR_NO_DEVICE = 23,
+        /// <summary>
+        /// Could not open Xen Store control
+        /// </summary>
+        VIR_ERR_NO_XENSTORE = 24,
+        /// <summary>
+        /// Too many drivers registered
+        /// </summary>
+        VIR_ERR_DRIVER_FULL = 25,
+        /// <summary>
+        /// Not supported by the drivers (DEPRECATED)
+        /// </summary>
+        VIR_ERR_CALL_FAILED = 26,
+        /// <summary>
+        /// An XML description is not well formed or broken
+        /// </summary>
+        VIR_ERR_XML_ERROR = 27,
+        /// <summary>
+        /// The domain already exist
+        /// </summary>
+        VIR_ERR_DOM_EXIST = 28,
+        /// <summary>
+        /// Operation forbidden on read-only connections
+        /// </summary>
+        VIR_ERR_OPERATION_DENIED = 29,
+        /// <summary>
+        /// Failed to open a conf file
+        /// </summary>
+        VIR_ERR_OPEN_FAILED = 30,
+        /// <summary>
+        /// Failed to read a conf file
+        /// </summary>
+        VIR_ERR_READ_FAILED = 31,
+        /// <summary>
+        /// Failed to parse a conf file
+        /// </summary>
+        VIR_ERR_PARSE_FAILED = 32,
+        /// <summary>
+        /// Failed to parse the syntax of a conf file
+        /// </summary>
+        VIR_ERR_CONF_SYNTAX = 33,
+        /// <summary>
+        /// Failed to write a conf file
+        /// </summary>
+        VIR_ERR_WRITE_FAILED = 34,
+        /// <summary>
+        /// Detail of an XML error
+        /// </summary>
+        VIR_ERR_XML_DETAIL = 35,
+        /// <summary>
+        /// Invalid network object
+        /// </summary>
+        VIR_ERR_INVALID_NETWORK = 36,
+        /// <summary>
+        /// The network already exist
+        /// </summary>
+        VIR_ERR_NETWORK_EXIST = 37,
+        /// <summary>
+        /// General system call failure
+        /// </summary>
+        VIR_ERR_SYSTEM_ERROR = 38,
+        /// <summary>
+        /// Some sort of RPC error
+        /// </summary>
+        VIR_ERR_RPC = 39,
+        /// <summary>
+        /// Error from a GNUTLS call
+        /// </summary>
+        VIR_ERR_GNUTLS_ERROR = 40,
+        /// <summary>
+        /// Failed to start network
+        /// </summary>
+        VIR_WAR_NO_NETWORK = 41,
+        /// <summary>
+        /// Domain not found or unexpectedly disappeared
+        /// </summary>
+        VIR_ERR_NO_DOMAIN = 42,
+        /// <summary>
+        /// Network not found
+        /// </summary>
+        VIR_ERR_NO_NETWORK = 43,
+        /// <summary>
+        /// Invalid MAC address
+        /// </summary>
+        VIR_ERR_INVALID_MAC = 44,
+        /// <summary>
+        /// Authentication failed
+        /// </summary>
+        VIR_ERR_AUTH_FAILED = 45,
+        /// <summary>
+        /// Invalid storage pool object
+        /// </summary>
+        VIR_ERR_INVALID_STORAGE_POOL = 46,
+        /// <summary>
+        /// Invalid storage vol object
+        /// </summary>
+        VIR_ERR_INVALID_STORAGE_VOL = 47,
+        /// <summary>
+        /// Failed to start storage
+        /// </summary>
+        VIR_WAR_NO_STORAGE = 48,
+        /// <summary>
+        /// Storage pool not found
+        /// </summary>
+        VIR_ERR_NO_STORAGE_POOL = 49,
+        /// <summary>
+        /// Storage pool not found
+        /// </summary>
+        VIR_ERR_NO_STORAGE_VOL = 50,
+        /// <summary>
+        /// Failed to start node driver
+        /// </summary>
+        VIR_WAR_NO_NODE = 51,
+        /// <summary>
+        /// Invalid node device object
+        /// </summary>
+        VIR_ERR_INVALID_NODE_DEVICE = 52,
+        /// <summary>
+        /// Node device not found
+        /// </summary>
+        VIR_ERR_NO_NODE_DEVICE = 53,
+        /// <summary>
+        /// Security model not found
+        /// </summary>
+        VIR_ERR_NO_SECURITY_MODEL = 54,
+        /// <summary>
+        /// Operation is not applicable at this time
+        /// </summary>
+        VIR_ERR_OPERATION_INVALID = 55,
+        /// <summary>
+        /// Failed to start interface driver
+        /// </summary>
+        VIR_WAR_NO_INTERFACE = 56,
+        /// <summary>
+        /// Interface driver not running
+        /// </summary>
+        VIR_ERR_NO_INTERFACE = 57,
+        /// <summary>
+        /// Invalid interface object
+        /// </summary>
+        VIR_ERR_INVALID_INTERFACE = 58,
+        /// <summary>
+        /// More than one matching interface found
+        /// </summary>
+        VIR_ERR_MULTIPLE_INTERFACES = 59,
+        /// <summary>
+        /// Failed to start secret storage
+        /// </summary>
+        VIR_WAR_NO_SECRET = 60,
+        /// <summary>
+        /// Invalid secret
+        /// </summary>
+        VIR_ERR_INVALID_SECRET = 61,
+        /// <summary>
+        /// Secret not found
+        /// </summary>
+        VIR_ERR_NO_SECRET = 62,
+        /// <summary>
+        /// Unsupported configuration construct
+        /// </summary>
+        VIR_ERR_CONFIG_UNSUPPORTED = 63,
+        /// <summary>
+        /// Timeout occurred during operation
+        /// </summary>
+        VIR_ERR_OPERATION_TIMEOUT = 64,
+        /// <summary>
+        /// A migration worked, but making the VM persist on the dest host failed
+        /// </summary>
+        VIR_ERR_MIGRATE_PERSIST_FAILED = 65,
+    }
+
+    /// <summary>
+    /// Enumrate types of domain errors
+    /// </summary>
+    public enum virErrorDomain
+    {
+        /// <summary>
+        /// None
+        /// </summary>
+        VIR_FROM_NONE = 0,
+        /// <summary>
+        /// Error at Xen hypervisor layer
+        /// </summary>
+        VIR_FROM_XEN = 1,
+        /// <summary>
+        /// Error at connection with xend daemon
+        /// </summary>
+        VIR_FROM_XEND = 2,
+        /// <summary>
+        /// Error at connection with xen store
+        /// </summary>
+        VIR_FROM_XENSTORE = 3,
+        /// <summary>
+        /// Error in the S-Expression code
+        /// </summary>
+        VIR_FROM_SEXPR = 4,
+        /// <summary>
+        /// Error in the XML code
+        /// </summary>
+        VIR_FROM_XML = 5,
+        /// <summary>
+        /// Error when operating on a domain
+        /// </summary>
+        VIR_FROM_DOM = 6,
+        /// <summary>
+        /// Error in the XML-RPC code
+        /// </summary>
+        VIR_FROM_RPC = 7,
+        /// <summary>
+        /// Error in the proxy code
+        /// </summary>
+        VIR_FROM_PROXY = 8,
+        /// <summary>
+        /// Error in the configuration file handling
+        /// </summary>
+        VIR_FROM_CONF = 9,
+        /// <summary>
+        /// Error at the QEMU daemon
+        /// </summary>
+        VIR_FROM_QEMU = 10,
+        /// <summary>
+        /// Error when operating on a network
+        /// </summary>
+        VIR_FROM_NET = 11,
+        /// <summary>
+        /// Error from test driver
+        /// </summary>
+        VIR_FROM_TEST = 12,
+        /// <summary>
+        /// Error from remote driver
+        /// </summary>
+        VIR_FROM_REMOTE = 13,
+        /// <summary>
+        /// Error from OpenVZ driver
+        /// </summary>
+        VIR_FROM_OPENVZ = 14,
+        /// <summary>
+        /// Error at Xen XM layer
+        /// </summary>
+        VIR_FROM_XENXM = 15,
+        /// <summary>
+        /// Error in the Linux Stats code
+        /// </summary>
+        VIR_FROM_STATS_LINUX = 16,
+        /// <summary>
+        /// Error from Linux Container driver
+        /// </summary>
+        VIR_FROM_LXC = 17,
+        /// <summary>
+        /// Error from storage driver
+        /// </summary>
+        VIR_FROM_STORAGE = 18,
+        /// <summary>
+        /// Error from network config
+        /// </summary>
+        VIR_FROM_NETWORK = 19,
+        /// <summary>
+        /// Error from domain config
+        /// </summary>
+        VIR_FROM_DOMAIN = 20,
+        /// <summary>
+        /// Error at the UML driver
+        /// </summary>
+        VIR_FROM_UML = 21,
+        /// <summary>
+        /// Error from node device monitor
+        /// </summary>
+        VIR_FROM_NODEDEV = 22,
+        /// <summary>
+        /// Error from xen inotify layer
+        /// </summary>
+        VIR_FROM_XEN_INOTIFY = 23,
+        /// <summary>
+        /// Error from security framework
+        /// </summary>
+        VIR_FROM_SECURITY = 24,
+        /// <summary>
+        /// Error from VirtualBox driver
+        /// </summary>
+        VIR_FROM_VBOX = 25,
+        /// <summary>
+        /// Error when operating on an interface
+        /// </summary>
+        VIR_FROM_INTERFACE = 26,
+        /// <summary>
+        /// Error from OpenNebula driver
+        /// </summary>
+        VIR_FROM_ONE = 27,
+        /// <summary>
+        /// Error from ESX driver
+        /// </summary>
+        VIR_FROM_ESX = 28,
+        /// <summary>
+        /// Error from IBM power hypervisor
+        /// </summary>
+        VIR_FROM_PHYP = 29,
+        /// <summary>
+        /// Error from secret storage
+        /// </summary>
+        VIR_FROM_SECRET = 30,
+        /// <summary>
+        /// Error from CPU driver
+        /// </summary>
+        VIR_FROM_CPU = 31,
+        /// <summary>
+        /// Error from XenAPI
+        /// </summary>
+        VIR_FROM_XENAPI = 32,
+        /// <summary>
+        /// Error from network filter driver
+        /// </summary>
+        VIR_FROM_NWFILTER = 33,
+        /// <summary>
+        /// Error from Synchronous hooks
+        /// </summary>
+        VIR_FROM_HOOK = 34,
+        /// <summary>
+        /// Error from domain snapshot
+        /// </summary>
+        VIR_FROM_DOMAIN_SNAPSHOT = 35
+    }
+
+    /// <summary>
+    /// Enumerate the error levels
+    /// </summary>
+    public enum virErrorLevel
+    {
+        /// <summary>
+        /// No error
+        /// </summary>
+        VIR_ERR_NONE = 0,
+        /// <summary>
+        /// A simple warning.
+        /// </summary>
+        VIR_ERR_WARNING = 1,
+        /// <summary>
+        /// An error.
+        /// </summary>
+        VIR_ERR_ERROR = 2,
+    }
+    ///<summary>
     /// Type of handles for callback
     ///</summary>
     [Flags]
diff --git a/MarshalHelper.cs b/MarshalHelper.cs
new file mode 100644
index 0000000..61d486a
--- /dev/null
+++ b/MarshalHelper.cs
@@ -0,0 +1,36 @@
+﻿/*
+ * Copyright (C)
+ *   Arnaud Champion <arnaud.champion@devatom.fr>
+ *   Jaromír Červenka <cervajz@cervajz.com>
+ *
+ * See COPYING.LIB for the License of this software
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace LibvirtBindings
+{
+    public class MarshalHelper
+    {
+        public static string[] ptrToStringArray(IntPtr stringPtr, int stringCount)
+        {
+            string[] members = new string[stringCount];
+            for (int i = 0; i < stringCount; ++i)
+            {
+                IntPtr s = Marshal.ReadIntPtr(stringPtr, i * IntPtr.Size);
+                members[i] = Marshal.PtrToStringAnsi(s);
+            }
+            return members;
+        }
+
+        public static string ptrToString(IntPtr stringPtr)
+        {
+            IntPtr s = Marshal.ReadIntPtr(stringPtr, IntPtr.Size);
+            return Marshal.PtrToStringAnsi(s);
+        }
+    }
+}
diff --git a/NativeFunctions.cs b/NativeFunctions.cs
new file mode 100644
index 0000000..fc71647
--- /dev/null
+++ b/NativeFunctions.cs
@@ -0,0 +1,23 @@
+﻿/*
+ * Copyright (C)
+ *   Arnaud Champion <arnaud.champion@devatom.fr>
+ *   Jaromír Červenka <cervajz@cervajz.com>
+ *
+ * See COPYING.LIB for the License of this software
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace LibvirtBindings
+{
+    public class NativeFunctions
+    {
+        // TODO : this is atemporary workaround for virConnectOpenAuth callback, this should be removed
+        [DllImport("msvcrt.dll", EntryPoint = "_strdup", CallingConvention = CallingConvention.Cdecl)]
+        public static extern IntPtr StrDup(IntPtr strSource);
+    }
+}
diff --git a/StringWithoutNativeCleanUpMarshaler.cs b/StringWithoutNativeCleanUpMarshaler.cs
index 45cd447..28876fc 100644
--- a/StringWithoutNativeCleanUpMarshaler.cs
+++ b/StringWithoutNativeCleanUpMarshaler.cs
@@ -1,4 +1,12 @@
-﻿using System;
+﻿/*
+ * Copyright (C)
+ *   Arnaud Champion <arnaud.champion@devatom.fr>
+ *   Jaromír Červenka <cervajz@cervajz.com>
+ *
+ * See COPYING.LIB for the License of this software
+ */
+
+using System;
 using System.Runtime.InteropServices;
 
 namespace LibvirtBindings
diff --git a/examples/MonoDevelop/virConnectOpenAuth/MainWindow.cs b/examples/MonoDevelop/virConnectOpenAuth/MainWindow.cs
index fdbf318..c34c7db 100644
--- a/examples/MonoDevelop/virConnectOpenAuth/MainWindow.cs
+++ b/examples/MonoDevelop/virConnectOpenAuth/MainWindow.cs
@@ -47,14 +47,14 @@ public partial class MainWindow : Gtk.Window
         };
 		
 		// Request the connection
-        IntPtr conn = libVirt.virConnectOpenAuth(entry1.Text, ref auth, 0);
+        IntPtr conn = virConnect.OpenAuth(entry1.Text, ref auth, 0);
 		
 		if (conn != IntPtr.Zero)
         {
             // Get the number of defined (not running) domains
-            int numOfDefinedDomains = libVirt.virConnectNumOfDefinedDomains(conn);
+            int numOfDefinedDomains = virConnect.NumOfDefinedDomains(conn);
             string[] definedDomainNames = new string[numOfDefinedDomains];
-            if (libVirt.virConnectListDefinedDomains(conn, ref definedDomainNames, numOfDefinedDomains) == -1)
+            if (virConnect.ListDefinedDomains(conn, ref definedDomainNames, numOfDefinedDomains) == -1)
             {
 				ShowError("Unable to list defined domains");
                 return;
@@ -67,9 +67,9 @@ public partial class MainWindow : Gtk.Window
 			}
 			
             // Get the number of running domains
-            int numOfRunningDomain = libVirt.virConnectNumOfDomains(conn);
+            int numOfRunningDomain = virConnect.NumOfDomains(conn);
             int[] runningDomainIDs = new int[numOfRunningDomain];
-            if (libVirt.virConnectListDomains(conn, runningDomainIDs, numOfRunningDomain) == -1)
+            if (virConnect.ListDomains(conn, runningDomainIDs, numOfRunningDomain) == -1)
             {
                 ShowError("Unable to list running domains");
                 return;
@@ -78,13 +78,13 @@ public partial class MainWindow : Gtk.Window
             // Add the domain names to the listbox
             foreach (int runningDomainID in runningDomainIDs)
             {
-                IntPtr domainPtr = libVirt.virDomainLookupByID(conn, runningDomainID);
+                IntPtr domainPtr = virDomain.LookupByID(conn, runningDomainID);
                 if (domainPtr == IntPtr.Zero)
                 {
                     ShowError("Unable to lookup domains by id");
                     return;
                 }
-                string domainName = libVirt.virDomainGetName(domainPtr);
+                string domainName = virDomain.GetName(domainPtr);
                 if (string.IsNullOrEmpty(domainName))
                 {
                     ShowError("Unable to get domain name");
@@ -92,7 +92,7 @@ public partial class MainWindow : Gtk.Window
                 }
                 AddDomainInTreeView(domainName);
             }
-            libVirt.virConnectClose(conn);
+            virConnect.Close(conn);
         }
         else
         {
diff --git a/examples/VisualStudio/virConnectOpenAuth/Form1.cs b/examples/VisualStudio/virConnectOpenAuth/Form1.cs
index ce9a896..6ba9f5a 100644
--- a/examples/VisualStudio/virConnectOpenAuth/Form1.cs
+++ b/examples/VisualStudio/virConnectOpenAuth/Form1.cs
@@ -59,14 +59,14 @@ namespace virConnectOpenAuth
             };
 
             // Request the connection
-            IntPtr conn = libVirt.virConnectOpenAuth(tbURI.Text, ref auth, 0);
+            IntPtr conn = virConnect.OpenAuth(tbURI.Text, ref auth, 0);
 
             if (conn != IntPtr.Zero)
             {
                 // Get the number of defined (not running) domains
-                int numOfDefinedDomains = libVirt.virConnectNumOfDefinedDomains(conn);
+                int numOfDefinedDomains = virConnect.NumOfDefinedDomains(conn);
                 string[] definedDomainNames = new string[numOfDefinedDomains];
-                if (libVirt.virConnectListDefinedDomains(conn, ref definedDomainNames, numOfDefinedDomains) == -1)
+                if (virConnect.ListDefinedDomains(conn, ref definedDomainNames, numOfDefinedDomains) == -1)
                 {
                    MessageBox.Show("Unable to list defined domains", "List defined domains failed", MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
@@ -78,9 +78,9 @@ namespace virConnectOpenAuth
                     lbDomains.Items.Add(domainName);
 
                 // Get the number of running domains
-                int numOfRunningDomain = libVirt.virConnectNumOfDomains(conn);
+                int numOfRunningDomain = virConnect.NumOfDomains(conn);
                 int[] runningDomainIDs = new int[numOfRunningDomain];
-                if (libVirt.virConnectListDomains(conn, runningDomainIDs, numOfRunningDomain) == -1)
+                if (virConnect.ListDomains(conn, runningDomainIDs, numOfRunningDomain) == -1)
                 {
                     MessageBox.Show("Unable to list running domains", "List running domains failed", MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
@@ -90,14 +90,14 @@ namespace virConnectOpenAuth
                 // Add the domain names to the listbox
                 foreach (int runningDomainID in runningDomainIDs)
                 {
-                    IntPtr domainPtr = libVirt.virDomainLookupByID(conn, runningDomainID);
+                    IntPtr domainPtr = virDomain.LookupByID(conn, runningDomainID);
                     if (domainPtr == IntPtr.Zero)
                     {
                         MessageBox.Show("Unable to lookup domains by id", "Lookup domain failed", MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
                         return;
                     }
-                    string domainName = libVirt.virDomainGetName(domainPtr);
+                    string domainName = virDomain.GetName(domainPtr);
                     if (string.IsNullOrEmpty(domainName))
                     {
                         MessageBox.Show("Unable to get domain name", "Get domain name failed", MessageBoxButtons.OK,
@@ -106,7 +106,7 @@ namespace virConnectOpenAuth
                     }
                     lbDomains.Items.Add(domainName);
                 }
-                libVirt.virConnectClose(conn);
+                virConnect.Close(conn);
             }
             else
             {
diff --git a/projects/MonoDevelop/LibvirtBindings.csproj b/projects/MonoDevelop/LibvirtBindings.csproj
index 62d90e5..accacc8 100644
--- a/projects/MonoDevelop/LibvirtBindings.csproj
+++ b/projects/MonoDevelop/LibvirtBindings.csproj
@@ -34,9 +34,6 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="AssemblyInfo.cs" />
-    <Compile Include="..\..\Libvirt.cs">
-      <Link>Libvirt.cs</Link>
-    </Compile>
     <Compile Include="..\..\LibvirtError.cs">
       <Link>LibvirtError.cs</Link>
     </Compile>
@@ -46,6 +43,50 @@
     <Compile Include="..\..\StringWithoutNativeCleanUpMarshaler.cs">
       <Link>StringWithoutNativeCleanUpMarshaler.cs</Link>
     </Compile>
+    <Compile Include="..\..\MarshalHelper.cs">
+      <Link>MarshalHelper.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virConnect.cs">
+      <Link>virConnect.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virDomain.cs">
+      <Link>virDomain.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virEvent.cs">
+      <Link>virEvent.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virInterface.cs">
+      <Link>virInterface.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virLibrary.cs">
+      <Link>virLibrary.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virNetwork.cs">
+      <Link>virNetwork.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virNode.cs">
+      <Link>virNode.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virSecret.cs">
+      <Link>virSecret.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virStoragePool.cs">
+      <Link>virStoragePool.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virStorageVol.cs">
+      <Link>virStorageVol.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virStream.cs">
+      <Link>virStream.cs</Link>
+    </Compile>
+    <Compile Include="..\..\NativeFunctions.cs">
+      <Link>NativeFunctions.cs</Link>
+    </Compile>
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <ItemGroup>
+    <None Include="LibvirtBindings.dll.config">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+  </ItemGroup>
 </Project>
\ No newline at end of file
diff --git a/projects/MonoDevelop/LibvirtBindings.dll.config b/projects/MonoDevelop/LibvirtBindings.dll.config
new file mode 100644
index 0000000..d0ded4c
--- /dev/null
+++ b/projects/MonoDevelop/LibvirtBindings.dll.config
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+	<dllmap dll="libvirt-0.dll">
+		<dllentry os="windows" dll="libvirt-0.dll" />
+		<dllentry os="linux" dll="libvirt.so.0" />
+	</dllmap>
+	<dllmap dll="msvcrt.dll">
+		<dllentry os="windows" dll="msvcrt.dll" name="_strdup" target="_strdup" />
+		<dllentry os="linux" dll="libc.so.6" name="_strdup" target="strdup" />
+	</dllmap>
+</configuration>
diff --git a/projects/VisualStudio/LibvirtBindings.csproj b/projects/VisualStudio/LibvirtBindings.csproj
index 43990ba..bbb6ecd 100644
--- a/projects/VisualStudio/LibvirtBindings.csproj
+++ b/projects/VisualStudio/LibvirtBindings.csproj
@@ -21,6 +21,7 @@
     <DefineConstants>TRACE;DEBUG;WINDOWS</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
@@ -40,18 +41,54 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="..\..\Libvirt.cs">
-      <Link>Libvirt.cs</Link>
-    </Compile>
     <Compile Include="..\..\LibvirtError.cs">
       <Link>LibvirtError.cs</Link>
     </Compile>
     <Compile Include="..\..\LibvirtTypes.cs">
       <Link>LibvirtTypes.cs</Link>
     </Compile>
+    <Compile Include="..\..\MarshalHelper.cs">
+      <Link>MarshalHelper.cs</Link>
+    </Compile>
+    <Compile Include="..\..\NativeFunctions.cs">
+      <Link>NativeFunctions.cs</Link>
+    </Compile>
     <Compile Include="..\..\StringWithoutNativeCleanUpMarshaler.cs">
       <Link>StringWithoutNativeCleanUpMarshaler.cs</Link>
     </Compile>
+    <Compile Include="..\..\virConnect.cs">
+      <Link>virConnect.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virDomain.cs">
+      <Link>virDomain.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virEvent.cs">
+      <Link>virEvent.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virInterface.cs">
+      <Link>virInterface.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virLibrary.cs">
+      <Link>virLibrary.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virNetwork.cs">
+      <Link>virNetwork.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virNode.cs">
+      <Link>virNode.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virSecret.cs">
+      <Link>virSecret.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virStoragePool.cs">
+      <Link>virStoragePool.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virStorageVol.cs">
+      <Link>virStorageVol.cs</Link>
+    </Compile>
+    <Compile Include="..\..\virStream.cs">
+      <Link>virStream.cs</Link>
+    </Compile>
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
diff --git a/virConnect.cs b/virConnect.cs
new file mode 100644
index 0000000..9d3c715
--- /dev/null
+++ b/virConnect.cs
@@ -0,0 +1,411 @@
+﻿/*
+ * Copyright (C)
+ *   Arnaud Champion <arnaud.champion@devatom.fr>
+ *   Jaromír Červenka <cervajz@cervajz.com>
+ *
+ * See COPYING.LIB for the License of this software
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace LibvirtBindings
+{
+    public class virConnect
+    {
+        private const int MaxStringLength = 1024;
+
+        /// <summary>
+        /// This function closes the connection to the Hypervisor. This should not be called if further interaction with the Hypervisor are needed especially if there is running domain which need further monitoring by the application.
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <returns>0 in case of success or -1 in case of error.</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint="virConnectClose")]
+        public static extern int Close(IntPtr conn);
+        /// <summary>
+        /// Provides capabilities of the hypervisor / driver.
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <returns>NULL in case of error, or an XML string defining the capabilities. The client must free the returned string after use.</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectGetCapabilities")]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
+        public static extern string GetCapabilities(IntPtr conn);
+        /// <summary>
+        /// This returns the system hostname on which the hypervisor is running (the result of the gethostname system call). If we are connected to a remote system, then this returns the hostname of the remote system.
+        /// </summary>
+        /// <param name="conn">pointer to a hypervisor connection</param>
+        /// <returns>the hostname which must be freed by the caller, or NULL if there was an error.</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectGetHostname")]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
+        public static extern string GetHostname(IntPtr conn);
+        /// <summary>
+        /// Provides @libVer, which is the version of libvirt used by the daemon running on the @conn host
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="libVer">returns the libvirt library version used on the connection (OUT)</param>
+        /// <returns>-1 in case of failure, 0 otherwise, and values for @libVer have the format major * 1,000,000 + minor * 1,000 + release.</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectGetLibVersion")]
+        public static extern int GetLibVersion(IntPtr conn, ref ulong libVer);
+        /// <summary>
+        /// Provides the maximum number of virtual CPUs supported for a guest VM of a specific type. The 'type' parameter here corresponds to the 'type' attribute in the domain element of the XML.
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="type">value of the 'type' attribute in the domain element</param>
+        /// <returns>the maximum of virtual CPU or -1 in case of error.</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectGetMaxVcpus")]
+        public static extern int GetMaxVcpus(IntPtr conn, string type);
+        /// <summary>
+        /// Get the name of the Hypervisor software used.
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <returns>NULL in case of error, a static zero terminated string otherwise. See also: http://www.redhat.com/archives/libvir-list/2007-February/msg00096.html</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectGetType")]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
+        public static extern string GetType(IntPtr conn);
+        /// <summary>
+        /// This returns the Uri (name) of the hypervisor connection. Normally this is the same as or similar to the string passed to the virConnectOpen/virConnectOpenReadOnly call, but the driver may make the Uri canonical. If name == NULL was passed to virConnectOpen, then the driver will return a non-NULL Uri which can be used to connect to the same hypervisor later.
+        /// </summary>
+        /// <param name="conn">pointer to a hypervisor connection</param>
+        /// <returns>the Uri string which must be freed by the caller, or NULL if there was an error.</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectGetURI")]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
+        public static extern string GetURI(IntPtr conn);
+        /// <summary>
+        /// Get the version level of the Hypervisor running. This may work only with hypervisor call, i.e. with privileged access to the hypervisor, not with a Read-Only connection.
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="hvVer">return value for the version of the running hypervisor (OUT)</param>
+        /// <returns>-1 in case of error, 0 otherwise. if the version can't be extracted by lack of capacities returns 0 and @hvVer is 0, otherwise @hvVer value is major * 1,000,000 + minor * 1,000 + release</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectGetVersion")]
+        public static extern int GetVersion(IntPtr conn, ref ulong hvVer);
+        /// <summary>
+        /// Determine if the connection to the hypervisor is encrypted
+        /// </summary>
+        /// <param name="conn">pointer to the connection object</param>
+        /// <returns>1 if encrypted, 0 if not encrypted, -1 on error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectIsEncrypted")]
+        public static extern int IsEncrypted(IntPtr conn);
+        /// <summary>
+        /// Determine if the connection to the hypervisor is secure A connection will be classed as secure if it is either encrypted, or running over a channel which is not exposed to eavesdropping (eg a UNIX domain socket, or pipe)
+        /// </summary>
+        /// <param name="conn">pointer to the connection object</param>
+        /// <returns>1 if secure, 0 if secure, -1 on error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectIsSecure")]
+        public static extern int IsSecure(IntPtr conn);
+        /// <summary>
+        /// list the defined but inactive domains, stores the pointers to the names in @names
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="names">pointer to an array to store the names</param>
+        /// <param name="maxnames">size of the array</param>
+        /// <returns>the number of names provided in the array or -1 in case of error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectListDefinedDomains")]
+        private static extern int ListDefinedDomains(IntPtr conn, IntPtr names, int maxnames);
+        /// <summary>
+        /// list the defined but inactive domains, stores the pointers to the names in @names
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="names">pointer to an array to store the names</param>
+        /// <param name="maxnames">size of the array</param>
+        /// <returns>the number of names provided in the array or -1 in case of error</returns>
+        public static int ListDefinedDomains(IntPtr conn, ref string[] names, int maxnames)
+        {
+            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
+            int count = ListDefinedDomains(conn, namesPtr, maxnames);
+            if (count > 0)
+                names = MarshalHelper.ptrToStringArray(namesPtr, count);
+            Marshal.FreeHGlobal(namesPtr);
+            return count;
+        }
+        /// <summary>
+        /// Collect the list of defined (inactive) physical host interfaces, and store their names in @names.
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="names">array to collect the list of names of interfaces</param>
+        /// <param name="maxnames">size of @names</param>
+        /// <returns>the number of interfaces found or -1 in case of error </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectListDefinedInterfaces")]
+        private static extern int ListDefinedInterfaces(IntPtr conn, IntPtr names, int maxnames);
+        ///<summary>
+        /// Collect the list of defined (inactive) physical host interfaces, and store their names in @names.
+        ///</summary>
+        ///<param name="conn">pointer to the hypervisor connection</param>
+        ///<param name="names">array to collect the list of names of interfaces</param>
+        ///<param name="maxnames">size of @names</param>
+        ///<returns>the number of interfaces found or -1 in case of error </returns>
+        public static int ListDefinedInterfaces(IntPtr conn, ref string[] names, int maxnames)
+        {
+            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
+            int count = ListDefinedInterfaces(conn, namesPtr, maxnames);
+            if (count > 0)
+                names = MarshalHelper.ptrToStringArray(namesPtr, count);
+            Marshal.FreeHGlobal(namesPtr);
+            return count;
+        }
+        /// <summary>
+        /// list the inactive networks, stores the pointers to the names in @names
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="names">pointer to an array to store the names</param>
+        /// <param name="maxnames">size of the array</param>
+        /// <returns>the number of names provided in the array or -1 in case of error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectListDefinedNetworks")]
+        private static extern int ListDefinedNetworks(IntPtr conn, IntPtr names, int maxnames);
+        /// <summary>
+        /// list the inactive networks, stores the pointers to the names in @names
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="names">pointer to an array to store the names</param>
+        /// <param name="maxnames">size of the array</param>
+        /// <returns>the number of names provided in the array or -1 in case of error</returns>
+        public static int ListDefinedNetworks(IntPtr conn, ref string[] names, int maxnames)
+        {
+            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
+            int count = ListDefinedNetworks(conn, namesPtr, maxnames);
+            if (count > 0)
+                names = MarshalHelper.ptrToStringArray(namesPtr, count);
+            Marshal.FreeHGlobal(namesPtr);
+            return count;
+        }
+        /// <summary>
+        /// Provides the list of names of inactive storage pools upto maxnames. If there are more than maxnames, the remaining names will be silently ignored.
+        /// </summary>
+        /// <param name="conn">pointer to hypervisor connection</param>
+        /// <param name="names">array of char * to fill with pool names (allocated by caller)</param>
+        /// <param name="maxnames">size of the names array</param>
+        /// <returns>0 on success, -1 on error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectListDefinedStoragePools")]
+        private static extern int ListDefinedStoragePools(IntPtr conn, IntPtr names, int maxnames);
+        /// <summary>
+        /// Provides the list of names of inactive storage pools upto maxnames. If there are more than maxnames, the remaining names will be silently ignored.
+        /// </summary>
+        /// <param name="conn">pointer to hypervisor connection</param>
+        /// <param name="names">array of char * to fill with pool names (allocated by caller)</param>
+        /// <param name="maxnames">size of the names array</param>
+        /// <returns>0 on success, -1 on error</returns>
+        public static int ListDefinedStoragePools(IntPtr conn, ref string[] names, int maxnames)
+        {
+            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
+            int count = ListDefinedStoragePools(conn, namesPtr, maxnames);
+            if (count > 0)
+                names = MarshalHelper.ptrToStringArray(namesPtr, count);
+            Marshal.FreeHGlobal(namesPtr);
+            return count;
+        }
+        /// <summary>
+        /// Collect the list of active domains, and store their ID in @maxids
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="ids">array to collect the list of IDs of active domains</param>
+        /// <param name="maxids">size of @ids</param>
+        /// <returns>the number of domain found or -1 in case of error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectListDomains")]
+        public static extern int ListDomains(IntPtr conn, int[] ids, int maxids);
+        /// <summary>
+        /// Collect the list of active physical host interfaces, and store their names in @names
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="names">array to collect the list of names of interfaces</param>
+        /// <param name="maxnames">size of @names</param>
+        /// <returns>the number of interfaces found or -1 in case of error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectListInterfaces")]
+        private static extern int ListInterfaces(IntPtr conn, IntPtr names, int maxnames);
+        /// <summary>
+        /// Collect the list of active physical host interfaces, and store their names in @names
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="names">array to collect the list of names of interfaces</param>
+        /// <param name="maxnames">size of @names</param>
+        /// <returns>the number of interfaces found or -1 in case of error</returns>
+        public static int ListInterfaces(IntPtr conn, ref string[] names, int maxnames)
+        {
+            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
+            int count = ListInterfaces(conn, namesPtr, maxnames);
+            if (count > 0)
+                names = MarshalHelper.ptrToStringArray(namesPtr, count);
+            Marshal.FreeHGlobal(namesPtr);
+            return count;
+        }
+        /// <summary>
+        /// Collect the list of active networks, and store their names in @names
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="names">array to collect the list of names of active networks</param>
+        /// <param name="maxnames">size of @names</param>
+        /// <returns>the number of networks found or -1 in case of error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectListNetworks")]
+        private static extern int ListNetworks(IntPtr conn, IntPtr names, int maxnames);
+        /// <summary>
+        /// Collect the list of active networks, and store their names in @names
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="names">array to collect the list of names of active networks</param>
+        /// <param name="maxnames">size of @names</param>
+        /// <returns>the number of networks found or -1 in case of error</returns>
+        public static int ListNetworks(IntPtr conn, ref string[] names, int maxnames)
+        {
+            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
+            int count = ListNetworks(conn, namesPtr, maxnames);
+            if (count > 0)
+                names = MarshalHelper.ptrToStringArray(namesPtr, count);
+            Marshal.FreeHGlobal(namesPtr);
+            return count;
+        }
+        /// <summary>
+        /// List UUIDs of defined secrets, store pointers to names in uuids.
+        /// </summary>
+        /// <param name="conn">virConnect connection</param>
+        /// <param name="uuids">Pointer to an array to store the UUIDs</param>
+        /// <param name="maxuuids">size of the array.</param>
+        /// <returns>the number of UUIDs provided in the array, or -1 on failure.</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectListSecrets")]
+        private static extern int ListSecrets(IntPtr conn, IntPtr uuids, int maxuuids);
+        /// <summary>
+        /// List UUIDs of defined secrets, store pointers to names in uuids.
+        /// </summary>
+        /// <param name="conn">virConnect connection</param>
+        /// <param name="uuids">Pointer to an array to store the UUIDs</param>
+        /// <param name="maxuuids">size of the array.</param>
+        /// <returns>the number of UUIDs provided in the array, or -1 on failure.</returns>
+        public static int ListSecrets(IntPtr conn, ref string[] uuids, int maxuuids)
+        {
+            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
+            int count = ListSecrets(conn, namesPtr, maxuuids);
+            if (count > 0)
+                uuids = MarshalHelper.ptrToStringArray(namesPtr, count);
+            Marshal.FreeHGlobal(namesPtr);
+            return count;
+        }
+        /// <summary>
+        /// Provides the list of names of active storage pools upto maxnames. If there are more than maxnames, the remaining names will be silently ignored.
+        /// </summary>
+        /// <param name="conn">pointer to hypervisor connection</param>
+        /// <param name="names">array of char * to fill with pool names (allocated by caller)</param>
+        /// <param name="maxnames">size of the names array</param>
+        /// <returns>0 on success, -1 on error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectListStoragePools")]
+        private static extern int ListStoragePools(IntPtr conn, IntPtr names, int maxnames);
+        /// <summary>
+        /// Provides the list of names of active storage pools upto maxnames. If there are more than maxnames, the remaining names will be silently ignored.
+        /// </summary>
+        /// <param name="conn">pointer to hypervisor connection</param>
+        /// <param name="names">array of char * to fill with pool names (allocated by caller)</param>
+        /// <param name="maxnames">size of the names array</param>
+        /// <returns>0 on success, -1 on error</returns>
+        public static int ListStoragePools(IntPtr conn, ref string[] names, int maxnames)
+        {
+            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
+            int count = ListStoragePools(conn, namesPtr, maxnames);
+            if (count > 0)
+                names = MarshalHelper.ptrToStringArray(namesPtr, count);
+            Marshal.FreeHGlobal(namesPtr);
+            return count;
+        }
+        /// <summary>
+        /// Provides the number of defined but inactive domains.
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <returns>the number of domain found or -1 in case of error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectNumOfDefinedDomains")]
+        public static extern int NumOfDefinedDomains(IntPtr conn);
+        /// <summary>
+        /// Provides the number of defined (inactive) interfaces on the physical host.
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <returns>the number of defined interface found or -1 in case of error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectNumOfDefinedInterfaces")]
+        public static extern int NumOfDefinedInterfaces(IntPtr conn);
+        /// <summary>
+        /// Provides the number of inactive networks.
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <returns>the number of networks found or -1 in case of error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectNumOfDefinedNetworks")]
+        public static extern int NumOfDefinedNetworks(IntPtr conn);
+        /// <summary>
+        /// Provides the number of inactive storage pools
+        /// </summary>
+        /// <param name="conn">pointer to hypervisor connection</param>
+        /// <returns>the number of pools found, or -1 on error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectNumOfDefinedStoragePools")]
+        public static extern int NumOfDefinedStoragePools(IntPtr conn);
+        /// <summary>
+        /// Provides the number of active domains.
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <returns>the number of domain found or -1 in case of error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectNumOfDomains")]
+        public static extern int NumOfDomains(IntPtr conn);
+        /// <summary>
+        /// Provides the number of active interfaces on the physical host.
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <returns>the number of active interfaces found or -1 in case of error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectNumOfInterfaces")]
+        public static extern int NumOfInterfaces(IntPtr conn);
+        /// <summary>
+        /// Provides the number of active networks.
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <returns>the number of network found or -1 in case of error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectNumOfNetworks")]
+        public static extern int NumOfNetworks(IntPtr conn);
+        /// <summary>
+        /// Fetch number of currently defined secrets.
+        /// </summary>
+        /// <param name="conn">virConnect connection</param>
+        /// <returns>the number currently defined secrets.</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectNumOfSecrets")]
+        public static extern int NumOfSecrets(IntPtr conn);
+        /// <summary>
+        /// Provides the number of active storage pools
+        /// </summary>
+        /// <param name="conn">pointer to hypervisor connection</param>
+        /// <returns>the number of pools found, or -1 on error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectNumOfStoragePools")]
+        public static extern int NumOfStoragePools(IntPtr conn);
+        /// <summary>
+        /// This function should be called first to get a connection to the Hypervisor and xen store
+        /// </summary>
+        /// <param name="name">Uri of the hypervisor</param>
+        /// <returns>pointer to the connection</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectOpen")]
+        public static extern IntPtr Open(string name);
+
+        ///<summary>
+        /// This function should be called first to get a connection to the Hypervisor. If necessary, authentication will be performed fetching credentials via the callback See virConnectOpen for notes about environment variables which can have an effect on opening drivers
+        ///</summary>
+        ///<param name="name">URI of the hypervisor</param>
+        ///<param name="auth">Authenticate callback parameters</param>
+        ///<param name="flags">Open flags</param>
+        ///<returns>a pointer to the hypervisor connection or NULL in case of error URIs are documented at http://libvirt.org/uri.html </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectOpenAuth")]
+        public static extern IntPtr OpenAuth(string name, ref virConnectAuth auth, int flags);
+
+        /// <summary>
+        /// This function should be called first to get a restricted connection to the library functionalities. The set of APIs usable are then restricted on the available methods to control the domains. See virConnectOpen for notes about environment variables which can have an effect on opening drivers
+        /// </summary>
+        /// <param name="name">Uri of the hypervisor</param>
+        /// <returns>a pointer to the hypervisor connection or NULL in case of error URIs are documented at http://libvirt.org/uri.html </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectOpenReadOnly")]
+        public static extern IntPtr OpenReadOnly(string name);
+        /// <summary>
+        /// Increment the reference count on the connection. For each additional call to this method, there shall be a corresponding call to virConnectClose to release the reference count, once the caller no longer needs the reference to this object. This method is typically useful for applications where multiple threads are using a connection, and it is required that the connection remain open until all threads have finished using it. ie, each new thread using a connection would increment the reference count.
+        /// </summary>
+        /// <param name="conn">the connection to hold a reference on</param>
+        /// <returns>0 in case of success, -1 in case of failure</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectRef")]
+        public static extern int Ref(IntPtr conn);
+        /// <summary>
+        /// Adds a callback to receive notifications of domain lifecycle events occurring on a connection Use of this method is no longer recommended. Instead applications should try virConnectDomainEventRegisterAny which has a more flexible API contract The virDomainPtr object handle passed into the callback upon delivery of an event is only valid for the duration of execution of the callback. If the callback wishes to keep the domain object after the callback
+        /// </summary>
+        /// <param name="conn">pointer to the connection</param>
+        /// <param name="cb">callback to the function handling domain events</param>
+        /// <param name="opaque">opaque data to pass on to the callback</param>
+        /// <param name="ff">optional function to deallocate opaque when not used anymore</param>
+        /// <returns>t shall take a reference to it, by calling virDomainRef. The reference can be released once the object is no longer required by calling virDomainFree. Returns 0 on success, -1 on failure</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnectDomainEventRegister")]
+        public static extern int DomainEventRegister(IntPtr conn, [MarshalAs(UnmanagedType.FunctionPtr)] virConnectDomainEventCallback cb,
+                                                                IntPtr opaque, [MarshalAs(UnmanagedType.FunctionPtr)] virFreeCallback ff);
+    }
+}
diff --git a/virDomain.cs b/virDomain.cs
new file mode 100644
index 0000000..913dcb9
--- /dev/null
+++ b/virDomain.cs
@@ -0,0 +1,608 @@
+﻿/*
+ * Copyright (C)
+ *   Arnaud Champion <arnaud.champion@devatom.fr>
+ *   Jaromír Červenka <cervajz@cervajz.com>
+ *
+ * See COPYING.LIB for the License of this software
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace LibvirtBindings
+{
+    public class virDomain
+    {
+        /// <summary>
+        /// /// Create a virtual device attachment to backend. This function, having hotplug semantics, is only allowed on an active domain.
+        /// </summary>
+        /// <param name="domain">pointer to domain object</param>
+        /// <param name="xml">pointer to XML description of one device</param>
+        /// <returns>0 in case of success, -1 in case of failure.</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainAttachDevice")]
+        public static extern int AttachDevice(IntPtr domain, string xml);
+        /// <summary>
+        /// Attach a virtual device to a domain, using the flags parameter to control how the device is attached. VIR_DOMAIN_DEVICE_MODIFY_CURRENT specifies that the device allocation is made based on current domain state. VIR_DOMAIN_DEVICE_MODIFY_LIVE specifies that the device shall be allocated to the active domain instance only and is not added to the persisted domain configuration. VIR_DOMAIN_DEVICE_MODIFY_CONFIG specifies that the device shall be allocated to the persisted domain configuration only. Note that the target hypervisor must return an error if unable to satisfy flags. E.g. the hypervisor driver will return failure if LIVE is specified but it only supports modifying the persisted device allocation.
+        /// </summary>
+        /// <param name="domain">pointer to domain object</param>
+        /// <param name="xml">pointer to XML description of one device</param>
+        /// <param name="flags">an OR'ed set of virDomainDeviceModifyFlags</param>
+        /// <returns>0 in case of success, -1 in case of failure.</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainAttachDeviceFlags")]
+        public static extern int AttachDeviceFlags(IntPtr domain, string xml, uint flags);
+
+        // TODO virDomainBlockPeek
+
+        /// <summary>
+        /// This function returns block device (disk) stats for block devices attached to the domain. The path parameter is the name of the block device. Get this by calling virDomainGetXMLDesc and finding the target dev='...' attribute within //domain/devices/disk. (For example, "xvda"). Domains may have more than one block device. To get stats for each you should make multiple calls to this function. Individual fields within the stats structure may be returned as -1, which indicates that the hypervisor does not support that particular statistic.
+        /// </summary>
+        /// <param name="dom">pointer to the domain object</param>
+        /// <param name="path">path to the block device</param>
+        /// <param name="stats">block device stats (returned)</param>
+        /// <param name="size">size of stats structure</param>
+        /// <returns>0 in case of success or -1 in case of failure.</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainBlockStats")]
+        public static extern int BlockStats(IntPtr dom, string path, virDomainBlockStatsStruct stats, int size);
+        /// <summary>
+        /// This method will dump the core of a domain on a given file for analysis. Note that for remote Xen Daemon the file path will be interpreted in the remote host.
+        /// </summary>
+        /// <param name="domain">a domain object</param>
+        /// <param name="to">path for the core file</param>
+        /// <param name="flags">extra flags, currently unused</param>
+        /// <returns>0 in case of success and -1 in case of failure.</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainCoreDump")]
+        public static extern int CoreDump(IntPtr domain, string to, int flags);
+        /// <summary>
+        /// Launch a defined domain. If the call succeed the domain moves from the defined to the running domains pools.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/> pointer to a defined domain.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success, -1 in case of error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainCreate")]
+        public static extern int Create(IntPtr domain);
+        /// <summary>
+        /// Launch a new guest domain, based on an XML description similar to the one returned by virDomainGetXMLDesc().
+        /// This function may requires 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).
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/> pointer to the hypervisor connection.
+        /// </param>
+        /// <param name="xmlDesc">
+        /// A string containing an XML description of the domain.
+        /// </param>
+        /// <param name="flags">
+        /// Callers should always pass 0.
+        /// </param>
+        /// <returns>
+        /// A new domain object or NULL in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainCreateXML")]
+        public static extern IntPtr CreateXML(IntPtr conn, string xmlDesc, uint flags);
+        /// <summary>
+        /// Define a domain, but does not start it. This definition is persistent, until explicitly undefined with virDomainUndefine(). 
+        /// A previous definition for this domain would be overriden if it already exists.
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
+        /// </param>
+        /// <param name="xml">
+        /// The XML description for the domain, preferably in UTF-8.
+        /// </param>
+        /// <returns>
+        /// NULL in case of error, a pointer to the domain otherwise.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainDefineXML")]
+        public static extern IntPtr DefineXML(IntPtr conn, string xml);
+        /// <summary>
+        /// Destroy the domain object. The running instance is shutdown if not down already 
+        /// and all resources used by it are given back to the hypervisor. 
+        /// This does not free the associated virDomainPtr object. This function may require privileged access
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>domain object.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success and -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainDestroy")]
+        public static extern int Destroy(IntPtr domain);
+        /// <summary>
+        /// Destroy a virtual device attachment to backend.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>pointer to domain object.
+        /// </param>
+        /// <param name="xml">
+        /// Pointer to XML description of one device.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success, -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainDetachDevice")]
+        public static extern int DetachDevice(IntPtr domain, string xml);
+        /// <summary>
+        /// Detach a virtual device from a domain, using the flags parameter to control how the device is detached. VIR_DOMAIN_DEVICE_MODIFY_CURRENT specifies that the device allocation is removed based on current domain state. VIR_DOMAIN_DEVICE_MODIFY_LIVE specifies that the device shall be deallocated from the active domain instance only and is not from the persisted domain configuration. VIR_DOMAIN_DEVICE_MODIFY_CONFIG specifies that the device shall be deallocated from the persisted domain configuration only. Note that the target hypervisor must return an error if unable to satisfy flags. E.g. the hypervisor driver will return failure if LIVE is specified but it only supports removing the persisted device allocation.
+        /// </summary>
+        /// <param name="domain">pointer to domain object</param>
+        /// <param name="xml">pointer to XML description of one device</param>
+        /// <param name="flags">an OR'ed set of virDomainDeviceModifyFlags</param>
+        /// <returns>0 in case of success, -1 in case of failure.</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainDetachDeviceFlags")]
+        public static extern int DetachDeviceFlags(IntPtr domain, string xml, uint flags);
+        /// <summary>
+        /// Free the domain object. The running instance is kept alive. The data structure is freed and should not be used thereafter.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>domain object.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success and -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainFree")]
+        public static extern int Free(IntPtr domain);
+        /// <summary>
+        /// Provides a boolean value indicating whether the domain configured to be automatically started when the host machine boots.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>domain object.
+        /// </param>
+        /// <param name="autostart">
+        /// The value returned.
+        /// </param>
+        /// <returns>
+        /// -1 in case of error, 0 in case of success.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainGetAutostart")]
+        public static extern int GetAutostart(IntPtr domain, out int autostart);
+        /// <summary>
+        /// Provides the connection pointer associated with a domain. 
+        /// The reference counter on the connection is not increased by this call. 
+        /// WARNING: When writing libvirt bindings in other languages, do not use this function. 
+        /// Instead, store the connection and the domain object together.
+        /// </summary>
+        /// <param name="dom">
+        /// A <see cref="IntPtr"/>pointer to a domain.
+        /// </param>
+        /// <returns>
+        /// The <see cref="IntPtr"/>or NULL in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainGetConnect")]
+        public static extern IntPtr GetConnect(IntPtr dom);
+        /// <summary>
+        /// Get the hypervisor ID number for the domain.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>domain object.
+        /// </param>
+        /// <returns>
+        /// The domain ID number or (unsigned int) -1 in case of error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainGetID")]
+        public static extern int GetID(IntPtr domain);
+        /// <summary>
+        /// 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.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>domain object.
+        /// </param>
+        /// <param name="info">
+        /// Pointer to a virDomainInfo structure allocated by the user.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success and -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainGetInfo")]
+        public static extern int GetInfo(IntPtr domain, [Out] virDomainInfo info);
+        /// <summary>
+        /// Retrieve the maximum amount of physical memory allocated to a domain. 
+        /// If domain is NULL, then this get the amount of memory reserved to Domain0 i.e. the domain where the application runs.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>domain object or NULL.
+        /// </param>
+        /// <returns>
+        /// the memory size in kilobytes or 0 in case of error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainGetMaxMemory")]
+        public static extern ulong GetMaxMemory(IntPtr domain);
+        /// <summary>
+        /// Provides the maximum number of virtual CPUs supported for the guest VM. 
+        /// If the guest is inactive, this is basically the same as virConnectGetMaxVcpus. 
+        /// If the guest is running this will reflect the maximum number of virtual CPUs the guest was booted with.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>pointer to domain object.
+        /// </param>
+        /// <returns>
+        /// The maximum of virtual CPU or -1 in case of error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainGetMaxVcpus")]
+        public static extern int GetMaxVcpus(IntPtr domain);
+        /// <summary>
+        /// Get the public name for that domain.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>domain object.
+        /// </param>
+        /// <returns>
+        /// Pointer to the name or NULL, the string need not be deallocated its lifetime will be the same as the domain object.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainGetName")]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
+        public static extern string GetName(IntPtr domain);
+        /// <summary>
+        /// Get the type of domain operation system.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>domain object.
+        /// </param>
+        /// <returns>
+        /// The new string or NULL in case of error, the string must be freed by the caller.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainGetOSType")]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
+        public static extern string GetOSType(IntPtr domain);
+
+        // TODO virDomainGetSchedulerParameters
+
+        // TODO virDomainGetSchedulerType
+
+        // TODO virDomainGetSecurityLabel
+
+        /// <summary>
+        /// Get the UUID for a domain.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>a domain object.
+        /// </param>
+        /// <param name="uuid">
+        /// A <see cref="System.Char"/>pointer to a VIR_UUID_BUFLEN bytes array.
+        /// </param>
+        /// <returns>
+        /// A <see cref="System.Int32"/>-1 in case of error, 0 in case of success.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainGetUUID")]
+        public static extern int GetUUID(IntPtr domain, [Out] char[] uuid);
+        /// <summary>
+        /// Get the UUID for a domain as string. For more information about UUID see RFC4122.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>domain object.
+        /// </param>
+        /// <param name="buf">
+        /// Pointer to a VIR_UUID_STRING_BUFLEN bytes array.
+        /// </param>
+        /// <returns>
+        /// -1 in case of error, 0 in case of success.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainGetUUIDString")]
+        public static extern int GetUUIDString(IntPtr domain, [Out] IntPtr buf);
+
+        // TODO virDomainGetVcpus
+
+        /// <summary>
+        /// Provide an XML description of the domain. The description may be reused later to relaunch the domain with virDomainCreateXML().
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>a domain object.
+        /// </param>
+        /// <param name="flags">
+        /// An OR'ed set of virDomainXMLFlags.
+        /// </param>
+        /// <returns>
+        /// A 0 terminated UTF-8 encoded XML instance, or NULL in case of error. the caller must free() the returned value.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainGetXMLDesc")]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
+        public static extern string GetXMLDesc(IntPtr domain, int flags);
+        /// <summary>
+        /// This function returns network interface stats for interfaces attached to the domain. 
+        /// The path parameter is the name of the network interface. Domains may have more than one network interface. 
+        /// To get stats for each you should make multiple calls to this function. 
+        /// Individual fields within the stats structure may be returned as -1, 
+        /// which indicates that the hypervisor does not support that particular statistic.
+        /// </summary>
+        /// <param name="dom">
+        /// A <see cref="IntPtr"/>pointer to the domain object.
+        /// </param>
+        /// <param name="path">
+        /// Path to the interface.
+        /// </param>
+        /// <param name="stats">
+        /// A <see cref="virDomainInterfaceStatsStruct"/>network interface stats (returned).
+        /// </param>
+        /// <param name="size">
+        /// Size of stats structure.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success or -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainInterfaceStats")]
+        public static extern int InterfaceStats(IntPtr dom, string path, virDomainInterfaceStatsStruct stats, int size);
+        /// <summary>
+        /// Determine if the domain is currently running.
+        /// </summary>
+        /// <param name="dom">
+        /// A <see cref="IntPtr"/>pointer to the domain object.
+        /// </param>
+        /// <returns>
+        /// 1 if running, 0 if inactive, -1 on error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainIsActive")]
+        public static extern int IsActive(IntPtr dom);
+
+        /// <summary>
+        /// Determine if the domain has a persistent configuration which means it will still exist after shutting down.
+        /// </summary>
+        /// <param name="dom">
+        /// A <see cref="IntPtr"/>pointer to the domain object.
+        /// </param>
+        /// <returns>
+        /// 1 if persistent, 0 if transient, -1 on error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainIsPersistent")]
+        public static extern int IsPersistent(IntPtr dom);
+
+        /// <summary>
+        /// Try to find a domain based on the hypervisor ID number.
+        /// Note that this won't work for inactive domains which have an ID of -1, 
+        /// in that case a lookup based on the Name or UUId need to be done instead.
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
+        /// </param>
+        /// <param name="id">
+        /// The domain ID number.
+        /// </param>
+        /// <returns>
+        /// A new domain object or NULL in case of failure. If the domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainLookupByID")]
+        public static extern IntPtr LookupByID(IntPtr conn, int id);
+
+        /// <summary>
+        /// Try to lookup a domain on the given hypervisor based on its name.
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
+        /// </param>
+        /// <param name="name">
+        /// A <see cref="System.String"/>name for the domain.
+        /// </param>
+        /// <returns>
+        /// A new domain object or NULL in case of failure. If the domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainLookupByName")]
+        public static extern IntPtr LookupByName(IntPtr conn, string name);
+
+        /// <summary>
+        /// Try to lookup a domain on the given hypervisor based on its UUID.
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
+        /// </param>
+        /// <param name="uuid">
+        /// A <see cref="System.Char"/>the raw UUID for the domain.
+        /// </param>
+        /// <returns>
+        /// A new domain object or NULL in case of failure. If the domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainLookupByUUID")]
+        public static extern IntPtr LookupByUUID(IntPtr conn, char[] uuid);
+
+        /// <summary>
+        /// Try to lookup a domain on the given hypervisor based on its UUID.
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
+        /// </param>
+        /// <param name="uuidstr">
+        /// The string UUID for the domain.
+        /// </param>
+        /// <returns>
+        /// A new domain object or NULL in case of failure. If the domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainLookupByUUIDString")]
+        public static extern IntPtr LookupByUUIDString(IntPtr conn, string uuidstr);
+
+        // TODO virDomainMemoryPeek
+
+        // TODO virDomainMigrate
+
+        // TODO virDomainMigrateToURI
+
+        // TODO virDomainPinVcpu
+
+        // TODO virDomainMemoryStats
+
+        /// <summary>
+        /// Reboot a domain, the domain object is still usable there after but the domain OS is being stopped for a restart. 
+        /// Note that the guest OS may ignore the request.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>domain object.
+        /// </param>
+        /// <param name="flags">
+        /// Extra flags for the reboot operation, not used yet.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success and -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainReboot")]
+        public static extern int Reboot(IntPtr domain, uint flags);
+
+        /// <summary>
+        /// Increment the reference count on the domain. For each additional call to this method, 
+        /// there shall be a corresponding call to virDomainFree to release the reference count, 
+        /// once the caller no longer needs the reference to this object. 
+        /// This method is typically useful for applications where multiple threads are using a connection, 
+        /// and it is required that the connection remain open until all threads have finished using it. ie, 
+        /// each new thread using a domain would increment the reference count.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>the domain to hold a reference on.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success and -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainRef")]
+        public static extern int Ref(IntPtr domain);
+
+        /// <summary>
+        /// This method will restore a domain saved to disk by virDomainSave().
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
+        /// </param>
+        /// <param name="from">
+        /// Path to the file with saved domain.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success and -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainRestore")]
+        public static extern int Restore(IntPtr conn, string from);
+
+        /// <summary>
+        /// Resume a suspended domain, the process is restarted from the state where it was frozen by calling virSuspendDomain(). 
+        /// This function may requires privileged access
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>domain object.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success and -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainResume")]
+        public static extern int Resume(IntPtr domain);
+
+        /// <summary>
+        /// This method will suspend a domain and save its memory contents to a file on disk. After the call, if successful, 
+        /// the domain is not listed as running anymore (this may be a problem). Use virDomainRestore() to restore a domain after saving.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>domain object.
+        /// </param>
+        /// <param name="to">
+        /// Path for the output file.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success and -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainSave")]
+        public static extern int Save(IntPtr domain, string to);
+
+        /// <summary>
+        /// Configure the domain to be automatically started when the host machine boots.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>domain object.
+        /// </param>
+        /// <param name="autostart">
+        /// Whether the domain should be automatically started 0 or 1.
+        /// </param>
+        /// <returns>
+        /// -1 in case of error, 0 in case of success.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainSetAutostart")]
+        public static extern int SetAutostart(IntPtr domain, int autostart);
+
+        /// <summary>
+        /// Dynamically change the maximum amount of physical memory allocated to a domain. 
+        /// If domain is NULL, then this change the amount of memory reserved to Domain0 i.e. 
+        /// the domain where the application runs. This function requires privileged access to the hypervisor.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>domain object or NULL.
+        /// </param>
+        /// <param name="memory">
+        /// The memory size in kilobytes.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success and -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainSetMaxMemory")]
+        public static extern int SetMaxMemory(IntPtr domain, ulong memory);
+
+        /// <summary>
+        /// Dynamically change the target amount of physical memory allocated to a domain. 
+        /// If domain is NULL, then this change the amount of memory reserved to Domain0 i.e. 
+        /// the domain where the application runs. This function may requires privileged access to the hypervisor.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>domain object or NULL.
+        /// </param>
+        /// <param name="memory">
+        /// The memory size in kilobytes.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success and -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainSetMemory")]
+        public static extern int SetMemory(IntPtr domain, ulong memory);
+
+        // TODO virDomainSetSchedulerParameters
+
+        /// <summary>
+        /// Dynamically change the number of virtual CPUs used by the domain. 
+        /// Note that this call may fail if the underlying virtualization hypervisor does not support it 
+        /// or if growing the number is arbitrary limited. This function requires privileged access to the hypervisor.
+        /// </summary>
+        /// <param name="domain">
+        /// Pointer to domain object, or NULL for Domain0
+        /// </param>
+        /// <param name="nvcpus">
+        /// The new number of virtual CPUs for this domain.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success, -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainSetVcpus")]
+        public static extern int SetVcpus(IntPtr domain, uint nvcpus);
+
+        /// <summary>
+        /// Shutdown a domain, the domain object is still usable there after but the domain OS is being stopped. 
+        /// Note that the guest OS may ignore the request. 
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>domain object.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success and -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainShutdown")]
+        public static extern int Shutdown(IntPtr domain);
+
+        /// <summary>
+        /// Suspends an active domain, the process is frozen without further access to CPU resources and I/O 
+        /// but the memory used by the domain at the hypervisor level will stay allocated. 
+        /// Use virDomainResume() to reactivate the domain. This function may requires privileged access.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>domain object.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success and -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainSuspend")]
+        public static extern int Suspend(IntPtr domain);
+
+        /// <summary>
+        /// Undefine a domain but does not stop it if it is running.
+        /// </summary>
+        /// <param name="domain">
+        /// A <see cref="IntPtr"/>pointer to a defined domain.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success, -1 in case of error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDomainUndefine")]
+        public static extern int Undefine(IntPtr domain);
+
+    }
+}
diff --git a/virEvent.cs b/virEvent.cs
new file mode 100644
index 0000000..7aacfc2
--- /dev/null
+++ b/virEvent.cs
@@ -0,0 +1,32 @@
+﻿/*
+ * Copyright (C)
+ *   Arnaud Champion <arnaud.champion@devatom.fr>
+ *   Jaromír Červenka <cervajz@cervajz.com>
+ *
+ * See COPYING.LIB for the License of this software
+ */
+
+using System.Runtime.InteropServices;
+
+namespace LibvirtBindings
+{
+    public class virEvent
+    {
+        ///<summary>
+        /// Function to install callbacks
+        ///</summary>
+        ///<param name="addHandle">the virEventAddHandleFunc which will be called (a delegate)</param>
+        ///<param name="updateHandle">the virEventUpdateHandleFunc which will be called (a delegate)</param>
+        ///<param name="removeHandle">the virEventRemoveHandleFunc which will be called (a delegate)</param>
+        ///<param name="addTimeout">the virEventAddTimeoutFunc which will be called (a delegate)</param>
+        ///<param name="updateTimeout">the virEventUpdateTimeoutFunc which will be called (a delegate)</param>
+        ///<param name="removeTimeout">the virEventRemoveTimeoutFunc which will be called (a delegate)</param>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virEventRegisterImpl")]
+        public static extern void RegisterImpl([MarshalAs(UnmanagedType.FunctionPtr)]virEventAddHandleFunc addHandle,
+                                               [MarshalAs(UnmanagedType.FunctionPtr)]virEventUpdateHandleFunc updateHandle,
+                                               [MarshalAs(UnmanagedType.FunctionPtr)]virEventRemoveHandleFunc removeHandle,
+                                               [MarshalAs(UnmanagedType.FunctionPtr)]virEventAddTimeoutFunc addTimeout,
+                                               [MarshalAs(UnmanagedType.FunctionPtr)]virEventUpdateTimeoutFunc updateTimeout,
+                                               [MarshalAs(UnmanagedType.FunctionPtr)]virEventRemoveTimeoutFunc removeTimeout);
+    }
+}
diff --git a/virInterface.cs b/virInterface.cs
new file mode 100644
index 0000000..1902023
--- /dev/null
+++ b/virInterface.cs
@@ -0,0 +1,39 @@
+﻿/*
+ * Copyright (C)
+ *   Arnaud Champion <arnaud.champion@devatom.fr>
+ *   Jaromír Červenka <cervajz@cervajz.com>
+ *
+ * See COPYING.LIB for the License of this software
+ */
+
+namespace LibvirtBindings
+{
+    public class virInterface
+    {
+        // TODO virInterfaceCreate
+
+        // TODO virInterfaceDefineXML
+
+        // TODO virInterfaceDestroy
+
+        // TODO virInterfaceFree
+
+        // TODO virInterfaceGetConnect
+
+        // TODO virInterfaceGetMACString
+
+        // TODO virInterfaceGetName
+
+        // TODO virInterfaceGetXMLDesc
+
+        // TODO virInterfaceIsActive
+
+        // TODO virInterfaceLookupByMACString
+
+        // TODO virInterfaceLookupByName
+
+        // TODO virInterfaceRef
+
+        // TODO virInterfaceUndefine
+    }
+}
diff --git a/virLibrary.cs b/virLibrary.cs
new file mode 100644
index 0000000..465dc98
--- /dev/null
+++ b/virLibrary.cs
@@ -0,0 +1,44 @@
+﻿/*
+ * Copyright (C)
+ *   Arnaud Champion <arnaud.champion@devatom.fr>
+ *   Jaromír Červenka <cervajz@cervajz.com>
+ *
+ * See COPYING.LIB for the License of this software
+ */
+
+using System.Runtime.InteropServices;
+
+namespace LibvirtBindings
+{
+    public class virLibrary
+    {
+        /// <summary>
+        /// Provides two information back, @libVer is the version of the library while @typeVer will be the version of the hypervisor 
+        /// type @type against which the library was compiled. If @type is NULL, "Xen" is assumed, 
+        /// if @type is unknown or not available, an error code will be returned and @typeVer will be 0.
+        /// </summary>
+        /// <param name="libVer">
+        /// A <see cref="System.UInt64"/>return value for the library version (OUT).
+        /// </param>
+        /// <param name="type">
+        /// A <see cref="System.String"/>the type of connection/driver looked at.
+        /// </param>
+        /// <param name="typeVer">
+        /// A <see cref="System.UInt64"/>return value for the version of the hypervisor (OUT).
+        /// </param>
+        /// <returns>
+        /// -1 in case of failure, 0 otherwise, and values for @libVer and @typeVer have the format major * 1,000,000 + minor * 1,000 + release.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virGetVersion")]
+        public static extern int GetVersion([Out] out ulong libVer, [In] string type, [Out] out ulong typeVer);
+        /// <summary>
+        /// Initialize the library. It's better to call this routine at startup in multithreaded applications to avoid 
+        /// potential race when initializing the library.
+        /// </summary>
+        /// <returns>
+        /// 0 in case of success, -1 in case of error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virInitialize")]
+        public static extern int Initialize();
+    }
+}
diff --git a/virNetwork.cs b/virNetwork.cs
new file mode 100644
index 0000000..96ac5db
--- /dev/null
+++ b/virNetwork.cs
@@ -0,0 +1,179 @@
+﻿/*
+ * Copyright (C)
+ *   Arnaud Champion <arnaud.champion@devatom.fr>
+ *   Jaromír Červenka <cervajz@cervajz.com>
+ *
+ * See COPYING.LIB for the License of this software
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace LibvirtBindings
+{
+    public class virNetwork
+    {
+        /// <summary>
+        /// Increment the reference count on the network. For each additional call to this method, 
+        /// there shall be a corresponding call to virNetworkFree to release the reference count, 
+        /// once the caller no longer needs the reference to this object. 
+        /// This method is typically useful for applications where multiple threads are using a connection, 
+        /// and it is required that the connection remain open until all threads have finished using it. ie, 
+        /// each new thread using a network would increment the reference count.
+        /// </summary>
+        /// <param name="network">
+        /// A <see cref="IntPtr"/>the network to hold a reference on.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success, -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkRef")]
+        public static extern int Ref(IntPtr network);
+
+        // TODO virNetworkSetAutostart
+
+        // TODO virNetworkUndefine
+        /// <summary>
+        /// Create and start a defined network. If the call succeed the network moves from the defined to the running networks pools.
+        /// </summary>
+        /// <param name="network">pointer to a defined network</param>
+        /// <returns>0 in case of success, -1 in case of error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkCreate")]
+        public static extern int Create(IntPtr network);
+        /// <summary>
+        /// Create and start a new virtual network, based on an XML description similar to the one returned by virNetworkGetXMLDesc()
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="xmlDesc">an XML description of the network</param>
+        /// <returns>a new network object or NULL in case of failure</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkCreateXML")]
+        public static extern IntPtr CreateXML(IntPtr conn, string xmlDesc);
+        /// <summary>
+        /// Define a network, but does not create it
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="xmlDesc">the XML description for the network, preferably in UTF-8</param>
+        /// <returns>NULL in case of error, a pointer to the network otherwise</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkDefineXML")]
+        public static extern IntPtr DefineXML(IntPtr conn, string xmlDesc);
+        /// <summary>
+        /// Destroy the network object. The running instance is shutdown if not down already and all resources used by it are given back to the hypervisor. This does not free the associated virNetworkPtr object. This function may require privileged access
+        /// </summary>
+        /// <param name="network">a network object</param>
+        /// <returns>0 in case of success and -1 in case of failure.</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkDestroy")]
+        public static extern int Destroy(IntPtr network);
+        /// <summary>
+        /// Free the network object. The running instance is kept alive. The data structure is freed and should not be used thereafter.
+        /// </summary>
+        /// <param name="network">a network object</param>
+        /// <returns>0 in case of success and -1 in case of failure</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkFree")]
+        public static extern int Free(IntPtr network);
+        /// <summary>
+        /// Provides a boolean value indicating whether the network configured to be automatically started when the host machine boots.
+        /// </summary>
+        /// <param name="network">a network object</param>
+        /// <param name="autostart">the value returned</param>
+        /// <returns>-1 in case of error, 0 in case of success</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkGetAutostart")]
+        public static extern int GetAutostart(IntPtr network, int autostart);
+        /// <summary>
+        /// Provides a bridge interface name to which a domain may connect a network interface in order to join the network.
+        /// </summary>
+        /// <param name="network">a network object</param>
+        /// <returns>a 0 terminated interface name, or NULL in case of error. the caller must free() the returned value</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkGetBridgeName")]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
+        public static extern string GetBridgeName(IntPtr network);
+        /// <summary>
+        /// Provides the connection pointer associated with a network. The reference counter on the connection is not increased by this call. WARNING: When writing libvirt bindings in other languages, do not use this function. Instead, store the connection and the network object together
+        /// </summary>
+        /// <param name="network">pointer to a network</param>
+        /// <returns>the virConnectPtr or NULL in case of failure</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkGetConnect")]
+        public static extern IntPtr GetConnect(IntPtr network);
+        /// <summary>
+        /// Get the public name for that network
+        /// </summary>
+        /// <param name="network">a network object</param>
+        /// <returns>a pointer to the name or NULL, the string need not be deallocated its lifetime will be the same as the network object</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkGetName")]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
+        public static extern string GetName(IntPtr network);
+        /// <summary>
+        /// Get the UUID for a network as string
+        /// </summary>
+        /// <param name="network">a network object</param>
+        /// <param name="uuid">string of the uuid</param>
+        /// <returns>-1 in case of error, 0 in case of success</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkGetUUIDString")]
+        private static extern int GetUUIDString(IntPtr network, [Out] char[] uuid);
+
+        ///<summary>
+        /// Get the UUID for a network as string
+        ///</summary>
+        ///<param name="network">a network object, a netowrk IntPtr</param>
+        ///<returns>string of the uuid</returns>
+        public static string virNetworkGetUUIDString(IntPtr network)
+        {
+            char[] uuidArray = new char[36];
+            GetUUIDString(network, uuidArray);
+            return new string(uuidArray);
+        }
+        /// <summary>
+        /// Provide an XML description of the network. The description may be reused later to relaunch the network with virNetworkCreateXML().
+        /// </summary>
+        /// <param name="network">a network object</param>
+        /// <param name="flags">an OR'ed set of extraction flags, not used yet</param>
+        /// <returns>a 0 terminated UTF-8 encoded XML instance, or NULL in case of error. the caller must free() the returned value</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkGetXMLDesc")]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
+        public static extern string GetXMLDesc(IntPtr network, int flags);
+        /// <summary>
+        /// Determine if the network is currently running
+        /// </summary>
+        /// <param name="network">pointer to the network object</param>
+        /// <returns>1 if running, 0 if inactive, -1 on error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkIsActive")]
+        public static extern int IsActive(IntPtr network);
+        /// <summary>
+        /// Determine if the network has a persistent configuration which means it will still exist after shutting down
+        /// </summary>
+        /// <param name="network">pointer to the network object</param>
+        /// <returns>x1 if persistent, 0 if transient, -1 on error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkIsPersistent")]
+        public static extern int IsPersistent(IntPtr network);
+        /// <summary>
+        /// Try to lookup a network on the given hypervisor based on its name.
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="name">name for the network</param>
+        /// <returns>a new network object or NULL in case of failure. If the network cannot be found, then VIR_ERR_NO_NETWORK error is raised</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkLookupByName")]
+        public static extern IntPtr LookupByName(IntPtr conn, string name);
+        /// <summary>
+        /// Try to lookup a network on the given hypervisor based on its UUID
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="uuidstr">the string UUID for the network</param>
+        /// <returns>a new network object or NULL in case of failure. If the network cannot be found, then VIR_ERR_NO_NETWORK error is raised</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkLookupByUUIDString")]
+        public static extern IntPtr LookupByUUIDString(IntPtr conn, string uuidstr);
+        /// <summary>
+        /// Configure the network to be automatically started when the host machine boots
+        /// </summary>
+        /// <param name="network">a network object</param>
+        /// <param name="autostart">whether the network should be automatically started 0 or 1</param>
+        /// <returns>-1 in case of error, 0 in case of success</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkSetAutostart")]
+        public static extern int SetAutostart(IntPtr network, int autostart);
+        /// <summary>
+        /// Undefine a network but does not stop it if it is running
+        /// </summary>
+        /// <param name="network">pointer to a defined network</param>
+        /// <returns>0 in case of success, -1 in case of error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNetworkUndefine")]
+        public static extern int Undefine(IntPtr network);
+    }
+}
diff --git a/virNode.cs b/virNode.cs
new file mode 100644
index 0000000..a4198dd
--- /dev/null
+++ b/virNode.cs
@@ -0,0 +1,163 @@
+﻿/*
+ * Copyright (C)
+ *   Arnaud Champion <arnaud.champion@devatom.fr>
+ *   Jaromír Červenka <cervajz@cervajz.com>
+ *
+ * See COPYING.LIB for the License of this software
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace LibvirtBindings
+{
+    public class virNode
+    {
+		private const int MaxStringLength = 1024;
+		
+        // TODO virNodeDeviceCreateXML
+
+        // TODO virNodeDeviceDestroy
+
+        // TODO virNodeDeviceDettach
+
+        // TODO virNodeDeviceFree
+
+        // TODO virNodeDeviceGetName
+
+        // TODO virNodeDeviceGetParent
+
+        /// <summary>
+        /// Fetch an XML document describing all aspects of the device.
+        /// </summary>
+        /// <param name="dev">pointer to the node device</param>
+        /// <param name="flags">flags for XML generation (unused, pass 0)</param>
+        /// <returns>the XML document, or NULL on error</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNodeDeviceGetXMLDesc")]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
+        public static extern string DeviceGetXMLDesc(IntPtr dev, uint flags);
+
+        // TODO virNodeDeviceListCaps
+
+        /// <summary>
+        /// Lookup a node device by its name.
+        /// </summary>
+        /// <param name="conn">pointer to the hypervisor connection</param>
+        /// <param name="name">unique device name</param>
+        /// <returns>a virNodeDevicePtr if found, NULL otherwise.</returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNodeDeviceLookupByName")]
+        public static extern IntPtr DeviceLookupByName(IntPtr conn, string name);
+        // TODO virNodeDeviceNumOfCaps
+
+        // TODO virNodeDeviceReAttach
+
+        // TODO virNodeDeviceRef
+
+        // TODO virNodeDeviceReset
+
+        // TODO virNodeGetCellsFreeMemory
+
+        /// <summary>
+        /// Provides the free memory available on the Node Note: most libvirt APIs provide memory sizes in kilobytes, 
+        /// but in this function the returned value is in bytes. Divide by 1024 as necessary.
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
+        /// </param>
+        /// <returns>
+        /// The available free memory in bytes or 0 in case of error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNodeGetFreeMemory")]
+        public static extern ulong GetFreeMemory(IntPtr conn);
+        /// <summary>
+        /// Extract hardware information about the node.
+        /// </summary>
+        /// <param name="h">
+        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
+        /// </param>
+        /// <param name="info">
+        /// Pointer to a virNodeInfo structure allocated by the user.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success and -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNodeGetInfo")]
+        public static extern int GetInfo(IntPtr h, [Out] virNodeInfo info);
+
+        // TODO virNodeGetSecurityModel
+
+        /// <summary>
+        /// Collect the list of node devices, and store their names in @names.
+        /// If the optional 'cap' argument is non-NULL, then the count will be restricted to devices with the specified capability.
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
+        /// </param>
+        /// <param name="cap">
+        /// Capability name.
+        /// </param>
+        /// <param name="names">
+        /// Array to collect the list of node device names.
+        /// </param>
+        /// <param name="maxnames">
+        /// Size of @names.
+        /// </param>
+        /// <param name="flags">
+        /// Flags (unused, pass 0).
+        /// </param>
+        /// <returns>
+        /// The number of node devices found or -1 in case of error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNodeListDevices")]
+        public static extern int ListDevices(IntPtr conn, string cap, IntPtr names, int maxnames, uint flags);
+        /// <summary>
+        /// Collect the list of node devices, and store their names in @names.
+        /// If the optional 'cap' argument is non-NULL, then the count will be restricted to devices with the specified capability.
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
+        /// </param>
+        /// <param name="cap">
+        /// Capability name.
+        /// </param>
+        /// <param name="names">
+        /// Array to collect the list of node device names.
+        /// </param>
+        /// <param name="maxnames">
+        /// Size of @names.
+        /// </param>
+        /// <param name="flags">
+        /// Flags (unused, pass 0).
+        /// </param>
+        /// <returns>
+        /// The number of node devices found or -1 in case of error.
+        /// </returns>
+        public static int virNodeListDevices(IntPtr conn, string cap, ref string[] names, int maxnames, uint flags)
+        {
+            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
+            int count = ListDevices(conn, cap, namesPtr, maxnames, 0);
+            if (count > 0)
+                names = MarshalHelper.ptrToStringArray(namesPtr, count);
+            Marshal.FreeHGlobal(namesPtr);
+            return count;
+        }
+        /// <summary>
+        /// Provides the number of node devices. If the optional 'cap' argument is non-NULL, 
+        /// then the count will be restricted to devices with the specified capability.
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to the hypervisor connection.
+        /// </param>
+        /// <param name="cap">
+        /// A <see cref="System.String"/>capability name.
+        /// </param>
+        /// <param name="flags">
+        /// A <see cref="System.UInt32"/>flags (unused, pass 0).
+        /// </param>
+        /// <returns>
+        /// The number of node devices or -1 in case of error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virNodeNumOfDevices")]
+        public static extern int NumOfDevices(IntPtr conn, string cap, uint flags);
+    }
+}
diff --git a/virSecret.cs b/virSecret.cs
new file mode 100644
index 0000000..fd3a2c6
--- /dev/null
+++ b/virSecret.cs
@@ -0,0 +1,43 @@
+﻿/*
+ * Copyright (C)
+ *   Arnaud Champion <arnaud.champion@devatom.fr>
+ *   Jaromír Červenka <cervajz@cervajz.com>
+ *
+ * See COPYING.LIB for the License of this software
+ */
+
+namespace LibvirtBindings
+{
+    public class virSecret
+    {
+        // TODO virSecretDefineXML
+
+        // TODO virSecretFree
+
+        // TODO virSecretGetConnect
+
+        // TODO virSecretGetUUID
+
+        // TODO virSecretGetUUIDString
+
+        // TODO virSecretGetUsageID
+
+        // TODO virSecretGetUsageType
+
+        // TODO virSecretGetValue
+
+        // TODO virSecretGetXMLDesc
+
+        // TODO virSecretLookupByUUID
+
+        // TODO virSecretLookupByUUIDString
+
+        // TODO virSecretLookupByUsage
+
+        // TODO virSecretRef
+
+        // TODO virSecretSetValue
+
+        // TODO virSecretUndefine
+    }
+}
diff --git a/virStoragePool.cs b/virStoragePool.cs
new file mode 100644
index 0000000..5df9be5
--- /dev/null
+++ b/virStoragePool.cs
@@ -0,0 +1,436 @@
+﻿/*
+ * Copyright (C)
+ *   Arnaud Champion <arnaud.champion@devatom.fr>
+ *   Jaromír Červenka <cervajz@cervajz.com>
+ *
+ * See COPYING.LIB for the License of this software
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace LibvirtBindings
+{
+    public class virStoragePool
+    {
+		private const int MaxStringLength = 1024;
+		
+        /// <summary>
+        /// Build the underlying storage pool.
+        /// </summary>
+        /// <param name="pool">
+        /// A pointer to storage pool.
+        /// </param>
+        /// <param name="flags">
+        /// Future flags, use 0 for now.
+        /// </param>
+        /// <returns>
+        /// 0 on success, or -1 upon failure
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolBuild")]
+        public static extern int Build(IntPtr pool, virStoragePoolBuildFlags flags);
+
+        /// <summary>
+        /// Starts an inactive storage pool.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        /// <param name="flags">
+        /// Future flags, use 0 for now.
+        /// </param>
+        /// <returns>
+        /// 0 on success, or -1 if it could not be started.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolCreate")]
+        public static extern int Create(IntPtr pool, uint flags);
+
+        /// <summary>
+        /// Create a new storage based on its XML description. The pool is not persistent, 
+        /// so its definition will disappear when it is destroyed, or if the host is restarted
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to hypervisor connection.
+        /// </param>
+        /// <param name="xmlDesc">
+        /// A <see cref="System.String"/>XML description for new pool.
+        /// </param>
+        /// <param name="flags">
+        /// A <see cref="System.UInt32"/>future flags, use 0 for now.
+        /// </param>
+        /// <returns>
+        /// A virStoragePoolPtr object, or NULL if creation failed.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolCreateXML")]
+        public static extern IntPtr CreateXML(IntPtr conn, string xmlDesc, uint flags);
+
+        /// <summary>
+        /// Define a new inactive storage pool based on its XML description. The pool is persistent, 
+        /// until explicitly undefined.
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to hypervisor connection.
+        /// </param>
+        /// <param name="xml">
+        /// A <see cref="System.String"/>XML description for new pool.
+        /// </param>
+        /// <param name="flags">
+        /// A <see cref="System.UInt32"/>future flags, use 0 for now.
+        /// </param>
+        /// <returns>
+        /// A virStoragePoolPtr object, or NULL if creation failed.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolDefineXML")]
+        public static extern IntPtr DefineXML(IntPtr conn, string xml, uint flags);
+
+        /// <summary>
+        /// Delete the underlying pool resources. This is a non-recoverable operation. The virStoragePoolPtr object itself is not free'd.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        /// <param name="flags">
+        /// A <see cref="virStoragePoolDeleteFlags"/>flags for obliteration process.
+        /// </param>
+        /// <returns>
+        /// 0 on success, or -1 if it could not be obliterate.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolDelete")]
+        public static extern int Delete(IntPtr pool, virStoragePoolDeleteFlags flags);
+
+        /// <summary>
+        /// Destroy an active storage pool. This will deactivate the pool on the host, 
+        /// but keep any persistent config associated with it. 
+        /// If it has a persistent config it can later be restarted with virStoragePoolCreate(). 
+        /// This does not free the associated virStoragePoolPtr object.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        /// <returns>
+        /// 0 on success, or -1 if it could not be destroyed.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolDestroy")]
+        public static extern int Destroy(IntPtr pool);
+
+        /// <summary>
+        /// Free a storage pool object, releasing all memory associated with it. Does not change the state of the pool on the host.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        /// <returns>
+        /// 0 on success, or -1 if it could not be free'd.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolFree")]
+        public static extern int Free(IntPtr pool);
+
+        /// <summary>
+        /// Fetches the value of the autostart flag, which determines whether the pool is automatically started at boot time.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        /// <param name="autotart"></param>
+        /// <returns>
+        /// 0 on success, -1 on failure
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolGetAutostart")]
+        public static extern int GetAutostart(IntPtr pool, out int autotart);
+
+        /// <summary>
+        /// Provides the connection pointer associated with a storage pool. The reference counter on the connection is not increased by this call. 
+        /// WARNING: When writing libvirt bindings in other languages, do not use this function. Instead, store the connection and the pool object together.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to a pool.
+        /// </param>
+        /// <returns>
+        /// A <see cref="IntPtr"/>the virConnectPtr or NULL in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolGetConnect")]
+        public static extern IntPtr GetConnect(IntPtr pool);
+
+        /// <summary>
+        /// Get volatile information about the storage pool such as free space / usage summary.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        /// <param name="info">
+        /// Pointer at which to store info.
+        /// </param>
+        /// <returns>
+        /// 0 on success, or -1 on failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolGetInfo")]
+        public static extern int GetInfo(IntPtr pool, ref virStoragePoolInfo info);
+
+        /// <summary>
+        /// Fetch the locally unique name of the storage pool.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        /// <returns>
+        /// The name of the pool, or NULL on error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolGetName")]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
+        public static extern string GetName(IntPtr pool);
+
+        /// <summary>
+        /// Fetch the globally unique ID of the storage pool.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>Pointer to storage pool.
+        /// </param>
+        /// <param name="uuid">
+        /// Buffer of VIR_UUID_BUFLEN bytes in size.
+        /// </param>
+        /// <returns>
+        /// 0 on success, or -1 on error
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolGetUUID")]
+        public static extern int GetUUID(IntPtr pool, [Out] char[] uuid);
+
+        /// <summary>
+        /// Fetch the globally unique ID of the storage pool as a string.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        /// <param name="uuid">
+        /// A <see cref="IntPtr"/>buffer of VIR_UUID_STRING_BUFLEN bytes in size.
+        /// </param>
+        /// <returns>
+        /// 0 on success, or -1 on error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolGetUUIDString")]
+        private static extern int GetUUIDString(IntPtr pool, [Out] char[] uuid);
+
+        ///<summary>
+        /// Fetch the globally unique ID of the storage pool as a string.
+        ///</summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        ///<returns>the storage pool UUID</returns>
+        public static string virStoragePoolGetUUIDString(IntPtr pool)
+        {
+            char[] uuidArray = new char[36];
+            GetUUIDString(pool, uuidArray);
+            return new string(uuidArray);
+        }
+        /// <summary>
+        /// Fetch an XML document describing all aspects of the storage pool. 
+        /// This is suitable for later feeding back into the virStoragePoolCreateXML method.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        /// <param name="flags">
+        /// Flags for XML format options (set of virDomainXMLFlags).
+        /// </param>
+        /// <returns>
+        /// A XML document, or NULL on error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolGetXMLDesc")]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
+        public static extern string GetXMLDesc(IntPtr pool, virDomainXMLFlags flags);
+
+        /// <summary>
+        /// Determine if the storage pool is currently running.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to the storage pool object.
+        /// </param>
+        /// <returns>
+        /// 1 if running, 0 if inactive, -1 on error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolIsActive")]
+        public static extern int IsActive(IntPtr pool);
+
+        /// <summary>
+        /// Determine if the storage pool has a persistent configuration which means it will still exist after shutting down.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to the storage pool object.
+        /// </param>
+        /// <returns>
+        /// 1 if persistent, 0 if transient, -1 on error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolIsPersistent")]
+        public static extern int IsPersistent(IntPtr pool);
+
+        /// <summary>
+        /// Fetch list of storage volume names, limiting to at most maxnames.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        /// <param name="names">
+        /// A <see cref="IntPtr"/>array in which to storage volume names.
+        /// </param>
+        /// <param name="maxnames">
+        /// A <see cref="System.Int32"/>size of names array.
+        /// </param>
+        /// <returns>
+        /// The number of names fetched, or -1 on error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolListVolumes")]
+        private static extern int ListVolumes(IntPtr pool, IntPtr names, int maxnames);
+        /// <summary>
+        /// Fetch list of storage volume names, limiting to at most maxnames.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        /// <param name="names">
+        /// A <see cref="IntPtr"/>array in which to storage volume names.
+        /// </param>
+        /// <param name="maxnames">
+        /// A <see cref="System.Int32"/>size of names array.
+        /// </param>
+        /// <returns>
+        /// The number of names fetched, or -1 on error.
+        /// </returns>
+        public static int virStoragePoolListVolumes(IntPtr pool, ref string[] names, int maxnames)
+        {
+            IntPtr namesPtr = Marshal.AllocHGlobal(MaxStringLength);
+            int count = ListVolumes(pool, namesPtr, maxnames);
+            if (count > 0)
+                names = MarshalHelper.ptrToStringArray(namesPtr, count);
+            Marshal.FreeHGlobal(namesPtr);
+            return count;
+        }
+        /// <summary>
+        /// Fetch a storage pool based on its unique name.
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to hypervisor connection.
+        /// </param>
+        /// <param name="name">
+        /// Name of pool to fetch.
+        /// </param>
+        /// <returns>
+        /// A <see cref="IntPtr"/>virStoragePoolPtr object, or NULL if no matching pool is found.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolLookupByName")]
+        public static extern IntPtr LookupByName(IntPtr conn, string name);
+
+        /// <summary>
+        /// Fetch a storage pool based on its globally unique id.
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to hypervisor connection.
+        /// </param>
+        /// <param name="uuid">
+        /// Globally unique id of pool to fetch.
+        /// </param>
+        /// <returns>
+        /// A virStoragePoolPtr object, or NULL if no matching pool is found
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolLookupByUUID")]
+        public static extern IntPtr LookupByUUID(IntPtr conn, char[] uuid);
+
+        /// <summary>
+        /// Fetch a storage pool based on its globally unique id.
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to hypervisor connection.
+        /// </param>
+        /// <param name="uuidstr">
+        /// A <see cref="System.String"/>globally unique id of pool to fetch.
+        /// </param>
+        /// <returns>
+        /// A <see cref="IntPtr"/>object, or NULL if no matching pool is found.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolLookupByUUIDString")]
+        public static extern IntPtr LookupByUUIDString(IntPtr conn, string uuidstr);
+
+        /// <summary>
+        /// Fetch a storage pool which contains a particular volume.
+        /// </summary>
+        /// <param name="vol">
+        /// A <see cref="IntPtr"/>pointer to storage volume.
+        /// </param>
+        /// <returns>
+        /// A <see cref="IntPtr"/>object, or NULL if no matching pool is found.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolLookupByVolume")]
+        public static extern IntPtr LookupByVolume(IntPtr vol);
+
+        /// <summary>
+        /// Fetch the number of storage volumes within a pool.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        /// <returns>
+        /// A <see cref="System.Int32"/>the number of storage pools, or -1 on failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolNumOfVolumes")]
+        public static extern int NumOfVolumes(IntPtr pool);
+
+        /// <summary>
+        /// Increment the reference count on the pool. For each additional call to this method, 
+        /// there shall be a corresponding call to virStoragePoolFree to release the reference count, 
+        /// once the caller no longer needs the reference to this object. 
+        /// This method is typically useful for applications where multiple threads are using a connection, 
+        /// and it is required that the connection remain open until all threads have finished using it. ie, 
+        /// each new thread using a pool would increment the reference count.
+        /// </summary>
+        /// <param name="pool">
+        /// The pool to hold a reference on.
+        /// </param>
+        /// <returns>
+        /// 0 in case of success, -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolRef")]
+        public static extern int Ref(IntPtr pool);
+
+        /// <summary>
+        /// Request that the pool refresh its list of volumes. This may involve communicating with a remote server, 
+        /// and/or initializing new devices at the OS layer.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        /// <param name="flags">
+        /// A <see cref="System.UInt32"/>flags to control refresh behaviour (currently unused, use 0).
+        /// </param>
+        /// <returns>
+        /// 0 if the volume list was refreshed, -1 on failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolRefresh")]
+        public static extern int Refresh(IntPtr pool, uint flags);
+
+        /// <summary>
+        /// Sets the autostart flag.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        /// <param name="autostart">
+        /// A <see cref="System.Int32"/>new flag setting.
+        /// </param>
+        /// <returns>
+        /// 0 on success, -1 on failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolSetAutostart")]
+        public static extern int SetAutostart(IntPtr pool, int autostart);
+
+        /// <summary>
+        /// Undefine an inactive storage pool.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        /// <returns>
+        /// 0 on success, -1 on failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStoragePoolUndefine")]
+        public static extern int Undefine(IntPtr pool);
+    }
+}
diff --git a/virStorageVol.cs b/virStorageVol.cs
new file mode 100644
index 0000000..18ebb5c
--- /dev/null
+++ b/virStorageVol.cs
@@ -0,0 +1,235 @@
+﻿/*
+ * Copyright (C)
+ *   Arnaud Champion <arnaud.champion@devatom.fr>
+ *   Jaromír Červenka <cervajz@cervajz.com>
+ *
+ * See COPYING.LIB for the License of this software
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace LibvirtBindings
+{
+    public class virStorageVol
+    {
+
+        /// <summary>
+        /// Create a storage volume within a pool based on an XML description. Not all pools support creation of volumes.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        /// <param name="xmldesc">
+        /// A <see cref="System.String"/>description of volume to create.
+        /// </param>
+        /// <param name="flags">
+        /// A <see cref="System.UInt32"/>flags for creation (unused, pass 0).
+        /// </param>
+        /// <returns>
+        /// The storage volume, or NULL on error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStorageVolCreateXML")]
+        public static extern IntPtr CreateXML(IntPtr pool, string xmldesc, uint flags);
+
+        /// <summary>
+        /// Create a storage volume in the parent pool, using the 'clonevol' volume as input. 
+        /// Information for the new volume (name, perms) are passed via a typical volume XML description.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to parent pool for the new volume.
+        /// </param>
+        /// <param name="xmldesc">
+        /// A <see cref="System.String"/>description of volume to create.
+        /// </param>
+        /// <param name="clonevol">
+        /// A <see cref="IntPtr"/>storage volume to use as input.
+        /// </param>
+        /// <param name="flags">
+        /// A <see cref="System.UInt32"/>flags for creation (unused, pass 0).
+        /// </param>
+        /// <returns>
+        /// A <see cref="IntPtr"/>the storage volume, or NULL on error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStorageVolCreateXMLFrom")]
+        public static extern IntPtr CreateXMLFrom(IntPtr pool, string xmldesc, IntPtr clonevol, uint flags);
+
+        /// <summary>
+        /// Delete the storage volume from the pool.
+        /// </summary>
+        /// <param name="vol">
+        /// A <see cref="IntPtr"/>pointer to storage volume.
+        /// </param>
+        /// <param name="flags">
+        /// A <see cref="System.UInt32"/>future flags, use 0 for now.
+        /// </param>
+        /// <returns>
+        /// 0 on success, or -1 on error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStorageVolDelete")]
+        public static extern int Delete(IntPtr vol, uint flags);
+
+        /// <summary>
+        /// Release the storage volume handle. The underlying storage volume continues to exist.
+        /// </summary>
+        /// <param name="vol">
+        /// A <see cref="IntPtr"/>pointer to storage volume.
+        /// </param>
+        /// <returns>
+        /// 0 on success, or -1 on error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStorageVolFree")]
+        public static extern int Free(IntPtr vol);
+
+        /// <summary>
+        /// Provides the connection pointer associated with a storage volume. 
+        /// The reference counter on the connection is not increased by this call. 
+        /// WARNING: When writing libvirt bindings in other languages, do not use this function. 
+        /// Instead, store the connection and the volume object together.
+        /// </summary>
+        /// <param name="vol">
+        /// A <see cref="IntPtr"/>
+        /// </param>
+        /// <returns>
+        /// A <see cref="IntPtr"/>
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStorageVolGetConnect")]
+        public static extern IntPtr GetConnect(IntPtr vol);
+
+        /// <summary>
+        /// Fetches volatile information about the storage volume such as its current allocation.
+        /// </summary>
+        /// <param name="vol">
+        /// A <see cref="IntPtr"/>pointer to storage volume.
+        /// </param>
+        /// <param name="info">
+        /// A <see cref="virStorageVolInfo"/>pointer at which to store info.
+        /// </param>
+        /// <returns>
+        /// 0 on success, or -1 on failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStorageVolGetInfo")]
+        public static extern int GetInfo(IntPtr vol, ref virStorageVolInfo info);
+
+        /// <summary>
+        /// Fetch the storage volume key. 
+        /// This is globally unique, so the same volume will have the same key no matter what host it is accessed from
+        /// </summary>
+        /// <param name="vol">
+        /// A <see cref="IntPtr"/>pointer to storage volume.
+        /// </param>
+        /// <returns>
+        /// The volume key, or NULL on error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStorageVolGetKey")]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
+        public static extern string GetKey(IntPtr vol);
+
+        /// <summary>
+        /// Fetch the storage volume name. This is unique within the scope of a pool.
+        /// </summary>
+        /// <param name="vol">
+        /// A <see cref="IntPtr"/>pointer to storage volume.
+        /// </param>
+        /// <returns>
+        /// The volume name, or NULL on error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStorageVolGetName")]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
+        public static extern string GetName(IntPtr vol);
+
+        /// <summary>
+        /// Fetch the storage volume path. 
+        /// Depending on the pool configuration this is either persistent across hosts, 
+        /// or dynamically assigned at pool startup. 
+        /// Consult pool documentation for information on getting the persistent naming.
+        /// </summary>
+        /// <param name="vol">
+        /// A <see cref="IntPtr"/>pointer to storage volume.
+        /// </param>
+        /// <returns>
+        /// The storage volume path, or NULL on error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStorageVolGetPath")]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
+        public static extern string GetPath(IntPtr vol);
+
+        /// <summary>
+        /// Fetch an XML document describing all aspects of the storage volume.
+        /// </summary>
+        /// <param name="vol">
+        /// A <see cref="IntPtr"/>pointer to storage volume.
+        /// </param>
+        /// <param name="flags">
+        /// A <see cref="System.UInt32"/>flags for XML generation (unused, pass 0).
+        /// </param>
+        /// <returns>
+        /// The XML document, or NULL on error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStorageVolGetXMLDesc")]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
+        public static extern string GetXMLDesc(IntPtr vol, uint flags);
+
+        /// <summary>
+        /// Fetch a pointer to a storage volume based on its globally unique key.
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to hypervisor connection.
+        /// </param>
+        /// <param name="key">
+        /// A <see cref="System.String"/>globally unique key.
+        /// </param>
+        /// <returns>
+        /// A <see cref="IntPtr"/>storage volume, or NULL if not found / error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStorageVolLookupByKey")]
+        public static extern IntPtr LookupByKey(IntPtr conn, string key);
+
+        /// <summary>
+        /// Fetch a pointer to a storage volume based on its name within a pool.
+        /// </summary>
+        /// <param name="pool">
+        /// A <see cref="IntPtr"/>pointer to storage pool.
+        /// </param>
+        /// <param name="name">
+        /// A <see cref="System.String"/>name of storage volume.
+        /// </param>
+        /// <returns>
+        /// A <see cref="IntPtr"/>storage volume, or NULL if not found / error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStorageVolLookupByName")]
+        public static extern IntPtr LookupByName(IntPtr pool, string name);
+
+        /// <summary>
+        /// Fetch a pointer to a storage volume based on its locally (host) unique path.
+        /// </summary>
+        /// <param name="conn">
+        /// A <see cref="IntPtr"/>pointer to hypervisor connection.
+        /// </param>
+        /// <param name="path">
+        /// A <see cref="System.String"/>locally unique path.
+        /// </param>
+        /// <returns>
+        /// A <see cref="IntPtr"/>storage volume, or NULL if not found / error.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStorageVolLookupByPath")]
+        public static extern IntPtr LookupByPath(IntPtr conn, string path);
+
+        /// <summary>
+        /// Increment the reference count on the vol. For each additional call to this method, 
+        /// there shall be a corresponding call to virStorageVolFree to release the reference count, 
+        /// once the caller no longer needs the reference to this object. 
+        /// This method is typically useful for applications where multiple threads are using a connection, 
+        /// and it is required that the connection remain open until all threads have finished using it. ie, 
+        /// each new thread using a vol would increment the reference count.
+        /// </summary>
+        /// <param name="vol">
+        /// A <see cref="IntPtr"/>the vol to hold a reference on.
+        /// </param>
+        /// <returns>
+        /// A <see cref="System.Int32"/>0 in case of success, -1 in case of failure.
+        /// </returns>
+        [DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virStorageVolRef")]
+        public static extern int Ref(IntPtr vol);
+    }
+}
diff --git a/virStream.cs b/virStream.cs
new file mode 100644
index 0000000..52aa8ec
--- /dev/null
+++ b/virStream.cs
@@ -0,0 +1,43 @@
+﻿/*
+ * Copyright (C)
+ *   Arnaud Champion <arnaud.champion@devatom.fr>
+ *   Jaromír Červenka <cervajz@cervajz.com>
+ *
+ * See COPYING.LIB for the License of this software
+ */
+
+namespace LibvirtBindings
+{
+    public class virStream
+    {
+        // TODO virStreamAbort
+
+        // TODO virStreamEventAddCallback
+
+        // TODO virStreamEventCallback
+
+        // TODO virStreamEventRemoveCallback
+
+        // TODO virStreamEventUpdateCallback
+
+        // TODO virStreamFinish
+
+        // TODO virStreamFree
+
+        // TODO virStreamNew
+
+        // TODO virStreamRecv
+
+        // TODO virStreamRecvAll
+
+        // TODO virStreamRef
+
+        // TODO virStreamSend
+
+        // TODO virStreamSendAll
+
+        // TODO virStreamSinkFunc
+
+        // TODO virStreamSourceFunc
+    }
+}
-- 
1.7.2.3.msysgit.0

