diff --git a/ChangeLog b/ChangeLog index 204a54c713..cd83d5bd31 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Thu May 21 14:32:22 BST 2009 Daniel P. Berrange + + Public APIs for domain XML conversions. + * docs/devhelp/libvirt-libvirt.html, docs/devhelp/libvirt-virterror.html, + docs/html/libvirt-libvirt.html, docs/html/libvirt-virterror.html, + docs/libvirt-api.xml, docs/libvirt-refs.xml: Regenerate with new public + APIs + * include/libvirt/libvirt.h, include/libvirt/libvirt.h.in, + src/driver.h, src/libvirt.c, src/libvirt_public.syms: Add + virConnectDomainXMLFromNative and virConnectDomainXMLToNative + * src/lxc_driver.c, src/openvz_driver.c, src/qemu_driver.c, + src/remote_internal.c, src/test.c, src/uml_driver.c, + src/xen_unified.c: Stub out new API entry points + * src/virsh.c: Add domxml-to-native and domxml-from-native commands + Thu May 21 11:52:22 BST 2009 Daniel P. Berrange * python/generator.py, python/libvirt_wrap.h, python/types.c: Add diff --git a/docs/devhelp/libvirt-libvirt.html b/docs/devhelp/libvirt-libvirt.html index 59717ef0ef..587b5bd08a 100644 --- a/docs/devhelp/libvirt-libvirt.html +++ b/docs/devhelp/libvirt-libvirt.html @@ -84,9 +84,11 @@ typedef struct _virNodeDevice virNodeDevice; typedef virConnect * virConnectPtr; typedef struct _virStorageVol virStorageVol; typedef virNodeDevice * virNodeDevicePtr; +typedef struct _virInterface virInterface; typedef struct _virSchedParameter virSchedParameter; typedef enum virConnectFlags; typedef enum virDomainEventDefinedDetailType; +typedef virInterface * virInterfacePtr; typedef enum virDomainMemoryFlags; typedef enum virDomainEventStoppedDetailType; typedef virStorageVol * virStorageVolPtr; @@ -122,6 +124,7 @@ int virNodeGetCellsFreeMemory (virInitialize (void); const char * virNodeDeviceGetName (virNodeDevicePtr dev); int virStoragePoolSetAutostart (virStoragePoolPtr pool,
int autostart); +char * virConnectDomainXMLFromNative (virConnectPtr conn,
const char * nativeFormat,
const char * nativeConfig,
unsigned int flags); int virNodeDeviceDettach (virNodeDevicePtr dev); int virDomainGetSecurityLabel (virDomainPtr domain,
virSecurityLabelPtr seclabel); int virConnectDomainEventDeregister (virConnectPtr conn,
virConnectDomainEventCallback cb); @@ -130,7 +133,7 @@ int virDomainGetSchedulerParametersvirConnectNumOfDefinedNetworks (virConnectPtr conn); int virConnectNumOfDomains (virConnectPtr conn); int virNetworkGetUUID (virNetworkPtr network,
unsigned char * uuid); -virNodeDevicePtr virNodeDeviceCreateXML (virConnectPtr conn,
const char * xmlDesc,
unsigned int flags); +char * virInterfaceGetXMLDesc (virInterfacePtr interface,
unsigned int flags); virConnectPtr virStoragePoolGetConnect (virStoragePoolPtr pool); int virConnectGetVersion (virConnectPtr conn,
unsigned long * hvVer); int virDomainFree (virDomainPtr domain); @@ -143,6 +146,7 @@ int virDomainSetAutostart (virNetworkCreate (virNetworkPtr network); int virDomainSetMaxMemory (virDomainPtr domain,
unsigned long memory); void virEventRegisterImpl (virEventAddHandleFunc addHandle,
virEventUpdateHandleFunc updateHandle,
virEventRemoveHandleFunc removeHandle,
virEventAddTimeoutFunc addTimeout,
virEventUpdateTimeoutFunc updateTimeout,
virEventRemoveTimeoutFunc removeTimeout); +virInterfacePtr virInterfaceDefineXML (virConnectPtr conn,
const char * xml,
unsigned int flags); virDomainPtr virDomainMigrate (virDomainPtr domain,
virConnectPtr dconn,
unsigned long flags,
const char * dname,
const char * uri,
unsigned long bandwidth); int virDomainSuspend (virDomainPtr domain); virDomainPtr virDomainCreateLinux (virConnectPtr conn,
const char * xmlDesc,
unsigned int flags); @@ -151,17 +155,20 @@ typedef void virEventUpdateHandleFunc (i int virDomainDestroy (virDomainPtr domain); int virConnectNumOfNetworks (virConnectPtr conn); virStoragePoolPtr virStoragePoolLookupByUUIDString (virConnectPtr conn,
const char * uuidstr); +int virInterfaceCreate (virInterfacePtr interface,
unsigned int flags); char * virDomainGetXMLDesc (virDomainPtr domain,
int flags); int virStoragePoolGetUUID (virStoragePoolPtr pool,
unsigned char * uuid); int virNodeDeviceFree (virNodeDevicePtr dev); int virStorageVolGetInfo (virStorageVolPtr vol,
virStorageVolInfoPtr info); int virDomainGetInfo (virDomainPtr domain,
virDomainInfoPtr info); +virNodeDevicePtr virNodeDeviceCreateXML (virConnectPtr conn,
const char * xmlDesc,
unsigned int flags); int virNetworkDestroy (virNetworkPtr network); virStoragePoolPtr virStoragePoolLookupByName (virConnectPtr conn,
const char * name); virStoragePoolPtr virStoragePoolCreateXML (virConnectPtr conn,
const char * xmlDesc,
unsigned int flags); int virNetworkGetAutostart (virNetworkPtr network,
int * autostart); char * virNetworkGetBridgeName (virNetworkPtr network); char * virStorageVolGetXMLDesc (virStorageVolPtr vol,
unsigned int flags); +char * virConnectDomainXMLToNative (virConnectPtr conn,
const char * nativeFormat,
const char * domainXml,
unsigned int flags); int virDomainSetSchedulerParameters (virDomainPtr domain,
virSchedParameterPtr params,
int nparams); const char * virConnectGetType (virConnectPtr conn); virStorageVolPtr virStorageVolCreateXML (virStoragePoolPtr pool,
const char * xmldesc,
unsigned int flags); @@ -170,6 +177,7 @@ int virDomainCreate (virConnectListDomains (virConnectPtr conn,
int * ids,
int maxids); int virDomainCoreDump (virDomainPtr domain,
const char * to,
int flags); int virDomainSetMemory (virDomainPtr domain,
unsigned long memory); +const char * virInterfaceGetName (virInterfacePtr interface); int virStoragePoolCreate (virStoragePoolPtr pool,
unsigned int flags); int virNodeGetInfo (virConnectPtr conn,
virNodeInfoPtr info); int virNetworkSetAutostart (virNetworkPtr network,
int autostart); @@ -192,6 +200,7 @@ const char * virDomainGetName (virStoragePoolRef (virStoragePoolPtr pool); char * virNetworkGetXMLDesc (virNetworkPtr network,
int flags); int virConnectNumOfStoragePools (virConnectPtr conn); +virConnectPtr virInterfaceGetConnect (virInterfacePtr interface); const char * virNetworkGetName (virNetworkPtr network); int virConnectListDefinedDomains (virConnectPtr conn,
char ** const names,
int maxnames); char * virConnectGetCapabilities (virConnectPtr conn); @@ -207,21 +216,24 @@ typedef int virConnectDomainEventCallba virDomainPtr virDomainLookupByID (virConnectPtr conn,
int id); int virStorageVolDelete (virStorageVolPtr vol,
unsigned int flags); int virStorageVolFree (virStorageVolPtr vol); +int virConnectListInterfaces (virConnectPtr conn,
char ** const names,
int maxnames); int virDomainMemoryPeek (virDomainPtr dom,
unsigned long long start,
size_t size,
void * buffer,
unsigned int flags); virNetworkPtr virNetworkLookupByUUID (virConnectPtr conn,
const unsigned char * uuid); int virConnectListDefinedNetworks (virConnectPtr conn,
char ** const names,
int maxnames); int virConnectRef (virConnectPtr conn); int virDomainGetUUID (virDomainPtr domain,
unsigned char * uuid); virNetworkPtr virNetworkCreateXML (virConnectPtr conn,
const char * xmlDesc); +int virConnectDomainEventRegister (virConnectPtr conn,
virConnectDomainEventCallback cb,
void * opaque,
virFreeCallback freecb); int virDomainGetVcpus (virDomainPtr domain,
virVcpuInfoPtr info,
int maxinfo,
unsigned char * cpumaps,
int maplen); virNodeDevicePtr virNodeDeviceLookupByName (virConnectPtr conn,
const char * name); int virStoragePoolGetInfo (virStoragePoolPtr pool,
virStoragePoolInfoPtr info); int virDomainResume (virDomainPtr domain); -int virNodeListDevices (virConnectPtr conn,
const char * cap,
char ** const names,
int maxnames,
unsigned int flags); +int virInterfaceRef (virInterfacePtr interface); +const char * virInterfaceGetMACString (virInterfacePtr interface); int virNetworkRef (virNetworkPtr network); int virStoragePoolRefresh (virStoragePoolPtr pool,
unsigned int flags); int virConnectNumOfDefinedDomains (virConnectPtr conn); -virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn,
const char * key); +virStorageVolPtr virStorageVolCreateXMLFrom (virStoragePoolPtr pool,
const char * xmldesc,
virStorageVolPtr clonevol,
unsigned int flags); int virDomainUndefine (virDomainPtr domain); int virDomainReboot (virDomainPtr domain,
unsigned int flags); int virNetworkGetUUIDString (virNetworkPtr network,
char * buf); @@ -245,10 +257,12 @@ typedef int virEventAddHandleFunc (int fd, int virNetworkUndefine (virNetworkPtr network); int virConnectListDefinedStoragePools (virConnectPtr conn,
char ** const names,
int maxnames); typedef void virEventTimeoutCallback (int timer,
void * opaque); -virStorageVolPtr virStorageVolCreateXMLFrom (virStoragePoolPtr pool,
const char * xmldesc,
virStorageVolPtr clonevol,
unsigned int flags); +int virInterfaceFree (virInterfacePtr interface); int virNodeDeviceNumOfCaps (virNodeDevicePtr dev); +virInterfacePtr virInterfaceLookupByMACString (virConnectPtr conn,
const char * macstr); virConnectPtr virNetworkGetConnect (virNetworkPtr net); unsigned long long virNodeGetFreeMemory (virConnectPtr conn); +int virInterfaceDestroy (virInterfacePtr interface,
unsigned int flags); virConnectPtr virStorageVolGetConnect (virStorageVolPtr vol); int virNodeNumOfDevices (virConnectPtr conn,
const char * cap,
unsigned int flags); int virStoragePoolDestroy (virStoragePoolPtr pool); @@ -260,18 +274,22 @@ int virConnectGetMaxVcpus (virDomainGetUUIDString (virDomainPtr domain,
char * buf); virConnectPtr virDomainGetConnect (virDomainPtr dom); int virConnectNumOfDefinedStoragePools (virConnectPtr conn); +int virNodeListDevices (virConnectPtr conn,
const char * cap,
char ** const names,
int maxnames,
unsigned int flags); const char * virNodeDeviceGetParent (virNodeDevicePtr dev); virConnectPtr virConnectOpen (const char * name); virDomainPtr virDomainCreateXML (virConnectPtr conn,
const char * xmlDesc,
unsigned int flags); int virNodeDeviceRef (virNodeDevicePtr dev); +int virInterfaceUndefine (virInterfacePtr interface); int virDomainSetVcpus (virDomainPtr domain,
unsigned int nvcpus); int virDomainRef (virDomainPtr domain); -int virConnectDomainEventRegister (virConnectPtr conn,
virConnectDomainEventCallback cb,
void * opaque,
virFreeCallback freecb); +int virConnectNumOfInterfaces (virConnectPtr conn); unsigned int virDomainGetID (virDomainPtr domain); int virDomainBlockPeek (virDomainPtr dom,
const char * path,
unsigned long long offset,
size_t size,
void * buffer,
unsigned int flags); typedef int virEventAddTimeoutFunc (int timeout,
virEventTimeoutCallback cb,
void * opaque,
virFreeCallback ff); +virInterfacePtr virInterfaceLookupByName (virConnectPtr conn,
const char * name); int virDomainInterfaceStats (virDomainPtr dom,
const char * path,
virDomainInterfaceStatsPtr stats,
size_t size); int virConnectListNetworks (virConnectPtr conn,
char ** const names,
int maxnames); +virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn,
const char * key);
@@ -550,6 +568,16 @@ The content of this structure is not made public by the API. VIR_EVENT_HANDLE_HANGUP = 8 };

+

+
+

Structure virInterface

struct _virInterface {
+The content of this structure is not made public by the API.
+} virInterface;
+

+

+
+

Typedef virInterfacePtr

virInterface * virInterfacePtr;
+

a virInterfacePtr is pointer to a virInterface private structure, this is the type used to reference a virtual interface in the API.


Structure virNetwork

struct _virNetwork {
@@ -794,6 +822,14 @@ The content of this structure is not made public by the API.
         

virConnectDomainEventRegister ()

int	virConnectDomainEventRegister	(virConnectPtr conn, 
virConnectDomainEventCallback cb,
void * opaque,
virFreeCallback freecb)

Adds a Domain Event Callback. Registering for a domain callback will enable delivery of the events 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

conn:pointer to the connection
cb:callback to the function handling domain events
opaque:opaque data to pass on to the callback
freecb:optional function to deallocate opaque when not used anymore
Returns:it 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
+
+

virConnectDomainXMLFromNative ()

char *	virConnectDomainXMLFromNative	(virConnectPtr conn, 
const char * nativeFormat,
const char * nativeConfig,
unsigned int flags)
+

Reads native configuration data describing a domain, and generates libvirt domain XML. The format of the native data is hypervisor dependant.

+
conn:a connection object
nativeFormat:configuration format importing from
nativeConfig:the configuration data to import
flags:currently unused, pass 0
Returns:a 0 terminated UTF-8 encoded XML instance, or NULL in case of error. the caller must free() the returned value.
+
+

virConnectDomainXMLToNative ()

char *	virConnectDomainXMLToNative	(virConnectPtr conn, 
const char * nativeFormat,
const char * domainXml,
unsigned int flags)
+

Reads a domain XML configuration document, and generates generates a native configuration file describing the domain. The format of the native data is hypervisor dependant.

+
conn:a connection object
nativeFormat:configuration format exporting to
domainXml:the domain configuration to export
flags:currently unused, pass 0
Returns:a 0 terminated UTF-8 encoded native config datafile, or NULL in case of error. the caller must free() the returned value.

virConnectFindStoragePoolSources ()

char *	virConnectFindStoragePoolSources	(virConnectPtr conn, 
const char * type,
const char * srcSpec,
unsigned int flags)

Talks to a storage backend and attempts to auto-discover the set of available storage pool sources. e.g. For iSCSI this would be a set of iSCSI targets. For NFS this would be a list of exported paths. The srcSpec (optional for some storage pool types, e.g. local ones) is an instance of the storage pool's source element specifying where to look for the pools. srcSpec is not required for some types (e.g., those querying local storage resources only)

@@ -838,6 +874,10 @@ The content of this structure is not made public by the API.

virConnectListDomains ()

int	virConnectListDomains		(virConnectPtr conn, 
int * ids,
int maxids)

Collect the list of active domains, and store their ID in @maxids

conn:pointer to the hypervisor connection
ids:array to collect the list of IDs of active domains
maxids:size of @ids
Returns:the number of domain found or -1 in case of error
+
+

virConnectListInterfaces ()

int	virConnectListInterfaces	(virConnectPtr conn, 
char ** const names,
int maxnames)
+

Collect the list of physical host interfaces, and store their names in @names

+
conn:pointer to the hypervisor connection
names:array to collect the list of names of interfaces
maxnames:size of @names
Returns:the number of interfaces found or -1 in case of error

virConnectListNetworks ()

int	virConnectListNetworks		(virConnectPtr conn, 
char ** const names,
int maxnames)

Collect the list of active networks, and store their names in @names

@@ -862,6 +902,10 @@ The content of this structure is not made public by the API.

virConnectNumOfDomains ()

int	virConnectNumOfDomains		(virConnectPtr conn)

Provides the number of active domains.

conn:pointer to the hypervisor connection
Returns:the number of domain found or -1 in case of error
+
+

virConnectNumOfInterfaces ()

int	virConnectNumOfInterfaces	(virConnectPtr conn)
+

Provides the number of interfaces on the physical host.

+
conn:pointer to the hypervisor connection
Returns:the number of interface found or -1 in case of error

virConnectNumOfNetworks ()

int	virConnectNumOfNetworks		(virConnectPtr conn)

Provides the number of active networks.

@@ -1086,6 +1130,54 @@ The content of this structure is not made public by the API. +
+

virInterfaceCreate ()

int	virInterfaceCreate		(virInterfacePtr interface, 
unsigned int flags)
+

Activate an interface (ie call "ifup")

+
interface:pointer to a defined interface
flags:and OR'ed set of extraction flags, not used yet
Returns:0 in case of success, -1 in case of error
+
+

virInterfaceDefineXML ()

virInterfacePtr	virInterfaceDefineXML	(virConnectPtr conn, 
const char * xml,
unsigned int flags)
+

Define an interface (or modify existing interface configuration)

+
conn:pointer to the hypervisor connection
xml:the XML description for the interface, preferably in UTF-8
flags:and OR'ed set of extraction flags, not used yet
Returns:NULL in case of error, a pointer to the interface otherwise
+
+

virInterfaceDestroy ()

int	virInterfaceDestroy		(virInterfacePtr interface, 
unsigned int flags)
+

deactivate an interface (ie call "ifdown") This does not remove the interface from the config, and does not free the associated virInterfacePtr object.

+
interface:an interface object
flags:and OR'ed set of extraction flags, not used yet
Returns:0 in case of success and -1 in case of failure.
+
+

virInterfaceFree ()

int	virInterfaceFree		(virInterfacePtr interface)
+

Free the interface object. The interface itself is unaltered. The data structure is freed and should not be used thereafter.

+
interface:a interface object
Returns:0 in case of success and -1 in case of failure.
+
+

virInterfaceGetConnect ()

virConnectPtr	virInterfaceGetConnect	(virInterfacePtr interface)
+

Provides the connection pointer associated with an interface. 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 interface object together.

+
interface:
Returns:the virConnectPtr or NULL in case of failure.
+
+

virInterfaceGetMACString ()

const char *	virInterfaceGetMACString	(virInterfacePtr interface)
+

Get the MAC for a interface as string. For more information about MAC see RFC4122.

+
interface:a interface object
Returns:a pointer to the MAC address (in null-terminated ASCII format) or NULL, the string need not be deallocated its lifetime will be the same as the interface object.
+
+

virInterfaceGetName ()

const char *	virInterfaceGetName	(virInterfacePtr interface)
+

Get the public name for that interface

+
interface:a interface object
Returns:a pointer to the name or NULL, the string need not be deallocated its lifetime will be the same as the interface object.
+
+

virInterfaceGetXMLDesc ()

char *	virInterfaceGetXMLDesc		(virInterfacePtr interface, 
unsigned int flags)
+

Provide an XML description of the interface. The description may be reused later to recreate the interface with virInterfaceCreateXML().

+
interface:a interface object
flags:and OR'ed set of extraction flags, not used yet
Returns:a 0 terminated UTF-8 encoded XML instance, or NULL in case of error. the caller must free() the returned value.
+
+

virInterfaceLookupByMACString ()

virInterfacePtr	virInterfaceLookupByMACString	(virConnectPtr conn, 
const char * macstr)
+

Try to lookup an interface on the given hypervisor based on its MAC.

+
conn:pointer to the hypervisor connection
macstr:the MAC for the interface (null-terminated ASCII format)
Returns:a new interface object or NULL in case of failure. If the interface cannot be found, then VIR_ERR_NO_INTERFACE error is raised.
+
+

virInterfaceLookupByName ()

virInterfacePtr	virInterfaceLookupByName	(virConnectPtr conn, 
const char * name)
+

Try to lookup an interface on the given hypervisor based on its name.

+
conn:pointer to the hypervisor connection
name:name for the interface
Returns:a new interface object or NULL in case of failure. If the interface cannot be found, then VIR_ERR_NO_INTERFACE error is raised.
+
+

virInterfaceRef ()

int	virInterfaceRef			(virInterfacePtr interface)
+

Increment the reference count on the interface. For each additional call to this method, there shall be a corresponding call to virInterfaceFree 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 interface would increment the reference count.

+
interface:the interface to hold a reference on
Returns:0 in case of success, -1 in case of failure.
+
+

virInterfaceUndefine ()

int	virInterfaceUndefine		(virInterfacePtr interface)
+

Undefine an interface, ie remove it from the config. This does not free the associated virInterfacePtr object.

+
interface:pointer to a defined interface
Returns:0 in case of success, -1 in case of error

virNetworkCreate ()

int	virNetworkCreate		(virNetworkPtr network)

Create and start a defined network. If the call succeed the network moves from the defined to the running networks pools.

diff --git a/docs/devhelp/libvirt-virterror.html b/docs/devhelp/libvirt-virterror.html index b2055832c0..e9e98965e2 100644 --- a/docs/devhelp/libvirt-virterror.html +++ b/docs/devhelp/libvirt-virterror.html @@ -107,7 +107,8 @@ void virConnResetLastError (VIR_FROM_NODEDEV = 22 /* Error from node device monitor */ VIR_FROM_XEN_INOTIFY = 23 /* Error from xen inotify layer */ VIR_FROM_SECURITY = 24 /* Error from security framework */ - VIR_FROM_VBOX = 25 /* Error from VirtualBox driver */ + VIR_FROM_VBOX = 25 /* Error from VirtualBox driver */ + VIR_FROM_INTERFACE = 26 /* Error when operating on an interface */ };

@@ -176,7 +177,10 @@ void virConnResetLastError (VIR_ERR_INVALID_NODE_DEVICE = 52 /* invalid node device object */ VIR_ERR_NO_NODE_DEVICE = 53 /* node device not found */ VIR_ERR_NO_SECURITY_MODEL = 54 /* security model not found */ - VIR_ERR_OPERATION_INVALID = 55 /* operation is not applicable at this time */ + VIR_ERR_OPERATION_INVALID = 55 /* operation is not applicable at this time */ + VIR_WAR_NO_INTERFACE = 56 /* failed to start interface driver */ + VIR_ERR_NO_INTERFACE = 57 /* interface driver not running */ + VIR_ERR_INVALID_INTERFACE = 58 /* invalid interface object */ };

diff --git a/docs/html/libvirt-libvirt.html b/docs/html/libvirt-libvirt.html index 4a12696739..073d2d7138 100644 --- a/docs/html/libvirt-libvirt.html +++ b/docs/html/libvirt-libvirt.html @@ -46,6 +46,8 @@ typedef virDomain * virDomainState typedef enum virDomainXMLFlags typedef enum virEventHandleType +typedef struct _virInterface virInterface +typedef virInterface * virInterfacePtr typedef struct _virNetwork virNetwork typedef virNetwork * virNetworkPtr typedef struct _virNodeDevice virNodeDevice @@ -84,6 +86,8 @@ int virConnectDomainEventCallback ( int virConnectDomainEventDeregister (virConnectPtr conn,
virConnectDomainEventCallback cb) int virConnectDomainEventRegister (virConnectPtr conn,
virConnectDomainEventCallback cb,
void * opaque,
virFreeCallback freecb) +char * virConnectDomainXMLFromNative (virConnectPtr conn,
const char * nativeFormat,
const char * nativeConfig,
unsigned int flags) +char * virConnectDomainXMLToNative (virConnectPtr conn,
const char * nativeFormat,
const char * domainXml,
unsigned int flags) char * virConnectFindStoragePoolSources (virConnectPtr conn,
const char * type,
const char * srcSpec,
unsigned int flags) char * virConnectGetCapabilities (virConnectPtr conn) char * virConnectGetHostname (virConnectPtr conn) @@ -95,12 +99,14 @@ int virConnectListDefinedDomains (virConnectListDefinedNetworks (virConnectPtr conn,
char ** const names,
int maxnames) int virConnectListDefinedStoragePools (virConnectPtr conn,
char ** const names,
int maxnames) int virConnectListDomains (virConnectPtr conn,
int * ids,
int maxids) +int virConnectListInterfaces (virConnectPtr conn,
char ** const names,
int maxnames) int virConnectListNetworks (virConnectPtr conn,
char ** const names,
int maxnames) int virConnectListStoragePools (virConnectPtr conn,
char ** const names,
int maxnames) int virConnectNumOfDefinedDomains (virConnectPtr conn) int virConnectNumOfDefinedNetworks (virConnectPtr conn) int virConnectNumOfDefinedStoragePools (virConnectPtr conn) int virConnectNumOfDomains (virConnectPtr conn) +int virConnectNumOfInterfaces (virConnectPtr conn) int virConnectNumOfNetworks (virConnectPtr conn) int virConnectNumOfStoragePools (virConnectPtr conn) virConnectPtr virConnectOpen (const char * name) @@ -184,6 +190,18 @@ void virFreeCallback (void * opaque) int virGetVersion (unsigned long * libVer,
const char * type,
unsigned long * typeVer) int virInitialize (void) +int virInterfaceCreate (virInterfacePtr interface,
unsigned int flags) +virInterfacePtr virInterfaceDefineXML (virConnectPtr conn,
const char * xml,
unsigned int flags) +int virInterfaceDestroy (virInterfacePtr interface,
unsigned int flags) +int virInterfaceFree (virInterfacePtr interface) +virConnectPtr virInterfaceGetConnect (virInterfacePtr interface) +const char * virInterfaceGetMACString (virInterfacePtr interface) +const char * virInterfaceGetName (virInterfacePtr interface) +char * virInterfaceGetXMLDesc (virInterfacePtr interface,
unsigned int flags) +virInterfacePtr virInterfaceLookupByMACString (virConnectPtr conn,
const char * macstr) +virInterfacePtr virInterfaceLookupByName (virConnectPtr conn,
const char * name) +int virInterfaceRef (virInterfacePtr interface) +int virInterfaceUndefine (virInterfacePtr interface) int virNetworkCreate (virNetworkPtr network) virNetworkPtr virNetworkCreateXML (virConnectPtr conn,
const char * xmlDesc) virNetworkPtr virNetworkDefineXML (virConnectPtr conn,
const char * xml) @@ -310,6 +328,9 @@ int virStorageVolRef (VIR_DOMAIN_XML_SECURE = 1 : dump security sensitive information tooVIR_DOMAIN_XML_INACTIVE = 2 : dump inactive domain information

}
 

virEventHandleType

virInterface

struct virInterface{
+
The content of this structure is not made public by the API
+}
 

virNetwork

struct virNetwork{
 
The content of this structure is not made public by the API
 }
@@ -362,7 +383,9 @@ int	virStorageVolRef		(
conn:pointer to the hypervisor connection
Returns:0 in case of success or -1 in case of error.

virConnectDomainEventCallback

typedef int	(*virConnectDomainEventCallback)	(virConnectPtr conn, 
virDomainPtr dom,
int event,
int detail,
void * opaque)

A callback function to be registered, and called when a domain event occurs

conn:virConnect connection
dom:The domain on which the event occured
event:The specfic virDomainEventType which occured
detail:event specific detail information
opaque:opaque user data
Returns:

virConnectDomainEventDeregister

int	virConnectDomainEventDeregister	(virConnectPtr conn, 
virConnectDomainEventCallback cb)

Removes a Domain Event Callback. De-registering for a domain callback will disable delivery of this event type

conn:pointer to the connection
cb:callback to the function handling domain events
Returns:0 on success, -1 on failure

virConnectDomainEventRegister

int	virConnectDomainEventRegister	(virConnectPtr conn, 
virConnectDomainEventCallback cb,
void * opaque,
virFreeCallback freecb)
-

Adds a Domain Event Callback. Registering for a domain callback will enable delivery of the events 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

conn:pointer to the connection
cb:callback to the function handling domain events
opaque:opaque data to pass on to the callback
freecb:optional function to deallocate opaque when not used anymore
Returns:it 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

virConnectFindStoragePoolSources

char *	virConnectFindStoragePoolSources	(virConnectPtr conn, 
const char * type,
const char * srcSpec,
unsigned int flags)
+

Adds a Domain Event Callback. Registering for a domain callback will enable delivery of the events 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

conn:pointer to the connection
cb:callback to the function handling domain events
opaque:opaque data to pass on to the callback
freecb:optional function to deallocate opaque when not used anymore
Returns:it 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

virConnectDomainXMLFromNative

char *	virConnectDomainXMLFromNative	(virConnectPtr conn, 
const char * nativeFormat,
const char * nativeConfig,
unsigned int flags)
+

Reads native configuration data describing a domain, and generates libvirt domain XML. The format of the native data is hypervisor dependant.

conn:a connection object
nativeFormat:configuration format importing from
nativeConfig:the configuration data to import
flags:currently unused, pass 0
Returns:a 0 terminated UTF-8 encoded XML instance, or NULL in case of error. the caller must free() the returned value.

virConnectDomainXMLToNative

char *	virConnectDomainXMLToNative	(virConnectPtr conn, 
const char * nativeFormat,
const char * domainXml,
unsigned int flags)
+

Reads a domain XML configuration document, and generates generates a native configuration file describing the domain. The format of the native data is hypervisor dependant.

conn:a connection object
nativeFormat:configuration format exporting to
domainXml:the domain configuration to export
flags:currently unused, pass 0
Returns:a 0 terminated UTF-8 encoded native config datafile, or NULL in case of error. the caller must free() the returned value.

virConnectFindStoragePoolSources

char *	virConnectFindStoragePoolSources	(virConnectPtr conn, 
const char * type,
const char * srcSpec,
unsigned int flags)

Talks to a storage backend and attempts to auto-discover the set of available storage pool sources. e.g. For iSCSI this would be a set of iSCSI targets. For NFS this would be a list of exported paths. The srcSpec (optional for some storage pool types, e.g. local ones) is an instance of the storage pool's source element specifying where to look for the pools. srcSpec is not required for some types (e.g., those querying local storage resources only)

conn:pointer to hypervisor connection
type:type of storage pool sources to discover
srcSpec:XML document specifying discovery source
flags:flags for discovery (unused, pass 0)
Returns:an xml document consisting of a SourceList element containing a source document appropriate to the given pool type for each discovered source.

virConnectGetCapabilities

char *	virConnectGetCapabilities	(virConnectPtr conn)

Provides capabilities of the hypervisor / driver.

conn:pointer to the hypervisor connection
Returns:NULL in case of error, or an XML string defining the capabilities. The client must free the returned string after use.

virConnectGetHostname

char *	virConnectGetHostname		(virConnectPtr conn)

This returns the system hostname on which the hypervisor is running (the result of the gethostname(2) system call). If we are connected to a remote system, then this returns the hostname of the remote system.

conn:pointer to a hypervisor connection
Returns:the hostname which must be freed by the caller, or NULL if there was an error.

virConnectGetMaxVcpus

int	virConnectGetMaxVcpus		(virConnectPtr conn, 
const char * type)
@@ -373,13 +396,15 @@ int virStorageVolRef (
conn:pointer to the hypervisor connection
names:pointer to an array to store the names
maxnames:size of the array
Returns:the number of names provided in the array or -1 in case of error

virConnectListDefinedNetworks

int	virConnectListDefinedNetworks	(virConnectPtr conn, 
char ** const names,
int maxnames)

list the inactive networks, stores the pointers to the names in @names

conn:pointer to the hypervisor connection
names:pointer to an array to store the names
maxnames:size of the array
Returns:the number of names provided in the array or -1 in case of error

virConnectListDefinedStoragePools

int	virConnectListDefinedStoragePools	(virConnectPtr conn, 
char ** const names,
int maxnames)

Provides the list of names of inactive storage pools upto maxnames. If there are more than maxnames, the remaining names will be silently ignored.

conn:pointer to hypervisor connection
names:array of char * to fill with pool names (allocated by caller)
maxnames:size of the names array
Returns:0 on success, -1 on error

virConnectListDomains

int	virConnectListDomains		(virConnectPtr conn, 
int * ids,
int maxids)
-

Collect the list of active domains, and store their ID in @maxids

conn:pointer to the hypervisor connection
ids:array to collect the list of IDs of active domains
maxids:size of @ids
Returns:the number of domain found or -1 in case of error

virConnectListNetworks

int	virConnectListNetworks		(virConnectPtr conn, 
char ** const names,
int maxnames)
+

Collect the list of active domains, and store their ID in @maxids

conn:pointer to the hypervisor connection
ids:array to collect the list of IDs of active domains
maxids:size of @ids
Returns:the number of domain found or -1 in case of error

virConnectListInterfaces

int	virConnectListInterfaces	(virConnectPtr conn, 
char ** const names,
int maxnames)
+

Collect the list of physical host interfaces, and store their names in @names

conn:pointer to the hypervisor connection
names:array to collect the list of names of interfaces
maxnames:size of @names
Returns:the number of interfaces found or -1 in case of error

virConnectListNetworks

int	virConnectListNetworks		(virConnectPtr conn, 
char ** const names,
int maxnames)

Collect the list of active networks, and store their names in @names

conn:pointer to the hypervisor connection
names:array to collect the list of names of active networks
maxnames:size of @names
Returns:the number of networks found or -1 in case of error

virConnectListStoragePools

int	virConnectListStoragePools	(virConnectPtr conn, 
char ** const names,
int maxnames)

Provides the list of names of active storage pools upto maxnames. If there are more than maxnames, the remaining names will be silently ignored.

conn:pointer to hypervisor connection
names:array of char * to fill with pool names (allocated by caller)
maxnames:size of the names array
Returns:0 on success, -1 on error

virConnectNumOfDefinedDomains

int	virConnectNumOfDefinedDomains	(virConnectPtr conn)

Provides the number of defined but inactive domains.

conn:pointer to the hypervisor connection
Returns:the number of domain found or -1 in case of error

virConnectNumOfDefinedNetworks

int	virConnectNumOfDefinedNetworks	(virConnectPtr conn)

Provides the number of inactive networks.

conn:pointer to the hypervisor connection
Returns:the number of networks found or -1 in case of error

virConnectNumOfDefinedStoragePools

int	virConnectNumOfDefinedStoragePools	(virConnectPtr conn)

Provides the number of inactive storage pools

conn:pointer to hypervisor connection
Returns:the number of pools found, or -1 on error

virConnectNumOfDomains

int	virConnectNumOfDomains		(virConnectPtr conn)
-

Provides the number of active domains.

conn:pointer to the hypervisor connection
Returns:the number of domain found or -1 in case of error

virConnectNumOfNetworks

int	virConnectNumOfNetworks		(virConnectPtr conn)
+

Provides the number of active domains.

conn:pointer to the hypervisor connection
Returns:the number of domain found or -1 in case of error

virConnectNumOfInterfaces

int	virConnectNumOfInterfaces	(virConnectPtr conn)
+

Provides the number of interfaces on the physical host.

conn:pointer to the hypervisor connection
Returns:the number of interface found or -1 in case of error

virConnectNumOfNetworks

int	virConnectNumOfNetworks		(virConnectPtr conn)

Provides the number of active networks.

conn:pointer to the hypervisor connection
Returns:the number of network found or -1 in case of error

virConnectNumOfStoragePools

int	virConnectNumOfStoragePools	(virConnectPtr conn)

Provides the number of active storage pools

conn:pointer to hypervisor connection
Returns:the number of pools found, or -1 on error

virConnectOpen

virConnectPtr	virConnectOpen		(const char * name)

This function should be called first to get a connection to the Hypervisor and xen store

name:URI of the hypervisor
Returns:a pointer to the hypervisor connection or NULL in case of error URIs are documented at http://libvirt.org/uri.html

virConnectOpenAuth

virConnectPtr	virConnectOpenAuth	(const char * name, 
virConnectAuthPtr auth,
int flags)
@@ -444,7 +469,19 @@ int virStorageVolRef (
timer:the timer to modify
timeout:the new timeout value

virFreeCallback

typedef void	(*virFreeCallback		)	(void * opaque)
 

opaque:

virGetVersion

int	virGetVersion			(unsigned long * libVer, 
const char * type,
unsigned long * typeVer)

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.

libVer:return value for the library version (OUT)
type:the type of connection/driver looked at
typeVer:return value for the version of the hypervisor (OUT)
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.

virInitialize

int	virInitialize			(void)
-

Initialize the library. It's better to call this routine at startup in multithreaded applications to avoid potential race when initializing the library.

Returns:0 in case of success, -1 in case of error

virNetworkCreate

int	virNetworkCreate		(virNetworkPtr network)
+

Initialize the library. It's better to call this routine at startup in multithreaded applications to avoid potential race when initializing the library.

Returns:0 in case of success, -1 in case of error

virInterfaceCreate

int	virInterfaceCreate		(virInterfacePtr interface, 
unsigned int flags)
+

Activate an interface (ie call "ifup")

interface:pointer to a defined interface
flags:and OR'ed set of extraction flags, not used yet
Returns:0 in case of success, -1 in case of error

virInterfaceDefineXML

virInterfacePtr	virInterfaceDefineXML	(virConnectPtr conn, 
const char * xml,
unsigned int flags)
+

Define an interface (or modify existing interface configuration)

conn:pointer to the hypervisor connection
xml:the XML description for the interface, preferably in UTF-8
flags:and OR'ed set of extraction flags, not used yet
Returns:NULL in case of error, a pointer to the interface otherwise

virInterfaceDestroy

int	virInterfaceDestroy		(virInterfacePtr interface, 
unsigned int flags)
+

deactivate an interface (ie call "ifdown") This does not remove the interface from the config, and does not free the associated virInterfacePtr object.

interface:an interface object
flags:and OR'ed set of extraction flags, not used yet
Returns:0 in case of success and -1 in case of failure.

virInterfaceFree

int	virInterfaceFree		(virInterfacePtr interface)
+

Free the interface object. The interface itself is unaltered. The data structure is freed and should not be used thereafter.

interface:a interface object
Returns:0 in case of success and -1 in case of failure.

virInterfaceGetConnect

virConnectPtr	virInterfaceGetConnect	(virInterfacePtr interface)
+

Provides the connection pointer associated with an interface. 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 interface object together.

interface:
Returns:the virConnectPtr or NULL in case of failure.

virInterfaceGetMACString

const char *	virInterfaceGetMACString	(virInterfacePtr interface)
+

Get the MAC for a interface as string. For more information about MAC see RFC4122.

interface:a interface object
Returns:a pointer to the MAC address (in null-terminated ASCII format) or NULL, the string need not be deallocated its lifetime will be the same as the interface object.

virInterfaceGetName

const char *	virInterfaceGetName	(virInterfacePtr interface)
+

Get the public name for that interface

interface:a interface object
Returns:a pointer to the name or NULL, the string need not be deallocated its lifetime will be the same as the interface object.

virInterfaceGetXMLDesc

char *	virInterfaceGetXMLDesc		(virInterfacePtr interface, 
unsigned int flags)
+

Provide an XML description of the interface. The description may be reused later to recreate the interface with virInterfaceCreateXML().

interface:a interface object
flags:and OR'ed set of extraction flags, not used yet
Returns:a 0 terminated UTF-8 encoded XML instance, or NULL in case of error. the caller must free() the returned value.

virInterfaceLookupByMACString

virInterfacePtr	virInterfaceLookupByMACString	(virConnectPtr conn, 
const char * macstr)
+

Try to lookup an interface on the given hypervisor based on its MAC.

conn:pointer to the hypervisor connection
macstr:the MAC for the interface (null-terminated ASCII format)
Returns:a new interface object or NULL in case of failure. If the interface cannot be found, then VIR_ERR_NO_INTERFACE error is raised.

virInterfaceLookupByName

virInterfacePtr	virInterfaceLookupByName	(virConnectPtr conn, 
const char * name)
+

Try to lookup an interface on the given hypervisor based on its name.

conn:pointer to the hypervisor connection
name:name for the interface
Returns:a new interface object or NULL in case of failure. If the interface cannot be found, then VIR_ERR_NO_INTERFACE error is raised.

virInterfaceRef

int	virInterfaceRef			(virInterfacePtr interface)
+

Increment the reference count on the interface. For each additional call to this method, there shall be a corresponding call to virInterfaceFree 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 interface would increment the reference count.

interface:the interface to hold a reference on
Returns:0 in case of success, -1 in case of failure.

virInterfaceUndefine

int	virInterfaceUndefine		(virInterfacePtr interface)
+

Undefine an interface, ie remove it from the config. This does not free the associated virInterfacePtr object.

interface:pointer to a defined interface
Returns:0 in case of success, -1 in case of error

virNetworkCreate

int	virNetworkCreate		(virNetworkPtr network)

Create and start a defined network. If the call succeed the network moves from the defined to the running networks pools.

network:pointer to a defined network
Returns:0 in case of success, -1 in case of error

virNetworkCreateXML

virNetworkPtr	virNetworkCreateXML	(virConnectPtr conn, 
const char * xmlDesc)

Create and start a new virtual network, based on an XML description similar to the one returned by virNetworkGetXMLDesc()

conn:pointer to the hypervisor connection
xmlDesc:an XML description of the network
Returns:a new network object or NULL in case of failure

virNetworkDefineXML

virNetworkPtr	virNetworkDefineXML	(virConnectPtr conn, 
const char * xml)

Define a network, but does not create it

conn:pointer to the hypervisor connection
xml:the XML description for the network, preferably in UTF-8
Returns:NULL in case of error, a pointer to the network otherwise

virNetworkDestroy

int	virNetworkDestroy		(virNetworkPtr network)
diff --git a/docs/html/libvirt-virterror.html b/docs/html/libvirt-virterror.html index bf757196f6..34d21eb181 100644 --- a/docs/html/libvirt-virterror.html +++ b/docs/html/libvirt-virterror.html @@ -27,11 +27,11 @@ void virSetErrorFunc (void * userData,
intcode : The error code, a virErrorNumber
intdomain : What part of the library raised this error
char *message : human-readable informative error message
virErrorLevellevel : how consequent is the error
virConnectPtrconn : connection if available, deprecated see note above
virDomainPtrdom : domain if available, deprecated see note above
char *str1 : extra string information
char *str2 : extra string information
char *str3 : extra string information
intint1 : extra number information
intint2 : extra number information
virNetworkPtrnet : network if available, deprecated see note above
 }
 

virErrorDomain

enum virErrorDomain {
-
VIR_FROM_NONE = 0
VIR_FROM_XEN = 1 : Error at Xen hypervisor layer
VIR_FROM_XEND = 2 : Error at connection with xend daemon
VIR_FROM_XENSTORE = 3 : Error at connection with xen store
VIR_FROM_SEXPR = 4 : Error in the S-Expression code
VIR_FROM_XML = 5 : Error in the XML code
VIR_FROM_DOM = 6 : Error when operating on a domain
VIR_FROM_RPC = 7 : Error in the XML-RPC code
VIR_FROM_PROXY = 8 : Error in the proxy code
VIR_FROM_CONF = 9 : Error in the configuration file handling
VIR_FROM_QEMU = 10 : Error at the QEMU daemon
VIR_FROM_NET = 11 : Error when operating on a network
VIR_FROM_TEST = 12 : Error from test driver
VIR_FROM_REMOTE = 13 : Error from remote driver
VIR_FROM_OPENVZ = 14 : Error from OpenVZ driver
VIR_FROM_XENXM = 15 : Error at Xen XM layer
VIR_FROM_STATS_LINUX = 16 : Error in the Linux Stats code
VIR_FROM_LXC = 17 : Error from Linux Container driver
VIR_FROM_STORAGE = 18 : Error from storage driver
VIR_FROM_NETWORK = 19 : Error from network config
VIR_FROM_DOMAIN = 20 : Error from domain config
VIR_FROM_UML = 21 : Error at the UML driver
VIR_FROM_NODEDEV = 22 : Error from node device monitor
VIR_FROM_XEN_INOTIFY = 23 : Error from xen inotify layer
VIR_FROM_SECURITY = 24 : Error from security framework
VIR_FROM_VBOX = 25 : Error from VirtualBox driver
}
+
VIR_FROM_NONE = 0
VIR_FROM_XEN = 1 : Error at Xen hypervisor layer
VIR_FROM_XEND = 2 : Error at connection with xend daemon
VIR_FROM_XENSTORE = 3 : Error at connection with xen store
VIR_FROM_SEXPR = 4 : Error in the S-Expression code
VIR_FROM_XML = 5 : Error in the XML code
VIR_FROM_DOM = 6 : Error when operating on a domain
VIR_FROM_RPC = 7 : Error in the XML-RPC code
VIR_FROM_PROXY = 8 : Error in the proxy code
VIR_FROM_CONF = 9 : Error in the configuration file handling
VIR_FROM_QEMU = 10 : Error at the QEMU daemon
VIR_FROM_NET = 11 : Error when operating on a network
VIR_FROM_TEST = 12 : Error from test driver
VIR_FROM_REMOTE = 13 : Error from remote driver
VIR_FROM_OPENVZ = 14 : Error from OpenVZ driver
VIR_FROM_XENXM = 15 : Error at Xen XM layer
VIR_FROM_STATS_LINUX = 16 : Error in the Linux Stats code
VIR_FROM_LXC = 17 : Error from Linux Container driver
VIR_FROM_STORAGE = 18 : Error from storage driver
VIR_FROM_NETWORK = 19 : Error from network config
VIR_FROM_DOMAIN = 20 : Error from domain config
VIR_FROM_UML = 21 : Error at the UML driver
VIR_FROM_NODEDEV = 22 : Error from node device monitor
VIR_FROM_XEN_INOTIFY = 23 : Error from xen inotify layer
VIR_FROM_SECURITY = 24 : Error from security framework
VIR_FROM_VBOX = 25 : Error from VirtualBox driver
VIR_FROM_INTERFACE = 26 : Error when operating on an interface
}
 

virErrorLevel

enum virErrorLevel {
 
VIR_ERR_NONE = 0
VIR_ERR_WARNING = 1 : A simple warning
VIR_ERR_ERROR = 2 : An error
}
 

virErrorNumber

enum virErrorNumber {
-
VIR_ERR_OK = 0
VIR_ERR_INTERNAL_ERROR = 1 : internal error
VIR_ERR_NO_MEMORY = 2 : memory allocation failure
VIR_ERR_NO_SUPPORT = 3 : no support for this function
VIR_ERR_UNKNOWN_HOST = 4 : could not resolve hostname
VIR_ERR_NO_CONNECT = 5 : can't connect to hypervisor
VIR_ERR_INVALID_CONN = 6 : invalid connection object
VIR_ERR_INVALID_DOMAIN = 7 : invalid domain object
VIR_ERR_INVALID_ARG = 8 : invalid function argument
VIR_ERR_OPERATION_FAILED = 9 : a command to hypervisor failed
VIR_ERR_GET_FAILED = 10 : a HTTP GET command to failed
VIR_ERR_POST_FAILED = 11 : a HTTP POST command to failed
VIR_ERR_HTTP_ERROR = 12 : unexpected HTTP error code
VIR_ERR_SEXPR_SERIAL = 13 : failure to serialize an S-Expr
VIR_ERR_NO_XEN = 14 : could not open Xen hypervisor control
VIR_ERR_XEN_CALL = 15 : failure doing an hypervisor call
VIR_ERR_OS_TYPE = 16 : unknown OS type
VIR_ERR_NO_KERNEL = 17 : missing kernel information
VIR_ERR_NO_ROOT = 18 : missing root device information
VIR_ERR_NO_SOURCE = 19 : missing source device information
VIR_ERR_NO_TARGET = 20 : missing target device information
VIR_ERR_NO_NAME = 21 : missing domain name information
VIR_ERR_NO_OS = 22 : missing domain OS information
VIR_ERR_NO_DEVICE = 23 : missing domain devices information
VIR_ERR_NO_XENSTORE = 24 : could not open Xen Store control
VIR_ERR_DRIVER_FULL = 25 : too many drivers registered
VIR_ERR_CALL_FAILED = 26 : not supported by the drivers (DEPRECATED)
VIR_ERR_XML_ERROR = 27 : an XML description is not well formed or broken
VIR_ERR_DOM_EXIST = 28 : the domain already exist
VIR_ERR_OPERATION_DENIED = 29 : operation forbidden on read-only connections
VIR_ERR_OPEN_FAILED = 30 : failed to open a conf file
VIR_ERR_READ_FAILED = 31 : failed to read a conf file
VIR_ERR_PARSE_FAILED = 32 : failed to parse a conf file
VIR_ERR_CONF_SYNTAX = 33 : failed to parse the syntax of a conf file
VIR_ERR_WRITE_FAILED = 34 : failed to write a conf file
VIR_ERR_XML_DETAIL = 35 : detail of an XML error
VIR_ERR_INVALID_NETWORK = 36 : invalid network object
VIR_ERR_NETWORK_EXIST = 37 : the network already exist
VIR_ERR_SYSTEM_ERROR = 38 : general system call failure
VIR_ERR_RPC = 39 : some sort of RPC error
VIR_ERR_GNUTLS_ERROR = 40 : error from a GNUTLS call
VIR_WAR_NO_NETWORK = 41 : failed to start network
VIR_ERR_NO_DOMAIN = 42 : domain not found or unexpectedly disappeared
VIR_ERR_NO_NETWORK = 43 : network not found
VIR_ERR_INVALID_MAC = 44 : invalid MAC address
VIR_ERR_AUTH_FAILED = 45 : authentication failed
VIR_ERR_INVALID_STORAGE_POOL = 46 : invalid storage pool object
VIR_ERR_INVALID_STORAGE_VOL = 47 : invalid storage vol object
VIR_WAR_NO_STORAGE = 48 : failed to start storage
VIR_ERR_NO_STORAGE_POOL = 49 : storage pool not found
VIR_ERR_NO_STORAGE_VOL = 50 : storage pool not found
VIR_WAR_NO_NODE = 51 : failed to start node driver
VIR_ERR_INVALID_NODE_DEVICE = 52 : invalid node device object
VIR_ERR_NO_NODE_DEVICE = 53 : node device not found
VIR_ERR_NO_SECURITY_MODEL = 54 : security model not found
VIR_ERR_OPERATION_INVALID = 55 : operation is not applicable at this time
}
+
VIR_ERR_OK = 0
VIR_ERR_INTERNAL_ERROR = 1 : internal error
VIR_ERR_NO_MEMORY = 2 : memory allocation failure
VIR_ERR_NO_SUPPORT = 3 : no support for this function
VIR_ERR_UNKNOWN_HOST = 4 : could not resolve hostname
VIR_ERR_NO_CONNECT = 5 : can't connect to hypervisor
VIR_ERR_INVALID_CONN = 6 : invalid connection object
VIR_ERR_INVALID_DOMAIN = 7 : invalid domain object
VIR_ERR_INVALID_ARG = 8 : invalid function argument
VIR_ERR_OPERATION_FAILED = 9 : a command to hypervisor failed
VIR_ERR_GET_FAILED = 10 : a HTTP GET command to failed
VIR_ERR_POST_FAILED = 11 : a HTTP POST command to failed
VIR_ERR_HTTP_ERROR = 12 : unexpected HTTP error code
VIR_ERR_SEXPR_SERIAL = 13 : failure to serialize an S-Expr
VIR_ERR_NO_XEN = 14 : could not open Xen hypervisor control
VIR_ERR_XEN_CALL = 15 : failure doing an hypervisor call
VIR_ERR_OS_TYPE = 16 : unknown OS type
VIR_ERR_NO_KERNEL = 17 : missing kernel information
VIR_ERR_NO_ROOT = 18 : missing root device information
VIR_ERR_NO_SOURCE = 19 : missing source device information
VIR_ERR_NO_TARGET = 20 : missing target device information
VIR_ERR_NO_NAME = 21 : missing domain name information
VIR_ERR_NO_OS = 22 : missing domain OS information
VIR_ERR_NO_DEVICE = 23 : missing domain devices information
VIR_ERR_NO_XENSTORE = 24 : could not open Xen Store control
VIR_ERR_DRIVER_FULL = 25 : too many drivers registered
VIR_ERR_CALL_FAILED = 26 : not supported by the drivers (DEPRECATED)
VIR_ERR_XML_ERROR = 27 : an XML description is not well formed or broken
VIR_ERR_DOM_EXIST = 28 : the domain already exist
VIR_ERR_OPERATION_DENIED = 29 : operation forbidden on read-only connections
VIR_ERR_OPEN_FAILED = 30 : failed to open a conf file
VIR_ERR_READ_FAILED = 31 : failed to read a conf file
VIR_ERR_PARSE_FAILED = 32 : failed to parse a conf file
VIR_ERR_CONF_SYNTAX = 33 : failed to parse the syntax of a conf file
VIR_ERR_WRITE_FAILED = 34 : failed to write a conf file
VIR_ERR_XML_DETAIL = 35 : detail of an XML error
VIR_ERR_INVALID_NETWORK = 36 : invalid network object
VIR_ERR_NETWORK_EXIST = 37 : the network already exist
VIR_ERR_SYSTEM_ERROR = 38 : general system call failure
VIR_ERR_RPC = 39 : some sort of RPC error
VIR_ERR_GNUTLS_ERROR = 40 : error from a GNUTLS call
VIR_WAR_NO_NETWORK = 41 : failed to start network
VIR_ERR_NO_DOMAIN = 42 : domain not found or unexpectedly disappeared
VIR_ERR_NO_NETWORK = 43 : network not found
VIR_ERR_INVALID_MAC = 44 : invalid MAC address
VIR_ERR_AUTH_FAILED = 45 : authentication failed
VIR_ERR_INVALID_STORAGE_POOL = 46 : invalid storage pool object
VIR_ERR_INVALID_STORAGE_VOL = 47 : invalid storage vol object
VIR_WAR_NO_STORAGE = 48 : failed to start storage
VIR_ERR_NO_STORAGE_POOL = 49 : storage pool not found
VIR_ERR_NO_STORAGE_VOL = 50 : storage pool not found
VIR_WAR_NO_NODE = 51 : failed to start node driver
VIR_ERR_INVALID_NODE_DEVICE = 52 : invalid node device object
VIR_ERR_NO_NODE_DEVICE = 53 : node device not found
VIR_ERR_NO_SECURITY_MODEL = 54 : security model not found
VIR_ERR_OPERATION_INVALID = 55 : operation is not applicable at this time
VIR_WAR_NO_INTERFACE = 56 : failed to start interface driver
VIR_ERR_NO_INTERFACE = 57 : interface driver not running
VIR_ERR_INVALID_INTERFACE = 58 : invalid interface object
}
 

Functions

virConnCopyLastError

int	virConnCopyLastError		(virConnectPtr conn, 
virErrorPtr to)

Copy the content of the last error caught on that connection This method is not protected against access from multiple threads. In a multi-threaded application, always use the global virGetLastError() API which is backed by thread local storage. If the connection object was discovered to be invalid by an API call, then the error will be reported against the global error object. Since 0.6.0, all errors reported in the per-connection object are also duplicated in the global error object. As such an application can always use virGetLastError(). This method remains for backwards compatability. One will need to free the result with virResetError()

conn:pointer to the hypervisor connection
to:target to receive the copy
Returns:0 if no error was found and the error code otherwise and -1 in case of parameter error.

virConnGetLastError

virErrorPtr	virConnGetLastError	(virConnectPtr conn)

Provide a pointer to the last error caught on that connection This method is not protected against access from multiple threads. In a multi-threaded application, always use the global virGetLastError() API which is backed by thread local storage. If the connection object was discovered to be invalid by an API call, then the error will be reported against the global error object. Since 0.6.0, all errors reported in the per-connection object are also duplicated in the global error object. As such an application can always use virGetLastError(). This method remains for backwards compatability.

conn:pointer to the hypervisor connection
Returns:a pointer to the last error or NULL if none occurred.

virConnResetLastError

void	virConnResetLastError		(virConnectPtr conn)
diff --git a/docs/libvirt-api.xml b/docs/libvirt-api.xml index c1121ebb69..4ce9384265 100644 --- a/docs/libvirt-api.xml +++ b/docs/libvirt-api.xml @@ -121,9 +121,11 @@ + + @@ -172,6 +174,7 @@ + @@ -180,7 +183,7 @@ - + @@ -193,6 +196,7 @@ + @@ -201,17 +205,20 @@ + + + @@ -220,6 +227,7 @@ + @@ -242,6 +250,7 @@ + @@ -257,21 +266,24 @@ + + - + + - + @@ -295,10 +307,12 @@ - + + + @@ -310,108 +324,116 @@ + + - + + + error handling interfaces for the libvirt library Provides the interfaces of the libvirt library to handle errors raised while using the library. Daniel Veillard <veillard@redhat.com> - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - + - - - + + + - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - @@ -554,6 +576,7 @@ + @@ -564,6 +587,7 @@ + @@ -583,7 +607,7 @@ - + @@ -604,6 +628,7 @@ + @@ -620,7 +645,7 @@ - + @@ -645,6 +670,7 @@ + @@ -741,6 +767,10 @@ see note above'/> + + + a virInterfacePtr is pointer to a virInterface private structure, this is the type used to reference a virtual interface in the API. + a virNetworkPtr is pointer to a virNetwork private structure, this is the type used to reference a virtual network in the API. @@ -871,6 +901,22 @@ see note above'/> + + Reads native configuration data describing a domain, and generates libvirt domain XML. The format of the native data is hypervisor dependant. + + + + + + + + Reads a domain XML configuration document, and generates generates a native configuration file describing the domain. The format of the native data is hypervisor dependant. + + + + + + Talks to a storage backend and attempts to auto-discover the set of available storage pool sources. e.g. For iSCSI this would be a set of iSCSI targets. For NFS this would be a list of exported paths. The srcSpec (optional for some storage pool types, e.g. local ones) is an instance of the storage pool's source element specifying where to look for the pools. srcSpec is not required for some types (e.g., those querying local storage resources only) @@ -939,6 +985,13 @@ see note above'/> + + Collect the list of physical host interfaces, and store their names in @names + + + + + Collect the list of active networks, and store their names in @names @@ -973,6 +1026,11 @@ see note above'/> + + Provides the number of interfaces on the physical host. + + + Provides the number of active networks. @@ -1402,6 +1460,73 @@ see note above'/> Initialize the library. It's better to call this routine at startup in multithreaded applications to avoid potential race when initializing the library. + + Activate an interface (ie call "ifup") + + + + + + Define an interface (or modify existing interface configuration) + + + + + + + deactivate an interface (ie call "ifdown") This does not remove the interface from the config, and does not free the associated virInterfacePtr object. + + + + + + Free the interface object. The interface itself is unaltered. The data structure is freed and should not be used thereafter. + + + + + Provides the connection pointer associated with an interface. 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 interface object together. + + + + + Get the MAC for a interface as string. For more information about MAC see RFC4122. + + + + + Get the public name for that interface + + + + + Provide an XML description of the interface. The description may be reused later to recreate the interface with virInterfaceCreateXML(). + + + + + + Try to lookup an interface on the given hypervisor based on its MAC. + + + + + + Try to lookup an interface on the given hypervisor based on its name. + + + + + + Increment the reference count on the interface. For each additional call to this method, there shall be a corresponding call to virInterfaceFree 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 interface would increment the reference count. + + + + + Undefine an interface, ie remove it from the config. This does not free the associated virInterfacePtr object. + + + Create and start a defined network. If the call succeed the network moves from the defined to the running networks pools. diff --git a/docs/libvirt-refs.xml b/docs/libvirt-refs.xml index abb9f7aeca..7d1db12b31 100644 --- a/docs/libvirt-refs.xml +++ b/docs/libvirt-refs.xml @@ -67,6 +67,7 @@ + @@ -77,6 +78,7 @@ + @@ -117,6 +119,7 @@ + @@ -167,6 +170,7 @@ + @@ -199,6 +203,8 @@ + + @@ -211,12 +217,14 @@ + + @@ -314,6 +322,20 @@ + + + + + + + + + + + + + + @@ -493,6 +515,7 @@ + @@ -503,6 +526,7 @@ + @@ -543,6 +567,7 @@ + @@ -593,6 +618,7 @@ + @@ -629,6 +655,8 @@ + + @@ -641,12 +669,14 @@ + + @@ -744,6 +774,20 @@ + + + + + + + + + + + + + + @@ -869,6 +913,7 @@ + @@ -888,6 +933,11 @@ + + + + + @@ -920,6 +970,7 @@ + @@ -954,6 +1005,8 @@ + + @@ -962,6 +1015,10 @@ + + + + @@ -1013,6 +1070,8 @@ + + @@ -1024,12 +1083,14 @@ + + @@ -1042,6 +1103,9 @@ + + + @@ -1155,6 +1219,17 @@ + + + + + + + + + + + @@ -1367,6 +1442,8 @@ + + @@ -1379,12 +1456,14 @@ + + @@ -1472,6 +1551,20 @@ + + + + + + + + + + + + + + @@ -1591,6 +1684,7 @@ + @@ -1601,6 +1695,7 @@ + @@ -1637,6 +1732,7 @@ + @@ -1660,6 +1756,7 @@ + @@ -1704,10 +1801,17 @@ + + + + + + + @@ -1785,6 +1889,7 @@ + @@ -1828,6 +1933,7 @@ + @@ -1945,6 +2051,8 @@ + + @@ -1953,6 +2061,7 @@ + @@ -1972,6 +2081,8 @@ + + @@ -2000,6 +2111,7 @@ + @@ -2017,11 +2129,14 @@ + + + @@ -2065,9 +2180,11 @@ - - + + + + @@ -2172,6 +2289,7 @@ + @@ -2183,12 +2301,14 @@ + + @@ -2200,6 +2320,7 @@ + @@ -2208,6 +2329,10 @@ + + + + @@ -2313,6 +2438,8 @@ + + @@ -2340,8 +2467,12 @@ + + + + @@ -2360,6 +2491,7 @@ + @@ -2384,6 +2516,10 @@ + + + + @@ -2412,6 +2548,7 @@ + @@ -2421,11 +2558,14 @@ + + + @@ -2444,6 +2584,7 @@ + @@ -2500,6 +2641,7 @@ + @@ -2508,6 +2650,7 @@ + @@ -2546,6 +2689,7 @@ + @@ -2634,6 +2778,7 @@ + @@ -2670,6 +2815,7 @@ + @@ -2701,6 +2847,9 @@ + + + @@ -2759,7 +2908,7 @@ - + @@ -2791,6 +2940,8 @@ + + @@ -2843,6 +2994,7 @@ + @@ -2936,6 +3088,8 @@ + + @@ -2946,6 +3100,8 @@ + + @@ -2997,6 +3153,8 @@ + + @@ -3081,6 +3239,7 @@ + @@ -3112,9 +3271,15 @@ + + + + + + @@ -3192,6 +3357,7 @@ + @@ -3210,6 +3376,7 @@ + @@ -3219,6 +3386,7 @@ + @@ -3268,6 +3436,8 @@ + + @@ -3276,12 +3446,14 @@ - + + + @@ -3290,13 +3462,18 @@ + + + + + @@ -3304,6 +3481,8 @@ + + @@ -3324,6 +3503,8 @@ + + @@ -3342,6 +3523,10 @@ + + + + @@ -3352,6 +3537,8 @@ + + @@ -3363,6 +3550,8 @@ + + @@ -3453,6 +3642,7 @@ + @@ -3474,6 +3664,8 @@ + + @@ -3549,6 +3741,7 @@ + @@ -3573,7 +3766,10 @@ + + + @@ -3633,6 +3829,7 @@ + @@ -3648,9 +3845,15 @@ + + + + + + @@ -3664,11 +3867,15 @@ + + + + - + @@ -3713,6 +3920,7 @@ + @@ -3744,6 +3952,7 @@ + @@ -3771,6 +3980,10 @@ + + + + @@ -3794,18 +4007,24 @@ + + + + + + @@ -3813,6 +4032,8 @@ + + @@ -3829,6 +4050,8 @@ + + @@ -3837,6 +4060,9 @@ + + + @@ -3856,6 +4082,7 @@ + @@ -3873,6 +4100,7 @@ + @@ -3880,6 +4108,8 @@ + + @@ -3913,6 +4143,10 @@ + + + + @@ -3944,6 +4178,8 @@ + + @@ -3981,7 +4217,7 @@ - + @@ -4030,6 +4266,7 @@ + @@ -4042,6 +4279,7 @@ + @@ -4049,6 +4287,8 @@ + + @@ -4104,6 +4344,12 @@ + + + + + + @@ -4115,6 +4361,12 @@ + + + + + + @@ -4137,6 +4389,7 @@ + @@ -4144,6 +4397,7 @@ + @@ -4178,6 +4432,7 @@ + @@ -4207,10 +4462,12 @@ + + @@ -4224,11 +4481,9 @@ - - - - + + @@ -4268,6 +4523,10 @@ + + + + @@ -4286,10 +4545,13 @@ + + + @@ -4330,8 +4592,6 @@ - - @@ -4342,6 +4602,7 @@ + @@ -4364,6 +4625,7 @@ + @@ -4420,11 +4682,13 @@ + + @@ -4435,6 +4699,8 @@ + + @@ -4458,6 +4724,7 @@ + @@ -4510,6 +4777,7 @@ + @@ -4526,6 +4794,8 @@ + + @@ -4642,6 +4912,7 @@ + @@ -4684,6 +4955,7 @@ + @@ -4701,6 +4973,7 @@ + @@ -4727,6 +5000,7 @@ + @@ -4737,6 +5011,8 @@ + + @@ -4747,6 +5023,7 @@ + @@ -4756,12 +5033,13 @@ - + + @@ -4775,6 +5053,10 @@ + + + + @@ -4788,6 +5070,8 @@ + + @@ -4796,6 +5080,7 @@ + @@ -4861,6 +5146,10 @@ + + + + @@ -4897,6 +5186,7 @@ + @@ -4937,6 +5227,7 @@ + @@ -4986,6 +5277,7 @@ + @@ -5000,6 +5292,7 @@ + @@ -5058,6 +5351,8 @@ + + @@ -5127,6 +5422,8 @@ + + @@ -5164,6 +5461,7 @@ + @@ -5235,6 +5533,7 @@ + @@ -5244,7 +5543,7 @@ - + @@ -5261,6 +5560,8 @@ + + @@ -5303,6 +5604,9 @@ + + + @@ -5338,6 +5642,7 @@ + @@ -5356,6 +5661,7 @@ + @@ -5378,6 +5684,8 @@ + + @@ -5427,6 +5735,7 @@ + @@ -5509,6 +5818,8 @@ + + @@ -5522,6 +5833,7 @@ + @@ -5543,6 +5855,7 @@ + @@ -5573,7 +5886,7 @@ - + @@ -5593,6 +5906,8 @@ + + @@ -5624,6 +5939,7 @@ + @@ -5649,6 +5965,10 @@ + + + + @@ -5662,6 +5982,7 @@ + @@ -5683,6 +6004,7 @@ + @@ -5836,10 +6158,12 @@ + + @@ -5872,6 +6196,8 @@ + + @@ -5884,6 +6210,7 @@ + @@ -5962,7 +6289,7 @@ - + @@ -5983,8 +6310,11 @@ + + + @@ -6002,6 +6332,7 @@ + @@ -6024,6 +6355,8 @@ + + @@ -6042,6 +6375,7 @@ + @@ -6050,6 +6384,7 @@ + @@ -6064,6 +6399,7 @@ + @@ -6079,6 +6415,7 @@ + @@ -6107,6 +6444,7 @@ + @@ -6149,6 +6487,7 @@ + @@ -6156,6 +6495,9 @@ + + + @@ -6207,6 +6549,7 @@ + @@ -6214,6 +6557,8 @@ + + @@ -6263,6 +6608,7 @@ + @@ -6277,36 +6623,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -6343,6 +6663,7 @@ + @@ -6356,7 +6677,7 @@ - + @@ -6365,6 +6686,8 @@ + + @@ -6375,6 +6698,7 @@ + @@ -6427,6 +6751,7 @@ + @@ -6524,6 +6849,16 @@ + + + + + + + + + + @@ -6695,6 +7030,7 @@ + @@ -6749,6 +7085,7 @@ + @@ -6759,6 +7096,7 @@ + @@ -6772,7 +7110,7 @@ - + @@ -6787,6 +7125,10 @@ + + + + @@ -6810,19 +7152,20 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/include/libvirt/libvirt.h b/include/libvirt/libvirt.h index 5835f70c17..633be86a46 100644 --- a/include/libvirt/libvirt.h +++ b/include/libvirt/libvirt.h @@ -591,6 +591,16 @@ typedef enum { char * virDomainGetXMLDesc (virDomainPtr domain, int flags); + +char * virConnectDomainXMLFromNative(virConnectPtr conn, + const char *nativeFormat, + const char *nativeConfig, + unsigned int flags); +char * virConnectDomainXMLToNative(virConnectPtr conn, + const char *nativeFormat, + const char *domainXml, + unsigned int flags); + int virDomainBlockStats (virDomainPtr dom, const char *path, virDomainBlockStatsPtr stats, diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 60048aec96..025e2a7f80 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -591,6 +591,16 @@ typedef enum { char * virDomainGetXMLDesc (virDomainPtr domain, int flags); + +char * virConnectDomainXMLFromNative(virConnectPtr conn, + const char *nativeFormat, + const char *nativeConfig, + unsigned int flags); +char * virConnectDomainXMLToNative(virConnectPtr conn, + const char *nativeFormat, + const char *domainXml, + unsigned int flags); + int virDomainBlockStats (virDomainPtr dom, const char *path, virDomainBlockStatsPtr stats, diff --git a/src/driver.h b/src/driver.h index 01758a9a12..15709178e1 100644 --- a/src/driver.h +++ b/src/driver.h @@ -152,6 +152,16 @@ typedef int typedef char * (*virDrvDomainDumpXML) (virDomainPtr dom, int flags); +typedef char * + (*virDrvConnectDomainXMLFromNative) (virConnectPtr conn, + const char *nativeFormat, + const char *nativeConfig, + unsigned int flags); +typedef char * + (*virDrvConnectDomainXMLToNative) (virConnectPtr conn, + const char *nativeFormat, + const char *domainXml, + unsigned int flags); typedef int (*virDrvListDefinedDomains) (virConnectPtr conn, char **const names, @@ -381,6 +391,8 @@ struct _virDriver { virDrvDomainGetSecurityLabel domainGetSecurityLabel; virDrvNodeGetSecurityModel nodeGetSecurityModel; virDrvDomainDumpXML domainDumpXML; + virDrvConnectDomainXMLFromNative domainXMLFromNative; + virDrvConnectDomainXMLToNative domainXMLToNative; virDrvListDefinedDomains listDefinedDomains; virDrvNumOfDefinedDomains numOfDefinedDomains; virDrvDomainCreate domainCreate; diff --git a/src/libvirt.c b/src/libvirt.c index cb486bbdcb..c601b94698 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -2730,6 +2730,111 @@ error: return NULL; } +/** + * virConnectDomainXMLFromNative: + * @conn: a connection object + * @nativeFormat: configuration format importing from + * @nativeConfig: the configuration data to import + * @flags: currently unused, pass 0 + * + * Reads native configuration data describing a domain, and + * generates libvirt domain XML. The format of the native + * data is hypervisor dependant. + * + * Returns a 0 terminated UTF-8 encoded XML instance, or NULL in case of error. + * the caller must free() the returned value. + */ +char *virConnectDomainXMLFromNative(virConnectPtr conn, + const char *nativeFormat, + const char *nativeConfig, + unsigned int flags) +{ + DEBUG("conn=%p, format=%s config=%s flags=%u", conn, nativeFormat, nativeConfig, flags); + + virResetLastError(); + + if (!VIR_IS_CONNECT(conn)) { + virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__); + return (NULL); + } + + if (nativeFormat == NULL || nativeConfig == NULL) { + virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__); + return (NULL); + } + + if (conn->driver->domainXMLFromNative) { + char *ret; + ret = conn->driver->domainXMLFromNative (conn, + nativeFormat, + nativeConfig, + flags); + if (!ret) + goto error; + return ret; + } + + virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); + +error: + /* Copy to connection error object for back compatability */ + virSetConnError(conn); + return NULL; +} + +/** + * virConnectDomainXMLToNative: + * @conn: a connection object + * @nativeFormat: configuration format exporting to + * @domainXml: the domain configuration to export + * @flags: currently unused, pass 0 + * + * Reads a domain XML configuration document, and generates + * generates a native configuration file describing the domain. + * The format of the native data is hypervisor dependant. + * + * Returns a 0 terminated UTF-8 encoded native config datafile, or NULL in case of error. + * the caller must free() the returned value. + */ +char *virConnectDomainXMLToNative(virConnectPtr conn, + const char *nativeFormat, + const char *domainXml, + unsigned int flags) +{ + DEBUG("conn=%p, format=%s xml=%s flags=%u", conn, nativeFormat, domainXml, flags); + + virResetLastError(); + + if (!VIR_IS_CONNECT(conn)) { + virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__); + return (NULL); + } + + if (nativeFormat == NULL || domainXml == NULL) { + virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__); + return (NULL); + } + + if (conn->driver->domainXMLToNative) { + char *ret; + ret = conn->driver->domainXMLToNative(conn, + nativeFormat, + domainXml, + flags); + if (!ret) + goto error; + return ret; + } + + virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); + +error: + /* Copy to connection error object for back compatability */ + virSetConnError(conn); + return NULL; +} + + /** * virDomainMigrate: * @domain: a domain object diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 85a26d40de..3f0f4bc3b0 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -264,8 +264,6 @@ LIBVIRT_0.6.3 { virNodeDeviceDestroy; } LIBVIRT_0.6.1; -# .... define new API here using predicted next version number .... - LIBVIRT_0.6.4 { global: virInterfaceGetConnect; @@ -283,4 +281,8 @@ LIBVIRT_0.6.4 { virInterfaceCreate; virInterfaceDestroy; virStorageVolCreateXMLFrom; + virConnectDomainXMLFromNative; + virConnectDomainXMLToNative; } LIBVIRT_0.6.3; + +# .... define new API here using predicted next version number .... diff --git a/src/lxc_driver.c b/src/lxc_driver.c index 64c735dc26..0109f15f80 100644 --- a/src/lxc_driver.c +++ b/src/lxc_driver.c @@ -1457,6 +1457,8 @@ static virDriver lxcDriver = { NULL, /* domainGetSecurityLabel */ NULL, /* nodeGetSecurityModel */ lxcDomainDumpXML, /* domainDumpXML */ + NULL, /* domainXmlFromNative */ + NULL, /* domainXmlToNative */ lxcListDefinedDomains, /* listDefinedDomains */ lxcNumDefinedDomains, /* numOfDefinedDomains */ lxcDomainStart, /* domainCreate */ diff --git a/src/openvz_driver.c b/src/openvz_driver.c index 755e449d9c..f6d41f2ed3 100644 --- a/src/openvz_driver.c +++ b/src/openvz_driver.c @@ -1344,6 +1344,8 @@ static virDriver openvzDriver = { NULL, /* domainGetSecurityLabel */ NULL, /* nodeGetSecurityModel */ openvzDomainDumpXML, /* domainDumpXML */ + NULL, /* domainXmlFromNative */ + NULL, /* domainXmlToNative */ openvzListDefinedDomains, /* listDefinedDomains */ openvzNumDefinedDomains, /* numOfDefinedDomains */ openvzDomainCreate, /* domainCreate */ diff --git a/src/qemu_driver.c b/src/qemu_driver.c index 4c5e8e5558..2cac1bf08f 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -5224,6 +5224,8 @@ static virDriver qemuDriver = { qemudDomainGetSecurityLabel, /* domainGetSecurityLabel */ qemudNodeGetSecurityModel, /* nodeGetSecurityModel */ qemudDomainDumpXML, /* domainDumpXML */ + NULL, /* domainXmlFromNative */ + NULL, /* domainXmlToNative */ qemudListDefinedDomains, /* listDefinedDomains */ qemudNumDefinedDomains, /* numOfDefinedDomains */ qemudDomainStart, /* domainCreate */ diff --git a/src/remote_internal.c b/src/remote_internal.c index 48c35fad4c..bc70f23951 100644 --- a/src/remote_internal.c +++ b/src/remote_internal.c @@ -7301,6 +7301,8 @@ static virDriver driver = { remoteDomainGetSecurityLabel, /* domainGetSecurityLabel */ remoteNodeGetSecurityModel, /* nodeGetSecurityModel */ remoteDomainDumpXML, /* domainDumpXML */ + NULL, /* domainXmlFromNative */ + NULL, /* domainXmlToNative */ remoteListDefinedDomains, /* listDefinedDomains */ remoteNumOfDefinedDomains, /* numOfDefinedDomains */ remoteDomainCreate, /* domainCreate */ diff --git a/src/test.c b/src/test.c index 9a9992f775..ba9ad6620c 100644 --- a/src/test.c +++ b/src/test.c @@ -3591,6 +3591,8 @@ static virDriver testDriver = { NULL, /* domainGetSecurityLabel */ NULL, /* nodeGetSecurityModel */ testDomainDumpXML, /* domainDumpXML */ + NULL, /* domainXmlFromNative */ + NULL, /* domainXmlToNative */ testListDefinedDomains, /* listDefinedDomains */ testNumOfDefinedDomains, /* numOfDefinedDomains */ testDomainCreate, /* domainCreate */ diff --git a/src/uml_driver.c b/src/uml_driver.c index 704ca4308d..4cb8eaabde 100644 --- a/src/uml_driver.c +++ b/src/uml_driver.c @@ -1854,6 +1854,8 @@ static virDriver umlDriver = { NULL, /* domainGetSecurityLabel */ NULL, /* nodeGetSecurityModel */ umlDomainDumpXML, /* domainDumpXML */ + NULL, /* domainXmlFromNative */ + NULL, /* domainXmlToNative */ umlListDefinedDomains, /* listDefinedDomains */ umlNumDefinedDomains, /* numOfDefinedDomains */ umlDomainStart, /* domainCreate */ diff --git a/src/virsh.c b/src/virsh.c index 865b6e5319..fe4e8e6a53 100644 --- a/src/virsh.c +++ b/src/virsh.c @@ -2209,6 +2209,98 @@ cmdDumpXML(vshControl *ctl, const vshCmd *cmd) return ret; } +/* + * "domxml-from-native" command + */ +static const vshCmdInfo info_domxmlfromnative[] = { + {"help", gettext_noop("Convert native config to domain XML")}, + {"desc", gettext_noop("Convert native guest configuration format to domain XML format.")}, + {NULL, NULL} +}; + +static const vshCmdOptDef opts_domxmlfromnative[] = { + {"format", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("source config data format")}, + {"config", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("config data file to import from")}, + {NULL, 0, 0, NULL} +}; + +static int +cmdDomXMLFromNative(vshControl *ctl, const vshCmd *cmd) +{ + int ret = TRUE; + char *format; + char *configFile; + char *configData; + char *xmlData; + int flags = 0; + + if (!vshConnectionUsability(ctl, ctl->conn, TRUE)) + return FALSE; + + format = vshCommandOptString(cmd, "format", NULL); + configFile = vshCommandOptString(cmd, "config", NULL); + + if (virFileReadAll(configFile, 1024*1024, &configData) < 0) { + return FALSE; + } + + xmlData = virConnectDomainXMLFromNative(ctl->conn, format, configData, flags); + if (xmlData != NULL) { + printf("%s", xmlData); + free(xmlData); + } else { + ret = FALSE; + } + + return ret; +} + +/* + * "domxml-to-native" command + */ +static const vshCmdInfo info_domxmltonative[] = { + {"help", gettext_noop("Convert domain XML to native config")}, + {"desc", gettext_noop("Convert domain XML config to a native guest configuration format.")}, + {NULL, NULL} +}; + +static const vshCmdOptDef opts_domxmltonative[] = { + {"format", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("target config data type format")}, + {"xml", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("xml data file to export from")}, + {NULL, 0, 0, NULL} +}; + +static int +cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd) +{ + int ret = TRUE; + char *format; + char *xmlFile; + char *configData; + char *xmlData; + int flags = 0; + + if (!vshConnectionUsability(ctl, ctl->conn, TRUE)) + return FALSE; + + format = vshCommandOptString(cmd, "format", NULL); + xmlFile = vshCommandOptString(cmd, "xml", NULL); + + if (virFileReadAll(xmlFile, 1024*1024, &xmlData) < 0) { + return FALSE; + } + + configData = virConnectDomainXMLToNative(ctl->conn, format, xmlData, flags); + if (configData != NULL) { + printf("%s", configData); + free(configData); + } else { + ret = FALSE; + } + + return ret; +} + /* * "domname" command */ @@ -6030,6 +6122,8 @@ static const vshCmdDef commands[] = { {"domstate", cmdDomstate, opts_domstate, info_domstate}, {"domblkstat", cmdDomblkstat, opts_domblkstat, info_domblkstat}, {"domifstat", cmdDomIfstat, opts_domifstat, info_domifstat}, + {"domxml-from-native", cmdDomXMLFromNative, opts_domxmlfromnative, info_domxmlfromnative}, + {"domxml-to-native", cmdDomXMLToNative, opts_domxmltonative, info_domxmltonative}, {"dumpxml", cmdDumpXML, opts_dumpxml, info_dumpxml}, {"edit", cmdEdit, opts_edit, info_edit}, {"find-storage-pool-sources", cmdPoolDiscoverSources, diff --git a/src/xen_unified.c b/src/xen_unified.c index e708980538..bd363ffe3b 100644 --- a/src/xen_unified.c +++ b/src/xen_unified.c @@ -1580,6 +1580,8 @@ static virDriver xenUnifiedDriver = { NULL, /* domainGetSecurityLabel */ NULL, /* nodeGetSecurityModel */ xenUnifiedDomainDumpXML, /* domainDumpXML */ + NULL, /* domainXmlFromNative */ + NULL, /* domainXmlToNative */ xenUnifiedListDefinedDomains, /* listDefinedDomains */ xenUnifiedNumOfDefinedDomains, /* numOfDefinedDomains */ xenUnifiedDomainCreate, /* domainCreate */