libvirt Reference Manual |
---|
libvirt - core interfaces for the libvirt library
Provides the interfaces of the libvirt library to handle virtualized domains
Author(s): Daniel Veillard <veillard@redhat.com>
#define VIR_NODEINFO_MAXCPUS(nodeinfo); #define LIBVIR_VERSION_NUMBER; #define VIR_USE_CPU(cpumap, cpu); #define VIR_SECURITY_DOI_BUFLEN; #define VIR_CPU_MAPLEN(cpu); #define VIR_SECURITY_LABEL_BUFLEN; #define VIR_CPU_USABLE(cpumaps, maplen, vcpu, cpu); #define VIR_COPY_CPUMAP(cpumaps, maplen, vcpu, cpumap); #define VIR_DOMAIN_SCHED_FIELD_LENGTH; #define VIR_SECURITY_MODEL_BUFLEN; #define VIR_UUID_STRING_BUFLEN; #define VIR_GET_CPUMAP(cpumaps, maplen, vcpu); #define VIR_UUID_BUFLEN; #define VIR_UNUSE_CPU(cpumap, cpu); typedef struct _virDomainBlockStats virDomainBlockStatsStruct; typedef enum virDomainMigrateFlags; typedef struct _virNodeInfo virNodeInfo; typedef struct _virNetwork virNetwork; typedef enum virDomainEventResumedDetailType; typedef virDomainBlockStatsStruct * virDomainBlockStatsPtr; typedef struct _virConnect virConnect; typedef enum virDomainEventStartedDetailType; typedef struct _virDomainInfo virDomainInfo; typedef enum virStoragePoolDeleteFlags; typedef enum virEventHandleType; typedef struct _virStoragePool virStoragePool; typedef enum virDomainEventType; typedef struct _virDomainInterfaceStats virDomainInterfaceStatsStruct; typedef struct _virStoragePoolInfo virStoragePoolInfo; typedef enum virDomainState; typedef struct _virDomain virDomain; typedef virDomainInterfaceStatsStruct * virDomainInterfaceStatsPtr; typedef virConnectAuth * virConnectAuthPtr; typedef struct _virStorageVolInfo virStorageVolInfo; typedef enum virSchedParameterType; typedef struct _virSecurityLabel virSecurityLabel; typedef virStorageVolInfo * virStorageVolInfoPtr; typedef virConnectCredential * virConnectCredentialPtr; typedef virStoragePool * virStoragePoolPtr; typedef virNodeInfo * virNodeInfoPtr; typedef virNetwork * virNetworkPtr; typedef virDomainInfo * virDomainInfoPtr; 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; typedef enum virVcpuState; typedef enum virStorageVolDeleteFlags; typedef struct _virVcpuInfo virVcpuInfo; typedef virSchedParameter * virSchedParameterPtr; typedef struct _virConnectAuth virConnectAuth; typedef struct _virConnectCredential virConnectCredential; typedef virSecurityModel * virSecurityModelPtr; typedef enum virDomainEventSuspendedDetailType; typedef virVcpuInfo * virVcpuInfoPtr; typedef enum virStoragePoolBuildFlags; typedef enum virDomainXMLFlags; typedef enum virStorageVolType; typedef enum virDomainEventUndefinedDetailType; typedef virDomain * virDomainPtr; typedef enum virConnectCredentialType; typedef enum virStoragePoolState; typedef virStoragePoolInfo * virStoragePoolInfoPtr; typedef enum virDomainCreateFlags; typedef virSecurityLabel * virSecurityLabelPtr; typedef struct _virSecurityModel virSecurityModel; char * virStoragePoolGetXMLDesc (virStoragePoolPtr pool,
unsigned int flags); const char * virStorageVolGetKey (virStorageVolPtr vol); typedef void virEventUpdateTimeoutFunc (int timer,
int timeout); int virConnectClose (virConnectPtr conn); virDomainPtr virDomainDefineXML (virConnectPtr conn,
const char * xml); int virDomainShutdown (virDomainPtr domain); int virConnectListStoragePools (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 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); int virDomainGetSchedulerParameters (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 virNetworkGetUUID (virNetworkPtr network,
unsigned char * uuid); char * virInterfaceGetXMLDesc (virInterfacePtr iface,
unsigned int flags); virConnectPtr virStoragePoolGetConnect (virStoragePoolPtr pool); int virConnectGetVersion (virConnectPtr conn,
unsigned long * hvVer); int virDomainFree (virDomainPtr domain); int virStorageVolRef (virStorageVolPtr vol); const char * virStoragePoolGetName (virStoragePoolPtr pool); int virDomainSetAutostart (virDomainPtr domain,
int autostart); virStoragePoolPtr virStoragePoolDefineXML (virConnectPtr conn,
const char * xml,
unsigned int flags); virStorageVolPtr virStorageVolLookupByPath (virConnectPtr conn,
const char * path); virStorageVolPtr virStorageVolLookupByName (virStoragePoolPtr pool,
const char * name); int 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); char * virNodeDeviceGetXMLDesc (virNodeDevicePtr dev,
unsigned int flags); typedef void virEventUpdateHandleFunc (int watch,
int event); int virDomainDestroy (virDomainPtr domain); int virConnectNumOfNetworks (virConnectPtr conn); virStoragePoolPtr virStoragePoolLookupByUUIDString (virConnectPtr conn,
const char * uuidstr); int virInterfaceCreate (virInterfacePtr iface,
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); int virDomainSave (virDomainPtr domain,
const char * to); int virDomainCreate (virDomainPtr domain); int 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 iface); int virStoragePoolCreate (virStoragePoolPtr pool,
unsigned int flags); int virNodeGetInfo (virConnectPtr conn,
virNodeInfoPtr info); int virNetworkSetAutostart (virNetworkPtr network,
int autostart); unsigned long virDomainGetMaxMemory (virDomainPtr domain); int virStoragePoolFree (virStoragePoolPtr pool); int virConnectNumOfDefinedInterfaces (virConnectPtr conn); typedef void virFreeCallback (void * opaque); virNetworkPtr virNetworkDefineXML (virConnectPtr conn,
const char * xml); int virNodeDeviceListCaps (virNodeDevicePtr dev,
char ** const names,
int maxnames); int 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); const char * virStorageVolGetName (virStorageVolPtr vol); int virStoragePoolGetAutostart (virStoragePoolPtr pool,
int * autostart); int virDomainGetAutostart (virDomainPtr domain,
int * autostart); int virStoragePoolListVolumes (virStoragePoolPtr pool,
char ** const names,
int maxnames); char * virConnectGetHostname (virConnectPtr conn); typedef int virEventRemoveTimeoutFunc (int timer); const char * virDomainGetName (virDomainPtr domain); int virStoragePoolRef (virStoragePoolPtr pool); char * virNetworkGetXMLDesc (virNetworkPtr network,
int flags); int virConnectNumOfStoragePools (virConnectPtr conn); virConnectPtr virInterfaceGetConnect (virInterfacePtr iface); const char * virNetworkGetName (virNetworkPtr network); 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 virDomainPinVcpu (virDomainPtr domain,
unsigned int vcpu,
unsigned char * cpumap,
int maplen); int virNodeGetSecurityModel (virConnectPtr conn,
virSecurityModelPtr secmodel); int virDomainRestore (virConnectPtr conn,
const char * from); int virNodeDeviceDestroy (virNodeDevicePtr dev); char * virStorageVolGetPath (virStorageVolPtr vol); virNetworkPtr virNetworkLookupByUUIDString (virConnectPtr conn,
const char * uuidstr); typedef int 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 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 virNetworkUndefine (virNetworkPtr network); 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 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 virDomainReboot (virDomainPtr domain,
unsigned int flags); int virNetworkGetUUIDString (virNetworkPtr network,
char * buf); virNetworkPtr virNetworkLookupByName (virConnectPtr conn,
const char * name); int virDomainGetMaxVcpus (virDomainPtr domain); typedef void virEventHandleCallback (int watch,
int fd,
int events,
void * opaque); char * virDomainGetSchedulerType (virDomainPtr domain,
int * nparams); int virNodeDeviceReset (virNodeDevicePtr dev); int virDomainDetachDevice (virDomainPtr domain,
const char * xml); int virStoragePoolNumOfVolumes (virStoragePoolPtr pool); int virStoragePoolGetUUIDString (virStoragePoolPtr pool,
char * buf); int virNodeDeviceReAttach (virNodeDevicePtr dev); int virStoragePoolUndefine (virStoragePoolPtr pool); typedef int virConnectAuthCallbackPtr (virConnectCredentialPtr cred,
unsigned int ncred,
void * cbdata); int virDomainAttachDevice (virDomainPtr domain,
const char * xml); char * virConnectGetURI (virConnectPtr conn); virConnectPtr virConnectOpenReadOnly (const char * name); 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); int virNetworkRef (virNetworkPtr network); int virConnectListDefinedStoragePools (virConnectPtr conn,
char ** const names,
int maxnames); typedef void virEventTimeoutCallback (int timer,
void * opaque); int virInterfaceFree (virInterfacePtr iface); int virNodeDeviceNumOfCaps (virNodeDevicePtr dev); virInterfacePtr virInterfaceLookupByMACString (virConnectPtr conn,
const char * macstr); virConnectPtr virNetworkGetConnect (virNetworkPtr net); unsigned long long virNodeGetFreeMemory (virConnectPtr conn); int virInterfaceDestroy (virInterfacePtr iface,
unsigned int flags); virConnectPtr virStorageVolGetConnect (virStorageVolPtr vol); int virNodeNumOfDevices (virConnectPtr conn,
const char * cap,
unsigned int flags); int virStoragePoolDestroy (virStoragePoolPtr pool); virStoragePoolPtr virStoragePoolLookupByVolume (virStorageVolPtr vol); virDomainPtr virDomainLookupByUUID (virConnectPtr conn,
const unsigned char * uuid); char * virDomainGetOSType (virDomainPtr domain); int virStoragePoolBuild (virStoragePoolPtr pool,
unsigned int flags); int virConnectGetMaxVcpus (virConnectPtr conn,
const char * type); int 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 iface); int virDomainSetVcpus (virDomainPtr domain,
unsigned int nvcpus); int virDomainRef (virDomainPtr domain); 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);
#define LIBVIR_VERSION_NUMBER;
Macro providing the version of the library as version * 1,000,000 + minor * 1000 + micro
#define VIR_COPY_CPUMAP(cpumaps, maplen, vcpu, cpumap);
This macro is to be used in conjunction with virDomainGetVcpus() and virDomainPinVcpu() APIs. VIR_COPY_CPUMAP macro extract the cpumap of the specified vcpu from cpumaps array and copy it into cpumap to be used later by virDomainPinVcpu() API.
cpumaps: | pointer to an array of cpumap (in 8-bit bytes) (IN) |
maplen: | the length (in bytes) of one cpumap |
vcpu: | the virtual CPU number |
cpumap: | pointer to a cpumap (in 8-bit bytes) (OUT) This cpumap must be previously allocated by the caller (ie: malloc(maplen)) |
#define VIR_CPU_MAPLEN(cpu);
This macro is to be used in conjunction with virDomainPinVcpu() API. It returns the length (in bytes) required to store the complete CPU map between a single virtual & all physical CPUs of a domain.
cpu: | number of physical CPUs |
#define VIR_CPU_USABLE(cpumaps, maplen, vcpu, cpu);
This macro is to be used in conjunction with virDomainGetVcpus() API. VIR_CPU_USABLE macro returns a non zero value (true) if the cpu is usable by the vcpu, and 0 otherwise.
cpumaps: | pointer to an array of cpumap (in 8-bit bytes) (IN) |
maplen: | the length (in bytes) of one cpumap |
vcpu: | the virtual CPU number |
cpu: | the physical CPU number |
#define VIR_DOMAIN_SCHED_FIELD_LENGTH;
Macro providing the field length of virSchedParameter
#define VIR_GET_CPUMAP(cpumaps, maplen, vcpu);
This macro is to be used in conjunction with virDomainGetVcpus() and virDomainPinVcpu() APIs. VIR_GET_CPUMAP macro returns a pointer to the cpumap of the specified vcpu from cpumaps array.
cpumaps: | pointer to an array of cpumap (in 8-bit bytes) (IN) |
maplen: | the length (in bytes) of one cpumap |
vcpu: | the virtual CPU number |
#define VIR_NODEINFO_MAXCPUS(nodeinfo);
This macro is to calculate the total number of CPUs supported but not necessary active in the host.
nodeinfo: | virNodeInfo instance |
#define VIR_SECURITY_DOI_BUFLEN;
Macro providing the maximum length of the virSecurityModel doi string.
#define VIR_SECURITY_LABEL_BUFLEN;
Macro providing the maximum length of the virSecurityLabel label string. Note that this value is based on that used by Labeled NFS.
#define VIR_SECURITY_MODEL_BUFLEN;
Macro providing the maximum length of the virSecurityModel model string.
#define VIR_UNUSE_CPU(cpumap, cpu);
This macro is to be used in conjunction with virDomainPinVcpu() API. USE_CPU macro reset the bit (CPU not usable) of the related cpu in cpumap.
cpumap: | pointer to a bit map of real CPUs (in 8-bit bytes) (IN/OUT) |
cpu: | the physical CPU number |
#define VIR_USE_CPU(cpumap, cpu);
This macro is to be used in conjunction with virDomainPinVcpu() API. USE_CPU macro set the bit (CPU usable) of the related cpu in cpumap.
cpumap: | pointer to a bit map of real CPUs (in 8-bit bytes) (IN/OUT) |
cpu: | the physical CPU number |
#define VIR_UUID_BUFLEN;
This macro provides the length of the buffer required for virDomainGetUUID()
#define VIR_UUID_STRING_BUFLEN;
This macro provides the length of the buffer required for virDomainGetUUIDString()
struct _virConnect { The content of this structure is not made public by the API. } virConnect;
struct _virConnectAuth { int * credtype : List of supported virConnectCredentialType values unsigned int ncredtype virConnectAuthCallbackPtr cb : Callback used to collect credentials void * cbdata } virConnectAuth;
virConnectAuth * virConnectAuthPtr;
struct _virConnectCredential { int type : One of virConnectCredentialType constants const char * prompt : Prompt to show to user const char * challenge : Additional challenge to show const char * defresult : Optional default result char * result : Result to be filled with user response (or defresult) unsigned int resultlen : Length of the result } virConnectCredential;
virConnectCredential * virConnectCredentialPtr;
enum virConnectCredentialType { VIR_CRED_USERNAME = 1 /* Identity to act as */ VIR_CRED_AUTHNAME = 2 /* Identify to authorize as */ VIR_CRED_LANGUAGE = 3 /* RFC 1766 languages, comma separated */ VIR_CRED_CNONCE = 4 /* client supplies a nonce */ VIR_CRED_PASSPHRASE = 5 /* Passphrase secret */ VIR_CRED_ECHOPROMPT = 6 /* Challenge response */ VIR_CRED_NOECHOPROMPT = 7 /* Challenge response */ VIR_CRED_REALM = 8 /* Authentication realm */ VIR_CRED_EXTERNAL = 9 /* Externally managed credential More may be added - expect the unexpected */ };
enum virConnectFlags { VIR_CONNECT_RO = 1 /* A readonly connection */ };
virConnect * virConnectPtr;
a virConnectPtr is pointer to a virConnect private structure, this is the type used to reference a connection to the Hypervisor in the API.
struct _virDomain { The content of this structure is not made public by the API. } virDomain;
virDomainBlockStatsStruct * virDomainBlockStatsPtr;
A pointer to a virDomainBlockStats structure
struct _virDomainBlockStats { long long rd_req : number of read requests long long rd_bytes : number of read bytes long long wr_req : number of write requests long long wr_bytes : number of written bytes long long errs : In Xen this returns the mysterious 'oo_req'. } virDomainBlockStatsStruct;
enum virDomainCreateFlags { VIR_DOMAIN_NONE = 0 };
enum virDomainEventDefinedDetailType { VIR_DOMAIN_EVENT_DEFINED_ADDED = 0 /* Newly created config file */ VIR_DOMAIN_EVENT_DEFINED_UPDATED = 1 /* Changed config file */ };
enum virDomainEventResumedDetailType { VIR_DOMAIN_EVENT_RESUMED_UNPAUSED = 0 /* Normal resume due to admin unpause */ VIR_DOMAIN_EVENT_RESUMED_MIGRATED = 1 /* Resumed for completion of migration */ };
enum virDomainEventStartedDetailType { VIR_DOMAIN_EVENT_STARTED_BOOTED = 0 /* Normal startup from boot */ VIR_DOMAIN_EVENT_STARTED_MIGRATED = 1 /* Incoming migration from another host */ VIR_DOMAIN_EVENT_STARTED_RESTORED = 2 /* Restored from a state file */ };
enum virDomainEventStoppedDetailType { VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN = 0 /* Normal shutdown */ VIR_DOMAIN_EVENT_STOPPED_DESTROYED = 1 /* Forced poweroff from host */ VIR_DOMAIN_EVENT_STOPPED_CRASHED = 2 /* Guest crashed */ VIR_DOMAIN_EVENT_STOPPED_MIGRATED = 3 /* Migrated off to another host */ VIR_DOMAIN_EVENT_STOPPED_SAVED = 4 /* Saved to a state file */ VIR_DOMAIN_EVENT_STOPPED_FAILED = 5 /* Host emulator/mgmt failed */ };
enum virDomainEventSuspendedDetailType { VIR_DOMAIN_EVENT_SUSPENDED_PAUSED = 0 /* Normal suspend due to admin pause */ VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED = 1 /* Suspended for offline migration */ };
enum virDomainEventType { VIR_DOMAIN_EVENT_DEFINED = 0 VIR_DOMAIN_EVENT_UNDEFINED = 1 VIR_DOMAIN_EVENT_STARTED = 2 VIR_DOMAIN_EVENT_SUSPENDED = 3 VIR_DOMAIN_EVENT_RESUMED = 4 VIR_DOMAIN_EVENT_STOPPED = 5 };
enum virDomainEventUndefinedDetailType { VIR_DOMAIN_EVENT_UNDEFINED_REMOVED = 0 /* Deleted the config file */ };
struct _virDomainInfo { unsigned char state : the running state, one of virDomainState unsigned long maxMem : the maximum memory in KBytes allowed unsigned long memory : the memory in KBytes used by the domain unsigned short nrVirtCpu : the number of virtual CPUs for the domain unsigned long long cpuTime : the CPU time used in nanoseconds } virDomainInfo;
virDomainInfo * virDomainInfoPtr;
a virDomainInfoPtr is a pointer to a virDomainInfo structure.
virDomainInterfaceStatsStruct * virDomainInterfaceStatsPtr;
A pointer to a virDomainInterfaceStats structure
struct _virDomainInterfaceStats { long long rx_bytes long long rx_packets long long rx_errs long long rx_drop long long tx_bytes long long tx_packets long long tx_errs long long tx_drop } virDomainInterfaceStatsStruct;
enum virDomainMemoryFlags { VIR_MEMORY_VIRTUAL = 1 /* addresses are virtual addresses */ VIR_MEMORY_PHYSICAL = 2 /* addresses are physical addresses */ };
enum virDomainMigrateFlags { VIR_MIGRATE_LIVE = 1 /* live migration */ };
virDomain * virDomainPtr;
a virDomainPtr is pointer to a virDomain private structure, this is the type used to reference a domain in the API.
enum virDomainState { VIR_DOMAIN_NOSTATE = 0 /* no state */ VIR_DOMAIN_RUNNING = 1 /* the domain is running */ VIR_DOMAIN_BLOCKED = 2 /* the domain is blocked on resource */ VIR_DOMAIN_PAUSED = 3 /* the domain is paused by user */ VIR_DOMAIN_SHUTDOWN = 4 /* the domain is being shut down */ VIR_DOMAIN_SHUTOFF = 5 /* the domain is shut off */ VIR_DOMAIN_CRASHED = 6 /* the domain is crashed */ };
enum virDomainXMLFlags { VIR_DOMAIN_XML_SECURE = 1 /* dump security sensitive information too */ VIR_DOMAIN_XML_INACTIVE = 2 /* dump inactive domain information */ };
enum virEventHandleType { VIR_EVENT_HANDLE_READABLE = 1 VIR_EVENT_HANDLE_WRITABLE = 2 VIR_EVENT_HANDLE_ERROR = 4 VIR_EVENT_HANDLE_HANGUP = 8 };
struct _virInterface { The content of this structure is not made public by the API. } virInterface;
virInterface * virInterfacePtr;
a virInterfacePtr is pointer to a virInterface private structure, this is the type used to reference a virtual interface in the API.
struct _virNetwork { The content of this structure is not made public by the API. } virNetwork;
virNetwork * virNetworkPtr;
a virNetworkPtr is pointer to a virNetwork private structure, this is the type used to reference a virtual network in the API.
struct _virNodeDevice { The content of this structure is not made public by the API. } virNodeDevice;
virNodeDevice * virNodeDevicePtr;
A virNodeDevicePtr is a pointer to a virNodeDevice structure. Get one via virNodeDeviceLookupByKey, virNodeDeviceLookupByName, or virNodeDeviceCreate. Be sure to Call virNodeDeviceFree when done using a virNodeDevicePtr obtained from any of the above functions to avoid leaking memory.
struct _virNodeInfo { charmodel[32] model : string indicating the CPU model unsigned long memory : memory size in kilobytes unsigned int cpus : the number of active CPUs unsigned int mhz : expected CPU frequency unsigned int nodes : the number of NUMA cell, 1 for uniform mem access unsigned int sockets : number of CPU socket per node unsigned int cores : number of core per socket unsigned int threads : number of threads per core } virNodeInfo;
virNodeInfo * virNodeInfoPtr;
a virNodeInfoPtr is a pointer to a virNodeInfo structure.
struct _virSchedParameter { charfield[VIR_DOMAIN_SCHED_FIELD_LENGTH] field : parameter name int type : parameter type } virSchedParameter;
virSchedParameter * virSchedParameterPtr;
a virSchedParameterPtr is a pointer to a virSchedParameter structure.
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 */ };
struct _virSecurityLabel { The content of this structure is not made public by the API. } virSecurityLabel;
virSecurityLabel * virSecurityLabelPtr;
a virSecurityLabelPtr is a pointer to a virSecurityLabel.
struct _virSecurityModel { The content of this structure is not made public by the API. } virSecurityModel;
virSecurityModel * virSecurityModelPtr;
a virSecurityModelPtr is a pointer to a virSecurityModel.
struct _virStoragePool { The content of this structure is not made public by the API. } virStoragePool;
enum virStoragePoolBuildFlags { VIR_STORAGE_POOL_BUILD_NEW = 0 /* Regular build from scratch */ VIR_STORAGE_POOL_BUILD_REPAIR = 1 /* Repair / reinitialize */ VIR_STORAGE_POOL_BUILD_RESIZE = 2 /* Extend existing pool */ };
enum virStoragePoolDeleteFlags { VIR_STORAGE_POOL_DELETE_NORMAL = 0 /* Delete metadata only (fast) */ VIR_STORAGE_POOL_DELETE_ZEROED = 1 /* Clear all data to zeros (slow) */ };
struct _virStoragePoolInfo { int state : virStoragePoolState flags unsigned long long capacity : Logical size bytes unsigned long long allocation : Current allocation bytes unsigned long long available : Remaining free space bytes } virStoragePoolInfo;
virStoragePoolInfo * virStoragePoolInfoPtr;
virStoragePool * virStoragePoolPtr;
a virStoragePoolPtr is pointer to a virStoragePool private structure, this is the type used to reference a storage pool in the API.
enum virStoragePoolState { VIR_STORAGE_POOL_INACTIVE = 0 /* Not running */ VIR_STORAGE_POOL_BUILDING = 1 /* Initializing pool, not available */ VIR_STORAGE_POOL_RUNNING = 2 /* Running normally */ VIR_STORAGE_POOL_DEGRADED = 3 /* Running degraded */ };
struct _virStorageVol { The content of this structure is not made public by the API. } virStorageVol;
enum virStorageVolDeleteFlags { VIR_STORAGE_VOL_DELETE_NORMAL = 0 /* Delete metadata only (fast) */ VIR_STORAGE_VOL_DELETE_ZEROED = 1 /* Clear all data to zeros (slow) */ };
struct _virStorageVolInfo { int type : virStorageVolType flags unsigned long long capacity : Logical size bytes unsigned long long allocation : Current allocation bytes } virStorageVolInfo;
virStorageVolInfo * virStorageVolInfoPtr;
virStorageVol * virStorageVolPtr;
a virStorageVolPtr is pointer to a virStorageVol private structure, this is the type used to reference a storage volume in the API.
enum virStorageVolType { VIR_STORAGE_VOL_FILE = 0 /* Regular file based volumes */ VIR_STORAGE_VOL_BLOCK = 1 /* Block based volumes */ };
struct _virVcpuInfo { unsigned int number : virtual CPU number int state : value from virVcpuState unsigned long long cpuTime : CPU time used, in nanoseconds int cpu : real CPU number, or -1 if offline } virVcpuInfo;
virVcpuInfo * virVcpuInfoPtr;
enum virVcpuState { VIR_VCPU_OFFLINE = 0 /* the virtual CPU is offline */ VIR_VCPU_RUNNING = 1 /* the virtual CPU is running */ VIR_VCPU_BLOCKED = 2 /* the virtual CPU is blocked on resource */ };
int virConnectAuthCallbackPtr (virConnectCredentialPtr cred,
unsigned int ncred,
void * cbdata)
cred: | |
ncred: | |
cbdata: | |
Returns: |
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: |
int virEventAddHandleFunc (int fd,
int event,
virEventHandleCallback cb,
void * opaque,
virFreeCallback ff)
Part of the EventImpl, this callback Adds a file handle callback to listen for specific events. The same file handle can be registered multiple times provided the requested event sets are non-overlapping If the opaque user data requires free'ing when the handle is unregistered, then a 2nd callback can be supplied for this purpose.
fd: | file descriptor to listen on |
event: | bitset of events on which to fire the callback |
cb: | the callback to be called when an event occurrs |
opaque: | user data to pass to the callback |
ff: | the callback invoked to free opaque data blob |
Returns: | a handle watch number to be used for updating and unregistering for events |
int virEventAddTimeoutFunc (int timeout,
virEventTimeoutCallback cb,
void * opaque,
virFreeCallback ff)
Part of the EventImpl, this user-defined callback handles adding an event timeout. If the opaque user data requires free'ing when the handle is unregistered, then a 2nd callback can be supplied for this purpose.
timeout: | The timeout to monitor |
cb: | the callback to call when timeout has expired |
opaque: | user data to pass to the callback |
ff: | the callback invoked to free opaque data blob |
Returns: | a timer value |
void virEventHandleCallback (int watch,
int fd,
int events,
void * opaque)
Callback for receiving file handle events. The callback will be invoked once for each event which is pending.
watch: | watch on which the event occurred |
fd: | file handle on which the event occurred |
events: | bitset of events from virEventHandleType constants |
opaque: | user data registered with handle |
int virEventRemoveHandleFunc (int watch)
Part of the EventImpl, this user-provided callback is notified when an fd is no longer being listened on. If a virEventHandleFreeFunc was supplied when the handle was registered, it will be invoked some time during, or after this function call, when it is safe to release the user data.
watch: | file descriptor watch to stop listening on |
Returns: |
int virEventRemoveTimeoutFunc (int timer)
Part of the EventImpl, this user-defined callback removes a timer If a virEventTimeoutFreeFunc was supplied when the handle was registered, it will be invoked some time during, or after this function call, when it is safe to release the user data.
timer: | the timer to remove |
Returns: | 0 on success, -1 on failure |
void virEventTimeoutCallback (int timer,
void * opaque)
callback for receiving timer events
timer: | timer id emitting the event |
opaque: | user data registered with handle |
void virEventUpdateHandleFunc (int watch,
int event)
Part of the EventImpl, this user-provided callback is notified when events to listen on change
watch: | file descriptor watch to modify |
event: | new events to listen on |
void virEventUpdateTimeoutFunc (int timer,
int timeout)
Part of the EventImpl, this user-defined callback updates an event timeout.
timer: | the timer to modify |
timeout: | the new timeout value |
virConnectAuthPtr virConnectAuthPtrDefault;
int virConnectClose (virConnectPtr conn)
This function closes the connection to the Hypervisor. This should not be called if further interaction with the Hypervisor are needed especially if there is running domain which need further monitoring by the application.
conn: | pointer to the hypervisor connection |
Returns: | 0 in case of success or -1 in case of error. |
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 |
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 |
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. |
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. |
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. |
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. |
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. |
int virConnectGetMaxVcpus (virConnectPtr conn,
const char * type)
Provides the maximum number of virtual CPUs supported for a guest VM of a specific type. The 'type' parameter here corresponds to the 'type' attribute in the <domain> element of the XML.
conn: | pointer to the hypervisor connection |
type: | value of the 'type' attribute in the <domain> element |
Returns: | the maximum of virtual CPU or -1 in case of error. |
const char * virConnectGetType (virConnectPtr conn)
Get the name of the Hypervisor software used.
conn: | pointer to the hypervisor connection |
Returns: | NULL in case of error, a static zero terminated string otherwise. See also: http://www.redhat.com/archives/libvir-list/2007-February/msg00096.html |
char * virConnectGetURI (virConnectPtr conn)
This returns the URI (name) of the hypervisor connection. Normally this is the same as or similar to the string passed to the virConnectOpen/virConnectOpenReadOnly call, but the driver may make the URI canonical. If name == NULL was passed to virConnectOpen, then the driver will return a non-NULL URI which can be used to connect to the same hypervisor later.
conn: | pointer to a hypervisor connection |
Returns: | the URI string which must be freed by the caller, or NULL if there was an error. |
int virConnectGetVersion (virConnectPtr conn,
unsigned long * hvVer)
Get the version level of the Hypervisor running. This may work only with hypervisor call, i.e. with privileged access to the hypervisor, not with a Read-Only connection.
conn: | pointer to the hypervisor connection |
hvVer: | return value for the version of the running hypervisor (OUT) |
Returns: | -1 in case of error, 0 otherwise. if the version can't be extracted by lack of capacities returns 0 and @hvVer is 0, otherwise @hvVer value is major * 1,000,000 + minor * 1,000 + release |
int virConnectListDefinedDomains (virConnectPtr conn,
char ** const names,
int maxnames)
list the defined but inactive domains, 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 |
int virConnectListDefinedInterfaces (virConnectPtr conn,
char ** const names,
int maxnames)
Collect the list of defined (inactive) 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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
virConnectPtr virConnectOpenReadOnly (const char * name)
This function should be called first to get a restricted connection to the library functionalities. The set of APIs usable are then restricted on the available methods to control the domains. See virConnectOpen for notes about environment variables which can have an effect on opening drivers
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 |
int virConnectRef (virConnectPtr conn)
Increment the reference count on the connection. For each additional call to this method, there shall be a corresponding call to virConnectClose to release the reference count, once the caller no longer needs the reference to this object. This method is typically useful for applications where multiple threads are using a connection, and it is required that the connection remain open until all threads have finished using it. ie, each new thread using a connection would increment the reference count.
conn: | the connection to hold a reference on |
Returns: | 0 in case of success, -1 in case of failure |
int virDomainAttachDevice (virDomainPtr domain,
const char * xml)
Create a virtual device attachment to backend.
domain: | pointer to domain object |
xml: | pointer to XML description of one device |
Returns: | 0 in case of success, -1 in case of failure. |
int virDomainBlockPeek (virDomainPtr dom,
const char * path,
unsigned long long offset,
size_t size,
void * buffer,
unsigned int flags)
This function allows you to read the contents of a domain's disk device. Typical uses for this are to determine if the domain has written a Master Boot Record (indicating that the domain has completed installation), or to try to work out the state of the domain's filesystems. (Note that in the local case you might try to open the block device or file directly, but that won't work in the remote case, nor if you don't have sufficient permission. Hence the need for this call). 'path' must be a device or file corresponding to the domain. In other words it must be the precise string returned in a <disk><source dev='...'/></disk> from virDomainGetXMLDesc. 'offset' and 'size' represent an area which must lie entirely within the device or file. 'size' may be 0 to test if the call would succeed. 'buffer' is the return buffer and must be at least 'size' bytes. NB. The remote driver imposes a 64K byte limit on 'size'. For your program to be able to work reliably over a remote connection you should split large requests to <= 65536 bytes.
dom: | pointer to the domain object |
path: | path to the block device |
offset: | offset within block device |
size: | size to read |
buffer: | return buffer (must be at least size bytes) |
flags: | unused, always pass 0 |
Returns: | 0 in case of success or -1 in case of failure. really 64 bits |
int virDomainBlockStats (virDomainPtr dom,
const char * path,
virDomainBlockStatsPtr stats,
size_t size)
This function returns block device (disk) stats for block devices attached to the domain. The path parameter is the name of the block device. Get this by calling virDomainGetXMLDesc and finding the <target dev='...'> attribute within //domain/devices/disk. (For example, "xvda"). Domains may have more than one block device. To get stats for each you should make multiple calls to this function. Individual fields within the stats structure may be returned as -1, which indicates that the hypervisor does not support that particular statistic.
dom: | pointer to the domain object |
path: | path to the block device |
stats: | block device stats (returned) |
size: | size of stats structure |
Returns: | 0 in case of success or -1 in case of failure. |
int virDomainCoreDump (virDomainPtr domain,
const char * to,
int flags)
This method will dump the core of a domain on a given file for analysis. Note that for remote Xen Daemon the file path will be interpreted in the remote host.
domain: | a domain object |
to: | path for the core file |
flags: | extra flags, currently unused |
Returns: | 0 in case of success and -1 in case of failure. |
int virDomainCreate (virDomainPtr domain)
launch a defined domain. If the call succeed the domain moves from the defined to the running domains pools.
domain: | pointer to a defined domain |
Returns: | 0 in case of success, -1 in case of error |
virDomainPtr virDomainCreateLinux (virConnectPtr conn,
const char * xmlDesc,
unsigned int flags)
Deprecated after 0.4.6. Renamed to virDomainCreateXML() providing identical functionality. This existing name will left indefinitely for API compatability.
conn: | pointer to the hypervisor connection |
xmlDesc: | string containing an XML description of the domain |
flags: | callers should always pass 0 |
Returns: | a new domain object or NULL in case of failure |
virDomainPtr virDomainCreateXML (virConnectPtr conn,
const char * xmlDesc,
unsigned int flags)
Launch a new guest domain, based on an XML description similar to the one returned by virDomainGetXMLDesc() This function may requires privileged access to the hypervisor. The domain is not persistent, so its definition will disappear when it is destroyed, or if the host is restarted (see virDomainDefineXML() to define persistent domains).
conn: | pointer to the hypervisor connection |
xmlDesc: | string containing an XML description of the domain |
flags: | callers should always pass 0 |
Returns: | a new domain object or NULL in case of failure |
virDomainPtr virDomainDefineXML (virConnectPtr conn,
const char * xml)
Define a domain, but does not start it. This definition is persistent, until explicitly undefined with virDomainUndefine(). A previous definition for this domain would be overriden if it already exists.
conn: | pointer to the hypervisor connection |
xml: | the XML description for the domain, preferably in UTF-8 |
Returns: | NULL in case of error, a pointer to the domain otherwise |
int virDomainDestroy (virDomainPtr domain)
Destroy the domain object. The running instance is shutdown if not down already and all resources used by it are given back to the hypervisor. This does not free the associated virDomainPtr object. This function may require privileged access
domain: | a domain object |
Returns: | 0 in case of success and -1 in case of failure. |
int virDomainDetachDevice (virDomainPtr domain,
const char * xml)
Destroy a virtual device attachment to backend.
domain: | pointer to domain object |
xml: | pointer to XML description of one device |
Returns: | 0 in case of success, -1 in case of failure. |
int virDomainFree (virDomainPtr domain)
Free the domain object. The running instance is kept alive. The data structure is freed and should not be used thereafter.
domain: | a domain object |
Returns: | 0 in case of success and -1 in case of failure. |
int virDomainGetAutostart (virDomainPtr domain,
int * autostart)
Provides a boolean value indicating whether the domain configured to be automatically started when the host machine boots.
domain: | a domain object |
autostart: | the value returned |
Returns: | -1 in case of error, 0 in case of success |
virConnectPtr virDomainGetConnect (virDomainPtr dom)
Provides the connection pointer associated with a domain. The reference counter on the connection is not increased by this call. WARNING: When writing libvirt bindings in other languages, do not use this function. Instead, store the connection and the domain object together.
dom: | pointer to a domain |
Returns: | the virConnectPtr or NULL in case of failure. |
unsigned int virDomainGetID (virDomainPtr domain)
Get the hypervisor ID number for the domain
domain: | a domain object |
Returns: | the domain ID number or (unsigned int) -1 in case of error |
int virDomainGetInfo (virDomainPtr domain,
virDomainInfoPtr info)
Extract information about a domain. Note that if the connection used to get the domain is limited only a partial set of the information can be extracted.
domain: | a domain object |
info: | pointer to a virDomainInfo structure allocated by the user |
Returns: | 0 in case of success and -1 in case of failure. |
unsigned long virDomainGetMaxMemory (virDomainPtr domain)
Retrieve the maximum amount of physical memory allocated to a domain. If domain is NULL, then this get the amount of memory reserved to Domain0 i.e. the domain where the application runs.
domain: | a domain object or NULL |
Returns: | the memory size in kilobytes or 0 in case of error. |
int virDomainGetMaxVcpus (virDomainPtr domain)
Provides the maximum number of virtual CPUs supported for the guest VM. If the guest is inactive, this is basically the same as virConnectGetMaxVcpus. If the guest is running this will reflect the maximum number of virtual CPUs the guest was booted with.
domain: | pointer to domain object |
Returns: | the maximum of virtual CPU or -1 in case of error. |
const char * virDomainGetName (virDomainPtr domain)
Get the public name for that domain
domain: | a domain object |
Returns: | a pointer to the name or NULL, the string need not be deallocated its lifetime will be the same as the domain object. |
char * virDomainGetOSType (virDomainPtr domain)
Get the type of domain operation system.
domain: | a domain object |
Returns: | the new string or NULL in case of error, the string must be freed by the caller. |
int virDomainGetSchedulerParameters (virDomainPtr domain,
virSchedParameterPtr params,
int * nparams)
Get the scheduler parameters, the @params array will be filled with the values.
domain: | pointer to domain object |
params: | pointer to scheduler parameter object (return value) |
nparams: | pointer to number of scheduler parameter (this value should be same than the returned value nparams of virDomainGetSchedulerType) |
Returns: | -1 in case of error, 0 in case of success. |
char * virDomainGetSchedulerType (virDomainPtr domain,
int * nparams)
Get the scheduler type.
domain: | pointer to domain object |
nparams: | number of scheduler parameters(return value) |
Returns: | NULL in case of error. The caller must free the returned string. |
int virDomainGetSecurityLabel (virDomainPtr domain,
virSecurityLabelPtr seclabel)
Extract security label of an active domain. The 'label' field in the @seclabel argument will be initialized to the empty string if the domain is not running under a security model.
domain: | a domain object |
seclabel: | pointer to a virSecurityLabel structure |
Returns: | 0 in case of success, -1 in case of failure |
int virDomainGetUUID (virDomainPtr domain,
unsigned char * uuid)
Get the UUID for a domain
domain: | a domain object |
uuid: | pointer to a VIR_UUID_BUFLEN bytes array |
Returns: | -1 in case of error, 0 in case of success |
int virDomainGetUUIDString (virDomainPtr domain,
char * buf)
Get the UUID for a domain as string. For more information about UUID see RFC4122.
domain: | a domain object |
buf: | pointer to a VIR_UUID_STRING_BUFLEN bytes array |
Returns: | -1 in case of error, 0 in case of success |
int virDomainGetVcpus (virDomainPtr domain,
virVcpuInfoPtr info,
int maxinfo,
unsigned char * cpumaps,
int maplen)
Extract information about virtual CPUs of domain, store it in info array and also in cpumaps if this pointer isn't NULL.
domain: | pointer to domain object, or NULL for Domain0 |
info: | pointer to an array of virVcpuInfo structures (OUT) |
maxinfo: | number of structures in info array |
cpumaps: | pointer to an bit map of real CPUs for all vcpus of this domain (in 8-bit bytes) (OUT) If cpumaps is NULL, then no cpumap information is returned by the API. It's assumed there is <maxinfo> cpumap in cpumaps array. The memory allocated to cpumaps must be (maxinfo * maplen) bytes (ie: calloc(maxinfo, maplen)). One cpumap inside cpumaps has the format described in virDomainPinVcpu() API. |
maplen: | number of bytes in one cpumap, from 1 up to size of CPU map in underlying virtualization system (Xen...). |
Returns: | the number of info filled in case of success, -1 in case of failure. |
char * virDomainGetXMLDesc (virDomainPtr domain,
int flags)
Provide an XML description of the domain. The description may be reused later to relaunch the domain with virDomainCreateXML().
domain: | a domain object |
flags: | an OR'ed set of virDomainXMLFlags |
Returns: | a 0 terminated UTF-8 encoded XML instance, or NULL in case of error. the caller must free() the returned value. |
int virDomainInterfaceStats (virDomainPtr dom,
const char * path,
virDomainInterfaceStatsPtr stats,
size_t size)
This function returns network interface stats for interfaces attached to the domain. The path parameter is the name of the network interface. Domains may have more than network interface. To get stats for each you should make multiple calls to this function. Individual fields within the stats structure may be returned as -1, which indicates that the hypervisor does not support that particular statistic.
dom: | pointer to the domain object |
path: | path to the interface |
stats: | network interface stats (returned) |
size: | size of stats structure |
Returns: | 0 in case of success or -1 in case of failure. |
virDomainPtr virDomainLookupByID (virConnectPtr conn,
int id)
Try to find a domain based on the hypervisor ID number Note that this won't work for inactive domains which have an ID of -1, in that case a lookup based on the Name or UUId need to be done instead.
conn: | pointer to the hypervisor connection |
id: | the domain ID number |
Returns: | a new domain object or NULL in case of failure. If the domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised. |
virDomainPtr virDomainLookupByName (virConnectPtr conn,
const char * name)
Try to lookup a domain on the given hypervisor based on its name.
conn: | pointer to the hypervisor connection |
name: | name for the domain |
Returns: | a new domain object or NULL in case of failure. If the domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised. |
virDomainPtr virDomainLookupByUUID (virConnectPtr conn,
const unsigned char * uuid)
Try to lookup a domain on the given hypervisor based on its UUID.
conn: | pointer to the hypervisor connection |
uuid: | the raw UUID for the domain |
Returns: | a new domain object or NULL in case of failure. If the domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised. |
virDomainPtr virDomainLookupByUUIDString (virConnectPtr conn,
const char * uuidstr)
Try to lookup a domain on the given hypervisor based on its UUID.
conn: | pointer to the hypervisor connection |
uuidstr: | the string UUID for the domain |
Returns: | a new domain object or NULL in case of failure. If the domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised. |
int virDomainMemoryPeek (virDomainPtr dom,
unsigned long long start,
size_t size,
void * buffer,
unsigned int flags)
This function allows you to read the contents of a domain's memory. The memory which is read is controlled by the 'start', 'size' and 'flags' parameters. If 'flags' is VIR_MEMORY_VIRTUAL then the 'start' and 'size' parameters are interpreted as virtual memory addresses for whichever task happens to be running on the domain at the moment. Although this sounds haphazard it is in fact what you want in order to read Linux kernel state, because it ensures that pointers in the kernel image can be interpreted coherently. 'buffer' is the return buffer and must be at least 'size' bytes. 'size' may be 0 to test if the call would succeed. NB. The remote driver imposes a 64K byte limit on 'size'. For your program to be able to work reliably over a remote connection you should split large requests to <= 65536 bytes.
dom: | pointer to the domain object |
start: | start of memory to peek |
size: | size of memory to peek |
buffer: | return buffer (must be at least size bytes) |
flags: | flags, see below |
Returns: | 0 in case of success or -1 in case of failure. really 64 bits |
virDomainPtr virDomainMigrate (virDomainPtr domain,
virConnectPtr dconn,
unsigned long flags,
const char * dname,
const char * uri,
unsigned long bandwidth)
Migrate the domain object from its current host to the destination host given by dconn (a connection to the destination host). Flags may be one of more of the following: VIR_MIGRATE_LIVE Attempt a live migration. If a hypervisor supports renaming domains during migration, then you may set the dname parameter to the new name (otherwise it keeps the same name). If this is not supported by the hypervisor, dname must be NULL or else you will get an error. Since typically the two hypervisors connect directly to each other in order to perform the migration, you may need to specify a path from the source to the destination. This is the purpose of the uri parameter. If uri is NULL, then libvirt will try to find the best method. Uri may specify the hostname or IP address of the destination host as seen from the source. Or uri may be a URI giving transport, hostname, user, port, etc. in the usual form. Refer to driver documentation for the particular URIs supported. The maximum bandwidth (in Mbps) that will be used to do migration can be specified with the bandwidth parameter. If set to 0, libvirt will choose a suitable default. Some hypervisors do not support this feature and will return an error if bandwidth is not 0. To see which features are supported by the current hypervisor, see virConnectGetCapabilities, /capabilities/host/migration_features. There are many limitations on migration imposed by the underlying technology - for example it may not be possible to migrate between different processors even with the same architecture, or between different types of hypervisor.
domain: | a domain object |
dconn: | destination host (a connection object) |
flags: | flags |
dname: | (optional) rename domain to this at destination |
uri: | (optional) dest hostname/URI as seen from the source host |
bandwidth: | (optional) specify migration bandwidth limit in Mbps |
Returns: | the new domain object if the migration was successful, or NULL in case of error. Note that the new domain object exists in the scope of the destination connection (dconn). |
int virDomainPinVcpu (virDomainPtr domain,
unsigned int vcpu,
unsigned char * cpumap,
int maplen)
Dynamically change the real CPUs which can be allocated to a virtual CPU. This function requires privileged access to the hypervisor.
domain: | pointer to domain object, or NULL for Domain0 |
vcpu: | virtual CPU number |
cpumap: | pointer to a bit map of real CPUs (in 8-bit bytes) (IN) Each bit set to 1 means that corresponding CPU is usable. Bytes are stored in little-endian order: CPU0-7, 8-15... In each byte, lowest CPU number is least significant bit. |
maplen: | number of bytes in cpumap, from 1 up to size of CPU map in underlying virtualization system (Xen...). If maplen < size, missing bytes are set to zero. If maplen > size, failure code is returned. |
Returns: | 0 in case of success, -1 in case of failure. |
int virDomainReboot (virDomainPtr domain,
unsigned int flags)
Reboot a domain, the domain object is still usable there after but the domain OS is being stopped for a restart. Note that the guest OS may ignore the request.
domain: | a domain object |
flags: | extra flags for the reboot operation, not used yet |
Returns: | 0 in case of success and -1 in case of failure. |
int virDomainRef (virDomainPtr domain)
Increment the reference count on the domain. For each additional call to this method, there shall be a corresponding call to virDomainFree to release the reference count, once the caller no longer needs the reference to this object. This method is typically useful for applications where multiple threads are using a connection, and it is required that the connection remain open until all threads have finished using it. ie, each new thread using a domain would increment the reference count.
domain: | the domain to hold a reference on |
Returns: | 0 in case of success and -1 in case of failure. |
int virDomainRestore (virConnectPtr conn,
const char * from)
This method will restore a domain saved to disk by virDomainSave().
conn: | pointer to the hypervisor connection |
from: | path to the |
Returns: | 0 in case of success and -1 in case of failure. |
int virDomainResume (virDomainPtr domain)
Resume an suspended domain, the process is restarted from the state where it was frozen by calling virSuspendDomain(). This function may requires privileged access
domain: | a domain object |
Returns: | 0 in case of success and -1 in case of failure. |
int virDomainSave (virDomainPtr domain,
const char * to)
This method will suspend a domain and save its memory contents to a file on disk. After the call, if successful, the domain is not listed as running anymore (this may be a problem). Use virDomainRestore() to restore a domain after saving.
domain: | a domain object |
to: | path for the output file |
Returns: | 0 in case of success and -1 in case of failure. |
int virDomainSetAutostart (virDomainPtr domain,
int autostart)
Configure the domain to be automatically started when the host machine boots.
domain: | a domain object |
autostart: | whether the domain should be automatically started 0 or 1 |
Returns: | -1 in case of error, 0 in case of success |
int virDomainSetMaxMemory (virDomainPtr domain,
unsigned long memory)
Dynamically change the maximum amount of physical memory allocated to a domain. If domain is NULL, then this change the amount of memory reserved to Domain0 i.e. the domain where the application runs. This function requires privileged access to the hypervisor.
domain: | a domain object or NULL |
memory: | the memory size in kilobytes |
Returns: | 0 in case of success and -1 in case of failure. |
int virDomainSetMemory (virDomainPtr domain,
unsigned long memory)
Dynamically change the target amount of physical memory allocated to a domain. If domain is NULL, then this change the amount of memory reserved to Domain0 i.e. the domain where the application runs. This function may requires privileged access to the hypervisor.
domain: | a domain object or NULL |
memory: | the memory size in kilobytes |
Returns: | 0 in case of success and -1 in case of failure. |
int virDomainSetSchedulerParameters (virDomainPtr domain,
virSchedParameterPtr params,
int nparams)
Change the scheduler parameters
domain: | pointer to domain object |
params: | pointer to scheduler parameter objects |
nparams: | number of scheduler parameter (this value should be same or less than the returned value nparams of virDomainGetSchedulerType) |
Returns: | -1 in case of error, 0 in case of success. |
int virDomainSetVcpus (virDomainPtr domain,
unsigned int nvcpus)
Dynamically change the number of virtual CPUs used by the domain. Note that this call may fail if the underlying virtualization hypervisor does not support it or if growing the number is arbitrary limited. This function requires privileged access to the hypervisor.
domain: | pointer to domain object, or NULL for Domain0 |
nvcpus: | the new number of virtual CPUs for this domain |
Returns: | 0 in case of success, -1 in case of failure. |
int virDomainShutdown (virDomainPtr domain)
Shutdown a domain, the domain object is still usable there after but the domain OS is being stopped. Note that the guest OS may ignore the request. TODO: should we add an option for reboot, knowing it may not be doable in the general case ?
domain: | a domain object |
Returns: | 0 in case of success and -1 in case of failure. |
int virDomainSuspend (virDomainPtr domain)
Suspends an active domain, the process is frozen without further access to CPU resources and I/O but the memory used by the domain at the hypervisor level will stay allocated. Use virDomainResume() to reactivate the domain. This function may requires privileged access.
domain: | a domain object |
Returns: | 0 in case of success and -1 in case of failure. |
int virDomainUndefine (virDomainPtr domain)
Undefine a domain but does not stop it if it is running
domain: | pointer to a defined domain |
Returns: | 0 in case of success, -1 in case of error |
void virEventRegisterImpl (virEventAddHandleFunc addHandle,
virEventUpdateHandleFunc updateHandle,
virEventRemoveHandleFunc removeHandle,
virEventAddTimeoutFunc addTimeout,
virEventUpdateTimeoutFunc updateTimeout,
virEventRemoveTimeoutFunc removeTimeout)
addHandle: | |
updateHandle: | |
removeHandle: | |
addTimeout: | |
updateTimeout: | |
removeTimeout: |
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. |
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 |
int virInterfaceCreate (virInterfacePtr iface,
unsigned int flags)
Activate an interface (ie call "ifup")
iface: | 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 |
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 |
int virInterfaceDestroy (virInterfacePtr iface,
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.
iface: | 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. |
int virInterfaceFree (virInterfacePtr iface)
Free the interface object. The interface itself is unaltered. The data structure is freed and should not be used thereafter.
iface: | a interface object |
Returns: | 0 in case of success and -1 in case of failure. |
virConnectPtr virInterfaceGetConnect (virInterfacePtr iface)
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.
iface: | pointer to a interface |
Returns: | the virConnectPtr or NULL in case of failure. |
const char * virInterfaceGetMACString (virInterfacePtr iface)
Get the MAC for a interface as string. For more information about MAC see RFC4122.
iface: | 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. |
const char * virInterfaceGetName (virInterfacePtr iface)
Get the public name for that interface
iface: | 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. |
char * virInterfaceGetXMLDesc (virInterfacePtr iface,
unsigned int flags)
Provide an XML description of the interface. The description may be reused later to recreate the interface with virInterfaceCreateXML().
iface: | 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. |
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. |
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. |
int virInterfaceRef (virInterfacePtr iface)
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.
iface: | the interface to hold a reference on |
Returns: | 0 in case of success, -1 in case of failure. |
int virInterfaceUndefine (virInterfacePtr iface)
Undefine an interface, ie remove it from the config. This does not free the associated virInterfacePtr object.
iface: | pointer to a defined interface |
Returns: | 0 in case of success, -1 in case of error |
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 |
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 |
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 |
int virNetworkDestroy (virNetworkPtr network)
Destroy the network object. The running instance is shutdown if not down already and all resources used by it are given back to the hypervisor. This does not free the associated virNetworkPtr object. This function may require privileged access
network: | a network object |
Returns: | 0 in case of success and -1 in case of failure. |
int virNetworkFree (virNetworkPtr network)
Free the network object. The running instance is kept alive. The data structure is freed and should not be used thereafter.
network: | a network object |
Returns: | 0 in case of success and -1 in case of failure. |
int virNetworkGetAutostart (virNetworkPtr network,
int * autostart)
Provides a boolean value indicating whether the network configured to be automatically started when the host machine boots.
network: | a network object |
autostart: | the value returned |
Returns: | -1 in case of error, 0 in case of success |
char * virNetworkGetBridgeName (virNetworkPtr network)
Provides a bridge interface name to which a domain may connect a network interface in order to join the network.
network: | a network object |
Returns: | a 0 terminated interface name, or NULL in case of error. the caller must free() the returned value. |
virConnectPtr virNetworkGetConnect (virNetworkPtr net)
Provides the connection pointer associated with a network. The reference counter on the connection is not increased by this call. WARNING: When writing libvirt bindings in other languages, do not use this function. Instead, store the connection and the network object together.
net: | pointer to a network |
Returns: | the virConnectPtr or NULL in case of failure. |
const char * virNetworkGetName (virNetworkPtr network)
Get the public name for that network
network: | a network object |
Returns: | a pointer to the name or NULL, the string need not be deallocated its lifetime will be the same as the network object. |
int virNetworkGetUUID (virNetworkPtr network,
unsigned char * uuid)
Get the UUID for a network
network: | a network object |
uuid: | pointer to a VIR_UUID_BUFLEN bytes array |
Returns: | -1 in case of error, 0 in case of success |
int virNetworkGetUUIDString (virNetworkPtr network,
char * buf)
Get the UUID for a network as string. For more information about UUID see RFC4122.
network: | a network object |
buf: | pointer to a VIR_UUID_STRING_BUFLEN bytes array |
Returns: | -1 in case of error, 0 in case of success |
char * virNetworkGetXMLDesc (virNetworkPtr network,
int flags)
Provide an XML description of the network. The description may be reused later to relaunch the network with virNetworkCreateXML().
network: | a network 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. |
virNetworkPtr virNetworkLookupByName (virConnectPtr conn,
const char * name)
Try to lookup a network on the given hypervisor based on its name.
conn: | pointer to the hypervisor connection |
name: | name for the network |
Returns: | a new network object or NULL in case of failure. If the network cannot be found, then VIR_ERR_NO_NETWORK error is raised. |
virNetworkPtr virNetworkLookupByUUID (virConnectPtr conn,
const unsigned char * uuid)
Try to lookup a network on the given hypervisor based on its UUID.
conn: | pointer to the hypervisor connection |
uuid: | the raw UUID for the network |
Returns: | a new network object or NULL in case of failure. If the network cannot be found, then VIR_ERR_NO_NETWORK error is raised. |
virNetworkPtr virNetworkLookupByUUIDString (virConnectPtr conn,
const char * uuidstr)
Try to lookup a network on the given hypervisor based on its UUID.
conn: | pointer to the hypervisor connection |
uuidstr: | the string UUID for the network |
Returns: | a new network object or NULL in case of failure. If the network cannot be found, then VIR_ERR_NO_NETWORK error is raised. |
int virNetworkRef (virNetworkPtr network)
Increment the reference count on the network. For each additional call to this method, there shall be a corresponding call to virNetworkFree to release the reference count, once the caller no longer needs the reference to this object. This method is typically useful for applications where multiple threads are using a connection, and it is required that the connection remain open until all threads have finished using it. ie, each new thread using a network would increment the reference count.
network: | the network to hold a reference on |
Returns: | 0 in case of success, -1 in case of failure. |
int virNetworkSetAutostart (virNetworkPtr network,
int autostart)
Configure the network to be automatically started when the host machine boots.
network: | a network object |
autostart: | whether the network should be automatically started 0 or 1 |
Returns: | -1 in case of error, 0 in case of success |
int virNetworkUndefine (virNetworkPtr network)
Undefine a network but does not stop it if it is running
network: | pointer to a defined network |
Returns: | 0 in case of success, -1 in case of error |
virNodeDevicePtr virNodeDeviceCreateXML (virConnectPtr conn,
const char * xmlDesc,
unsigned int flags)
Create a new device on the VM host machine, for example, virtual HBAs created using vport_create.
conn: | pointer to the hypervisor connection |
xmlDesc: | string containing an XML description of the device to be created |
flags: | callers should always pass 0 |
Returns: | a node device object if successful, NULL in case of failure |
int virNodeDeviceDestroy (virNodeDevicePtr dev)
Destroy the device object. The virtual device is removed from the host operating system. This function may require privileged access
dev: | a device object |
Returns: | 0 in case of success and -1 in case of failure. |
int virNodeDeviceDettach (virNodeDevicePtr dev)
Dettach the node device from the node itself so that it may be assigned to a guest domain. Depending on the hypervisor, this may involve operations such as unbinding any device drivers from the device, binding the device to a dummy device driver and resetting the device. If the device is currently in use by the node, this method may fail. Once the device is not assigned to any guest, it may be re-attached to the node using the virNodeDeviceReattach() method.
dev: | pointer to the node device |
Returns: | 0 in case of success, -1 in case of failure. |
int virNodeDeviceFree (virNodeDevicePtr dev)
Drops a reference to the node device, freeing it if this was the last reference.
dev: | pointer to the node device |
Returns: | the 0 for success, -1 for error. |
const char * virNodeDeviceGetName (virNodeDevicePtr dev)
Just return the device name
dev: | the device |
Returns: | the device name or NULL in case of error |
const char * virNodeDeviceGetParent (virNodeDevicePtr dev)
Accessor for the parent of the device
dev: | the device |
Returns: | the name of the device's parent, or NULL if the device has no parent. |
char * virNodeDeviceGetXMLDesc (virNodeDevicePtr dev,
unsigned int flags)
Fetch an XML document describing all aspects of the device.
dev: | pointer to the node device |
flags: | flags for XML generation (unused, pass 0) |
Returns: | the XML document, or NULL on error |
int virNodeDeviceListCaps (virNodeDevicePtr dev,
char ** const names,
int maxnames)
Lists the names of the capabilities supported by the device.
dev: | the device |
names: | array to collect the list of capability names |
maxnames: | size of @names |
Returns: | the number of capability names listed in @names. |
virNodeDevicePtr virNodeDeviceLookupByName (virConnectPtr conn,
const char * name)
Lookup a node device by its name.
conn: | pointer to the hypervisor connection |
name: | unique device name |
Returns: | a virNodeDevicePtr if found, NULL otherwise. |
int virNodeDeviceNumOfCaps (virNodeDevicePtr dev)
Accessor for the number of capabilities supported by the device.
dev: | the device |
Returns: | the number of capabilities supported by the device. |
int virNodeDeviceReAttach (virNodeDevicePtr dev)
Re-attach a previously dettached node device to the node so that it may be used by the node again. Depending on the hypervisor, this may involve operations such as resetting the device, unbinding it from a dummy device driver and binding it to its appropriate driver. If the device is currently in use by a guest, this method may fail.
dev: | pointer to the node device |
Returns: | 0 in case of success, -1 in case of failure. |
int virNodeDeviceRef (virNodeDevicePtr dev)
Increment the reference count on the dev. For each additional call to this method, there shall be a corresponding call to virNodeDeviceFree 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 dev would increment the reference count.
dev: | the dev to hold a reference on |
Returns: | 0 in case of success, -1 in case of failure. |
int virNodeDeviceReset (virNodeDevicePtr dev)
Reset a previously dettached node device to the node before or after assigning it to a guest. The exact reset semantics depends on the hypervisor and device type but, for example, KVM will attempt to reset PCI devices with a Function Level Reset, Secondary Bus Reset or a Power Management D-State reset. If the reset will affect other devices which are currently in use, this function may fail.
dev: | pointer to the node device |
Returns: | 0 in case of success, -1 in case of failure. |
int virNodeGetCellsFreeMemory (virConnectPtr conn,
unsigned long long * freeMems,
int startCell,
int maxCells)
This call returns the amount of free memory in one or more NUMA cells. The @freeMems array must be allocated by the caller and will be filled with the amount of free memory in bytes for each cell requested, starting with startCell (in freeMems[0]), up to either (startCell + maxCells), or the number of additional cells in the node, whichever is smaller.
conn: | pointer to the hypervisor connection |
freeMems: | pointer to the array of unsigned long long |
startCell: | index of first cell to return freeMems info on. |
maxCells: | Maximum number of cells for which freeMems information can be returned. |
Returns: | the number of entries filled in freeMems, or -1 in case of error. |
unsigned long long virNodeGetFreeMemory (virConnectPtr conn)
provides the free memory available on the Node Note: most libvirt APIs provide memory sizes in kilobytes, but in this function the returned value is in bytes. Divide by 1024 as necessary.
conn: | pointer to the hypervisor connection |
Returns: | the available free memory in bytes or 0 in case of error |
int virNodeGetInfo (virConnectPtr conn,
virNodeInfoPtr info)
Extract hardware information about the node.
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. |
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 |
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 |
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 |
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 |
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 |
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 |
virStoragePoolPtr virStoragePoolDefineXML (virConnectPtr conn,
const char * xml,
unsigned int flags)
Define a new inactive storage pool based on its XML description. The pool is persistent, until explicitly undefined.
conn: | pointer to hypervisor connection |
xml: | XML description for new pool |
flags: | future flags, use 0 for now |
Returns: | a virStoragePoolPtr object, or NULL if creation failed |
int virStoragePoolDelete (virStoragePoolPtr pool,
unsigned int flags)
Delete the underlying pool resources. This is a non-recoverable operation. The virStoragePoolPtr object itself is not free'd.
pool: | pointer to storage pool |
flags: | flags for obliteration process |
Returns: | 0 on success, or -1 if it could not be obliterate |
int virStoragePoolDestroy (virStoragePoolPtr pool)
Destroy an active storage pool. This will deactivate the pool on the host, but keep any persistent config associated with it. If it has a persistent config it can later be restarted with virStoragePoolCreate(). This does not free the associated virStoragePoolPtr object.
pool: | pointer to storage pool |
Returns: | 0 on success, or -1 if it could not be destroyed |
int virStoragePoolFree (virStoragePoolPtr pool)
Free a storage pool object, releasing all memory associated with it. Does not change the state of the pool on the host.
pool: | pointer to storage pool |
Returns: | 0 on success, or -1 if it could not be free'd. |
int virStoragePoolGetAutostart (virStoragePoolPtr pool,
int * autostart)
Fetches the value of the autostart flag, which determines whether the pool is automatically started at boot time
pool: | pointer to storage pool |
autostart: | location in which to store autostart flag |
Returns: | 0 on success, -1 on failure |
virConnectPtr virStoragePoolGetConnect (virStoragePoolPtr pool)
Provides the connection pointer associated with a storage pool. The reference counter on the connection is not increased by this call. WARNING: When writing libvirt bindings in other languages, do not use this function. Instead, store the connection and the pool object together.
pool: | pointer to a pool |
Returns: | the virConnectPtr or NULL in case of failure. |
int virStoragePoolGetInfo (virStoragePoolPtr pool,
virStoragePoolInfoPtr info)
Get volatile information about the storage pool such as free space / usage summary
pool: | pointer to storage pool |
info: | pointer at which to store info |
Returns: | 0 on success, or -1 on failure. |
const char * virStoragePoolGetName (virStoragePoolPtr pool)
Fetch the locally unique name of the storage pool
pool: | pointer to storage pool |
Returns: | the name of the pool, or NULL on error |
int virStoragePoolGetUUID (virStoragePoolPtr pool,
unsigned char * uuid)
Fetch the globally unique ID of the storage pool
pool: | pointer to storage pool |
uuid: | buffer of VIR_UUID_BUFLEN bytes in size |
Returns: | 0 on success, or -1 on error; |
int virStoragePoolGetUUIDString (virStoragePoolPtr pool,
char * buf)
Fetch the globally unique ID of the storage pool as a string
pool: | pointer to storage pool |
buf: | buffer of VIR_UUID_STRING_BUFLEN bytes in size |
Returns: | 0 on success, or -1 on error; |
char * virStoragePoolGetXMLDesc (virStoragePoolPtr pool,
unsigned int flags)
Fetch an XML document describing all aspects of the storage pool. This is suitable for later feeding back into the virStoragePoolCreateXML method.
pool: | pointer to storage pool |
flags: | flags for XML format options (set of virDomainXMLFlags) |
Returns: | a XML document, or NULL on error |
int virStoragePoolListVolumes (virStoragePoolPtr pool,
char ** const names,
int maxnames)
Fetch list of storage volume names, limiting to at most maxnames.
pool: | pointer to storage pool |
names: | array in which to storage volume names |
maxnames: | size of names array |
Returns: | the number of names fetched, or -1 on error |
virStoragePoolPtr virStoragePoolLookupByName (virConnectPtr conn,
const char * name)
Fetch a storage pool based on its unique name
conn: | pointer to hypervisor connection |
name: | name of pool to fetch |
Returns: | a virStoragePoolPtr object, or NULL if no matching pool is found |
virStoragePoolPtr virStoragePoolLookupByUUID (virConnectPtr conn,
const unsigned char * uuid)
Fetch a storage pool based on its globally unique id
conn: | pointer to hypervisor connection |
uuid: | globally unique id of pool to fetch |
Returns: | a virStoragePoolPtr object, or NULL if no matching pool is found |
virStoragePoolPtr virStoragePoolLookupByUUIDString (virConnectPtr conn,
const char * uuidstr)
Fetch a storage pool based on its globally unique id
conn: | pointer to hypervisor connection |
uuidstr: | globally unique id of pool to fetch |
Returns: | a virStoragePoolPtr object, or NULL if no matching pool is found |
virStoragePoolPtr virStoragePoolLookupByVolume (virStorageVolPtr vol)
Fetch a storage pool which contains a particular volume
vol: | pointer to storage volume |
Returns: | a virStoragePoolPtr object, or NULL if no matching pool is found |
int virStoragePoolNumOfVolumes (virStoragePoolPtr pool)
Fetch the number of storage volumes within a pool
pool: | pointer to storage pool |
Returns: | the number of storage pools, or -1 on failure |
int virStoragePoolRef (virStoragePoolPtr pool)
Increment the reference count on the pool. For each additional call to this method, there shall be a corresponding call to virStoragePoolFree to release the reference count, once the caller no longer needs the reference to this object. This method is typically useful for applications where multiple threads are using a connection, and it is required that the connection remain open until all threads have finished using it. ie, each new thread using a pool would increment the reference count.
pool: | the pool to hold a reference on |
Returns: | 0 in case of success, -1 in case of failure. |
int virStoragePoolRefresh (virStoragePoolPtr pool,
unsigned int flags)
Request that the pool refresh its list of volumes. This may involve communicating with a remote server, and/or initializing new devices at the OS layer
pool: | pointer to storage pool |
flags: | flags to control refresh behaviour (currently unused, use 0) |
Returns: | 0 if the volume list was refreshed, -1 on failure |
int virStoragePoolSetAutostart (virStoragePoolPtr pool,
int autostart)
Sets the autostart flag
pool: | pointer to storage pool |
autostart: | new flag setting |
Returns: | 0 on success, -1 on failure |
int virStoragePoolUndefine (virStoragePoolPtr pool)
Undefine an inactive storage pool
pool: | pointer to storage pool |
Returns: | 0 on success, -1 on failure |
virStorageVolPtr virStorageVolCreateXML (virStoragePoolPtr pool,
const char * xmldesc,
unsigned int flags)
Create a storage volume within a pool based on an XML description. Not all pools support creation of volumes
pool: | pointer to storage pool |
xmldesc: | description of volume to create |
flags: | flags for creation (unused, pass 0) |
Returns: | the storage volume, or NULL on error |
virStorageVolPtr virStorageVolCreateXMLFrom (virStoragePoolPtr pool,
const char * xmldesc,
virStorageVolPtr clonevol,
unsigned int flags)
Create a storage volume in the parent pool, using the 'clonevol' volume as input. Information for the new volume (name, perms) are passed via a typical volume XML description.
pool: | pointer to parent pool for the new volume |
xmldesc: | description of volume to create |
clonevol: | storage volume to use as input |
flags: | flags for creation (unused, pass 0) |
Returns: | the storage volume, or NULL on error |
int virStorageVolDelete (virStorageVolPtr vol,
unsigned int flags)
Delete the storage volume from the pool
vol: | pointer to storage volume |
flags: | future flags, use 0 for now |
Returns: | 0 on success, or -1 on error |
int virStorageVolFree (virStorageVolPtr vol)
Release the storage volume handle. The underlying storage volume continues to exist.
vol: | pointer to storage volume |
Returns: | 0 on success, or -1 on error |
virConnectPtr virStorageVolGetConnect (virStorageVolPtr vol)
Provides the connection pointer associated with a storage volume. The reference counter on the connection is not increased by this call. WARNING: When writing libvirt bindings in other languages, do not use this function. Instead, store the connection and the volume object together.
vol: | pointer to a pool |
Returns: | the virConnectPtr or NULL in case of failure. |
int virStorageVolGetInfo (virStorageVolPtr vol,
virStorageVolInfoPtr info)
Fetches volatile information about the storage volume such as its current allocation
vol: | pointer to storage volume |
info: | pointer at which to store info |
Returns: | 0 on success, or -1 on failure |
const char * virStorageVolGetKey (virStorageVolPtr vol)
Fetch the storage volume key. This is globally unique, so the same volume will have the same key no matter what host it is accessed from
vol: | pointer to storage volume |
Returns: | the volume key, or NULL on error |
const char * virStorageVolGetName (virStorageVolPtr vol)
Fetch the storage volume name. This is unique within the scope of a pool
vol: | pointer to storage volume |
Returns: | the volume name, or NULL on error |
char * virStorageVolGetPath (virStorageVolPtr vol)
Fetch the storage volume path. Depending on the pool configuration this is either persistent across hosts, or dynamically assigned at pool startup. Consult pool documentation for information on getting the persistent naming
vol: | pointer to storage volume |
Returns: | the storage volume path, or NULL on error |
char * virStorageVolGetXMLDesc (virStorageVolPtr vol,
unsigned int flags)
Fetch an XML document describing all aspects of the storage volume
vol: | pointer to storage volume |
flags: | flags for XML generation (unused, pass 0) |
Returns: | the XML document, or NULL on error |
virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn,
const char * key)
Fetch a pointer to a storage volume based on its globally unique key
conn: | pointer to hypervisor connection |
key: | globally unique key |
Returns: | a storage volume, or NULL if not found / error |
virStorageVolPtr virStorageVolLookupByName (virStoragePoolPtr pool,
const char * name)
Fetch a pointer to a storage volume based on its name within a pool
pool: | pointer to storage pool |
name: | name of storage volume |
Returns: | a storage volume, or NULL if not found / error |
virStorageVolPtr virStorageVolLookupByPath (virConnectPtr conn,
const char * path)
Fetch a pointer to a storage volume based on its locally (host) unique path
conn: | pointer to hypervisor connection |
path: | locally unique path |
Returns: | a storage volume, or NULL if not found / error |
int virStorageVolRef (virStorageVolPtr vol)
Increment the reference count on the vol. For each additional call to this method, there shall be a corresponding call to virStorageVolFree to release the reference count, once the caller no longer needs the reference to this object. This method is typically useful for applications where multiple threads are using a connection, and it is required that the connection remain open until all threads have finished using it. ie, each new thread using a vol would increment the reference count.
vol: | the vol to hold a reference on |
Returns: | 0 in case of success, -1 in case of failure. |