From 9dc3b99345f8dc6ca120a48c49a478392a5f09d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Miloslav=20Trma=C4=8D?= Date: Tue, 4 Aug 2009 20:38:21 +0200 Subject: [PATCH] Secret manipulation API docs refresh & wire up python generator Sample session: >>> import libvirt >>> c = libvirt.open('qemu:///session') >>> c.listSecrets() ['12247729-47d2-a783-88ce-b329d4781cd3', 'reee', 'abc'] >>> s = c.secretDefineXML("\nSomething for use\n/foo/bar\n\n") >>> s.UUIDString() '340c2dfb-811b-eda8-da9e-25ccd7bfd650' >>> s.XMLDesc() "\n 340c2dfb-811b-eda8-da9e-25ccd7bfd650\n Something for use\n /foo/bar\n\n" >>> s.setValue('abc\0xx\xffx') 0 >>> s.value() 'abc\x00xx\xffx' >>> s.undefine() 0 * python/generator.py: Add rules for virSecret APIs * python/libvir.c, python/libvirt-python-api.xml: Manual impl of virSecretSetValue, virSecretGetValue$ and virConnectListSecrets APIs * python/libvirt_wrap.h, python/types.c: Wrapper for virSecret objects * docs/libvirt-api.xml, docs/libvirt-refs.xml, docs/html/libvirt-virterror.html, docs/html/libvirt-libvirt.html, docs/devhelp/libvirt-virterror.html, docs/devhelp/libvirt-libvirt.html: Re-generate with 'make api' --- docs/devhelp/libvirt-libvirt.html | 86 +++++- docs/devhelp/libvirt-virterror.html | 7 +- docs/html/libvirt-libvirt.html | 35 ++- docs/html/libvirt-virterror.html | 4 +- docs/libvirt-api.xml | 113 +++++++- docs/libvirt-refs.xml | 390 +++++++++++++++++++--------- python/generator.py | 31 ++- python/libvir.c | 100 +++++++ python/libvirt-python-api.xml | 18 ++ python/libvirt_wrap.h | 9 + python/types.c | 13 + 11 files changed, 661 insertions(+), 145 deletions(-) diff --git a/docs/devhelp/libvirt-libvirt.html b/docs/devhelp/libvirt-libvirt.html index 4f2f774038..e3e91aa08c 100644 --- a/docs/devhelp/libvirt-libvirt.html +++ b/docs/devhelp/libvirt-libvirt.html @@ -59,6 +59,7 @@ typedef struct _virNetwork virNetwork; typedef enum virDomainEventResumedDetailType; typedef virDomainBlockStatsStruct * virDomainBlockStatsPtr; typedef struct _virConnect virConnect; +typedef virSecret * virSecretPtr; typedef enum virDomainEventStartedDetailType; typedef struct _virDomainInfo virDomainInfo; typedef enum virStoragePoolDeleteFlags; @@ -67,6 +68,7 @@ typedef struct _virStoragePool virStoragePool; typedef enum virDomainEventType; typedef struct _virDomainInterfaceStats virDomainInterfaceStatsStruct; typedef struct _virStoragePoolInfo virStoragePoolInfo; +typedef struct _virSecret virSecret; typedef enum virDomainState; typedef struct _virDomain virDomain; typedef virDomainInterfaceStatsStruct * virDomainInterfaceStatsPtr; @@ -113,16 +115,18 @@ typedef enum virDomainCreateFlags; typedef virSecurityLabel * virSecurityLabelPtr; typedef struct _virSecurityModel virSecurityModel; char * virStoragePoolGetXMLDesc (virStoragePoolPtr pool,
unsigned int flags); +char * virSecretGetUUIDString (virSecretPtr secret); const char * virStorageVolGetKey (virStorageVolPtr vol); typedef void virEventUpdateTimeoutFunc (int timer,
int timeout); -int virConnectClose (virConnectPtr conn); +int virDomainUndefine (virDomainPtr domain); virDomainPtr virDomainDefineXML (virConnectPtr conn,
const char * xml); int virDomainShutdown (virDomainPtr domain); -int virConnectListStoragePools (virConnectPtr conn,
char ** const names,
int maxnames); +int virConnectListDefinedInterfaces (virConnectPtr conn,
char ** const names,
int maxnames); int virGetVersion (unsigned long * libVer,
const char * type,
unsigned long * typeVer); int virNodeGetCellsFreeMemory (virConnectPtr conn,
unsigned long long * freeMems,
int startCell,
int maxCells); int virInitialize (void); const char * virNodeDeviceGetName (virNodeDevicePtr dev); +int virConnectNumOfSecrets (virConnectPtr conn); int virStoragePoolSetAutostart (virStoragePoolPtr pool,
int autostart); char * virConnectDomainXMLFromNative (virConnectPtr conn,
const char * nativeFormat,
const char * nativeConfig,
unsigned int flags); int virNodeDeviceDettach (virNodeDevicePtr dev); @@ -131,7 +135,7 @@ int virConnectDomainEventDeregistervirDomainGetSchedulerParameters (virDomainPtr domain,
virSchedParameterPtr params,
int * nparams); virDomainPtr virDomainLookupByUUIDString (virConnectPtr conn,
const char * uuidstr); int virConnectNumOfDefinedNetworks (virConnectPtr conn); -int virConnectListDefinedInterfaces (virConnectPtr conn,
char ** const names,
int maxnames); +int virConnectListStoragePools (virConnectPtr conn,
char ** const names,
int maxnames); int virNetworkGetUUID (virNetworkPtr network,
unsigned char * uuid); char * virInterfaceGetXMLDesc (virInterfacePtr iface,
unsigned int flags); virConnectPtr virStoragePoolGetConnect (virStoragePoolPtr pool); @@ -155,6 +159,7 @@ typedef void virEventUpdateHandleFunc (i int virDomainDestroy (virDomainPtr domain); int virConnectNumOfNetworks (virConnectPtr conn); virStoragePoolPtr virStoragePoolLookupByUUIDString (virConnectPtr conn,
const char * uuidstr); +virConnectPtr virSecretGetConnect (virSecretPtr secret); int virInterfaceCreate (virInterfacePtr iface,
unsigned int flags); char * virDomainGetXMLDesc (virDomainPtr domain,
int flags); int virStoragePoolGetUUID (virStoragePoolPtr pool,
unsigned char * uuid); @@ -181,6 +186,7 @@ const char * virInterfaceGetName (virStoragePoolCreate (virStoragePoolPtr pool,
unsigned int flags); int virNodeGetInfo (virConnectPtr conn,
virNodeInfoPtr info); int virNetworkSetAutostart (virNetworkPtr network,
int autostart); +virSecretPtr virSecretLookupByUUIDString (virConnectPtr conn,
const char * uuid); unsigned long virDomainGetMaxMemory (virDomainPtr domain); int virStoragePoolFree (virStoragePoolPtr pool); int virConnectNumOfDefinedInterfaces (virConnectPtr conn); @@ -190,7 +196,7 @@ int virNodeDeviceListCaps (virDomainBlockStats (virDomainPtr dom,
const char * path,
virDomainBlockStatsPtr stats,
size_t size); virConnectPtr virConnectOpenAuth (const char * name,
virConnectAuthPtr auth,
int flags); int virStoragePoolDelete (virStoragePoolPtr pool,
unsigned int flags); -typedef int virEventRemoveHandleFunc (int watch); +int virDomainResume (virDomainPtr domain); const char * virStorageVolGetName (virStorageVolPtr vol); int virStoragePoolGetAutostart (virStoragePoolPtr pool,
int * autostart); int virDomainGetAutostart (virDomainPtr domain,
int * autostart); @@ -203,10 +209,12 @@ char * virNetworkGetXMLDesc (virConnectNumOfStoragePools (virConnectPtr conn); virConnectPtr virInterfaceGetConnect (virInterfacePtr iface); const char * virNetworkGetName (virNetworkPtr network); +char * virSecretGetXMLDesc (virSecretPtr secret,
unsigned int flags); int virConnectListDefinedDomains (virConnectPtr conn,
char ** const names,
int maxnames); char * virConnectGetCapabilities (virConnectPtr conn); virDomainPtr virDomainLookupByName (virConnectPtr conn,
const char * name); char * virConnectFindStoragePoolSources (virConnectPtr conn,
const char * type,
const char * srcSpec,
unsigned int flags); +int virStorageVolFree (virStorageVolPtr vol); int virDomainPinVcpu (virDomainPtr domain,
unsigned int vcpu,
unsigned char * cpumap,
int maplen); int virNodeGetSecurityModel (virConnectPtr conn,
virSecurityModelPtr secmodel); int virDomainRestore (virConnectPtr conn,
const char * from); @@ -216,7 +224,7 @@ char * virStorageVolGetPath (virConnectDomainEventCallback (virConnectPtr conn,
virDomainPtr dom,
int event,
int detail,
void * opaque); virDomainPtr virDomainLookupByID (virConnectPtr conn,
int id); int virStorageVolDelete (virStorageVolPtr vol,
unsigned int flags); -int virStorageVolFree (virStorageVolPtr vol); +int virSecretUndefine (virSecretPtr secret); 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); @@ -229,14 +237,14 @@ int virConnectDomainEventRegister ( 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); +typedef int virEventRemoveHandleFunc (int watch); int virInterfaceRef (virInterfacePtr iface); const char * virInterfaceGetMACString (virInterfacePtr iface); int virConnectNumOfDomains (virConnectPtr conn); int virStoragePoolRefresh (virStoragePoolPtr pool,
unsigned int flags); int virConnectNumOfDefinedDomains (virConnectPtr conn); virStorageVolPtr virStorageVolCreateXMLFrom (virStoragePoolPtr pool,
const char * xmldesc,
virStorageVolPtr clonevol,
unsigned int flags); -int virDomainUndefine (virDomainPtr domain); +int virConnectClose (virConnectPtr conn); int virDomainReboot (virDomainPtr domain,
unsigned int flags); int virNetworkGetUUIDString (virNetworkPtr network,
char * buf); virNetworkPtr virNetworkLookupByName (virConnectPtr conn,
const char * name); @@ -253,6 +261,7 @@ typedef int virConnectAuthCallbackPtr ( int virDomainAttachDevice (virDomainPtr domain,
const char * xml); char * virConnectGetURI (virConnectPtr conn); virConnectPtr virConnectOpenReadOnly (const char * name); +virSecretPtr virSecretDefineXML (virConnectPtr conn,
const char * xml,
unsigned int flags); int virNetworkFree (virNetworkPtr network); virStoragePoolPtr virStoragePoolLookupByUUID (virConnectPtr conn,
const unsigned char * uuid); typedef int virEventAddHandleFunc (int fd,
int event,
virEventHandleCallback cb,
void * opaque,
virFreeCallback ff); @@ -265,6 +274,7 @@ int virNodeDeviceNumOfCaps (virConnectPtr virNetworkGetConnect (virNetworkPtr net); unsigned long long virNodeGetFreeMemory (virConnectPtr conn); int virInterfaceDestroy (virInterfacePtr iface,
unsigned int flags); +int virSecretSetValue (virSecretPtr secret,
const unsigned char * value,
size_t value_size,
unsigned int flags); virConnectPtr virStorageVolGetConnect (virStorageVolPtr vol); int virNodeNumOfDevices (virConnectPtr conn,
const char * cap,
unsigned int flags); int virStoragePoolDestroy (virStoragePoolPtr pool); @@ -276,6 +286,7 @@ int virConnectGetMaxVcpus (virDomainGetUUIDString (virDomainPtr domain,
char * buf); virConnectPtr virDomainGetConnect (virDomainPtr dom); int virConnectNumOfDefinedStoragePools (virConnectPtr conn); +int virSecretFree (virSecretPtr secret); 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); @@ -284,13 +295,16 @@ int virNodeDeviceRef (virInterfaceUndefine (virInterfacePtr iface); int virDomainSetVcpus (virDomainPtr domain,
unsigned int nvcpus); int virDomainRef (virDomainPtr domain); +int virConnectListSecrets (virConnectPtr conn,
char ** uuids,
int maxuuids); int virConnectNumOfInterfaces (virConnectPtr conn); unsigned int virDomainGetID (virDomainPtr domain); +int virSecretRef (virSecretPtr secret); 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); +unsigned char * virSecretGetValue (virSecretPtr secret,
size_t * value_size,
unsigned int flags); virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn,
const char * key); @@ -640,6 +654,16 @@ The content of this structure is not made public by the API. VIR_DOMAIN_SCHED_FIELD_BOOLEAN = 6 /* boolean(character) case */ };

+ +


+

Structure virSecret

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

+

+
+

Typedef virSecretPtr

virSecret * virSecretPtr;
+


Structure virSecurityLabel

struct _virSecurityLabel {
@@ -889,6 +913,10 @@ The content of this structure is not made public by the API.
         

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
+
+

virConnectListSecrets ()

int	virConnectListSecrets		(virConnectPtr conn, 
char ** uuids,
int maxuuids)
+

List UUIDs of defined secrets, store pointers to names in uuids.

+
conn:virConnect connection
uuids:Pointer to an array to store the UUIDs
maxuuids:size of the array.
Returns:the number of UUIDs provided in the array, or -1 on failure.

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.

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

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
+
+

virConnectNumOfSecrets ()

int	virConnectNumOfSecrets		(virConnectPtr conn)
+

Fetch number of currently defined secrets.

+
conn:virConnect connection
Returns:the number currently defined secrets.

virConnectNumOfStoragePools ()

int	virConnectNumOfStoragePools	(virConnectPtr conn)

Provides the number of active storage pools

@@ -1337,6 +1369,46 @@ The content of this structure is not made public by the API.

virNodeNumOfDevices ()

int	virNodeNumOfDevices		(virConnectPtr conn, 
const char * cap,
unsigned int flags)

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

conn:pointer to the hypervisor connection
cap:capability name
flags:flags (unused, pass 0)
Returns:the number of node devices or -1 in case of error
+
+

virSecretDefineXML ()

virSecretPtr	virSecretDefineXML	(virConnectPtr conn, 
const char * xml,
unsigned int flags)
+

If XML specifies an UUID, locates the specified secret and replaces all attributes of the secret specified by UUID by attributes specified in xml (any attributes not specified in xml are discarded). Otherwise, creates a new secret with an automatically chosen UUID, and initializes its attributes from xml.

+
conn:virConnect connection
xml:XML describing the secret.
flags:flags, use 0 for now
Returns:a the secret on success, NULL on failure.
+
+

virSecretFree ()

int	virSecretFree			(virSecretPtr secret)
+

Release the secret handle. The underlying secret continues to exist.

+
secret:pointer to a secret
Returns:0 on success, or -1 on error
+
+

virSecretGetConnect ()

virConnectPtr	virSecretGetConnect	(virSecretPtr secret)
+

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

+
secret:A virSecret secret
Returns:the virConnectPtr or NULL in case of failure.
+
+

virSecretGetUUIDString ()

char *	virSecretGetUUIDString		(virSecretPtr secret)
+

Fetches the UUID of the secret.

+
secret:A virSecret secret
Returns:ID of the secret (not necessarily in the UUID format) on success, NULL on failure. The caller must free() the ID.
+
+

virSecretGetValue ()

unsigned char *	virSecretGetValue	(virSecretPtr secret, 
size_t * value_size,
unsigned int flags)
+

Fetches the value of a secret.

+
secret:A virSecret connection
value_size:Place for storing size of the secret value
flags:flags, use 0 for now
Returns:the secret value on success, NULL on failure. The caller must free() the secret value.
+
+

virSecretGetXMLDesc ()

char *	virSecretGetXMLDesc		(virSecretPtr secret, 
unsigned int flags)
+

Fetches an XML document describing attributes of the secret.

+
secret:A virSecret secret
flags:flags, use 0 for now
Returns:the XML document on success, NULL on failure. The caller must free() the XML.
+
+

virSecretLookupByUUIDString ()

virSecretPtr	virSecretLookupByUUIDString	(virConnectPtr conn, 
const char * uuid)
+

Fetches a secret based on uuid.

+
conn:virConnect connection
uuid:ID of a secret
Returns:the secret on success, or NULL on failure.
+
+

virSecretRef ()

int	virSecretRef			(virSecretPtr secret)
+

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

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

virSecretSetValue ()

int	virSecretSetValue		(virSecretPtr secret, 
const unsigned char * value,
size_t value_size,
unsigned int flags)
+

Sets the value of a secret.

+
secret:A virSecret secret
value:Value of the secret
value_size:Size of the value
flags:flags, use 0 for now
Returns:0 on success, -1 on failure.
+
+

virSecretUndefine ()

int	virSecretUndefine		(virSecretPtr secret)
+

Deletes the specified secret. This does not free the associated virSecretPtr object.

+
secret:A virSecret secret
Returns:0 on success, -1 on failure.

virStoragePoolBuild ()

int	virStoragePoolBuild		(virStoragePoolPtr pool, 
unsigned int flags)

Build the underlying storage pool

diff --git a/docs/devhelp/libvirt-virterror.html b/docs/devhelp/libvirt-virterror.html index 88a8505e82..28e184ef7f 100644 --- a/docs/devhelp/libvirt-virterror.html +++ b/docs/devhelp/libvirt-virterror.html @@ -111,7 +111,8 @@ void virConnResetLastError (VIR_FROM_INTERFACE = 26 /* Error when operating on an interface */ VIR_FROM_ONE = 27 /* Error from OpenNebula driver */ VIR_FROM_ESX = 28 /* Error from ESX driver */ - VIR_FROM_PHYP = 29 /* Error from IBM power hypervisor */ + VIR_FROM_PHYP = 29 /* Error from IBM power hypervisor */ + VIR_FROM_SECRET = 30 /* Error from secret storage */ };

@@ -184,7 +185,9 @@ void virConnResetLastError (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 */ - VIR_ERR_MULTIPLE_INTERFACES = 59 /* more than one matching interface found */ + VIR_ERR_MULTIPLE_INTERFACES = 59 /* more than one matching interface found */ + VIR_WAR_NO_SECRET = 60 /* failed to start secret storage */ + VIR_ERR_INVALID_SECRET = 61 /* invalid secret */ };

diff --git a/docs/html/libvirt-libvirt.html b/docs/html/libvirt-libvirt.html index 748861fdf3..5772fbef43 100644 --- a/docs/html/libvirt-libvirt.html +++ b/docs/html/libvirt-libvirt.html @@ -57,6 +57,8 @@ typedef virNodeInfo * virSchedParameter typedef virSchedParameter * virSchedParameterPtr typedef enum virSchedParameterType +typedef struct _virSecret virSecret +typedef virSecret * virSecretPtr typedef struct _virSecurityLabel virSecurityLabel typedef virSecurityLabel * virSecurityLabelPtr typedef struct _virSecurityModel virSecurityModel @@ -102,6 +104,7 @@ int virConnectListDefinedStoragePoo 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 virConnectListSecrets (virConnectPtr conn,
char ** uuids,
int maxuuids) int virConnectListStoragePools (virConnectPtr conn,
char ** const names,
int maxnames) int virConnectNumOfDefinedDomains (virConnectPtr conn) int virConnectNumOfDefinedInterfaces (virConnectPtr conn) @@ -110,6 +113,7 @@ int virConnectNumOfDefinedStorageP int virConnectNumOfDomains (virConnectPtr conn) int virConnectNumOfInterfaces (virConnectPtr conn) int virConnectNumOfNetworks (virConnectPtr conn) +int virConnectNumOfSecrets (virConnectPtr conn) int virConnectNumOfStoragePools (virConnectPtr conn) virConnectPtr virConnectOpen (const char * name) virConnectPtr virConnectOpenAuth (const char * name,
virConnectAuthPtr auth,
int flags) @@ -241,6 +245,16 @@ int virNodeGetInfo (virNodeGetSecurityModel (virConnectPtr conn,
virSecurityModelPtr secmodel) int virNodeListDevices (virConnectPtr conn,
const char * cap,
char ** const names,
int maxnames,
unsigned int flags) int virNodeNumOfDevices (virConnectPtr conn,
const char * cap,
unsigned int flags) +virSecretPtr virSecretDefineXML (virConnectPtr conn,
const char * xml,
unsigned int flags) +int virSecretFree (virSecretPtr secret) +virConnectPtr virSecretGetConnect (virSecretPtr secret) +char * virSecretGetUUIDString (virSecretPtr secret) +unsigned char * virSecretGetValue (virSecretPtr secret,
size_t * value_size,
unsigned int flags) +char * virSecretGetXMLDesc (virSecretPtr secret,
unsigned int flags) +virSecretPtr virSecretLookupByUUIDString (virConnectPtr conn,
const char * uuid) +int virSecretRef (virSecretPtr secret) +int virSecretSetValue (virSecretPtr secret,
const unsigned char * value,
size_t value_size,
unsigned int flags) +int virSecretUndefine (virSecretPtr secret) int virStoragePoolBuild (virStoragePoolPtr pool,
unsigned int flags) int virStoragePoolCreate (virStoragePoolPtr pool,
unsigned int flags) virStoragePoolPtr virStoragePoolCreateXML (virConnectPtr conn,
const char * xmlDesc,
unsigned int flags) @@ -347,6 +361,9 @@ int virStorageVolRef (virSchedParameterType

enum virSchedParameterType {
 
VIR_DOMAIN_SCHED_FIELD_INT = 1 : integer case
VIR_DOMAIN_SCHED_FIELD_UINT = 2 : unsigned integer case
VIR_DOMAIN_SCHED_FIELD_LLONG = 3 : long long case
VIR_DOMAIN_SCHED_FIELD_ULLONG = 4 : unsigned long long case
VIR_DOMAIN_SCHED_FIELD_DOUBLE = 5 : double case
VIR_DOMAIN_SCHED_FIELD_BOOLEAN = 6 : boolean(character) case
}
+

virSecret

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

virSecurityLabel

struct virSecurityLabel{
 
The content of this structure is not made public by the API
 }
@@ -401,7 +418,8 @@ int	virStorageVolRef		(
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

virConnectListInterfaces

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

Collect the list of active 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)
+

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

virConnectListSecrets

int	virConnectListSecrets		(virConnectPtr conn, 
char ** uuids,
int maxuuids)
+

List UUIDs of defined secrets, store pointers to names in uuids.

conn:virConnect connection
uuids:Pointer to an array to store the UUIDs
maxuuids:size of the array.
Returns:the number of UUIDs provided in the array, or -1 on failure.

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

virConnectNumOfDefinedInterfaces

int	virConnectNumOfDefinedInterfaces	(virConnectPtr conn)

Provides the number of defined (inactive) interfaces on the physical host.

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

virConnectNumOfDefinedNetworks

int	virConnectNumOfDefinedNetworks	(virConnectPtr conn)
@@ -409,7 +427,8 @@ int virStorageVolRef (
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

virConnectNumOfInterfaces

int	virConnectNumOfInterfaces	(virConnectPtr conn)

Provides the number of active interfaces on the physical host.

conn:pointer to the hypervisor connection
Returns:the number of active interfaces 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 networks.

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

virConnectNumOfSecrets

int	virConnectNumOfSecrets		(virConnectPtr conn)
+

Fetch number of currently defined secrets.

conn:virConnect connection
Returns:the number currently defined secrets.

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 If @name is NULL then probing will be done to determine a suitable default driver to activate. This involves trying each hypervisor in turn until one successfully opens. If the LIBVIRT_DEFAULT_URI environment variable is set, then it will be used in preference to probing for a driver. If connecting to an unprivileged hypervisor driver which requires the libvirtd daemon to be active, it will automatically be launched if not already running. This can be prevented by setting the environment variable LIBVIRT_AUTOSTART=0 URIs are documented at http://libvirt.org/uri.html

virConnectOpenAuth

virConnectPtr	virConnectOpenAuth	(const char * name, 
virConnectAuthPtr auth,
int flags)

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

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

virConnectOpenReadOnly

virConnectPtr	virConnectOpenReadOnly	(const char * name)
@@ -522,7 +541,17 @@ int virStorageVolRef (
conn:pointer to the hypervisor connection
info:pointer to a virNodeInfo structure allocated by the user
Returns:0 in case of success and -1 in case of failure.

virNodeGetSecurityModel

int	virNodeGetSecurityModel		(virConnectPtr conn, 
virSecurityModelPtr secmodel)

Extract the security model of a hypervisor. The 'model' field in the @secmodel argument may be initialized to the empty string if the driver has not activated a security model.

conn:a connection object
secmodel:pointer to a virSecurityModel structure
Returns:0 in case of success, -1 in case of failure

virNodeListDevices

int	virNodeListDevices		(virConnectPtr conn, 
const char * cap,
char ** const names,
int maxnames,
unsigned int flags)

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

conn:pointer to the hypervisor connection
cap:capability name
names:array to collect the list of node device names
maxnames:size of @names
flags:flags (unused, pass 0)
Returns:the number of node devices found or -1 in case of error

virNodeNumOfDevices

int	virNodeNumOfDevices		(virConnectPtr conn, 
const char * cap,
unsigned int flags)
-

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

conn:pointer to the hypervisor connection
cap:capability name
flags:flags (unused, pass 0)
Returns:the number of node devices or -1 in case of error

virStoragePoolBuild

int	virStoragePoolBuild		(virStoragePoolPtr pool, 
unsigned int flags)
+

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

conn:pointer to the hypervisor connection
cap:capability name
flags:flags (unused, pass 0)
Returns:the number of node devices or -1 in case of error

virSecretDefineXML

virSecretPtr	virSecretDefineXML	(virConnectPtr conn, 
const char * xml,
unsigned int flags)
+

If XML specifies an UUID, locates the specified secret and replaces all attributes of the secret specified by UUID by attributes specified in xml (any attributes not specified in xml are discarded). Otherwise, creates a new secret with an automatically chosen UUID, and initializes its attributes from xml.

conn:virConnect connection
xml:XML describing the secret.
flags:flags, use 0 for now
Returns:a the secret on success, NULL on failure.

virSecretFree

int	virSecretFree			(virSecretPtr secret)
+

Release the secret handle. The underlying secret continues to exist.

secret:pointer to a secret
Returns:0 on success, or -1 on error

virSecretGetConnect

virConnectPtr	virSecretGetConnect	(virSecretPtr secret)
+

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

secret:A virSecret secret
Returns:the virConnectPtr or NULL in case of failure.

virSecretGetUUIDString

char *	virSecretGetUUIDString		(virSecretPtr secret)
+

Fetches the UUID of the secret.

secret:A virSecret secret
Returns:ID of the secret (not necessarily in the UUID format) on success, NULL on failure. The caller must free() the ID.

virSecretGetValue

unsigned char *	virSecretGetValue	(virSecretPtr secret, 
size_t * value_size,
unsigned int flags)
+

Fetches the value of a secret.

secret:A virSecret connection
value_size:Place for storing size of the secret value
flags:flags, use 0 for now
Returns:the secret value on success, NULL on failure. The caller must free() the secret value.

virSecretGetXMLDesc

char *	virSecretGetXMLDesc		(virSecretPtr secret, 
unsigned int flags)
+

Fetches an XML document describing attributes of the secret.

secret:A virSecret secret
flags:flags, use 0 for now
Returns:the XML document on success, NULL on failure. The caller must free() the XML.

virSecretLookupByUUIDString

virSecretPtr	virSecretLookupByUUIDString	(virConnectPtr conn, 
const char * uuid)
+

Fetches a secret based on uuid.

conn:virConnect connection
uuid:ID of a secret
Returns:the secret on success, or NULL on failure.

virSecretRef

int	virSecretRef			(virSecretPtr secret)
+

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

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

virSecretSetValue

int	virSecretSetValue		(virSecretPtr secret, 
const unsigned char * value,
size_t value_size,
unsigned int flags)
+

Sets the value of a secret.

secret:A virSecret secret
value:Value of the secret
value_size:Size of the value
flags:flags, use 0 for now
Returns:0 on success, -1 on failure.

virSecretUndefine

int	virSecretUndefine		(virSecretPtr secret)
+

Deletes the specified secret. This does not free the associated virSecretPtr object.

secret:A virSecret secret
Returns:0 on success, -1 on failure.

virStoragePoolBuild

int	virStoragePoolBuild		(virStoragePoolPtr pool, 
unsigned int flags)

Build the underlying storage pool

pool:pointer to storage pool
flags:future flags, use 0 for now
Returns:0 on success, or -1 upon failure

virStoragePoolCreate

int	virStoragePoolCreate		(virStoragePoolPtr pool, 
unsigned int flags)

Starts an inactive storage pool

pool:pointer to storage pool
flags:future flags, use 0 for now
Returns:0 on success, or -1 if it could not be started

virStoragePoolCreateXML

virStoragePoolPtr	virStoragePoolCreateXML	(virConnectPtr conn, 
const char * xmlDesc,
unsigned int flags)

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

conn:pointer to hypervisor connection
xmlDesc:XML description for new pool
flags:future flags, use 0 for now
Returns:a virStoragePoolPtr object, or NULL if creation failed

virStoragePoolDefineXML

virStoragePoolPtr	virStoragePoolDefineXML	(virConnectPtr conn, 
const char * xml,
unsigned int flags)
diff --git a/docs/html/libvirt-virterror.html b/docs/html/libvirt-virterror.html index c3cbe11122..b4d74be847 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_INTERFACE = 26 : Error when operating on an interface
VIR_FROM_ONE = 27 : Error from OpenNebula driver
VIR_FROM_ESX = 28 : Error from ESX driver
VIR_FROM_PHYP = 29 : Error from IBM power hypervisor
}
+
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
VIR_FROM_ONE = 27 : Error from OpenNebula driver
VIR_FROM_ESX = 28 : Error from ESX driver
VIR_FROM_PHYP = 29 : Error from IBM power hypervisor
VIR_FROM_SECRET = 30 : Error from secret storage
}
 

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_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
VIR_ERR_MULTIPLE_INTERFACES = 59 : more than one matching interface found
}
+
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
VIR_ERR_MULTIPLE_INTERFACES = 59 : more than one matching interface found
VIR_WAR_NO_SECRET = 60 : failed to start secret storage
VIR_ERR_INVALID_SECRET = 61 : invalid secret
}
 

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 cbf0916a9b..ceca3ff1a8 100644 --- a/docs/libvirt-api.xml +++ b/docs/libvirt-api.xml @@ -97,6 +97,7 @@ + @@ -105,6 +106,7 @@ + @@ -164,16 +166,18 @@ + - + - + + @@ -182,7 +186,7 @@ - + @@ -206,6 +210,7 @@ + @@ -232,6 +237,7 @@ + @@ -241,7 +247,7 @@ - + @@ -254,10 +260,12 @@ + + @@ -267,7 +275,7 @@ - + @@ -280,14 +288,14 @@ - + - + @@ -304,6 +312,7 @@ + @@ -316,6 +325,7 @@ + @@ -327,6 +337,7 @@ + @@ -335,13 +346,16 @@ + + + @@ -355,6 +369,7 @@ + @@ -383,6 +398,7 @@ + @@ -413,9 +429,10 @@ - + + @@ -587,9 +604,10 @@ + - + @@ -645,11 +663,12 @@ - + + @@ -685,6 +704,7 @@ + @@ -812,6 +832,8 @@ see note above'/> a virSchedParameterPtr is a pointer to a virSchedParameter structure. + + a virSecurityLabelPtr is a pointer to a virSecurityLabel. @@ -1018,6 +1040,13 @@ see note above'/> + + List UUIDs of defined secrets, store pointers to names in uuids. + + + + + Provides the list of names of active storage pools upto maxnames. If there are more than maxnames, the remaining names will be silently ignored. @@ -1060,6 +1089,11 @@ see note above'/> + + Fetch number of currently defined secrets. + + + Provides the number of active storage pools @@ -1776,6 +1810,65 @@ see note above'/> Save the last error into a new error object. + + If XML specifies an UUID, locates the specified secret and replaces all attributes of the secret specified by UUID by attributes specified in xml (any attributes not specified in xml are discarded). Otherwise, creates a new secret with an automatically chosen UUID, and initializes its attributes from xml. + + + + + + + Release the secret handle. The underlying secret continues to exist. + + + + + Provides the connection pointer associated with a secret. 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 secret object together. + + + + + Fetches the UUID of the secret. + + + + + Fetches the value of a secret. + + + + + + + Fetches an XML document describing attributes of the secret. + + + + + + Fetches a secret based on uuid. + + + + + + Increment the reference count on the secret. For each additional call to this method, there shall be a corresponding call to virSecretFree 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 secret would increment the reference count. + + + + + Sets the value of a secret. + + + + + + + + Deletes the specified secret. This does not free the associated virSecretPtr object. + + + 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. diff --git a/docs/libvirt-refs.xml b/docs/libvirt-refs.xml index cfa31bf052..1c2f858e6d 100644 --- a/docs/libvirt-refs.xml +++ b/docs/libvirt-refs.xml @@ -71,6 +71,7 @@ + @@ -134,6 +135,7 @@ + @@ -178,6 +180,7 @@ + @@ -225,6 +228,7 @@ + @@ -233,6 +237,7 @@ + @@ -392,6 +397,18 @@ + + + + + + + + + + + + @@ -526,6 +543,7 @@ + @@ -589,6 +607,7 @@ + @@ -633,6 +652,7 @@ + @@ -684,6 +704,7 @@ + @@ -692,6 +713,7 @@ + @@ -851,6 +873,18 @@ + + + + + + + + + + + + @@ -913,6 +947,9 @@ + + + @@ -929,6 +966,7 @@ + @@ -963,6 +1001,10 @@ + + + + @@ -980,6 +1022,9 @@ + + + @@ -995,6 +1040,7 @@ + @@ -1010,6 +1056,10 @@ + + + + @@ -1038,6 +1088,10 @@ + + + + @@ -1101,6 +1155,7 @@ + @@ -1109,6 +1164,7 @@ + @@ -1136,6 +1192,8 @@ + + @@ -1282,6 +1340,16 @@ + + + + + + + + + + @@ -1477,6 +1545,7 @@ + @@ -1485,6 +1554,7 @@ + @@ -1631,6 +1701,18 @@ + + + + + + + + + + + + @@ -1708,6 +1790,7 @@ + @@ -1767,6 +1850,7 @@ + @@ -1783,6 +1867,7 @@ + @@ -1966,6 +2051,9 @@ + + + @@ -2042,6 +2130,7 @@ + @@ -2062,6 +2151,10 @@ + + + + @@ -2081,6 +2174,7 @@ + @@ -2139,6 +2233,7 @@ + @@ -2156,6 +2251,7 @@ + @@ -2199,6 +2295,7 @@ + @@ -2297,6 +2394,9 @@ + + + @@ -2310,6 +2410,12 @@ + + + + + + @@ -2345,6 +2451,7 @@ + @@ -2378,6 +2485,7 @@ + @@ -2431,6 +2539,7 @@ + @@ -2444,6 +2553,9 @@ + + + @@ -2519,6 +2631,11 @@ + + + + + @@ -2578,6 +2695,9 @@ + + + @@ -2586,6 +2706,7 @@ + @@ -2596,6 +2717,7 @@ + @@ -2690,6 +2812,7 @@ + @@ -2739,6 +2862,8 @@ + + @@ -2806,6 +2931,7 @@ + @@ -2827,6 +2953,7 @@ + @@ -2843,34 +2970,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2900,6 +2999,8 @@ + + @@ -2927,6 +3028,10 @@ + + + + @@ -2939,6 +3044,7 @@ + @@ -2995,6 +3101,7 @@ + @@ -3045,6 +3152,7 @@ + @@ -3156,6 +3264,10 @@ + + + + @@ -3264,6 +3376,9 @@ + + + @@ -3385,6 +3500,7 @@ + @@ -3414,6 +3530,7 @@ + @@ -3435,6 +3552,7 @@ + @@ -3442,6 +3560,7 @@ + @@ -3474,6 +3593,9 @@ + + + @@ -3491,6 +3613,7 @@ + @@ -3554,8 +3677,10 @@ + + @@ -3595,6 +3720,8 @@ + + @@ -3674,6 +3801,9 @@ + + + @@ -3701,6 +3831,7 @@ + @@ -3725,6 +3856,7 @@ + @@ -3807,6 +3939,7 @@ + @@ -3900,6 +4033,7 @@ + @@ -4031,6 +4165,7 @@ + @@ -4047,35 +4182,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -4089,35 +4195,9 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -4158,6 +4238,7 @@ + @@ -4260,8 +4341,6 @@ - - @@ -4271,6 +4350,7 @@ + @@ -4316,6 +4396,7 @@ + @@ -4329,6 +4410,7 @@ + @@ -4382,6 +4464,8 @@ + + @@ -4442,6 +4526,7 @@ + @@ -4451,6 +4536,7 @@ + @@ -4502,6 +4588,9 @@ + + + @@ -4593,6 +4682,7 @@ + @@ -4610,8 +4700,6 @@ - - @@ -4663,6 +4751,7 @@ + @@ -4753,6 +4842,7 @@ + @@ -4832,6 +4922,9 @@ + + + @@ -4846,6 +4939,7 @@ + @@ -4870,6 +4964,8 @@ + + @@ -4983,6 +5079,7 @@ + @@ -5070,6 +5167,7 @@ + @@ -5094,13 +5192,14 @@ + + + - - @@ -5109,6 +5208,7 @@ + @@ -5125,6 +5225,9 @@ + + + @@ -5151,6 +5254,7 @@ + @@ -5208,6 +5312,10 @@ + + + + @@ -5223,6 +5331,8 @@ + + @@ -5261,6 +5371,7 @@ + @@ -5303,6 +5414,7 @@ + @@ -5358,6 +5470,7 @@ + @@ -5514,6 +5627,7 @@ + @@ -5603,6 +5717,7 @@ + @@ -5734,6 +5849,7 @@ + @@ -5753,6 +5869,7 @@ + @@ -5788,6 +5905,9 @@ + + + @@ -5827,6 +5947,7 @@ + @@ -6021,6 +6142,10 @@ + + + + @@ -6079,6 +6204,7 @@ + @@ -6171,6 +6297,11 @@ + + + + + @@ -6255,12 +6386,14 @@ + + @@ -6274,6 +6407,9 @@ + + + @@ -6452,6 +6588,7 @@ + @@ -6477,6 +6614,7 @@ + @@ -6493,6 +6631,7 @@ + @@ -6520,6 +6659,7 @@ + @@ -6570,6 +6710,7 @@ + @@ -6594,6 +6735,7 @@ + @@ -6639,6 +6781,7 @@ + @@ -6700,6 +6843,11 @@ + + + + + @@ -6716,6 +6864,7 @@ + @@ -6755,6 +6904,7 @@ + @@ -6762,6 +6912,12 @@ + + + + + + @@ -6769,29 +6925,6 @@ - - - - - - - - - - - - - - - - - - - - - - - @@ -6823,6 +6956,10 @@ + + + + @@ -6849,6 +6986,7 @@ + @@ -6987,6 +7125,20 @@ + + + + + + + + + + + + + + @@ -7128,6 +7280,7 @@ + @@ -7183,6 +7336,7 @@ + @@ -7193,6 +7347,7 @@ + @@ -7212,6 +7367,7 @@ + @@ -7252,10 +7408,10 @@ - - - - + + + + diff --git a/python/generator.py b/python/generator.py index feff7a3637..4dbad1c373 100755 --- a/python/generator.py +++ b/python/generator.py @@ -270,6 +270,11 @@ py_types = { 'const virNodeDevicePtr': ('O', "virNodeDevice", "virNodeDevicePtr", "virNodeDevicePtr"), 'virNodeDevice *': ('O', "virNodeDevice", "virNodeDevicePtr", "virNodeDevicePtr"), 'const virNodeDevice *': ('O', "virNodeDevice", "virNodeDevicePtr", "virNodeDevicePtr"), + + 'virSecretPtr': ('O', "virSecret", "virSecretPtr", "virSecretPtr"), + 'const virSecretPtr': ('O', "virSecret", "virSecretPtr", "virSecretPtr"), + 'virSecret *': ('O', "virSecret", "virSecretPtr", "virSecretPtr"), + 'const virSecret *': ('O', "virSecret", "virSecretPtr", "virSecretPtr"), } py_return_types = { @@ -296,6 +301,7 @@ skip_impl = ( 'virConnectListDefinedNetworks', 'virConnectListInterfaces', 'virConnectListDefinedInterfaces', + 'virConnectListSecrets', 'virConnectListStoragePools', 'virConnectListDefinedStoragePools', 'virConnectListStorageVols', @@ -320,6 +326,8 @@ skip_impl = ( 'virDomainSetSchedulerParameters', 'virDomainGetVcpus', 'virDomainPinVcpu', + 'virSecretGetValue', + 'virSecretSetValue', 'virStoragePoolGetUUID', 'virStoragePoolGetUUIDString', 'virStoragePoolLookupByUUID', @@ -623,6 +631,8 @@ classes_type = { "virStorageVol *": ("._o", "virStorageVol(self, _obj=%s)", "virStorageVol"), "virNodeDevicePtr": ("._o", "virNodeDevice(self, _obj=%s)", "virNodeDevice"), "virNodeDevice *": ("._o", "virNodeDevice(self, _obj=%s)", "virNodeDevice"), + "virSecretPtr": ("._o", "virSecret(self, _obj=%s)", "virSecret"), + "virSecret *": ("._o", "virSecret(self, _obj=%s)", "virSecret"), "virConnectPtr": ("._o", "virConnect(_obj=%s)", "virConnect"), "virConnect *": ("._o", "virConnect(_obj=%s)", "virConnect"), } @@ -632,7 +642,7 @@ converter_type = { primary_classes = ["virDomain", "virNetwork", "virInterface", "virStoragePool", "virStorageVol", - "virConnect", "virNodeDevice" ] + "virConnect", "virNodeDevice", "virSecret" ] classes_ancestor = { } @@ -642,7 +652,8 @@ classes_destructors = { "virInterface": "virInterfaceFree", "virStoragePool": "virStoragePoolFree", "virStorageVol": "virStorageVolFree", - "virNodeDevice" : "virNodeDeviceFree" + "virNodeDevice" : "virNodeDeviceFree", + "virSecret": "virSecretFree" } functions_noexcept = { @@ -714,6 +725,12 @@ def nameFixup(name, classe, type, file): elif name[0:18] == "virInterfaceLookup": func = name[3:] func = string.lower(func[0:1]) + func[1:] + elif name[0:15] == "virSecretDefine": + func = name[3:] + func = string.lower(func[0:1]) + func[1:] + elif name[0:15] == "virSecretLookup": + func = name[3:] + func = string.lower(func[0:1]) + func[1:] elif name[0:20] == "virStoragePoolDefine": func = name[3:] func = string.lower(func[0:1]) + func[1:] @@ -747,6 +764,12 @@ def nameFixup(name, classe, type, file): elif name[0:12] == "virInterface": func = name[10:] func = string.lower(func[0:1]) + func[1:] + elif name[0:12] == 'virSecretGet': + func = name[12:] + func = string.lower(func[0:1]) + func[1:] + elif name[0:9] == 'virSecret': + func = name[9:] + func = string.lower(func[0:1]) + func[1:] elif name[0:17] == "virStoragePoolGet": func = name[17:] func = string.lower(func[0:1]) + func[1:] @@ -1018,7 +1041,7 @@ def buildWrappers(): else: txt.write("Class %s()\n" % (classname)) classes.write("class %s:\n" % (classname)) - if classname in [ "virDomain", "virNetwork", "virInterface", "virStoragePool", "virStorageVol", "virNodeDevice" ]: + if classname in [ "virDomain", "virNetwork", "virInterface", "virStoragePool", "virStorageVol", "virNodeDevice", "virSecret" ]: classes.write(" def __init__(self, conn, _obj=None):\n") else: classes.write(" def __init__(self, _obj=None):\n") @@ -1026,7 +1049,7 @@ def buildWrappers(): list = reference_keepers[classname] for ref in list: classes.write(" self.%s = None\n" % ref[1]) - if classname in [ "virDomain", "virNetwork", "virInterface", "virNodeDevice" ]: + if classname in [ "virDomain", "virNetwork", "virInterface", "virNodeDevice", "virSecret" ]: classes.write(" self._conn = conn\n") elif classname in [ "virStorageVol", "virStoragePool" ]: classes.write(" self._conn = conn\n" + \ diff --git a/python/libvir.c b/python/libvir.c index e2105979ab..e2c196a693 100644 --- a/python/libvir.c +++ b/python/libvir.c @@ -1562,6 +1562,103 @@ libvirt_virNodeDeviceListCaps(PyObject *self ATTRIBUTE_UNUSED, return(py_retval); } +static PyObject * +libvirt_virConnectListSecrets(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) { + PyObject *py_retval; + char **uuids = NULL; + virConnectPtr conn; + int c_retval, i; + PyObject *pyobj_conn; + + if (!PyArg_ParseTuple(args, (char *)"O:virConnectListSecrets", &pyobj_conn)) + return NULL; + conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn); + + LIBVIRT_BEGIN_ALLOW_THREADS; + c_retval = virConnectNumOfSecrets(conn); + LIBVIRT_END_ALLOW_THREADS; + if (c_retval < 0) + return VIR_PY_NONE; + + if (c_retval) { + uuids = malloc(sizeof(*uuids) * c_retval); + if (!uuids) + return VIR_PY_NONE; + LIBVIRT_BEGIN_ALLOW_THREADS; + c_retval = virConnectListSecrets(conn, uuids, c_retval); + LIBVIRT_END_ALLOW_THREADS; + if (c_retval < 0) { + free(uuids); + return VIR_PY_NONE; + } + } + py_retval = PyList_New(c_retval); + + if (uuids) { + for (i = 0;i < c_retval;i++) { + PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(uuids[i])); + free(uuids[i]); + } + free(uuids); + } + + return py_retval; +} + +static PyObject * +libvirt_virSecretGetValue(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) { + PyObject *py_retval; + unsigned char *c_retval; + size_t size; + virSecretPtr secret; + PyObject *pyobj_secret; + unsigned int flags; + + if (!PyArg_ParseTuple(args, (char *)"Oi:virSecretGetValue", &pyobj_secret, + &flags)) + return NULL; + secret = (virSecretPtr) PyvirSecret_Get(pyobj_secret); + + LIBVIRT_BEGIN_ALLOW_THREADS; + c_retval = virSecretGetValue(secret, &size, flags); + LIBVIRT_END_ALLOW_THREADS; + + if (c_retval == NULL) + return VIR_PY_NONE; + + py_retval = PyString_FromStringAndSize((const char *)c_retval, size); + memset(c_retval, 0, size); + free(c_retval); + + return py_retval; +} + +static PyObject * +libvirt_virSecretSetValue(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) { + PyObject *py_retval; + int c_retval; + virSecretPtr secret; + PyObject *pyobj_secret; + const char *value; + int size; + unsigned int flags; + + if (!PyArg_ParseTuple(args, (char *)"Oz#i:virSecretSetValue", &pyobj_secret, + &value, &size, &flags)) + return NULL; + secret = (virSecretPtr) PyvirSecret_Get(pyobj_secret); + + LIBVIRT_BEGIN_ALLOW_THREADS; + c_retval = virSecretSetValue(secret, (const unsigned char *)value, size, + flags); + LIBVIRT_END_ALLOW_THREADS; + + py_retval = libvirt_intWrap(c_retval); + return py_retval; +} /******************************************* * Helper functions to avoid importing modules @@ -2261,6 +2358,9 @@ static PyMethodDef libvirtMethods[] = { {(char *) "virEventInvokeTimeoutCallback", libvirt_virEventInvokeTimeoutCallback, METH_VARARGS, NULL}, {(char *) "virNodeListDevices", libvirt_virNodeListDevices, METH_VARARGS, NULL}, {(char *) "virNodeDeviceListCaps", libvirt_virNodeDeviceListCaps, METH_VARARGS, NULL}, + {(char *) "virConnectListSecrets", libvirt_virConnectListSecrets, METH_VARARGS, NULL}, + {(char *) "virSecretGetValue", libvirt_virSecretGetValue, METH_VARARGS, NULL}, + {(char *) "virSecretSetValue", libvirt_virSecretSetValue, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} }; diff --git a/python/libvirt-python-api.xml b/python/libvirt-python-api.xml index 43a5b4e7ea..e5c1fb927b 100644 --- a/python/libvirt-python-api.xml +++ b/python/libvirt-python-api.xml @@ -172,5 +172,23 @@ + + Fetches the value associated with a secret. + + + + + + List the defined secret IDs + + + + + Associates a value with a secret. + + + + + diff --git a/python/libvirt_wrap.h b/python/libvirt_wrap.h index 4a32eddb70..99d5805f2b 100644 --- a/python/libvirt_wrap.h +++ b/python/libvirt_wrap.h @@ -83,6 +83,14 @@ typedef struct { virNodeDevicePtr obj; } PyvirNodeDevice_Object; +#define PyvirSecret_Get(v) (((v) == Py_None) ? NULL : \ + (((PyvirSecret_Object *)(v))->obj)) + +typedef struct { + PyObject_HEAD + virSecretPtr obj; +} PyvirSecret_Object; + #define PyvirEventHandleCallback_Get(v) (((v) == Py_None) ? NULL : \ (((PyvirEventHandleCallback_Object *)(v))->obj)) @@ -135,6 +143,7 @@ PyObject * libvirt_virEventTimeoutCallbackWrap(virEventTimeoutCallback node); PyObject * libvirt_virFreeCallbackWrap(virFreeCallback node); PyObject * libvirt_virVoidPtrWrap(void* node); PyObject * libvirt_virNodeDevicePtrWrap(virNodeDevicePtr node); +PyObject * libvirt_virSecretPtrWrap(virSecretPtr node); /* Provide simple macro statement wrappers (adapted from GLib, in turn from Perl): diff --git a/python/types.c b/python/types.c index de75471c90..c445f5fa52 100644 --- a/python/types.c +++ b/python/types.c @@ -193,6 +193,19 @@ libvirt_virNodeDevicePtrWrap(virNodeDevicePtr node) return (ret); } +PyObject * +libvirt_virSecretPtrWrap(virSecretPtr node) +{ + PyObject *ret; + + if (node == NULL) { + Py_INCREF(Py_None); + return Py_None; + } + ret = PyCObject_FromVoidPtrAndDesc(node, (char *) "virSecretPtr", NULL); + return (ret); +} + PyObject * libvirt_virEventHandleCallbackWrap(virEventHandleCallback node) { -- 2.47.2