📄 libvirt.h
字号:
/* -*- c -*- * libvirt.h: * Summary: core interfaces for the libvirt library * Description: Provides the interfaces of the libvirt library to handle * virtualized domains * * Copy: Copyright (C) 2005,2006 Red Hat, Inc. * * See COPYING.LIB for the License of this software * * Author: Daniel Veillard <veillard@redhat.com> */#ifndef __VIR_VIRLIB_H__#define __VIR_VIRLIB_H__#include <sys/types.h>#ifdef __cplusplusextern "C" {#endif#ifndef VIR_DEPRECATED /* The feature is present in gcc-3.1 and newer. */# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)# define VIR_DEPRECATED __attribute__((__deprecated__))# else# define VIR_DEPRECATED /* nothing */# endif#endif /* VIR_DEPRECATED *//** * virConnect: * * a virConnect is a private structure representing a connection to * the Hypervisor. */typedef struct _virConnect 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. */typedef virConnect *virConnectPtr;/** * virDomain: * * a virDomain is a private structure representing a domain. */typedef struct _virDomain virDomain;/** * virDomainPtr: * * a virDomainPtr is pointer to a virDomain private structure, this is the * type used to reference a domain in the API. */typedef virDomain *virDomainPtr;/** * virDomainState: * * A domain may be in different states at a given point in time */typedef enum { 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 */} virDomainState;/** * virDomainInfoPtr: * * a virDomainInfo is a structure filled by virDomainGetInfo() and extracting * runtime information for a given active Domain */typedef struct _virDomainInfo virDomainInfo;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 */};/** * virDomainInfoPtr: * * a virDomainInfoPtr is a pointer to a virDomainInfo structure. */typedef virDomainInfo *virDomainInfoPtr;/** * virDomainCreateFlags: * * Flags OR'ed together to provide specific behaviour when creating a * Domain. */typedef enum { VIR_DOMAIN_NONE = 0} virDomainCreateFlags;/** * virNodeInfoPtr: * * a virNodeInfo is a structure filled by virNodeGetInfo() and providing * the information for the Node. */typedef struct _virNodeInfo virNodeInfo;struct _virNodeInfo { char model[32]; /* 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 */};/** * virDomainSchedParameterType: * * A scheduler parameter field type */typedef enum { 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 */} virSchedParameterType;/** * VIR_DOMAIN_SCHED_FIELD_LENGTH: * * Macro providing the field length of virSchedParameter */#define VIR_DOMAIN_SCHED_FIELD_LENGTH 80/** * virDomainSchedParameter: * * a virDomainSchedParameter is the set of scheduler parameters */typedef struct _virSchedParameter virSchedParameter;struct _virSchedParameter { char field[VIR_DOMAIN_SCHED_FIELD_LENGTH]; /* parameter name */ int type; /* parameter type */ union { int i; /* data for integer case */ unsigned int ui; /* data for unsigned integer case */ long long int l; /* data for long long integer case */ unsigned long long int ul; /* data for unsigned long long integer case */ double d; /* data for double case */ char b; /* data for char case */ } value; /* parameter value */};/** * virSchedParameterPtr: * * a virSchedParameterPtr is a pointer to a virSchedParameter structure. */typedef virSchedParameter *virSchedParameterPtr;/* * Fetch scheduler parameters, caller allocates 'params' field of size 'nparams' */int virDomainGetSchedulerParameters (virDomainPtr domain, virSchedParameterPtr params, int *nparams);/* * Change scheduler parameters */int virDomainSetSchedulerParameters (virDomainPtr domain, virSchedParameterPtr params, int nparams);/** * virDomainBlockStats: * * Block device stats for virDomainBlockStats. * * Hypervisors may return a field set to ((long long)-1) which indicates * that the hypervisor does not support that statistic. * * NB. Here 'long long' means 64 bit integer. */typedef struct _virDomainBlockStats virDomainBlockStatsStruct;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'. */};/** * virDomainBlockStatsPtr: * * A pointer to a virDomainBlockStats structure */typedef virDomainBlockStatsStruct *virDomainBlockStatsPtr;/** * virDomainInterfaceStats: * * Network interface stats for virDomainInterfaceStats. * * Hypervisors may return a field set to ((long long)-1) which indicates * that the hypervisor does not support that statistic. * * NB. Here 'long long' means 64 bit integer. */typedef struct _virDomainInterfaceStats virDomainInterfaceStatsStruct;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;};/** * virDomainInterfaceStatsPtr: * * A pointer to a virDomainInterfaceStats structure */typedef virDomainInterfaceStatsStruct *virDomainInterfaceStatsPtr;/* Domain migration flags. */typedef enum { VIR_MIGRATE_LIVE = 1, /* live migration */} virDomainMigrateFlags;/* Domain migration. */virDomainPtr virDomainMigrate (virDomainPtr domain, virConnectPtr dconn, unsigned long flags, const char *dname, const char *uri, unsigned long bandwidth);/** * VIR_NODEINFO_MAXCPUS: * @nodeinfo: virNodeInfo instance * * This macro is to calculate the total number of CPUs supported * but not necessary active in the host. */#define VIR_NODEINFO_MAXCPUS(nodeinfo) ((nodeinfo).nodes*(nodeinfo).sockets*(nodeinfo).cores*(nodeinfo).threads)/** * virNodeInfoPtr: * * a virNodeInfoPtr is a pointer to a virNodeInfo structure. */typedef virNodeInfo *virNodeInfoPtr;/** * virConnectFlags * * Flags when opening a connection to a hypervisor */typedef enum { VIR_CONNECT_RO = 1, /* A readonly connection */} virConnectFlags;typedef enum { 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 */} virConnectCredentialType;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 */};typedef struct _virConnectCredential virConnectCredential;typedef virConnectCredential *virConnectCredentialPtr;/** * virConnectCredCallbackPtr * * @param authtype type of authentication being performed * @param cred list of virConnectCredential object to fetch from user * @param ncred size of cred list * @param cbdata opaque data passed to virConnectOpenAuth * * When authentication requires one or more interactions, this callback * is invoked. For each interaction supplied, data must be gathered
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -