convert TAB-based indentation in C sources to use only spaces

Done using this command (also includes .c.in and .h.in files):
for i in $(g ls-files|grep -E '\.[ch](\.in)?$'|grep -v gnulib); do
  expand -i $i > j && mv j $i;done
This commit is contained in:
Jim Meyering 2008-04-10 16:54:54 +00:00
parent dc42a9d2de
commit 5bf824ea10
59 changed files with 4446 additions and 4441 deletions

View File

@ -1,4 +1,9 @@
2008-04-10 Jim Meyering <meyering@redhat.com>
Thu Apr 10 18:54:03 CEST 2008 Jim Meyering <meyering@redhat.com>
Convert TAB-based indentation in C sources to use only spaces.
Done using this command (also includes .c.in and .h.in files):
for i in $(g ls-files|grep -E '\.[ch](\.in)?$'|grep -v gnulib); do
expand -i $i > j && mv j $i;done
Remove Vim and Emacs variable settings from C source files.
Done with these commands:

View File

@ -29,21 +29,21 @@ getDomainInfo(int id) {
conn = virConnectOpenReadOnly(NULL);
if (conn == NULL) {
fprintf(stderr, "Failed to connect to hypervisor\n");
goto error;
goto error;
}
/* Find the domain of the given id */
dom = virDomainLookupByID(conn, id);
if (dom == NULL) {
fprintf(stderr, "Failed to find Domain %d\n", id);
goto error;
goto error;
}
/* Get the information */
ret = virDomainGetInfo(dom, &info);
if (ret < 0) {
fprintf(stderr, "Failed to get information for Domain %d\n", id);
goto error;
goto error;
}
printf("Domains %d: %d CPUs\n", id, info.nrVirtCpu);
@ -52,7 +52,7 @@ error:
if (dom != NULL)
virDomainFree(dom);
if (conn != NULL)
virConnectClose(conn);
virConnectClose(conn);
}
int main() {

View File

@ -30,7 +30,7 @@ checkDomainState(virDomainPtr dom) {
ret = virDomainGetInfo(dom, &info);
if (ret < 0) {
return(-1);
return(-1);
}
return(info.state);
}
@ -50,42 +50,42 @@ SuspendAndResumeDomain(int id) {
dom = virDomainLookupByID(conn, id);
if (dom == NULL) {
fprintf(stderr, "Failed to find Domain %d\n", id);
goto error;
goto error;
}
/* Check state */
state = checkDomainState(dom);
if ((state == VIR_DOMAIN_RUNNING) ||
(state == VIR_DOMAIN_NOSTATE) ||
(state == VIR_DOMAIN_BLOCKED)) {
printf("Suspending domain...\n");
ret = virDomainSuspend(dom);
if (ret < 0) {
fprintf(stderr, "Failed to suspend Domain %d\n", id);
goto error;
}
state = checkDomainState(dom);
if (state != VIR_DOMAIN_PAUSED) {
fprintf(stderr, "Domain %d state is not suspended\n", id);
} else {
printf("Domain suspended, resuming it...\n");
}
ret = virDomainResume(dom);
if (ret < 0) {
fprintf(stderr, "Failed to resume Domain %d\n", id);
goto error;
}
state = checkDomainState(dom);
if ((state == VIR_DOMAIN_RUNNING) ||
(state == VIR_DOMAIN_NOSTATE) ||
(state == VIR_DOMAIN_BLOCKED)) {
printf("Domain resumed\n");
} else {
fprintf(stderr, "Domain %d state indicate it is not resumed\n", id);
}
(state == VIR_DOMAIN_BLOCKED)) {
printf("Suspending domain...\n");
ret = virDomainSuspend(dom);
if (ret < 0) {
fprintf(stderr, "Failed to suspend Domain %d\n", id);
goto error;
}
state = checkDomainState(dom);
if (state != VIR_DOMAIN_PAUSED) {
fprintf(stderr, "Domain %d state is not suspended\n", id);
} else {
printf("Domain suspended, resuming it...\n");
}
ret = virDomainResume(dom);
if (ret < 0) {
fprintf(stderr, "Failed to resume Domain %d\n", id);
goto error;
}
state = checkDomainState(dom);
if ((state == VIR_DOMAIN_RUNNING) ||
(state == VIR_DOMAIN_NOSTATE) ||
(state == VIR_DOMAIN_BLOCKED)) {
printf("Domain resumed\n");
} else {
fprintf(stderr, "Domain %d state indicate it is not resumed\n", id);
}
} else {
fprintf(stderr, "Domain %d is not in a state where it should be suspended\n", id);
goto error;
goto error;
}
error:
@ -100,7 +100,7 @@ int main(int argc, char **argv) {
conn = virConnectOpenReadOnly(NULL);
if (conn == NULL) {
fprintf(stderr, "Failed to connect to hypervisor\n");
goto error;
goto error;
}
if (argc > 1) {
@ -108,27 +108,27 @@ int main(int argc, char **argv) {
}
if (id == 0) {
int i, j, ids[10];
i = virConnectListDomains(conn, &ids[0], 10);
if (i < 0) {
fprintf(stderr, "Failed to list the domains\n");
goto error;
}
for (j = 0;j < i;j++) {
if (ids[j] != 0) {
id = ids[j];
break;
}
}
i = virConnectListDomains(conn, &ids[0], 10);
if (i < 0) {
fprintf(stderr, "Failed to list the domains\n");
goto error;
}
for (j = 0;j < i;j++) {
if (ids[j] != 0) {
id = ids[j];
break;
}
}
}
if (id == 0) {
fprintf(stderr, "Failed find a running guest domain\n");
goto error;
fprintf(stderr, "Failed find a running guest domain\n");
goto error;
}
SuspendAndResumeDomain(id);
error:
if (conn != NULL)
virConnectClose(conn);
virConnectClose(conn);
return(0);
}

View File

@ -178,15 +178,15 @@ typedef virSchedParameter *virSchedParameterPtr;
* Fetch scheduler parameters, caller allocates 'params' field of size 'nparams'
*/
int virDomainGetSchedulerParameters (virDomainPtr domain,
virSchedParameterPtr params,
int *nparams);
virSchedParameterPtr params,
int *nparams);
/*
* Change scheduler parameters
*/
int virDomainSetSchedulerParameters (virDomainPtr domain,
virSchedParameterPtr params,
int nparams);
virSchedParameterPtr params,
int nparams);
/**
* virDomainBlockStats:
@ -253,8 +253,8 @@ typedef enum {
/* Domain migration. */
virDomainPtr virDomainMigrate (virDomainPtr domain, virConnectPtr dconn,
unsigned long flags, const char *dname,
const char *uri, unsigned long bandwidth);
unsigned long flags, const char *dname,
const char *uri, unsigned long bandwidth);
/**
* VIR_NODEINFO_MAXCPUS:
@ -328,8 +328,8 @@ typedef virConnectCredential *virConnectCredentialPtr;
* Return 0 if all interactions were filled, or -1 upon error
*/
typedef int (*virConnectAuthCallbackPtr)(virConnectCredentialPtr cred,
unsigned int ncred,
void *cbdata);
unsigned int ncred,
void *cbdata);
struct _virConnectAuth {
int *credtype; /* List of supported virConnectCredentialType values */
@ -375,8 +375,8 @@ extern virConnectAuthPtr virConnectAuthPtrDefault;
#define LIBVIR_VERSION_NUMBER 4002
int virGetVersion (unsigned long *libVer,
const char *type,
unsigned long *typeVer);
const char *type,
unsigned long *typeVer);
/*
* Connection and disconnections to the Hypervisor
@ -386,12 +386,12 @@ int virInitialize (void);
virConnectPtr virConnectOpen (const char *name);
virConnectPtr virConnectOpenReadOnly (const char *name);
virConnectPtr virConnectOpenAuth (const char *name,
virConnectAuthPtr auth,
int flags);
virConnectAuthPtr auth,
int flags);
int virConnectClose (virConnectPtr conn);
const char * virConnectGetType (virConnectPtr conn);
int virConnectGetVersion (virConnectPtr conn,
unsigned long *hvVer);
unsigned long *hvVer);
char * virConnectGetHostname (virConnectPtr conn);
char * virConnectGetURI (virConnectPtr conn);
@ -401,9 +401,9 @@ char * virConnectGetURI (virConnectPtr conn);
*/
int virConnectGetMaxVcpus (virConnectPtr conn,
const char *type);
const char *type);
int virNodeGetInfo (virConnectPtr conn,
virNodeInfoPtr info);
virNodeInfoPtr info);
char * virConnectGetCapabilities (virConnectPtr conn);
unsigned long long virNodeGetFreeMemory (virConnectPtr conn);
@ -412,8 +412,8 @@ unsigned long long virNodeGetFreeMemory (virConnectPtr conn);
* Gather list of running domains
*/
int virConnectListDomains (virConnectPtr conn,
int *ids,
int maxids);
int *ids,
int maxids);
/*
* Number of domains
@ -430,20 +430,20 @@ virConnectPtr virDomainGetConnect (virDomainPtr domain);
* Domain creation and destruction
*/
virDomainPtr virDomainCreateLinux (virConnectPtr conn,
const char *xmlDesc,
unsigned int flags);
const char *xmlDesc,
unsigned int flags);
virDomainPtr virDomainLookupByName (virConnectPtr conn,
const char *name);
const char *name);
virDomainPtr virDomainLookupByID (virConnectPtr conn,
int id);
int id);
virDomainPtr virDomainLookupByUUID (virConnectPtr conn,
const unsigned char *uuid);
const unsigned char *uuid);
virDomainPtr virDomainLookupByUUIDString (virConnectPtr conn,
const char *uuid);
const char *uuid);
int virDomainShutdown (virDomainPtr domain);
int virDomainReboot (virDomainPtr domain,
unsigned int flags);
unsigned int flags);
int virDomainDestroy (virDomainPtr domain);
int virDomainFree (virDomainPtr domain);
@ -457,28 +457,28 @@ int virDomainResume (virDomainPtr domain);
* Domain save/restore
*/
int virDomainSave (virDomainPtr domain,
const char *to);
const char *to);
int virDomainRestore (virConnectPtr conn,
const char *from);
const char *from);
/*
* Domain core dump
*/
int virDomainCoreDump (virDomainPtr domain,
const char *to,
int flags);
const char *to,
int flags);
/*
* Domain runtime information
*/
int virDomainGetInfo (virDomainPtr domain,
virDomainInfoPtr info);
virDomainInfoPtr info);
/*
* Return scheduler type in effect 'sedf', 'credit', 'linux'
*/
char * virDomainGetSchedulerType(virDomainPtr domain,
int *nparams);
int *nparams);
/*
* Dynamic control of domains
@ -486,15 +486,15 @@ char * virDomainGetSchedulerType(virDomainPtr domain,
const char * virDomainGetName (virDomainPtr domain);
unsigned int virDomainGetID (virDomainPtr domain);
int virDomainGetUUID (virDomainPtr domain,
unsigned char *uuid);
unsigned char *uuid);
int virDomainGetUUIDString (virDomainPtr domain,
char *buf);
char *buf);
char * virDomainGetOSType (virDomainPtr domain);
unsigned long virDomainGetMaxMemory (virDomainPtr domain);
int virDomainSetMaxMemory (virDomainPtr domain,
unsigned long memory);
unsigned long memory);
int virDomainSetMemory (virDomainPtr domain,
unsigned long memory);
unsigned long memory);
int virDomainGetMaxVcpus (virDomainPtr domain);
/*
@ -512,34 +512,34 @@ typedef enum {
} virDomainXMLFlags;
char * virDomainGetXMLDesc (virDomainPtr domain,
int flags);
int flags);
int virDomainBlockStats (virDomainPtr dom,
const char *path,
virDomainBlockStatsPtr stats,
size_t size);
const char *path,
virDomainBlockStatsPtr stats,
size_t size);
int virDomainInterfaceStats (virDomainPtr dom,
const char *path,
virDomainInterfaceStatsPtr stats,
size_t size);
const char *path,
virDomainInterfaceStatsPtr stats,
size_t size);
/*
* defined but not running domains
*/
virDomainPtr virDomainDefineXML (virConnectPtr conn,
const char *xml);
const char *xml);
int virDomainUndefine (virDomainPtr domain);
int virConnectNumOfDefinedDomains (virConnectPtr conn);
int virConnectListDefinedDomains (virConnectPtr conn,
char **const names,
int maxnames);
char **const names,
int maxnames);
int virDomainCreate (virDomainPtr domain);
int virDomainGetAutostart (virDomainPtr domain,
int *autostart);
int *autostart);
int virDomainSetAutostart (virDomainPtr domain,
int autostart);
int autostart);
/**
* virVcpuInfo: structure for information about a virtual CPU in a domain.
@ -561,12 +561,12 @@ struct _virVcpuInfo {
typedef virVcpuInfo *virVcpuInfoPtr;
int virDomainSetVcpus (virDomainPtr domain,
unsigned int nvcpus);
unsigned int nvcpus);
int virDomainPinVcpu (virDomainPtr domain,
unsigned int vcpu,
unsigned char *cpumap,
int maplen);
unsigned int vcpu,
unsigned char *cpumap,
int maplen);
/**
* VIR_USE_CPU:
@ -603,10 +603,10 @@ int virDomainPinVcpu (virDomainPtr domain,
int virDomainGetVcpus (virDomainPtr domain,
virVcpuInfoPtr info,
int maxinfo,
unsigned char *cpumaps,
int maplen);
virVcpuInfoPtr info,
int maxinfo,
unsigned char *cpumaps,
int maplen);
/**
* VIR_CPU_USABLE:
@ -621,7 +621,7 @@ int virDomainGetVcpus (virDomainPtr domain,
*/
#define VIR_CPU_USABLE(cpumaps,maplen,vcpu,cpu) \
(cpumaps[((vcpu)*(maplen))+((cpu)/8)] & (1<<((cpu)%8)))
(cpumaps[((vcpu)*(maplen))+((cpu)/8)] & (1<<((cpu)%8)))
/**
* VIR_COPY_CPUMAP:
@ -638,7 +638,7 @@ int virDomainGetVcpus (virDomainPtr domain,
* later by virDomainPinVcpu() API.
*/
#define VIR_COPY_CPUMAP(cpumaps,maplen,vcpu,cpumap) \
memcpy(cpumap, &(cpumaps[(vcpu)*(maplen)]), (maplen))
memcpy(cpumap, &(cpumaps[(vcpu)*(maplen)]), (maplen))
/**
@ -661,9 +661,9 @@ int virDomainDetachDevice(virDomainPtr domain, const char *xml);
*/
int virNodeGetCellsFreeMemory(virConnectPtr conn,
unsigned long long *freeMems,
int startCell,
int maxCells);
unsigned long long *freeMems,
int startCell,
int maxCells);
/*
* Virtual Networks API
@ -694,38 +694,38 @@ virConnectPtr virNetworkGetConnect (virNetworkPtr network);
*/
int virConnectNumOfNetworks (virConnectPtr conn);
int virConnectListNetworks (virConnectPtr conn,
char **const names,
int maxnames);
char **const names,
int maxnames);
/*
* List inactive networks
*/
int virConnectNumOfDefinedNetworks (virConnectPtr conn);
int virConnectListDefinedNetworks (virConnectPtr conn,
char **const names,
int maxnames);
char **const names,
int maxnames);
/*
* Lookup network by name or uuid
*/
virNetworkPtr virNetworkLookupByName (virConnectPtr conn,
const char *name);
const char *name);
virNetworkPtr virNetworkLookupByUUID (virConnectPtr conn,
const unsigned char *uuid);
const unsigned char *uuid);
virNetworkPtr virNetworkLookupByUUIDString (virConnectPtr conn,
const char *uuid);
const char *uuid);
/*
* Create active transient network
*/
virNetworkPtr virNetworkCreateXML (virConnectPtr conn,
const char *xmlDesc);
const char *xmlDesc);
/*
* Define inactive persistent network
*/
virNetworkPtr virNetworkDefineXML (virConnectPtr conn,
const char *xmlDesc);
const char *xmlDesc);
/*
* Delete persistent network
@ -748,17 +748,17 @@ int virNetworkFree (virNetworkPtr network);
*/
const char* virNetworkGetName (virNetworkPtr network);
int virNetworkGetUUID (virNetworkPtr network,
unsigned char *uuid);
unsigned char *uuid);
int virNetworkGetUUIDString (virNetworkPtr network,
char *buf);
char *buf);
char * virNetworkGetXMLDesc (virNetworkPtr network,
int flags);
int flags);
char * virNetworkGetBridgeName (virNetworkPtr network);
int virNetworkGetAutostart (virNetworkPtr network,
int *autostart);
int *autostart);
int virNetworkSetAutostart (virNetworkPtr network,
int autostart);
int autostart);
/**
@ -854,76 +854,76 @@ virConnectPtr virStoragePoolGetConnect (virStoragePoolPtr pool);
*/
int virConnectNumOfStoragePools (virConnectPtr conn);
int virConnectListStoragePools (virConnectPtr conn,
char **const names,
int maxnames);
char **const names,
int maxnames);
/*
* List inactive storage pools
*/
int virConnectNumOfDefinedStoragePools(virConnectPtr conn);
int virConnectListDefinedStoragePools(virConnectPtr conn,
char **const names,
int maxnames);
char **const names,
int maxnames);
/*
* Lookup pool by name or uuid
*/
virStoragePoolPtr virStoragePoolLookupByName (virConnectPtr conn,
const char *name);
const char *name);
virStoragePoolPtr virStoragePoolLookupByUUID (virConnectPtr conn,
const unsigned char *uuid);
const unsigned char *uuid);
virStoragePoolPtr virStoragePoolLookupByUUIDString(virConnectPtr conn,
const char *uuid);
const char *uuid);
virStoragePoolPtr virStoragePoolLookupByVolume (virStorageVolPtr vol);
/*
* Creating/destroying pools
*/
virStoragePoolPtr virStoragePoolCreateXML (virConnectPtr conn,
const char *xmlDesc,
unsigned int flags);
const char *xmlDesc,
unsigned int flags);
virStoragePoolPtr virStoragePoolDefineXML (virConnectPtr conn,
const char *xmlDesc,
unsigned int flags);
const char *xmlDesc,
unsigned int flags);
int virStoragePoolBuild (virStoragePoolPtr pool,
unsigned int flags);
unsigned int flags);
int virStoragePoolUndefine (virStoragePoolPtr pool);
int virStoragePoolCreate (virStoragePoolPtr pool,
unsigned int flags);
unsigned int flags);
int virStoragePoolDestroy (virStoragePoolPtr pool);
int virStoragePoolDelete (virStoragePoolPtr pool,
unsigned int flags);
unsigned int flags);
int virStoragePoolFree (virStoragePoolPtr pool);
int virStoragePoolRefresh (virStoragePoolPtr pool,
unsigned int flags);
unsigned int flags);
/*
* StoragePool information
*/
const char* virStoragePoolGetName (virStoragePoolPtr pool);
int virStoragePoolGetUUID (virStoragePoolPtr pool,
unsigned char *uuid);
unsigned char *uuid);
int virStoragePoolGetUUIDString (virStoragePoolPtr pool,
char *buf);
char *buf);
int virStoragePoolGetInfo (virStoragePoolPtr vol,
virStoragePoolInfoPtr info);
virStoragePoolInfoPtr info);
char * virStoragePoolGetXMLDesc (virStoragePoolPtr pool,
unsigned int flags);
unsigned int flags);
int virStoragePoolGetAutostart (virStoragePoolPtr pool,
int *autostart);
int *autostart);
int virStoragePoolSetAutostart (virStoragePoolPtr pool,
int autostart);
int autostart);
/*
* List/lookup storage volumes within a pool
*/
int virStoragePoolNumOfVolumes (virStoragePoolPtr pool);
int virStoragePoolListVolumes (virStoragePoolPtr pool,
char **const names,
int maxnames);
char **const names,
int maxnames);
virConnectPtr virStorageVolGetConnect (virStorageVolPtr vol);
@ -931,27 +931,27 @@ virConnectPtr virStorageVolGetConnect (virStorageVolPtr vol);
* Lookup volumes based on various attributes
*/
virStorageVolPtr virStorageVolLookupByName (virStoragePoolPtr pool,
const char *name);
const char *name);
virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn,
const char *key);
const char *key);
virStorageVolPtr virStorageVolLookupByPath (virConnectPtr conn,
const char *path);
const char *path);
const char* virStorageVolGetName (virStorageVolPtr vol);
const char* virStorageVolGetKey (virStorageVolPtr vol);
virStorageVolPtr virStorageVolCreateXML (virStoragePoolPtr pool,
const char *xmldesc,
unsigned int flags);
const char *xmldesc,
unsigned int flags);
int virStorageVolDelete (virStorageVolPtr vol,
unsigned int flags);
unsigned int flags);
int virStorageVolFree (virStorageVolPtr vol);
int virStorageVolGetInfo (virStorageVolPtr vol,
virStorageVolInfoPtr info);
virStorageVolInfoPtr info);
char * virStorageVolGetXMLDesc (virStorageVolPtr pool,
unsigned int flags);
unsigned int flags);
char * virStorageVolGetPath (virStorageVolPtr vol);

View File

@ -178,15 +178,15 @@ typedef virSchedParameter *virSchedParameterPtr;
* Fetch scheduler parameters, caller allocates 'params' field of size 'nparams'
*/
int virDomainGetSchedulerParameters (virDomainPtr domain,
virSchedParameterPtr params,
int *nparams);
virSchedParameterPtr params,
int *nparams);
/*
* Change scheduler parameters
*/
int virDomainSetSchedulerParameters (virDomainPtr domain,
virSchedParameterPtr params,
int nparams);
virSchedParameterPtr params,
int nparams);
/**
* virDomainBlockStats:
@ -253,8 +253,8 @@ typedef enum {
/* Domain migration. */
virDomainPtr virDomainMigrate (virDomainPtr domain, virConnectPtr dconn,
unsigned long flags, const char *dname,
const char *uri, unsigned long bandwidth);
unsigned long flags, const char *dname,
const char *uri, unsigned long bandwidth);
/**
* VIR_NODEINFO_MAXCPUS:
@ -328,8 +328,8 @@ typedef virConnectCredential *virConnectCredentialPtr;
* Return 0 if all interactions were filled, or -1 upon error
*/
typedef int (*virConnectAuthCallbackPtr)(virConnectCredentialPtr cred,
unsigned int ncred,
void *cbdata);
unsigned int ncred,
void *cbdata);
struct _virConnectAuth {
int *credtype; /* List of supported virConnectCredentialType values */
@ -375,8 +375,8 @@ extern virConnectAuthPtr virConnectAuthPtrDefault;
#define LIBVIR_VERSION_NUMBER @LIBVIRT_VERSION_NUMBER@
int virGetVersion (unsigned long *libVer,
const char *type,
unsigned long *typeVer);
const char *type,
unsigned long *typeVer);
/*
* Connection and disconnections to the Hypervisor
@ -386,12 +386,12 @@ int virInitialize (void);
virConnectPtr virConnectOpen (const char *name);
virConnectPtr virConnectOpenReadOnly (const char *name);
virConnectPtr virConnectOpenAuth (const char *name,
virConnectAuthPtr auth,
int flags);
virConnectAuthPtr auth,
int flags);
int virConnectClose (virConnectPtr conn);
const char * virConnectGetType (virConnectPtr conn);
int virConnectGetVersion (virConnectPtr conn,
unsigned long *hvVer);
unsigned long *hvVer);
char * virConnectGetHostname (virConnectPtr conn);
char * virConnectGetURI (virConnectPtr conn);
@ -401,9 +401,9 @@ char * virConnectGetURI (virConnectPtr conn);
*/
int virConnectGetMaxVcpus (virConnectPtr conn,
const char *type);
const char *type);
int virNodeGetInfo (virConnectPtr conn,
virNodeInfoPtr info);
virNodeInfoPtr info);
char * virConnectGetCapabilities (virConnectPtr conn);
unsigned long long virNodeGetFreeMemory (virConnectPtr conn);
@ -412,8 +412,8 @@ unsigned long long virNodeGetFreeMemory (virConnectPtr conn);
* Gather list of running domains
*/
int virConnectListDomains (virConnectPtr conn,
int *ids,
int maxids);
int *ids,
int maxids);
/*
* Number of domains
@ -430,20 +430,20 @@ virConnectPtr virDomainGetConnect (virDomainPtr domain);
* Domain creation and destruction
*/
virDomainPtr virDomainCreateLinux (virConnectPtr conn,
const char *xmlDesc,
unsigned int flags);
const char *xmlDesc,
unsigned int flags);
virDomainPtr virDomainLookupByName (virConnectPtr conn,
const char *name);
const char *name);
virDomainPtr virDomainLookupByID (virConnectPtr conn,
int id);
int id);
virDomainPtr virDomainLookupByUUID (virConnectPtr conn,
const unsigned char *uuid);
const unsigned char *uuid);
virDomainPtr virDomainLookupByUUIDString (virConnectPtr conn,
const char *uuid);
const char *uuid);
int virDomainShutdown (virDomainPtr domain);
int virDomainReboot (virDomainPtr domain,
unsigned int flags);
unsigned int flags);
int virDomainDestroy (virDomainPtr domain);
int virDomainFree (virDomainPtr domain);
@ -457,28 +457,28 @@ int virDomainResume (virDomainPtr domain);
* Domain save/restore
*/
int virDomainSave (virDomainPtr domain,
const char *to);
const char *to);
int virDomainRestore (virConnectPtr conn,
const char *from);
const char *from);
/*
* Domain core dump
*/
int virDomainCoreDump (virDomainPtr domain,
const char *to,
int flags);
const char *to,
int flags);
/*
* Domain runtime information
*/
int virDomainGetInfo (virDomainPtr domain,
virDomainInfoPtr info);
virDomainInfoPtr info);
/*
* Return scheduler type in effect 'sedf', 'credit', 'linux'
*/
char * virDomainGetSchedulerType(virDomainPtr domain,
int *nparams);
int *nparams);
/*
* Dynamic control of domains
@ -486,15 +486,15 @@ char * virDomainGetSchedulerType(virDomainPtr domain,
const char * virDomainGetName (virDomainPtr domain);
unsigned int virDomainGetID (virDomainPtr domain);
int virDomainGetUUID (virDomainPtr domain,
unsigned char *uuid);
unsigned char *uuid);
int virDomainGetUUIDString (virDomainPtr domain,
char *buf);
char *buf);
char * virDomainGetOSType (virDomainPtr domain);
unsigned long virDomainGetMaxMemory (virDomainPtr domain);
int virDomainSetMaxMemory (virDomainPtr domain,
unsigned long memory);
unsigned long memory);
int virDomainSetMemory (virDomainPtr domain,
unsigned long memory);
unsigned long memory);
int virDomainGetMaxVcpus (virDomainPtr domain);
/*
@ -512,34 +512,34 @@ typedef enum {
} virDomainXMLFlags;
char * virDomainGetXMLDesc (virDomainPtr domain,
int flags);
int flags);
int virDomainBlockStats (virDomainPtr dom,
const char *path,
virDomainBlockStatsPtr stats,
size_t size);
const char *path,
virDomainBlockStatsPtr stats,
size_t size);
int virDomainInterfaceStats (virDomainPtr dom,
const char *path,
virDomainInterfaceStatsPtr stats,
size_t size);
const char *path,
virDomainInterfaceStatsPtr stats,
size_t size);
/*
* defined but not running domains
*/
virDomainPtr virDomainDefineXML (virConnectPtr conn,
const char *xml);
const char *xml);
int virDomainUndefine (virDomainPtr domain);
int virConnectNumOfDefinedDomains (virConnectPtr conn);
int virConnectListDefinedDomains (virConnectPtr conn,
char **const names,
int maxnames);
char **const names,
int maxnames);
int virDomainCreate (virDomainPtr domain);
int virDomainGetAutostart (virDomainPtr domain,
int *autostart);
int *autostart);
int virDomainSetAutostart (virDomainPtr domain,
int autostart);
int autostart);
/**
* virVcpuInfo: structure for information about a virtual CPU in a domain.
@ -561,12 +561,12 @@ struct _virVcpuInfo {
typedef virVcpuInfo *virVcpuInfoPtr;
int virDomainSetVcpus (virDomainPtr domain,
unsigned int nvcpus);
unsigned int nvcpus);
int virDomainPinVcpu (virDomainPtr domain,
unsigned int vcpu,
unsigned char *cpumap,
int maplen);
unsigned int vcpu,
unsigned char *cpumap,
int maplen);
/**
* VIR_USE_CPU:
@ -603,10 +603,10 @@ int virDomainPinVcpu (virDomainPtr domain,
int virDomainGetVcpus (virDomainPtr domain,
virVcpuInfoPtr info,
int maxinfo,
unsigned char *cpumaps,
int maplen);
virVcpuInfoPtr info,
int maxinfo,
unsigned char *cpumaps,
int maplen);
/**
* VIR_CPU_USABLE:
@ -621,7 +621,7 @@ int virDomainGetVcpus (virDomainPtr domain,
*/
#define VIR_CPU_USABLE(cpumaps,maplen,vcpu,cpu) \
(cpumaps[((vcpu)*(maplen))+((cpu)/8)] & (1<<((cpu)%8)))
(cpumaps[((vcpu)*(maplen))+((cpu)/8)] & (1<<((cpu)%8)))
/**
* VIR_COPY_CPUMAP:
@ -638,7 +638,7 @@ int virDomainGetVcpus (virDomainPtr domain,
* later by virDomainPinVcpu() API.
*/
#define VIR_COPY_CPUMAP(cpumaps,maplen,vcpu,cpumap) \
memcpy(cpumap, &(cpumaps[(vcpu)*(maplen)]), (maplen))
memcpy(cpumap, &(cpumaps[(vcpu)*(maplen)]), (maplen))
/**
@ -661,9 +661,9 @@ int virDomainDetachDevice(virDomainPtr domain, const char *xml);
*/
int virNodeGetCellsFreeMemory(virConnectPtr conn,
unsigned long long *freeMems,
int startCell,
int maxCells);
unsigned long long *freeMems,
int startCell,
int maxCells);
/*
* Virtual Networks API
@ -694,38 +694,38 @@ virConnectPtr virNetworkGetConnect (virNetworkPtr network);
*/
int virConnectNumOfNetworks (virConnectPtr conn);
int virConnectListNetworks (virConnectPtr conn,
char **const names,
int maxnames);
char **const names,
int maxnames);
/*
* List inactive networks
*/
int virConnectNumOfDefinedNetworks (virConnectPtr conn);
int virConnectListDefinedNetworks (virConnectPtr conn,
char **const names,
int maxnames);
char **const names,
int maxnames);
/*
* Lookup network by name or uuid
*/
virNetworkPtr virNetworkLookupByName (virConnectPtr conn,
const char *name);
const char *name);
virNetworkPtr virNetworkLookupByUUID (virConnectPtr conn,
const unsigned char *uuid);
const unsigned char *uuid);
virNetworkPtr virNetworkLookupByUUIDString (virConnectPtr conn,
const char *uuid);
const char *uuid);
/*
* Create active transient network
*/
virNetworkPtr virNetworkCreateXML (virConnectPtr conn,
const char *xmlDesc);
const char *xmlDesc);
/*
* Define inactive persistent network
*/
virNetworkPtr virNetworkDefineXML (virConnectPtr conn,
const char *xmlDesc);
const char *xmlDesc);
/*
* Delete persistent network
@ -748,17 +748,17 @@ int virNetworkFree (virNetworkPtr network);
*/
const char* virNetworkGetName (virNetworkPtr network);
int virNetworkGetUUID (virNetworkPtr network,
unsigned char *uuid);
unsigned char *uuid);
int virNetworkGetUUIDString (virNetworkPtr network,
char *buf);
char *buf);
char * virNetworkGetXMLDesc (virNetworkPtr network,
int flags);
int flags);
char * virNetworkGetBridgeName (virNetworkPtr network);
int virNetworkGetAutostart (virNetworkPtr network,
int *autostart);
int *autostart);
int virNetworkSetAutostart (virNetworkPtr network,
int autostart);
int autostart);
/**
@ -854,76 +854,76 @@ virConnectPtr virStoragePoolGetConnect (virStoragePoolPtr pool);
*/
int virConnectNumOfStoragePools (virConnectPtr conn);
int virConnectListStoragePools (virConnectPtr conn,
char **const names,
int maxnames);
char **const names,
int maxnames);
/*
* List inactive storage pools
*/
int virConnectNumOfDefinedStoragePools(virConnectPtr conn);
int virConnectListDefinedStoragePools(virConnectPtr conn,
char **const names,
int maxnames);
char **const names,
int maxnames);
/*
* Lookup pool by name or uuid
*/
virStoragePoolPtr virStoragePoolLookupByName (virConnectPtr conn,
const char *name);
const char *name);
virStoragePoolPtr virStoragePoolLookupByUUID (virConnectPtr conn,
const unsigned char *uuid);
const unsigned char *uuid);
virStoragePoolPtr virStoragePoolLookupByUUIDString(virConnectPtr conn,
const char *uuid);
const char *uuid);
virStoragePoolPtr virStoragePoolLookupByVolume (virStorageVolPtr vol);
/*
* Creating/destroying pools
*/
virStoragePoolPtr virStoragePoolCreateXML (virConnectPtr conn,
const char *xmlDesc,
unsigned int flags);
const char *xmlDesc,
unsigned int flags);
virStoragePoolPtr virStoragePoolDefineXML (virConnectPtr conn,
const char *xmlDesc,
unsigned int flags);
const char *xmlDesc,
unsigned int flags);
int virStoragePoolBuild (virStoragePoolPtr pool,
unsigned int flags);
unsigned int flags);
int virStoragePoolUndefine (virStoragePoolPtr pool);
int virStoragePoolCreate (virStoragePoolPtr pool,
unsigned int flags);
unsigned int flags);
int virStoragePoolDestroy (virStoragePoolPtr pool);
int virStoragePoolDelete (virStoragePoolPtr pool,
unsigned int flags);
unsigned int flags);
int virStoragePoolFree (virStoragePoolPtr pool);
int virStoragePoolRefresh (virStoragePoolPtr pool,
unsigned int flags);
unsigned int flags);
/*
* StoragePool information
*/
const char* virStoragePoolGetName (virStoragePoolPtr pool);
int virStoragePoolGetUUID (virStoragePoolPtr pool,
unsigned char *uuid);
unsigned char *uuid);
int virStoragePoolGetUUIDString (virStoragePoolPtr pool,
char *buf);
char *buf);
int virStoragePoolGetInfo (virStoragePoolPtr vol,
virStoragePoolInfoPtr info);
virStoragePoolInfoPtr info);
char * virStoragePoolGetXMLDesc (virStoragePoolPtr pool,
unsigned int flags);
unsigned int flags);
int virStoragePoolGetAutostart (virStoragePoolPtr pool,
int *autostart);
int *autostart);
int virStoragePoolSetAutostart (virStoragePoolPtr pool,
int autostart);
int autostart);
/*
* List/lookup storage volumes within a pool
*/
int virStoragePoolNumOfVolumes (virStoragePoolPtr pool);
int virStoragePoolListVolumes (virStoragePoolPtr pool,
char **const names,
int maxnames);
char **const names,
int maxnames);
virConnectPtr virStorageVolGetConnect (virStorageVolPtr vol);
@ -931,27 +931,27 @@ virConnectPtr virStorageVolGetConnect (virStorageVolPtr vol);
* Lookup volumes based on various attributes
*/
virStorageVolPtr virStorageVolLookupByName (virStoragePoolPtr pool,
const char *name);
const char *name);
virStorageVolPtr virStorageVolLookupByKey (virConnectPtr conn,
const char *key);
const char *key);
virStorageVolPtr virStorageVolLookupByPath (virConnectPtr conn,
const char *path);
const char *path);
const char* virStorageVolGetName (virStorageVolPtr vol);
const char* virStorageVolGetKey (virStorageVolPtr vol);
virStorageVolPtr virStorageVolCreateXML (virStoragePoolPtr pool,
const char *xmldesc,
unsigned int flags);
const char *xmldesc,
unsigned int flags);
int virStorageVolDelete (virStorageVolPtr vol,
unsigned int flags);
unsigned int flags);
int virStorageVolFree (virStorageVolPtr vol);
int virStorageVolGetInfo (virStorageVolPtr vol,
virStorageVolInfoPtr info);
virStorageVolInfoPtr info);
char * virStorageVolGetXMLDesc (virStorageVolPtr pool,
unsigned int flags);
unsigned int flags);
char * virStorageVolGetPath (virStorageVolPtr vol);

View File

@ -170,12 +170,12 @@ int virCopyLastError (virErrorPtr to);
void virDefaultErrorFunc (virErrorPtr err);
void virSetErrorFunc (void *userData,
virErrorFunc handler);
virErrorFunc handler);
void virConnSetErrorFunc (virConnectPtr conn,
void *userData,
virErrorFunc handler);
void *userData,
virErrorFunc handler);
int virConnCopyLastError (virConnectPtr conn,
virErrorPtr to);
virErrorPtr to);
#ifdef __cplusplus
}
#endif

View File

@ -93,10 +93,10 @@ proxyInitXen(void) {
return(-1);
} else {
ret = xenHypervisorGetVersion(conn, &xenVersion);
if (ret != 0) {
fprintf(stderr, "Failed to get Xen hypervisor version\n");
return(-1);
}
if (ret != 0) {
fprintf(stderr, "Failed to get Xen hypervisor version\n");
return(-1);
}
}
ret = xenDaemonOpen_unix(conn, "/var/lib/xend/xend-socket");
if (ret < 0) {
@ -110,12 +110,12 @@ proxyInitXen(void) {
}
ret = xenDaemonGetVersion(conn, &xenVersion2);
if (ret != 0) {
fprintf(stderr, "Failed to get Xen daemon version\n");
return(-1);
fprintf(stderr, "Failed to get Xen daemon version\n");
return(-1);
}
if (debug)
fprintf(stderr, "Connected to hypervisor %lu and daemon %lu\n",
xenVersion, xenVersion2);
xenVersion, xenVersion2);
if (xenVersion2 > xenVersion)
xenVersion = xenVersion2;
return(0);
@ -168,7 +168,7 @@ proxyListenUnixSocket(const char *path) {
fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
fprintf(stderr, "Failed to create unix socket");
return(-1);
return(-1);
}
/*
@ -185,13 +185,13 @@ proxyListenUnixSocket(const char *path) {
*/
if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
fprintf(stderr, "Failed to bind to socket %s\n", path);
close(fd);
return (-1);
close(fd);
return (-1);
}
if (listen(fd, 30 /* backlog */ ) < 0) {
fprintf(stderr, "Failed to listen to socket %s\n", path);
close(fd);
return (-1);
close(fd);
return (-1);
}
if (debug > 0)
@ -221,28 +221,28 @@ retry:
client = accept(pollInfos[0].fd, &client_addr, &client_addrlen);
if (client < 0) {
if (errno == EINTR) {
if (debug > 0)
fprintf(stderr, "accept connection on socket %d interrupted\n",
pollInfos[0].fd);
goto retry;
}
if (debug > 0)
fprintf(stderr, "accept connection on socket %d interrupted\n",
pollInfos[0].fd);
goto retry;
}
fprintf(stderr, "Failed to accept incoming connection on socket %d\n",
pollInfos[0].fd);
done = 1;
return(-1);
pollInfos[0].fd);
done = 1;
return(-1);
}
if (nbClients >= MAX_CLIENT) {
fprintf(stderr, "Too many client registered\n");
close(client);
return(-1);
close(client);
return(-1);
}
nbClients++;
pollInfos[nbClients].fd = client;
pollInfos[nbClients].events = POLLIN | POLLERR | POLLHUP | POLLNVAL;
if (debug > 0)
fprintf(stderr, "accept connection on socket %d for client %d\n",
client, nbClients);
fprintf(stderr, "accept connection on socket %d for client %d\n",
client, nbClients);
return(client);
}
@ -266,14 +266,14 @@ proxyCloseClientSocket(int nr) {
ret = close(pollInfos[nr].fd);
if (ret != 0)
fprintf(stderr, "Failed to close socket %d from client %d\n",
pollInfos[nr].fd, nr);
fprintf(stderr, "Failed to close socket %d from client %d\n",
pollInfos[nr].fd, nr);
else if (debug > 0)
fprintf(stderr, "Closed socket %d from client %d\n",
pollInfos[nr].fd, nr);
fprintf(stderr, "Closed socket %d from client %d\n",
pollInfos[nr].fd, nr);
if (nr < nbClients) {
memmove(&pollInfos[nr], &pollInfos[nr + 1],
(nbClients - nr) * sizeof(pollInfos[0]));
(nbClients - nr) * sizeof(pollInfos[0]));
}
nbClients--;
return(ret);
@ -290,12 +290,12 @@ proxyCloseClientSockets(void) {
for (i = 1;i <= nbClients;i++) {
ret = close(pollInfos[i].fd);
if (ret != 0)
fprintf(stderr, "Failed to close socket %d from client %d\n",
pollInfos[i].fd, i);
else if (debug > 0)
fprintf(stderr, "Closed socket %d from client %d\n",
pollInfos[i].fd, i);
if (ret != 0)
fprintf(stderr, "Failed to close socket %d from client %d\n",
pollInfos[i].fd, i);
else if (debug > 0)
fprintf(stderr, "Closed socket %d from client %d\n",
pollInfos[i].fd, i);
}
nbClients = 0;
}
@ -316,37 +316,37 @@ proxyWriteClientSocket(int nr, virProxyPacketPtr req) {
if ((nr <= 0) || (nr > nbClients) || (req == NULL) ||
(req->len < sizeof(virProxyPacket)) ||
(req->len > sizeof(virProxyFullPacket)) ||
(pollInfos[nr].fd < 0)) {
fprintf(stderr, "write to client %d in error", nr);
proxyCloseClientSocket(nr);
return(-1);
(req->len > sizeof(virProxyFullPacket)) ||
(pollInfos[nr].fd < 0)) {
fprintf(stderr, "write to client %d in error", nr);
proxyCloseClientSocket(nr);
return(-1);
}
ret = safewrite(pollInfos[nr].fd, (char *) req, req->len);
if (ret < 0) {
fprintf(stderr, "write %d bytes to socket %d from client %d failed\n",
req->len, pollInfos[nr].fd, nr);
req->len, pollInfos[nr].fd, nr);
proxyCloseClientSocket(nr);
return(-1);
}
if (ret == 0) {
if (debug)
fprintf(stderr, "end of stream from client %d on socket %d\n",
nr, pollInfos[nr].fd);
proxyCloseClientSocket(nr);
return(-1);
if (debug)
fprintf(stderr, "end of stream from client %d on socket %d\n",
nr, pollInfos[nr].fd);
proxyCloseClientSocket(nr);
return(-1);
}
if (ret != req->len) {
fprintf(stderr, "write %d of %d bytes to socket %d from client %d\n",
ret, req->len, pollInfos[nr].fd, nr);
proxyCloseClientSocket(nr);
return(-1);
ret, req->len, pollInfos[nr].fd, nr);
proxyCloseClientSocket(nr);
return(-1);
}
if (debug)
fprintf(stderr, "wrote %d bytes to client %d on socket %d\n",
ret, nr, pollInfos[nr].fd);
ret, nr, pollInfos[nr].fd);
return(0);
}
@ -367,32 +367,32 @@ retry:
ret = read(pollInfos[nr].fd, req, sizeof(virProxyPacket));
if (ret < 0) {
if (errno == EINTR) {
if (debug > 0)
fprintf(stderr, "read socket %d from client %d interrupted\n",
pollInfos[nr].fd, nr);
goto retry;
}
if (debug > 0)
fprintf(stderr, "read socket %d from client %d interrupted\n",
pollInfos[nr].fd, nr);
goto retry;
}
fprintf(stderr, "Failed to read socket %d from client %d\n",
pollInfos[nr].fd, nr);
proxyCloseClientSocket(nr);
return(-1);
pollInfos[nr].fd, nr);
proxyCloseClientSocket(nr);
return(-1);
}
if (ret == 0) {
if (debug)
fprintf(stderr, "end of stream from client %d on socket %d\n",
nr, pollInfos[nr].fd);
proxyCloseClientSocket(nr);
return(-1);
if (debug)
fprintf(stderr, "end of stream from client %d on socket %d\n",
nr, pollInfos[nr].fd);
proxyCloseClientSocket(nr);
return(-1);
}
if (debug)
fprintf(stderr, "read %d bytes from client %d on socket %d\n",
ret, nr, pollInfos[nr].fd);
ret, nr, pollInfos[nr].fd);
if ((req->version != PROXY_PROTO_VERSION) ||
(req->len < sizeof(virProxyPacket)) ||
(req->len > sizeof(virProxyFullPacket)))
goto comm_error;
(req->len > sizeof(virProxyFullPacket)))
goto comm_error;
if (debug)
@ -404,195 +404,195 @@ retry:
*/
if (req->len > ret) {
int total, extra;
char *base = (char *) &request;
char *base = (char *) &request;
total = ret;
while (total < req->len) {
extra = req->len - total;
while (total < req->len) {
extra = req->len - total;
retry2:
ret = read(pollInfos[nr].fd, base + total, extra);
if (ret < 0) {
if (errno == EINTR) {
if (debug > 0)
fprintf(stderr,
"read socket %d from client %d interrupted\n",
pollInfos[nr].fd, nr);
goto retry2;
}
fprintf(stderr, "Failed to read socket %d from client %d\n",
pollInfos[nr].fd, nr);
proxyCloseClientSocket(nr);
return(-1);
}
if (ret == 0) {
if (debug)
fprintf(stderr,
"end of stream from client %d on socket %d\n",
nr, pollInfos[nr].fd);
proxyCloseClientSocket(nr);
return(-1);
}
total += ret;
}
ret = read(pollInfos[nr].fd, base + total, extra);
if (ret < 0) {
if (errno == EINTR) {
if (debug > 0)
fprintf(stderr,
"read socket %d from client %d interrupted\n",
pollInfos[nr].fd, nr);
goto retry2;
}
fprintf(stderr, "Failed to read socket %d from client %d\n",
pollInfos[nr].fd, nr);
proxyCloseClientSocket(nr);
return(-1);
}
if (ret == 0) {
if (debug)
fprintf(stderr,
"end of stream from client %d on socket %d\n",
nr, pollInfos[nr].fd);
proxyCloseClientSocket(nr);
return(-1);
}
total += ret;
}
}
switch (req->command) {
case VIR_PROXY_NONE:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
break;
case VIR_PROXY_VERSION:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
req->data.larg = xenVersion;
break;
case VIR_PROXY_LIST: {
int maxids;
case VIR_PROXY_NONE:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
break;
case VIR_PROXY_VERSION:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
req->data.larg = xenVersion;
break;
case VIR_PROXY_LIST: {
int maxids;
if (req->len != sizeof(virProxyPacket))
goto comm_error;
maxids = sizeof(request.extra.arg) / sizeof(int);
ret = xenHypervisorListDomains(conn, &request.extra.arg[0],
maxids);
if (ret < 0) {
req->len = sizeof(virProxyPacket);
req->data.arg = 0;
} else {
req->len = sizeof(virProxyPacket) + ret * sizeof(int);
req->data.arg = ret;
}
break;
}
case VIR_PROXY_NUM_DOMAIN:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
req->data.arg = xenHypervisorNumOfDomains(conn);
break;
case VIR_PROXY_MAX_MEMORY:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
req->data.larg = xenHypervisorGetDomMaxMemory(conn, req->data.arg);
break;
case VIR_PROXY_DOMAIN_INFO:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
memset(&request.extra.dinfo, 0, sizeof(virDomainInfo));
ret = xenHypervisorGetDomInfo(conn, req->data.arg,
&request.extra.dinfo);
if (ret < 0) {
req->data.arg = -1;
} else {
req->len += sizeof(virDomainInfo);
}
break;
case VIR_PROXY_LOOKUP_ID: {
char *name = NULL;
unsigned char uuid[VIR_UUID_BUFLEN];
int len;
if (req->len != sizeof(virProxyPacket))
goto comm_error;
if (xenDaemonDomainLookupByID(conn, req->data.arg, &name, uuid) < 0) {
req->data.arg = -1;
} else {
len = strlen(name);
if (len > 1000) {
len = 1000;
name[1000] = 0;
}
req->len += VIR_UUID_BUFLEN + len + 1;
memcpy(&request.extra.str[0], uuid, VIR_UUID_BUFLEN);
strcpy(&request.extra.str[VIR_UUID_BUFLEN], name);
}
free(name);
break;
}
case VIR_PROXY_LOOKUP_UUID: {
char **names;
char **tmp;
int ident, len;
char *name = NULL;
unsigned char uuid[VIR_UUID_BUFLEN];
if (req->len != sizeof(virProxyPacket) + VIR_UUID_BUFLEN)
goto comm_error;
/*
* Xend API forces to collect the full domain list by names, and
* then query each of them until the id is found
*/
names = xenDaemonListDomainsOld(conn);
tmp = names;
if (names != NULL) {
while (*tmp != NULL) {
ident = xenDaemonDomainLookupByName_ids(conn, *tmp, &uuid[0]);
if (!memcmp(uuid, &request.extra.str[0], VIR_UUID_BUFLEN)) {
name = *tmp;
break;
}
tmp++;
}
}
if (name == NULL) {
/* not found */
req->data.arg = -1;
req->len = sizeof(virProxyPacket);
} else {
len = strlen(name);
if (len > 1000) {
len = 1000;
name[1000] = 0;
}
req->len = sizeof(virProxyPacket) + len + 1;
strcpy(&request.extra.str[0], name);
req->data.arg = ident;
}
free(names);
break;
}
case VIR_PROXY_LOOKUP_NAME: {
int ident;
unsigned char uuid[VIR_UUID_BUFLEN];
if (req->len > sizeof(virProxyPacket) + 1000)
goto comm_error;
ident = xenDaemonDomainLookupByName_ids(conn,
&request.extra.str[0], &uuid[0]);
if (ident < 0) {
/* not found */
req->data.arg = -1;
req->len = sizeof(virProxyPacket);
} else {
req->len = sizeof(virProxyPacket) + VIR_UUID_BUFLEN;
memcpy(&request.extra.str[0], uuid, VIR_UUID_BUFLEN);
req->data.arg = ident;
}
break;
}
case VIR_PROXY_NODE_INFO:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
/*
* Hum, could we expect those information to be unmutable and
* cache them ? Since it's probably an unfrequent call better
* not make assumption and do the xend RPC each call.
*/
ret = xenDaemonNodeGetInfo(conn, &request.extra.ninfo);
if (ret < 0) {
req->data.arg = -1;
req->len = sizeof(virProxyPacket);
} else {
if (req->len != sizeof(virProxyPacket))
goto comm_error;
maxids = sizeof(request.extra.arg) / sizeof(int);
ret = xenHypervisorListDomains(conn, &request.extra.arg[0],
maxids);
if (ret < 0) {
req->len = sizeof(virProxyPacket);
req->data.arg = 0;
req->len = sizeof(virProxyPacket) + sizeof(virNodeInfo);
}
break;
} else {
req->len = sizeof(virProxyPacket) + ret * sizeof(int);
req->data.arg = ret;
}
break;
}
case VIR_PROXY_NUM_DOMAIN:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
req->data.arg = xenHypervisorNumOfDomains(conn);
break;
case VIR_PROXY_MAX_MEMORY:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
req->data.larg = xenHypervisorGetDomMaxMemory(conn, req->data.arg);
break;
case VIR_PROXY_DOMAIN_INFO:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
memset(&request.extra.dinfo, 0, sizeof(virDomainInfo));
ret = xenHypervisorGetDomInfo(conn, req->data.arg,
&request.extra.dinfo);
if (ret < 0) {
req->data.arg = -1;
} else {
req->len += sizeof(virDomainInfo);
}
break;
case VIR_PROXY_LOOKUP_ID: {
char *name = NULL;
unsigned char uuid[VIR_UUID_BUFLEN];
int len;
case VIR_PROXY_GET_CAPABILITIES:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
if (req->len != sizeof(virProxyPacket))
goto comm_error;
if (xenDaemonDomainLookupByID(conn, req->data.arg, &name, uuid) < 0) {
req->data.arg = -1;
} else {
len = strlen(name);
if (len > 1000) {
len = 1000;
name[1000] = 0;
}
req->len += VIR_UUID_BUFLEN + len + 1;
memcpy(&request.extra.str[0], uuid, VIR_UUID_BUFLEN);
strcpy(&request.extra.str[VIR_UUID_BUFLEN], name);
}
free(name);
break;
}
case VIR_PROXY_LOOKUP_UUID: {
char **names;
char **tmp;
int ident, len;
char *name = NULL;
unsigned char uuid[VIR_UUID_BUFLEN];
if (req->len != sizeof(virProxyPacket) + VIR_UUID_BUFLEN)
goto comm_error;
/*
* Xend API forces to collect the full domain list by names, and
* then query each of them until the id is found
*/
names = xenDaemonListDomainsOld(conn);
tmp = names;
if (names != NULL) {
while (*tmp != NULL) {
ident = xenDaemonDomainLookupByName_ids(conn, *tmp, &uuid[0]);
if (!memcmp(uuid, &request.extra.str[0], VIR_UUID_BUFLEN)) {
name = *tmp;
break;
}
tmp++;
}
}
if (name == NULL) {
/* not found */
req->data.arg = -1;
req->len = sizeof(virProxyPacket);
} else {
len = strlen(name);
if (len > 1000) {
len = 1000;
name[1000] = 0;
}
req->len = sizeof(virProxyPacket) + len + 1;
strcpy(&request.extra.str[0], name);
req->data.arg = ident;
}
free(names);
break;
}
case VIR_PROXY_LOOKUP_NAME: {
int ident;
unsigned char uuid[VIR_UUID_BUFLEN];
if (req->len > sizeof(virProxyPacket) + 1000)
goto comm_error;
ident = xenDaemonDomainLookupByName_ids(conn,
&request.extra.str[0], &uuid[0]);
if (ident < 0) {
/* not found */
req->data.arg = -1;
req->len = sizeof(virProxyPacket);
} else {
req->len = sizeof(virProxyPacket) + VIR_UUID_BUFLEN;
memcpy(&request.extra.str[0], uuid, VIR_UUID_BUFLEN);
req->data.arg = ident;
}
break;
}
case VIR_PROXY_NODE_INFO:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
/*
* Hum, could we expect those information to be unmutable and
* cache them ? Since it's probably an unfrequent call better
* not make assumption and do the xend RPC each call.
*/
ret = xenDaemonNodeGetInfo(conn, &request.extra.ninfo);
if (ret < 0) {
req->data.arg = -1;
req->len = sizeof(virProxyPacket);
} else {
req->data.arg = 0;
req->len = sizeof(virProxyPacket) + sizeof(virNodeInfo);
}
break;
case VIR_PROXY_GET_CAPABILITIES:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
xml = xenHypervisorGetCapabilities (conn);
if (!xml) {
@ -612,21 +612,21 @@ retry2:
}
break;
case VIR_PROXY_DOMAIN_XML:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
case VIR_PROXY_DOMAIN_XML:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
/*
* Ideally we should get the CPUs used by the domain
* but that information is really node specific and it
* rather hard to get from that code path. So proxy
* users won't see CPU pinning (last NULL arg)
*/
xml = xenDaemonDomainDumpXMLByID(conn, request.data.arg, 0, NULL);
* Ideally we should get the CPUs used by the domain
* but that information is really node specific and it
* rather hard to get from that code path. So proxy
* users won't see CPU pinning (last NULL arg)
*/
xml = xenDaemonDomainDumpXMLByID(conn, request.data.arg, 0, NULL);
if (!xml) {
req->data.arg = -1;
req->len = sizeof(virProxyPacket);
} else {
} else {
int xmllen = strlen(xml);
if (xmllen > (int) sizeof(request.extra.str)) {
req->data.arg = -2;
@ -637,17 +637,17 @@ retry2:
req->len = sizeof(virProxyPacket) + xmllen;
}
free(xml);
}
break;
case VIR_PROXY_DOMAIN_OSTYPE:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
}
break;
case VIR_PROXY_DOMAIN_OSTYPE:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
ostype = xenStoreDomainGetOSTypeID(conn, request.data.arg);
ostype = xenStoreDomainGetOSTypeID(conn, request.data.arg);
if (!ostype) {
req->data.arg = -1;
req->len = sizeof(virProxyPacket);
} else {
} else {
int ostypelen = strlen(ostype);
if (ostypelen > (int) sizeof(request.extra.str)) {
req->data.arg = -2;
@ -658,17 +658,17 @@ retry2:
req->len = sizeof(virProxyPacket) + ostypelen;
}
free(ostype);
}
break;
default:
goto comm_error;
}
break;
default:
goto comm_error;
}
ret = proxyWriteClientSocket(nr, req);
return(ret);
comm_error:
fprintf(stderr,
"Communication error with client %d: malformed packet\n", nr);
"Communication error with client %d: malformed packet\n", nr);
proxyCloseClientSocket(nr);
return(-1);
}
@ -691,59 +691,59 @@ proxyProcessRequests(void) {
while (!done) {
/*
* wait for requests, with a one second timeout
*/
* wait for requests, with a one second timeout
*/
ret = poll(&pollInfos[0], nbClients + 1, 1000);
if (ret == 0) { /* timeout */
if ((nbClients == 0) && (persist == 0)) {
exit_timeout--;
if (exit_timeout == 0) {
done = 1;
if (debug > 0) {
fprintf(stderr, "Exitting after 30s without clients\n");
}
}
} else
exit_timeout = 30;
if (debug > 1)
fprintf(stderr, "poll timeout\n");
continue;
} else if (ret < 0) {
if (errno == EINTR) {
if (debug > 0)
fprintf(stderr, "poll syscall interrupted\n");
continue;
}
fprintf(stderr, "poll syscall failed\n");
break;
}
/*
* there have been I/O to process
*/
exit_timeout = 30;
if (pollInfos[0].revents != 0) {
if (pollInfos[0].revents & POLLIN) {
proxyAcceptClientSocket();
} else {
fprintf(stderr, "Got an error %d on incoming socket %d\n",
pollInfos[0].revents, pollInfos[0].fd);
break;
}
}
if (ret == 0) { /* timeout */
if ((nbClients == 0) && (persist == 0)) {
exit_timeout--;
if (exit_timeout == 0) {
done = 1;
if (debug > 0) {
fprintf(stderr, "Exitting after 30s without clients\n");
}
}
} else
exit_timeout = 30;
if (debug > 1)
fprintf(stderr, "poll timeout\n");
continue;
} else if (ret < 0) {
if (errno == EINTR) {
if (debug > 0)
fprintf(stderr, "poll syscall interrupted\n");
continue;
}
fprintf(stderr, "poll syscall failed\n");
break;
}
/*
* there have been I/O to process
*/
exit_timeout = 30;
if (pollInfos[0].revents != 0) {
if (pollInfos[0].revents & POLLIN) {
proxyAcceptClientSocket();
} else {
fprintf(stderr, "Got an error %d on incoming socket %d\n",
pollInfos[0].revents, pollInfos[0].fd);
break;
}
}
/*
* process the clients in reverse order since on error or disconnect
* pollInfos is compacted to remove the given client.
*/
for (i = nbClients;i > 0;i--) {
if (pollInfos[i].revents & POLLIN) {
proxyReadClientSocket(i);
} else if (pollInfos[i].revents != 0) {
fprintf(stderr, "Got an error %d on client %d socket %d\n",
pollInfos[i].revents, i, pollInfos[i].fd);
proxyCloseClientSocket(i);
}
}
/*
* process the clients in reverse order since on error or disconnect
* pollInfos is compacted to remove the given client.
*/
for (i = nbClients;i > 0;i--) {
if (pollInfos[i].revents & POLLIN) {
proxyReadClientSocket(i);
} else if (pollInfos[i].revents != 0) {
fprintf(stderr, "Got an error %d on client %d socket %d\n",
pollInfos[i].revents, i, pollInfos[i].fd);
proxyCloseClientSocket(i);
}
}
}
}
@ -758,9 +758,9 @@ proxyProcessRequests(void) {
static void
proxyMainLoop(void) {
while (! done) {
if (proxyListenUnixSocket(PROXY_SOCKET_PATH) < 0)
break;
proxyProcessRequests();
if (proxyListenUnixSocket(PROXY_SOCKET_PATH) < 0)
break;
proxyProcessRequests();
}
proxyCloseClientSockets();
}
@ -790,32 +790,32 @@ int main(int argc, char **argv) {
if (!setlocale(LC_ALL, "")) {
perror("setlocale");
return -1;
return -1;
}
if (!bindtextdomain(GETTEXT_PACKAGE, LOCALEBASEDIR)) {
perror("bindtextdomain");
return -1;
return -1;
}
if (!textdomain(GETTEXT_PACKAGE)) {
perror("textdomain");
return -1;
return -1;
}
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-v")) {
debug++;
debug++;
} else if (!strcmp(argv[i], "-no-timeout")) {
persist = 1;
} else {
usage(argv[0]);
exit(1);
}
persist = 1;
} else {
usage(argv[0]);
exit(1);
}
}
if (geteuid() != 0) {
fprintf(stderr, "%s must be run as root or suid\n", argv[0]);
/* exit(1); */
/* exit(1); */
}
/*
@ -832,7 +832,7 @@ int main(int argc, char **argv) {
if (proxyListenUnixSocket(PROXY_SOCKET_PATH) < 0)
exit(0);
if (proxyInitXen() == 0)
proxyMainLoop();
proxyMainLoop();
sleep(1);
proxyCloseUnixSocket();
exit(0);

View File

@ -76,7 +76,7 @@ libvirt_virDomainInterfaceStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
if (!PyArg_ParseTuple(args, (char *)"Oz:virDomainInterfaceStats",
&pyobj_domain,&path))
return(NULL);
return(NULL);
domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
c_retval = virDomainInterfaceStats(domain, path, &stats, sizeof(stats));
@ -498,14 +498,14 @@ libvirt_virErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, virErrorPtr err)
Py_XINCREF(libvirt_virPythonErrorFuncCtxt);
PyTuple_SetItem(info, 0, PyInt_FromLong((long) err->code));
PyTuple_SetItem(info, 1, PyInt_FromLong((long) err->domain));
PyTuple_SetItem(info, 2, libvirt_constcharPtrWrap(err->message));
PyTuple_SetItem(info, 2, libvirt_constcharPtrWrap(err->message));
PyTuple_SetItem(info, 3, PyInt_FromLong((long) err->level));
PyTuple_SetItem(info, 4, libvirt_constcharPtrWrap(err->str1));
PyTuple_SetItem(info, 5, libvirt_constcharPtrWrap(err->str2));
PyTuple_SetItem(info, 6, libvirt_constcharPtrWrap(err->str3));
PyTuple_SetItem(info, 4, libvirt_constcharPtrWrap(err->str1));
PyTuple_SetItem(info, 5, libvirt_constcharPtrWrap(err->str2));
PyTuple_SetItem(info, 6, libvirt_constcharPtrWrap(err->str3));
PyTuple_SetItem(info, 7, PyInt_FromLong((long) err->int1));
PyTuple_SetItem(info, 8, PyInt_FromLong((long) err->int2));
/* TODO pass conn and dom if available */
/* TODO pass conn and dom if available */
result = PyEval_CallObject(libvirt_virPythonErrorFuncHandler, list);
Py_XDECREF(list);
Py_XDECREF(result);
@ -542,14 +542,14 @@ libvirt_virRegisterErrorHandler(ATTRIBUTE_UNUSED PyObject * self,
if ((pyobj_f == Py_None) && (pyobj_ctx == Py_None)) {
libvirt_virPythonErrorFuncHandler = NULL;
libvirt_virPythonErrorFuncCtxt = NULL;
libvirt_virPythonErrorFuncCtxt = NULL;
} else {
Py_XINCREF(pyobj_ctx);
Py_XINCREF(pyobj_f);
Py_XINCREF(pyobj_ctx);
Py_XINCREF(pyobj_f);
/* TODO: check f is a function ! */
libvirt_virPythonErrorFuncHandler = pyobj_f;
libvirt_virPythonErrorFuncCtxt = pyobj_ctx;
/* TODO: check f is a function ! */
libvirt_virPythonErrorFuncHandler = pyobj_f;
libvirt_virPythonErrorFuncCtxt = pyobj_ctx;
}
py_retval = libvirt_intWrap(1);
@ -738,7 +738,7 @@ libvirt_virConnectListDomainsID(PyObject *self ATTRIBUTE_UNUSED,
static PyObject *
libvirt_virConnectListDefinedDomains(PyObject *self ATTRIBUTE_UNUSED,
PyObject *args) {
PyObject *args) {
PyObject *py_retval;
char **names = NULL;
int c_retval, i;
@ -884,7 +884,7 @@ libvirt_virDomainLookupByUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
static PyObject *
libvirt_virConnectListNetworks(PyObject *self ATTRIBUTE_UNUSED,
PyObject *args) {
PyObject *args) {
PyObject *py_retval;
char **names = NULL;
int c_retval, i;
@ -926,7 +926,7 @@ libvirt_virConnectListNetworks(PyObject *self ATTRIBUTE_UNUSED,
static PyObject *
libvirt_virConnectListDefinedNetworks(PyObject *self ATTRIBUTE_UNUSED,
PyObject *args) {
PyObject *args) {
PyObject *py_retval;
char **names = NULL;
int c_retval, i;
@ -1092,8 +1092,8 @@ error:
}
py_retval = PyList_New(c_retval);
for (i = 0;i < c_retval;i++) {
PyList_SetItem(py_retval, i,
libvirt_longlongWrap((long long) freeMems[i]));
PyList_SetItem(py_retval, i,
libvirt_longlongWrap((long long) freeMems[i]));
}
free(freeMems);
return(py_retval);

View File

@ -22,7 +22,7 @@
#endif
#define PyvirConnect_Get(v) (((v) == Py_None) ? NULL : \
(((PyvirConnect_Object *)(v))->obj))
(((PyvirConnect_Object *)(v))->obj))
typedef struct {
PyObject_HEAD
@ -31,7 +31,7 @@ typedef struct {
#define PyvirDomain_Get(v) (((v) == Py_None) ? NULL : \
(((PyvirDomain_Object *)(v))->obj))
(((PyvirDomain_Object *)(v))->obj))
typedef struct {
PyObject_HEAD
@ -40,7 +40,7 @@ typedef struct {
#define PyvirNetwork_Get(v) (((v) == Py_None) ? NULL : \
(((PyvirNetwork_Object *)(v))->obj))
(((PyvirNetwork_Object *)(v))->obj))
typedef struct {
PyObject_HEAD
@ -49,7 +49,7 @@ typedef struct {
#define PyvirStoragePool_Get(v) (((v) == Py_None) ? NULL : \
(((PyvirStoragePool_Object *)(v))->obj))
(((PyvirStoragePool_Object *)(v))->obj))
typedef struct {
PyObject_HEAD
@ -58,7 +58,7 @@ typedef struct {
#define PyvirStorageVol_Get(v) (((v) == Py_None) ? NULL : \
(((PyvirStorageVol_Object *)(v))->obj))
(((PyvirStorageVol_Object *)(v))->obj))
typedef struct {
PyObject_HEAD

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -254,32 +254,32 @@ virBufferEscapeString(virBufferPtr buf, const char *format, const char *str)
out = escaped;
while (*cur != 0) {
if (*cur == '<') {
*out++ = '&';
*out++ = 'l';
*out++ = 't';
*out++ = ';';
} else if (*cur == '>') {
*out++ = '&';
*out++ = 'g';
*out++ = 't';
*out++ = ';';
} else if (*cur == '&') {
*out++ = '&';
*out++ = 'a';
*out++ = 'm';
*out++ = 'p';
*out++ = ';';
} else if ((*cur >= 0x20) || (*cur == '\n') || (*cur == '\t') ||
(*cur == '\r')) {
/*
* default case, just copy !
* Note that character over 0x80 are likely to give problem
* with UTF-8 XML, but since our string don't have an encoding
* it's hard to handle properly we have to assume it's UTF-8 too
*/
*out++ = *cur;
}
cur++;
*out++ = '&';
*out++ = 'l';
*out++ = 't';
*out++ = ';';
} else if (*cur == '>') {
*out++ = '&';
*out++ = 'g';
*out++ = 't';
*out++ = ';';
} else if (*cur == '&') {
*out++ = '&';
*out++ = 'a';
*out++ = 'm';
*out++ = 'p';
*out++ = ';';
} else if ((*cur >= 0x20) || (*cur == '\n') || (*cur == '\t') ||
(*cur == '\r')) {
/*
* default case, just copy !
* Note that character over 0x80 are likely to give problem
* with UTF-8 XML, but since our string don't have an encoding
* it's hard to handle properly we have to assume it's UTF-8 too
*/
*out++ = *cur;
}
cur++;
}
*out = 0;
@ -289,7 +289,7 @@ virBufferEscapeString(virBufferPtr buf, const char *format, const char *str)
buf->content[buf->use] = 0;
grow_size = (count > 1000) ? count : 1000;
if (virBufferGrow(buf, grow_size) < 0) {
free(escaped);
free(escaped);
return (-1);
}
size = buf->size - buf->use - 1;

View File

@ -48,11 +48,11 @@ struct _virConfParserCtxt {
#define IS_BLANK(c) (((c) == ' ') || ((c) == '\n') || ((c) == '\r') || \
((c) == '\t'))
#define SKIP_BLANKS {while ((ctxt->cur < ctxt->end) && (IS_BLANK(CUR))){\
if (CUR == '\n') ctxt->line++; \
ctxt->cur++;}}
if (CUR == '\n') ctxt->line++; \
ctxt->cur++;}}
#define IS_SPACE(c) (((c) == ' ') || ((c) == '\t'))
#define SKIP_SPACES {while ((ctxt->cur < ctxt->end) && (IS_SPACE(CUR))) \
ctxt->cur++;}
ctxt->cur++;}
#define IS_CHAR(c) ((((c) >= 'a') && ((c) <= 'z')) || \
(((c) >= 'A') && ((c) <= 'Z')))
#define IS_DIGIT(c) (((c) >= '0') && ((c) <= '9'))
@ -216,9 +216,9 @@ virConfAddEntry(virConfPtr conf, char *name, virConfValuePtr value, char *comm)
conf->entries = ret;
} else {
prev = conf->entries;
while (prev->next != NULL)
prev = prev->next;
prev->next = ret;
while (prev->next != NULL)
prev = prev->next;
prev->next = ret;
}
return(ret);
}
@ -245,40 +245,40 @@ virConfSaveValue(virBufferPtr buf, virConfValuePtr val)
return(-1);
switch (val->type) {
case VIR_CONF_NONE:
return(-1);
case VIR_CONF_LONG:
virBufferVSprintf(buf, "%ld", val->l);
break;
case VIR_CONF_STRING:
if (strchr(val->str, '\n') != NULL) {
virBufferVSprintf(buf, "\"\"\"%s\"\"\"", val->str);
} else if (strchr(val->str, '"') == NULL) {
virBufferVSprintf(buf, "\"%s\"", val->str);
} else if (strchr(val->str, '\'') == NULL) {
virBufferVSprintf(buf, "'%s'", val->str);
} else {
virBufferVSprintf(buf, "\"\"\"%s\"\"\"", val->str);
}
break;
case VIR_CONF_LIST: {
virConfValuePtr cur;
return(-1);
case VIR_CONF_LONG:
virBufferVSprintf(buf, "%ld", val->l);
break;
case VIR_CONF_STRING:
if (strchr(val->str, '\n') != NULL) {
virBufferVSprintf(buf, "\"\"\"%s\"\"\"", val->str);
} else if (strchr(val->str, '"') == NULL) {
virBufferVSprintf(buf, "\"%s\"", val->str);
} else if (strchr(val->str, '\'') == NULL) {
virBufferVSprintf(buf, "'%s'", val->str);
} else {
virBufferVSprintf(buf, "\"\"\"%s\"\"\"", val->str);
}
break;
case VIR_CONF_LIST: {
virConfValuePtr cur;
cur = val->list;
virBufferAddLit(buf, "[ ");
if (cur != NULL) {
virConfSaveValue(buf, cur);
cur = cur->next;
while (cur != NULL) {
virBufferAddLit(buf, ", ");
virConfSaveValue(buf, cur);
cur = cur->next;
}
}
virBufferAddLit(buf, " ]");
break;
}
default:
return(-1);
cur = val->list;
virBufferAddLit(buf, "[ ");
if (cur != NULL) {
virConfSaveValue(buf, cur);
cur = cur->next;
while (cur != NULL) {
virBufferAddLit(buf, ", ");
virConfSaveValue(buf, cur);
cur = cur->next;
}
}
virBufferAddLit(buf, " ]");
break;
}
default:
return(-1);
}
return(0);
}
@ -297,15 +297,15 @@ virConfSaveEntry(virBufferPtr buf, virConfEntryPtr cur)
{
if (cur->name != NULL) {
virBufferAdd(buf, cur->name, -1);
virBufferAddLit(buf, " = ");
virConfSaveValue(buf, cur->value);
if (cur->comment != NULL) {
virBufferAddLit(buf, " #");
virBufferAdd(buf, cur->comment, -1);
}
virBufferAddLit(buf, " = ");
virConfSaveValue(buf, cur->value);
if (cur->comment != NULL) {
virBufferAddLit(buf, " #");
virBufferAdd(buf, cur->comment, -1);
}
} else if (cur->comment != NULL) {
virBufferAddLit(buf, "#");
virBufferAdd(buf, cur->comment, -1);
virBufferAddLit(buf, "#");
virBufferAdd(buf, cur->comment, -1);
}
virBufferAddLit(buf, "\n");
return(0);
@ -334,18 +334,18 @@ virConfParseLong(virConfParserCtxtPtr ctxt, long *val)
if (CUR == '-') {
neg = 1;
NEXT;
NEXT;
} else if (CUR == '+') {
NEXT;
}
if ((ctxt->cur >= ctxt->end) || (!IS_DIGIT(CUR))) {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("unterminated number"),
ctxt->line);
return(-1);
ctxt->line);
return(-1);
}
while ((ctxt->cur < ctxt->end) && (IS_DIGIT(CUR))) {
l = l * 10 + (CUR - '0');
NEXT;
NEXT;
}
if (neg)
l = -l;
@ -369,45 +369,45 @@ virConfParseString(virConfParserCtxtPtr ctxt)
if (CUR == '\'') {
NEXT;
base = ctxt->cur;
while ((ctxt->cur < ctxt->end) && (CUR != '\'') && (!IS_EOL(CUR)))
NEXT;
if (CUR != '\'') {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("unterminated string"),
ctxt->line);
return(NULL);
}
ret = strndup(base, ctxt->cur - base);
NEXT;
base = ctxt->cur;
while ((ctxt->cur < ctxt->end) && (CUR != '\'') && (!IS_EOL(CUR)))
NEXT;
if (CUR != '\'') {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("unterminated string"),
ctxt->line);
return(NULL);
}
ret = strndup(base, ctxt->cur - base);
NEXT;
} else if ((ctxt->cur + 6 < ctxt->end) && (ctxt->cur[0] == '"') &&
(ctxt->cur[1] == '"') && (ctxt->cur[2] == '"')) {
ctxt->cur += 3;
base = ctxt->cur;
while ((ctxt->cur + 2 < ctxt->end) && (ctxt->cur[0] == '"') &&
(ctxt->cur[1] == '"') && (ctxt->cur[2] == '"')) {
if (CUR == '\n') ctxt->line++;
NEXT;
}
if ((ctxt->cur[0] != '"') || (ctxt->cur[1] != '"') ||
(ctxt->cur[2] != '"')) {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("unterminated string"),
ctxt->line);
return(NULL);
}
ret = strndup(base, ctxt->cur - base);
ctxt->cur += 3;
ctxt->cur += 3;
base = ctxt->cur;
while ((ctxt->cur + 2 < ctxt->end) && (ctxt->cur[0] == '"') &&
(ctxt->cur[1] == '"') && (ctxt->cur[2] == '"')) {
if (CUR == '\n') ctxt->line++;
NEXT;
}
if ((ctxt->cur[0] != '"') || (ctxt->cur[1] != '"') ||
(ctxt->cur[2] != '"')) {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("unterminated string"),
ctxt->line);
return(NULL);
}
ret = strndup(base, ctxt->cur - base);
ctxt->cur += 3;
} else if (CUR == '"') {
NEXT;
base = ctxt->cur;
while ((ctxt->cur < ctxt->end) && (CUR != '"') && (!IS_EOL(CUR)))
NEXT;
if (CUR != '"') {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("unterminated string"),
ctxt->line);
return(NULL);
}
ret = strndup(base, ctxt->cur - base);
NEXT;
base = ctxt->cur;
while ((ctxt->cur < ctxt->end) && (CUR != '"') && (!IS_EOL(CUR)))
NEXT;
if (CUR != '"') {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("unterminated string"),
ctxt->line);
return(NULL);
}
ret = strndup(base, ctxt->cur - base);
NEXT;
}
return(ret);
}
@ -431,66 +431,66 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
SKIP_SPACES;
if (ctxt->cur >= ctxt->end) {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("expecting a value"),
ctxt->line);
return(NULL);
ctxt->line);
return(NULL);
}
if ((CUR == '"') || (CUR == '\'')) {
type = VIR_CONF_STRING;
str = virConfParseString(ctxt);
if (str == NULL)
return(NULL);
if (str == NULL)
return(NULL);
} else if (CUR == '[') {
type = VIR_CONF_LIST;
NEXT;
SKIP_BLANKS;
if ((ctxt->cur < ctxt->end) && (CUR != ']')) {
lst = virConfParseValue(ctxt);
SKIP_BLANKS;
}
while ((ctxt->cur < ctxt->end) && (CUR != ']')) {
if (CUR != ',') {
virConfError(NULL, VIR_ERR_CONF_SYNTAX,
_("expecting a separator in list"), ctxt->line);
virConfFreeList(lst);
return(NULL);
}
NEXT;
SKIP_BLANKS;
if (CUR == ']') {
break;
}
tmp = virConfParseValue(ctxt);
if (tmp == NULL) {
virConfFreeList(lst);
return(NULL);
}
prev = lst;
while (prev->next != NULL) prev = prev->next;
prev->next = tmp;
SKIP_BLANKS;
}
if (CUR == ']') {
NEXT;
} else {
virConfError(NULL, VIR_ERR_CONF_SYNTAX,
_("list is not closed with ]"), ctxt->line);
virConfFreeList(lst);
return(NULL);
}
SKIP_BLANKS;
if ((ctxt->cur < ctxt->end) && (CUR != ']')) {
lst = virConfParseValue(ctxt);
SKIP_BLANKS;
}
while ((ctxt->cur < ctxt->end) && (CUR != ']')) {
if (CUR != ',') {
virConfError(NULL, VIR_ERR_CONF_SYNTAX,
_("expecting a separator in list"), ctxt->line);
virConfFreeList(lst);
return(NULL);
}
NEXT;
SKIP_BLANKS;
if (CUR == ']') {
break;
}
tmp = virConfParseValue(ctxt);
if (tmp == NULL) {
virConfFreeList(lst);
return(NULL);
}
prev = lst;
while (prev->next != NULL) prev = prev->next;
prev->next = tmp;
SKIP_BLANKS;
}
if (CUR == ']') {
NEXT;
} else {
virConfError(NULL, VIR_ERR_CONF_SYNTAX,
_("list is not closed with ]"), ctxt->line);
virConfFreeList(lst);
return(NULL);
}
} else if (IS_DIGIT(CUR) || (CUR == '-') || (CUR == '+')) {
if (virConfParseLong(ctxt, &l) < 0) {
return(NULL);
}
return(NULL);
}
type = VIR_CONF_LONG;
} else {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("expecting a value"),
ctxt->line);
return(NULL);
ctxt->line);
return(NULL);
}
ret = calloc(1, sizeof(*ret));
if (ret == NULL) {
virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"), 0);
free(str);
free(str);
return(NULL);
}
ret->type = type;
@ -519,14 +519,14 @@ virConfParseName(virConfParserCtxtPtr ctxt)
/* TODO: probably need encoding support and UTF-8 parsing ! */
if (!IS_CHAR(CUR)) {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("expecting a name"), ctxt->line);
return(NULL);
return(NULL);
}
while ((ctxt->cur < ctxt->end) && ((IS_CHAR(CUR)) || (IS_DIGIT(CUR)) || (CUR == '_')))
NEXT;
ret = strndup(base, ctxt->cur - base);
if (ret == NULL) {
virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"),
ctxt->line);
ctxt->line);
return(NULL);
}
return(ret);
@ -554,7 +554,7 @@ virConfParseComment(virConfParserCtxtPtr ctxt)
comm = strndup(base, ctxt->cur - base);
if (comm == NULL) {
virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"),
ctxt->line);
ctxt->line);
return(-1);
}
virConfAddEntry(ctxt->conf, NULL, NULL, comm);
@ -574,16 +574,16 @@ virConfParseSeparator(virConfParserCtxtPtr ctxt)
{
SKIP_SPACES;
if (ctxt->cur >= ctxt->end)
return(0);
return(0);
if (IS_EOL(CUR)) {
SKIP_BLANKS
SKIP_BLANKS
} else if (CUR == ';') {
NEXT;
SKIP_BLANKS;
NEXT;
SKIP_BLANKS;
} else {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("expecting a separator"),
ctxt->line);
return(-1);
ctxt->line);
return(-1);
}
return(0);
}
@ -614,7 +614,7 @@ virConfParseStatement(virConfParserCtxtPtr ctxt)
SKIP_SPACES;
if (CUR != '=') {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("expecting an assignment"),
ctxt->line);
ctxt->line);
return(-1);
}
NEXT;
@ -622,27 +622,27 @@ virConfParseStatement(virConfParserCtxtPtr ctxt)
value = virConfParseValue(ctxt);
if (value == NULL) {
free(name);
return(-1);
return(-1);
}
SKIP_SPACES;
if (CUR == '#') {
NEXT;
base = ctxt->cur;
while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT;
comm = strndup(base, ctxt->cur - base);
if (comm == NULL) {
virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"),
ctxt->line);
free(name);
virConfFreeValue(value);
return(-1);
}
NEXT;
base = ctxt->cur;
while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT;
comm = strndup(base, ctxt->cur - base);
if (comm == NULL) {
virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"),
ctxt->line);
free(name);
virConfFreeValue(value);
return(-1);
}
}
if (virConfAddEntry(ctxt->conf, name, value, comm) == NULL) {
free(name);
virConfFreeValue(value);
virConfFreeValue(value);
free(comm);
return(-1);
return(-1);
}
return(0);
}
@ -674,9 +674,9 @@ virConfParse(const char *filename, const char *content, int len) {
while (ctxt.cur < ctxt.end) {
if (virConfParseStatement(&ctxt) < 0)
goto error;
if (virConfParseSeparator(&ctxt) < 0)
goto error;
goto error;
if (virConfParseSeparator(&ctxt) < 0)
goto error;
}
return(ctxt.conf);
@ -801,7 +801,7 @@ __virConfGetValue(virConfPtr conf, const char *setting)
cur = conf->entries;
while (cur != NULL) {
if ((cur->name != NULL) && (!strcmp(cur->name, setting)))
return(cur->value);
return(cur->value);
cur = cur->next;
}
return(NULL);
@ -894,14 +894,14 @@ __virConfWriteFile(const char *filename, virConfPtr conf)
cur = conf->entries;
while (cur != NULL) {
virConfSaveEntry(buf, cur);
cur = cur->next;
cur = cur->next;
}
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR );
if (fd < 0) {
virConfError(NULL, VIR_ERR_WRITE_FAILED, _("failed to open file"), 0);
ret = -1;
goto error;
goto error;
}
ret = safewrite(fd, buf->content, buf->use);
@ -909,7 +909,7 @@ __virConfWriteFile(const char *filename, virConfPtr conf)
if (ret != (int) buf->use) {
virConfError(NULL, VIR_ERR_WRITE_FAILED, _("failed to save content"), 0);
ret = -1;
goto error;
goto error;
}
error:
virBufferFree(buf);

View File

@ -68,19 +68,19 @@ typedef virConf *virConfPtr;
virConfPtr __virConfNew (void);
virConfPtr __virConfReadFile (const char *filename);
virConfPtr __virConfReadMem (const char *memory,
int len);
int len);
int __virConfFree (virConfPtr conf);
virConfValuePtr __virConfGetValue (virConfPtr conf,
const char *setting);
const char *setting);
int __virConfSetValue (virConfPtr conf,
const char *setting,
virConfValuePtr value);
const char *setting,
virConfValuePtr value);
int __virConfWriteFile (const char *filename,
virConfPtr conf);
virConfPtr conf);
int __virConfWriteMem (char *memory,
int *len,
virConfPtr conf);
int *len,
virConfPtr conf);
#define virConfNew() (__virConfNew())
#define virConfReadFile(f) (__virConfReadFile((f)))

View File

@ -71,146 +71,146 @@ typedef enum {
((drv)->supports_feature ? (drv)->supports_feature((conn),(feature)) : 0)
typedef const char *
(*virDrvProbe) (void);
(*virDrvProbe) (void);
typedef virDrvOpenStatus
(*virDrvOpen) (virConnectPtr conn,
(*virDrvOpen) (virConnectPtr conn,
xmlURIPtr uri,
virConnectAuthPtr auth,
int flags);
typedef int
(*virDrvClose) (virConnectPtr conn);
(*virDrvClose) (virConnectPtr conn);
typedef int
(*virDrvSupportsFeature) (virConnectPtr conn, int feature);
typedef const char *
(*virDrvGetType) (virConnectPtr conn);
(*virDrvGetType) (virConnectPtr conn);
typedef int
(*virDrvGetVersion) (virConnectPtr conn,
unsigned long *hvVer);
(*virDrvGetVersion) (virConnectPtr conn,
unsigned long *hvVer);
typedef char *
(*virDrvGetHostname) (virConnectPtr conn);
typedef char *
(*virDrvGetURI) (virConnectPtr conn);
typedef int
(*virDrvGetMaxVcpus) (virConnectPtr conn,
const char *type);
(*virDrvGetMaxVcpus) (virConnectPtr conn,
const char *type);
typedef int
(*virDrvNodeGetInfo) (virConnectPtr conn,
virNodeInfoPtr info);
(*virDrvNodeGetInfo) (virConnectPtr conn,
virNodeInfoPtr info);
typedef char *
(*virDrvGetCapabilities) (virConnectPtr conn);
(*virDrvGetCapabilities) (virConnectPtr conn);
typedef int
(*virDrvListDomains) (virConnectPtr conn,
int *ids,
int maxids);
(*virDrvListDomains) (virConnectPtr conn,
int *ids,
int maxids);
typedef int
(*virDrvNumOfDomains) (virConnectPtr conn);
(*virDrvNumOfDomains) (virConnectPtr conn);
typedef virDomainPtr
(*virDrvDomainCreateLinux) (virConnectPtr conn,
const char *xmlDesc,
unsigned int flags);
(*virDrvDomainCreateLinux) (virConnectPtr conn,
const char *xmlDesc,
unsigned int flags);
typedef virDomainPtr
(*virDrvDomainLookupByID) (virConnectPtr conn,
int id);
(*virDrvDomainLookupByID) (virConnectPtr conn,
int id);
typedef virDomainPtr
(*virDrvDomainLookupByUUID) (virConnectPtr conn,
const unsigned char *uuid);
(*virDrvDomainLookupByUUID) (virConnectPtr conn,
const unsigned char *uuid);
typedef virDomainPtr
(*virDrvDomainLookupByName) (virConnectPtr conn,
const char *name);
(*virDrvDomainLookupByName) (virConnectPtr conn,
const char *name);
typedef int
(*virDrvDomainSuspend) (virDomainPtr domain);
(*virDrvDomainSuspend) (virDomainPtr domain);
typedef int
(*virDrvDomainResume) (virDomainPtr domain);
(*virDrvDomainResume) (virDomainPtr domain);
typedef int
(*virDrvDomainShutdown) (virDomainPtr domain);
(*virDrvDomainShutdown) (virDomainPtr domain);
typedef int
(*virDrvDomainReboot) (virDomainPtr domain,
unsigned int flags);
(*virDrvDomainReboot) (virDomainPtr domain,
unsigned int flags);
typedef int
(*virDrvDomainDestroy) (virDomainPtr domain);
(*virDrvDomainDestroy) (virDomainPtr domain);
typedef char *
(*virDrvDomainGetOSType) (virDomainPtr domain);
(*virDrvDomainGetOSType) (virDomainPtr domain);
typedef unsigned long
(*virDrvDomainGetMaxMemory) (virDomainPtr domain);
(*virDrvDomainGetMaxMemory) (virDomainPtr domain);
typedef int
(*virDrvDomainSetMaxMemory) (virDomainPtr domain,
unsigned long memory);
(*virDrvDomainSetMaxMemory) (virDomainPtr domain,
unsigned long memory);
typedef int
(*virDrvDomainSetMemory) (virDomainPtr domain,
unsigned long memory);
(*virDrvDomainSetMemory) (virDomainPtr domain,
unsigned long memory);
typedef int
(*virDrvDomainGetInfo) (virDomainPtr domain,
virDomainInfoPtr info);
(*virDrvDomainGetInfo) (virDomainPtr domain,
virDomainInfoPtr info);
typedef int
(*virDrvDomainSave) (virDomainPtr domain,
const char *to);
(*virDrvDomainSave) (virDomainPtr domain,
const char *to);
typedef int
(*virDrvDomainRestore) (virConnectPtr conn,
const char *from);
(*virDrvDomainRestore) (virConnectPtr conn,
const char *from);
typedef int
(*virDrvDomainCoreDump) (virDomainPtr domain,
const char *to,
int flags);
(*virDrvDomainCoreDump) (virDomainPtr domain,
const char *to,
int flags);
typedef char *
(*virDrvDomainDumpXML) (virDomainPtr dom,
int flags);
(*virDrvDomainDumpXML) (virDomainPtr dom,
int flags);
typedef int
(*virDrvListDefinedDomains) (virConnectPtr conn,
char **const names,
int maxnames);
(*virDrvListDefinedDomains) (virConnectPtr conn,
char **const names,
int maxnames);
typedef int
(*virDrvNumOfDefinedDomains) (virConnectPtr conn);
(*virDrvNumOfDefinedDomains) (virConnectPtr conn);
typedef int
(*virDrvDomainCreate) (virDomainPtr dom);
(*virDrvDomainCreate) (virDomainPtr dom);
typedef virDomainPtr
(*virDrvDomainDefineXML) (virConnectPtr conn,
const char *xml);
(*virDrvDomainDefineXML) (virConnectPtr conn,
const char *xml);
typedef int
(*virDrvDomainUndefine) (virDomainPtr dom);
(*virDrvDomainUndefine) (virDomainPtr dom);
typedef int
(*virDrvDomainSetVcpus) (virDomainPtr domain,
unsigned int nvcpus);
(*virDrvDomainSetVcpus) (virDomainPtr domain,
unsigned int nvcpus);
typedef int
(*virDrvDomainPinVcpu) (virDomainPtr domain,
unsigned int vcpu,
unsigned char *cpumap,
int maplen);
(*virDrvDomainPinVcpu) (virDomainPtr domain,
unsigned int vcpu,
unsigned char *cpumap,
int maplen);
typedef int
(*virDrvDomainGetVcpus) (virDomainPtr domain,
virVcpuInfoPtr info,
int maxinfo,
unsigned char *cpumaps,
int maplen);
(*virDrvDomainGetVcpus) (virDomainPtr domain,
virVcpuInfoPtr info,
int maxinfo,
unsigned char *cpumaps,
int maplen);
typedef int
(*virDrvDomainGetMaxVcpus) (virDomainPtr domain);
(*virDrvDomainGetMaxVcpus) (virDomainPtr domain);
typedef int
(*virDrvDomainAttachDevice) (virDomainPtr domain,
const char *xml);
(*virDrvDomainAttachDevice) (virDomainPtr domain,
const char *xml);
typedef int
(*virDrvDomainDetachDevice) (virDomainPtr domain,
const char *xml);
(*virDrvDomainDetachDevice) (virDomainPtr domain,
const char *xml);
typedef int
(*virDrvDomainGetAutostart) (virDomainPtr domain,
int *autostart);
(*virDrvDomainGetAutostart) (virDomainPtr domain,
int *autostart);
typedef int
(*virDrvDomainSetAutostart) (virDomainPtr domain,
int autostart);
(*virDrvDomainSetAutostart) (virDomainPtr domain,
int autostart);
typedef char *
(*virDrvDomainGetSchedulerType) (virDomainPtr domain,
int *nparams);
(*virDrvDomainGetSchedulerType) (virDomainPtr domain,
int *nparams);
typedef int
(*virDrvDomainGetSchedulerParameters)
(virDomainPtr domain,
virSchedParameterPtr params,
int *nparams);
(*virDrvDomainGetSchedulerParameters)
(virDomainPtr domain,
virSchedParameterPtr params,
int *nparams);
typedef int
(*virDrvDomainSetSchedulerParameters)
(virDomainPtr domain,
virSchedParameterPtr params,
int nparams);
(*virDrvDomainSetSchedulerParameters)
(virDomainPtr domain,
virSchedParameterPtr params,
int nparams);
typedef int
(*virDrvDomainBlockStats)
@ -265,7 +265,7 @@ typedef int
typedef unsigned long long
(*virDrvNodeGetFreeMemory)
(virConnectPtr conn);
(virConnectPtr conn);
/**
* _virDriver:
@ -340,46 +340,46 @@ struct _virDriver {
};
typedef int
(*virDrvNumOfNetworks) (virConnectPtr conn);
(*virDrvNumOfNetworks) (virConnectPtr conn);
typedef int
(*virDrvListNetworks) (virConnectPtr conn,
char **const names,
int maxnames);
(*virDrvListNetworks) (virConnectPtr conn,
char **const names,
int maxnames);
typedef int
(*virDrvNumOfDefinedNetworks) (virConnectPtr conn);
(*virDrvNumOfDefinedNetworks) (virConnectPtr conn);
typedef int
(*virDrvListDefinedNetworks) (virConnectPtr conn,
char **const names,
int maxnames);
(*virDrvListDefinedNetworks) (virConnectPtr conn,
char **const names,
int maxnames);
typedef virNetworkPtr
(*virDrvNetworkLookupByUUID) (virConnectPtr conn,
const unsigned char *uuid);
(*virDrvNetworkLookupByUUID) (virConnectPtr conn,
const unsigned char *uuid);
typedef virNetworkPtr
(*virDrvNetworkLookupByName) (virConnectPtr conn,
const char *name);
(*virDrvNetworkLookupByName) (virConnectPtr conn,
const char *name);
typedef virNetworkPtr
(*virDrvNetworkCreateXML) (virConnectPtr conn,
const char *xmlDesc);
(*virDrvNetworkCreateXML) (virConnectPtr conn,
const char *xmlDesc);
typedef virNetworkPtr
(*virDrvNetworkDefineXML) (virConnectPtr conn,
const char *xml);
(*virDrvNetworkDefineXML) (virConnectPtr conn,
const char *xml);
typedef int
(*virDrvNetworkUndefine) (virNetworkPtr network);
(*virDrvNetworkUndefine) (virNetworkPtr network);
typedef int
(*virDrvNetworkCreate) (virNetworkPtr network);
(*virDrvNetworkCreate) (virNetworkPtr network);
typedef int
(*virDrvNetworkDestroy) (virNetworkPtr network);
(*virDrvNetworkDestroy) (virNetworkPtr network);
typedef char *
(*virDrvNetworkDumpXML) (virNetworkPtr network,
int flags);
(*virDrvNetworkDumpXML) (virNetworkPtr network,
int flags);
typedef char *
(*virDrvNetworkGetBridgeName) (virNetworkPtr network);
(*virDrvNetworkGetBridgeName) (virNetworkPtr network);
typedef int
(*virDrvNetworkGetAutostart) (virNetworkPtr network,
int *autostart);
(*virDrvNetworkGetAutostart) (virNetworkPtr network,
int *autostart);
typedef int
(*virDrvNetworkSetAutostart) (virNetworkPtr network,
int autostart);
(*virDrvNetworkSetAutostart) (virNetworkPtr network,
int autostart);
typedef struct _virNetworkDriver virNetworkDriver;
@ -396,24 +396,24 @@ typedef virNetworkDriver *virNetworkDriverPtr;
* - close
*/
struct _virNetworkDriver {
const char * name; /* the name of the driver */
virDrvOpen open;
virDrvClose close;
virDrvNumOfNetworks numOfNetworks;
virDrvListNetworks listNetworks;
virDrvNumOfDefinedNetworks numOfDefinedNetworks;
virDrvListDefinedNetworks listDefinedNetworks;
virDrvNetworkLookupByUUID networkLookupByUUID;
virDrvNetworkLookupByName networkLookupByName;
virDrvNetworkCreateXML networkCreateXML;
virDrvNetworkDefineXML networkDefineXML;
virDrvNetworkUndefine networkUndefine;
virDrvNetworkCreate networkCreate;
virDrvNetworkDestroy networkDestroy;
virDrvNetworkDumpXML networkDumpXML;
virDrvNetworkGetBridgeName networkGetBridgeName;
virDrvNetworkGetAutostart networkGetAutostart;
virDrvNetworkSetAutostart networkSetAutostart;
const char * name; /* the name of the driver */
virDrvOpen open;
virDrvClose close;
virDrvNumOfNetworks numOfNetworks;
virDrvListNetworks listNetworks;
virDrvNumOfDefinedNetworks numOfDefinedNetworks;
virDrvListDefinedNetworks listDefinedNetworks;
virDrvNetworkLookupByUUID networkLookupByUUID;
virDrvNetworkLookupByName networkLookupByName;
virDrvNetworkCreateXML networkCreateXML;
virDrvNetworkDefineXML networkDefineXML;
virDrvNetworkUndefine networkUndefine;
virDrvNetworkCreate networkCreate;
virDrvNetworkDestroy networkDestroy;
virDrvNetworkDumpXML networkDumpXML;
virDrvNetworkGetBridgeName networkGetBridgeName;
virDrvNetworkGetAutostart networkGetAutostart;
virDrvNetworkSetAutostart networkSetAutostart;
};

View File

@ -119,11 +119,11 @@ typedef void (*virEventUpdateTimeoutFunc)(int, int);
typedef int (*virEventRemoveTimeoutFunc)(int);
void __virEventRegisterImpl(virEventAddHandleFunc addHandle,
virEventUpdateHandleFunc updateHandle,
virEventRemoveHandleFunc removeHandle,
virEventAddTimeoutFunc addTimeout,
virEventUpdateTimeoutFunc updateTimeout,
virEventRemoveTimeoutFunc removeTimeout);
virEventUpdateHandleFunc updateHandle,
virEventRemoveHandleFunc removeHandle,
virEventAddTimeoutFunc addTimeout,
virEventUpdateTimeoutFunc updateTimeout,
virEventRemoveTimeoutFunc removeTimeout);
#define virEventRegisterImpl(ah,rh,at,rt) __virEventRegisterImpl(ah,rh,at,rt)

View File

@ -66,16 +66,16 @@ int virHashSize(virHashTablePtr table);
* Add a new entry to the hash table.
*/
int virHashAddEntry(virHashTablePtr table,
const char *name, void *userdata);
const char *name, void *userdata);
int virHashUpdateEntry(virHashTablePtr table,
const char *name,
void *userdata, virHashDeallocator f);
const char *name,
void *userdata, virHashDeallocator f);
/*
* Remove an entry from the hash table.
*/
int virHashRemoveEntry(virHashTablePtr table,
const char *name, virHashDeallocator f);
const char *name, virHashDeallocator f);
/*
* Retrieve the userdata.

View File

@ -266,15 +266,15 @@ struct _virStorageVol {
************************************************************************/
extern virError __lastErr;
void __virRaiseError(virConnectPtr conn,
virDomainPtr dom,
virNetworkPtr net,
int domain,
int code,
virErrorLevel level,
const char *str1,
const char *str2,
const char *str3,
int int1, int int2, const char *msg, ...)
virDomainPtr dom,
virNetworkPtr net,
int domain,
int code,
virErrorLevel level,
const char *str1,
const char *str2,
const char *str3,
int int1, int int2, const char *msg, ...)
ATTRIBUTE_FORMAT(printf, 12, 13);
const char *__virErrorMsg(virErrorNumber error, const char *info);

View File

@ -454,12 +454,12 @@ virRegisterNetworkDriver(virNetworkDriverPtr driver)
if (driver == NULL) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
return(-1);
}
if (virNetworkDriverTabCount >= MAX_DRIVERS) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
}
virNetworkDriverTab[virNetworkDriverTabCount] = driver;
@ -486,7 +486,7 @@ virRegisterStorageDriver(virStorageDriverPtr driver)
}
if (virStorageDriverTabCount >= MAX_DRIVERS) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
}
@ -510,16 +510,16 @@ virRegisterDriver(virDriverPtr driver)
if (driver == NULL) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
return(-1);
}
if (virDriverTabCount >= MAX_DRIVERS) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
}
if (driver->no < 0) {
virLibConnError
virLibConnError
(NULL, VIR_ERR_INVALID_ARG,
"virRegisterDriver: tried to register an internal Xen driver");
return -1;
@ -549,7 +549,7 @@ virRegisterStateDriver(virStateDriverPtr driver)
}
if (virStateDriverTabCount >= MAX_DRIVERS) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
}
@ -633,7 +633,7 @@ virGetVersion(unsigned long *libVer, const char *type,
if (!initialized)
if (virInitialize() < 0)
return -1;
return -1;
if (libVer == NULL)
return (-1);
@ -641,14 +641,14 @@ virGetVersion(unsigned long *libVer, const char *type,
if (typeVer != NULL) {
if (type == NULL)
type = "Xen";
for (i = 0;i < virDriverTabCount;i++) {
if ((virDriverTab[i] != NULL) &&
(!strcasecmp(virDriverTab[i]->name, type))) {
*typeVer = virDriverTab[i]->ver;
break;
}
}
type = "Xen";
for (i = 0;i < virDriverTabCount;i++) {
if ((virDriverTab[i] != NULL) &&
(!strcasecmp(virDriverTab[i]->name, type))) {
*typeVer = virDriverTab[i]->ver;
break;
}
}
if (i >= virDriverTabCount) {
*typeVer = 0;
virLibConnError(NULL, VIR_ERR_NO_SUPPORT, type);
@ -675,38 +675,38 @@ do_open (const char *name,
if (!name || name[0] == '\0') {
char *defname = getenv("LIBVIRT_DEFAULT_URI");
if (defname && *defname) {
DEBUG("Using LIBVIRT_DEFAULT_URI %s", defname);
DEBUG("Using LIBVIRT_DEFAULT_URI %s", defname);
name = defname;
} else {
const char *use = NULL;
const char *latest;
int probes = 0;
for (i = 0; i < virNetworkDriverTabCount; i++) {
if ((virDriverTab[i]->probe != NULL) &&
((latest = virDriverTab[i]->probe()) != NULL)) {
probes++;
const char *use = NULL;
const char *latest;
int probes = 0;
for (i = 0; i < virNetworkDriverTabCount; i++) {
if ((virDriverTab[i]->probe != NULL) &&
((latest = virDriverTab[i]->probe()) != NULL)) {
probes++;
DEBUG("Probed %s", latest);
/*
* if running a xen kernel, give it priority over
* QEmu emulation
*/
if (STREQ(latest, "xen:///"))
use = latest;
else if (use == NULL)
use = latest;
}
}
if (use == NULL) {
name = "xen:///";
DEBUG("Could not probe any hypervisor defaulting to %s",
name);
} else {
name = use;
DEBUG("Using %s as default URI, %d hypervisor found",
use, probes);
}
}
DEBUG("Probed %s", latest);
/*
* if running a xen kernel, give it priority over
* QEmu emulation
*/
if (STREQ(latest, "xen:///"))
use = latest;
else if (use == NULL)
use = latest;
}
}
if (use == NULL) {
name = "xen:///";
DEBUG("Could not probe any hypervisor defaulting to %s",
name);
} else {
name = use;
DEBUG("Using %s as default URI, %d hypervisor found",
use, probes);
}
}
}
/* Convert xen -> xen:/// for back compat */
@ -824,7 +824,7 @@ do_open (const char *name,
failed:
if (ret->driver) ret->driver->close (ret);
if (uri) xmlFreeURI(uri);
virUnrefConnect(ret);
virUnrefConnect(ret);
return NULL;
}
@ -1218,7 +1218,7 @@ virDomainCreateLinux(virConnectPtr conn, const char *xmlDesc,
}
if (conn->flags & VIR_CONNECT_RO) {
virLibConnError(conn, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (NULL);
return (NULL);
}
if (conn->driver->domainCreateLinux)
@ -1334,8 +1334,8 @@ virDomainLookupByUUIDString(virConnectPtr conn, const char *uuidstr)
raw + 12, raw + 13, raw + 14, raw + 15);
if (ret!=VIR_UUID_BUFLEN) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (NULL);
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (NULL);
}
for (i = 0; i < VIR_UUID_BUFLEN; i++)
uuid[i] = raw[i] & 0xFF;
@ -1401,7 +1401,7 @@ virDomainDestroy(virDomainPtr domain)
conn = domain->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
if (conn->driver->domainDestroy)
@ -1458,7 +1458,7 @@ virDomainSuspend(virDomainPtr domain)
}
if (domain->conn->flags & VIR_CONNECT_RO) {
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
conn = domain->conn;
@ -1492,7 +1492,7 @@ virDomainResume(virDomainPtr domain)
}
if (domain->conn->flags & VIR_CONNECT_RO) {
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
conn = domain->conn;
@ -1529,7 +1529,7 @@ virDomainSave(virDomainPtr domain, const char *to)
}
if (domain->conn->flags & VIR_CONNECT_RO) {
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
conn = domain->conn;
if (to == NULL) {
@ -1585,7 +1585,7 @@ virDomainRestore(virConnectPtr conn, const char *from)
}
if (conn->flags & VIR_CONNECT_RO) {
virLibConnError(conn, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
if (from == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
@ -1643,7 +1643,7 @@ virDomainCoreDump(virDomainPtr domain, const char *to, int flags)
}
if (domain->conn->flags & VIR_CONNECT_RO) {
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
conn = domain->conn;
if (to == NULL) {
@ -1703,7 +1703,7 @@ virDomainShutdown(virDomainPtr domain)
}
if (domain->conn->flags & VIR_CONNECT_RO) {
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
conn = domain->conn;
@ -1738,7 +1738,7 @@ virDomainReboot(virDomainPtr domain, unsigned int flags)
}
if (domain->conn->flags & VIR_CONNECT_RO) {
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
conn = domain->conn;
@ -1930,7 +1930,7 @@ virDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
if (domain == NULL) {
TODO
return (-1);
return (-1);
}
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
@ -1938,7 +1938,7 @@ virDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
}
if (domain->conn->flags & VIR_CONNECT_RO) {
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
if (memory < 4096) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
@ -1973,7 +1973,7 @@ virDomainSetMemory(virDomainPtr domain, unsigned long memory)
if (domain == NULL) {
TODO
return (-1);
return (-1);
}
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
@ -1981,7 +1981,7 @@ virDomainSetMemory(virDomainPtr domain, unsigned long memory)
}
if (domain->conn->flags & VIR_CONNECT_RO) {
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
if (memory < 4096) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
@ -2413,7 +2413,7 @@ virDomainGetSchedulerType(virDomainPtr domain, int *nparams)
*/
int
virDomainGetSchedulerParameters(virDomainPtr domain,
virSchedParameterPtr params, int *nparams)
virSchedParameterPtr params, int *nparams)
{
virConnectPtr conn;
DEBUG("domain=%p, params=%p, nparams=%p", domain, params, nparams);
@ -2445,7 +2445,7 @@ virDomainGetSchedulerParameters(virDomainPtr domain,
*/
int
virDomainSetSchedulerParameters(virDomainPtr domain,
virSchedParameterPtr params, int nparams)
virSchedParameterPtr params, int nparams)
{
virConnectPtr conn;
DEBUG("domain=%p, params=%p, nparams=%d", domain, params, nparams);
@ -2601,7 +2601,7 @@ virDomainDefineXML(virConnectPtr conn, const char *xml) {
}
if (conn->flags & VIR_CONNECT_RO) {
virLibConnError(conn, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (NULL);
return (NULL);
}
if (xml == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
@ -2635,7 +2635,7 @@ virDomainUndefine(virDomainPtr domain) {
conn = domain->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
if (conn->driver->domainUndefine)
@ -2719,7 +2719,7 @@ virDomainCreate(virDomainPtr domain) {
if (domain == NULL) {
TODO
return (-1);
return (-1);
}
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
@ -2728,7 +2728,7 @@ virDomainCreate(virDomainPtr domain) {
conn = domain->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
if (conn->driver->domainCreate)
@ -2826,7 +2826,7 @@ virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
if (domain == NULL) {
TODO
return (-1);
return (-1);
}
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
@ -2834,7 +2834,7 @@ virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
}
if (domain->conn->flags & VIR_CONNECT_RO) {
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
if (nvcpus < 1) {
@ -2877,7 +2877,7 @@ virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
if (domain == NULL) {
TODO
return (-1);
return (-1);
}
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
@ -2885,7 +2885,7 @@ virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
}
if (domain->conn->flags & VIR_CONNECT_RO) {
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
if ((vcpu > 32000) || (cpumap == NULL) || (maplen < 1)) {
@ -2925,14 +2925,14 @@ virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
*/
int
virDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
unsigned char *cpumaps, int maplen)
unsigned char *cpumaps, int maplen)
{
virConnectPtr conn;
DEBUG("domain=%p, info=%p, maxinfo=%d, cpumaps=%p, maplen=%d", domain, info, maxinfo, cpumaps, maplen);
if (domain == NULL) {
TODO
return (-1);
return (-1);
}
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
@ -3011,7 +3011,7 @@ virDomainAttachDevice(virDomainPtr domain, const char *xml)
}
if (domain->conn->flags & VIR_CONNECT_RO) {
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
conn = domain->conn;
@ -3043,7 +3043,7 @@ virDomainDetachDevice(virDomainPtr domain, const char *xml)
}
if (domain->conn->flags & VIR_CONNECT_RO) {
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
conn = domain->conn;
@ -3342,8 +3342,8 @@ virNetworkLookupByUUIDString(virConnectPtr conn, const char *uuidstr)
raw + 12, raw + 13, raw + 14, raw + 15);
if (ret!=VIR_UUID_BUFLEN) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (NULL);
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (NULL);
}
for (i = 0; i < VIR_UUID_BUFLEN; i++)
uuid[i] = raw[i] & 0xFF;
@ -3376,7 +3376,7 @@ virNetworkCreateXML(virConnectPtr conn, const char *xmlDesc)
}
if (conn->flags & VIR_CONNECT_RO) {
virLibConnError(conn, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (NULL);
return (NULL);
}
if (conn->networkDriver && conn->networkDriver->networkCreateXML)
@ -3406,7 +3406,7 @@ virNetworkDefineXML(virConnectPtr conn, const char *xml)
}
if (conn->flags & VIR_CONNECT_RO) {
virLibConnError(conn, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (NULL);
return (NULL);
}
if (xml == NULL) {
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
@ -3440,7 +3440,7 @@ virNetworkUndefine(virNetworkPtr network) {
conn = network->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibNetworkError(network, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
if (conn->networkDriver && conn->networkDriver->networkUndefine)
@ -3467,7 +3467,7 @@ virNetworkCreate(virNetworkPtr network)
if (network == NULL) {
TODO
return (-1);
return (-1);
}
if (!VIR_IS_CONNECTED_NETWORK(network)) {
virLibNetworkError(NULL, VIR_ERR_INVALID_NETWORK, __FUNCTION__);
@ -3476,7 +3476,7 @@ virNetworkCreate(virNetworkPtr network)
conn = network->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibNetworkError(network, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
if (conn->networkDriver && conn->networkDriver->networkCreate)
@ -3512,7 +3512,7 @@ virNetworkDestroy(virNetworkPtr network)
conn = network->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibNetworkError(network, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return (-1);
return (-1);
}
if (conn->networkDriver && conn->networkDriver->networkDestroy)
@ -3987,7 +3987,7 @@ virStoragePoolLookupByUUID(virConnectPtr conn,
*/
virStoragePoolPtr
virStoragePoolLookupByUUIDString(virConnectPtr conn,
const char *uuidstr)
const char *uuidstr)
{
unsigned char uuid[VIR_UUID_BUFLEN];
DEBUG("conn=%p, uuidstr=%s", conn, uuidstr);

View File

@ -183,10 +183,10 @@ static int lxcParseDomainUUID(virConnectPtr conn, unsigned char *uuid,
if (virUUIDParse(res, uuid) < 0) {
lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
_("invalid uuid element"));
free(res);
free(res);
return(-1);
}
free(res);
free(res);
}
return(0);
}
@ -228,7 +228,7 @@ static int lxcParseDomainMounts(virConnectPtr conn,
}
prevObj = mountObj;
}
free(list);
free(list);
}
rc = nmounts;
@ -253,7 +253,7 @@ static int lxcParseDomainInit(virConnectPtr conn, char** init,
lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
_("init string too long"));
free(res);
return(-1);
return(-1);
}
*init = res;
@ -270,10 +270,10 @@ static int lxcParseDomainTty(virConnectPtr conn, char **tty, xmlXPathContextPtr
if (res == NULL) {
/* make sure the tty string is empty */
*tty = strdup("");
if (*tty == NULL) {
lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL);
return(-1);
}
if (*tty == NULL) {
lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL);
return(-1);
}
} else {
*tty = res;
}
@ -288,14 +288,14 @@ static int lxcParseDomainMemory(virConnectPtr conn, int* memory, xmlXPathContext
rc = virXPathLong("string(/domain/memory[1])", contextPtr, &res);
if ((rc == -2) || ((rc == 0) && (res <= 0))) {
*memory = -1;
lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
_("invalid memory value"));
*memory = -1;
lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
_("invalid memory value"));
} else if (rc < 0) {
/* not an error, default to an invalid value so it's not used */
*memory = -1;
*memory = -1;
} else {
*memory = (int) res;
*memory = (int) res;
}
return(0);
}
@ -656,7 +656,7 @@ int lxcLoadContainerInfo(lxc_driver_t *driver)
} else {
lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("failed to open config directory %s: %s"),
driver->configDir, strerror(errno));
driver->configDir, strerror(errno));
}
goto load_complete;
@ -700,12 +700,12 @@ char *lxcGenerateXML(virConnectPtr conn,
if (lxcIsActiveVM(vm)) {
if (virBufferVSprintf(buf, "<domain type='%s' id='%d'>\n",
LXC_DOMAIN_TYPE, vm->def->id) < 0) {
LXC_DOMAIN_TYPE, vm->def->id) < 0) {
goto no_memory;
}
} else {
if (virBufferVSprintf(buf, "<domain type='%s'>\n",
LXC_DOMAIN_TYPE) < 0) {
if (virBufferVSprintf(buf, "<domain type='%s'>\n",
LXC_DOMAIN_TYPE) < 0) {
goto no_memory;
}
}

View File

@ -238,8 +238,8 @@ openvzAssignVMDef(virConnectPtr conn,
else
{
openvzLog(OPENVZ_ERR,
_("Error already an active OPENVZ VM having id '%s'"),
def->name);
_("Error already an active OPENVZ VM having id '%s'"),
def->name);
openvzFreeVMDef(def);
return NULL; /* can't redefine an active domain */
}
@ -342,7 +342,7 @@ static struct openvz_vm_def
/* rejecting VPS ID <= OPENVZ_RSRV_VM_LIMIT for they are reserved */
if (strtoI((const char *) obj->stringval) <= OPENVZ_RSRV_VM_LIMIT) {
error(conn, VIR_ERR_INTERNAL_ERROR,
_("VPS ID Error (must be an integer greater than 100"));
_("VPS ID Error (must be an integer greater than 100"));
goto bail_out;
}
strncpy(def->name, (const char *) obj->stringval, OPENVZ_NAME_MAX);
@ -385,20 +385,20 @@ static struct openvz_vm_def
if ((obj == NULL) || (obj->type != XPATH_STRING) || (obj->stringval == NULL)
|| (obj->stringval[0] == 0)) {
openvzLog(OPENVZ_WARN,
_("No IP address in the given xml config file '%s'"),
xml->name);
_("No IP address in the given xml config file '%s'"),
xml->name);
}
if (xmlStrlen(obj->stringval) >= (OPENVZ_IP_MAX)) {
char errorMessage[OPENVZ_MAX_ERROR_LEN];
snprintf(errorMessage, OPENVZ_MAX_ERROR_LEN - 1, "%s",
_("ipaddress length too long"));
_("ipaddress length too long"));
error(conn, VIR_ERR_INTERNAL_ERROR, errorMessage);
goto bail_out;
}
if (!(ovzIp = calloc(1, sizeof(*ovzIp)))) {
openvzLog(OPENVZ_ERR,
_("Failed to Create Memory for 'ovz_ip' structure"));
_("Failed to Create Memory for 'ovz_ip' structure"));
goto bail_out;
}
strncpy(ovzIp->ip, (const char *) obj->stringval, OPENVZ_IP_MAX);
@ -410,14 +410,14 @@ static struct openvz_vm_def
if ((obj == NULL) || (obj->type != XPATH_STRING)
|| (obj->stringval == NULL) || (obj->stringval[0] == 0))
openvzLog(OPENVZ_WARN,
_("No Netmask address in the given xml config file '%s'"),
xml->name);
_("No Netmask address in the given xml config file '%s'"),
xml->name);
if (strlen((const char *) obj->stringval) >= (OPENVZ_IP_MAX)) {
char errorMessage[OPENVZ_MAX_ERROR_LEN];
snprintf(errorMessage, OPENVZ_MAX_ERROR_LEN - 1, "%s",
_("netmask length too long"));
_("netmask length too long"));
error(conn, VIR_ERR_INTERNAL_ERROR, errorMessage);
goto bail_out;
}
@ -429,14 +429,14 @@ static struct openvz_vm_def
if ((obj == NULL) || (obj->type != XPATH_STRING) || (obj->stringval == NULL)
|| (obj->stringval[0] == 0))
openvzLog(OPENVZ_WARN,
_("No hostname in the given xml config file '%s'"),
xml->name);
_("No hostname in the given xml config file '%s'"),
xml->name);
if (strlen((const char *) obj->stringval) >= (OPENVZ_HOSTNAME_MAX - 1)) {
char errorMessage[OPENVZ_MAX_ERROR_LEN];
snprintf(errorMessage, OPENVZ_MAX_ERROR_LEN - 1,
"%s", _("hostname length too long"));
"%s", _("hostname length too long"));
error(conn, VIR_ERR_INTERNAL_ERROR, errorMessage);
goto bail_out;
}
@ -448,8 +448,8 @@ static struct openvz_vm_def
if ((obj == NULL) || (obj->type != XPATH_STRING) || (obj->stringval == NULL)
|| (obj->stringval[0] == 0))
openvzLog(OPENVZ_WARN,
_("No Gateway address in the given xml config file '%s'"),
xml->name);
_("No Gateway address in the given xml config file '%s'"),
xml->name);
if (strlen((const char *) obj->stringval) >= (OPENVZ_IP_MAX)) {
char errorMessage[OPENVZ_MAX_ERROR_LEN];
@ -467,8 +467,8 @@ static struct openvz_vm_def
if ((obj == NULL) || (obj->type != XPATH_STRING) || (obj->stringval == NULL)
|| (obj->stringval[0] == 0))
openvzLog(OPENVZ_WARN,
_("No Nameserver address inthe given xml config file '%s'"),
xml->name);
_("No Nameserver address inthe given xml config file '%s'"),
xml->name);
if (strlen((const char *) obj->stringval) >= (OPENVZ_IP_MAX)) {
char errorMessage[OPENVZ_MAX_ERROR_LEN];
@ -549,10 +549,10 @@ openvzGetVPSInfo(virConnectPtr conn) {
vm = *pnext;
if (fscanf(fp, "%d %s\n", &veid, status) != 2) {
error(conn, VIR_ERR_INTERNAL_ERROR,
_("Failed to parse vzlist output"));
goto error;
}
error(conn, VIR_ERR_INTERNAL_ERROR,
_("Failed to parse vzlist output"));
goto error;
}
if(strcmp(status, "stopped")) {
(*pnext)->status = VIR_DOMAIN_RUNNING;
driver->num_active ++;
@ -561,17 +561,17 @@ openvzGetVPSInfo(virConnectPtr conn) {
else {
(*pnext)->status = VIR_DOMAIN_SHUTOFF;
driver->num_inactive ++;
/*
* inactive domains don't have their ID set in libvirt,
* thought this doesn't make sense for OpenVZ
*/
/*
* inactive domains don't have their ID set in libvirt,
* thought this doesn't make sense for OpenVZ
*/
(*pnext)->vpsid = -1;
}
vmdef = calloc(1, sizeof(*vmdef));
if(!vmdef) {
error(conn, VIR_ERR_INTERNAL_ERROR, _("calloc failed"));
goto error;
goto error;
}
snprintf(vmdef->name, OPENVZ_NAME_MAX, "%i", veid);
@ -580,8 +580,8 @@ openvzGetVPSInfo(virConnectPtr conn) {
if(ret == -1) {
error(conn, VIR_ERR_INTERNAL_ERROR,
_("UUID in config file malformed"));
free(vmdef);
_("UUID in config file malformed"));
free(vmdef);
goto error;
}
@ -593,10 +593,10 @@ error:
while (vm != NULL) {
struct openvz_vm *next;
next = vm->next;
free(vm->vmdef);
free(vm);
vm = next;
next = vm->next;
free(vm->vmdef);
free(vm);
vm = next;
}
return NULL;
}
@ -609,7 +609,7 @@ static char
while(conf_dir_list[i]) {
if(!access(conf_dir_list[i], F_OK))
return strdup(conf_dir_list[i]);
return strdup(conf_dir_list[i]);
i ++;
}
@ -703,18 +703,18 @@ openvzSetUUID(int vpsid)
return -1;
if (uuidstr[0] == 0) {
FILE *fp = fopen(conf_file, "a"); /* append */
if (fp == NULL)
return -1;
FILE *fp = fopen(conf_file, "a"); /* append */
if (fp == NULL)
return -1;
virUUIDGenerate(uuid);
virUUIDFormat(uuid, uuidstr);
/* Record failure if fprintf or fclose fails,
and be careful always to close the stream. */
if ((fprintf(fp, "\n#UUID: %s\n", uuidstr) < 0)
+ (fclose(fp) == EOF))
return -1;
/* Record failure if fprintf or fclose fails,
and be careful always to close the stream. */
if ((fprintf(fp, "\n#UUID: %s\n", uuidstr) < 0)
+ (fclose(fp) == EOF))
return -1;
}
return 0;

View File

@ -44,11 +44,11 @@ struct openvz_driver {
int openvzRegister(void);
#define openvzLog(level, msg...) { if(level == OPENVZ_WARN) \
fprintf(stderr, "\nWARNING: ");\
else \
fprintf(stderr, "\nERROR: ");\
fprintf(stderr, "\n\t");\
fprintf(stderr, msg);\
fprintf(stderr, "\n"); }
fprintf(stderr, "\nWARNING: ");\
else \
fprintf(stderr, "\nERROR: ");\
fprintf(stderr, "\n\t");\
fprintf(stderr, msg);\
fprintf(stderr, "\n"); }
#endif

View File

@ -174,7 +174,7 @@ virProxyForkServer(void)
if (!proxyPath) {
fprintf(stderr, "failed to find libvirt_proxy\n");
return(-1);
return(-1);
}
if (debug)
@ -184,12 +184,12 @@ virProxyForkServer(void)
pid = fork();
if (pid == 0) {
long open_max;
long i;
long i;
/* don't hold open fd opened from the client of the library */
open_max = sysconf (_SC_OPEN_MAX);
for (i = 0; i < open_max; i++)
fcntl (i, F_SETFD, FD_CLOEXEC);
open_max = sysconf (_SC_OPEN_MAX);
for (i = 0; i < open_max; i++)
fcntl (i, F_SETFD, FD_CLOEXEC);
setsid();
if (fork() == 0) {
@ -238,7 +238,7 @@ virProxyOpenClientSocket(const char *path) {
retry:
fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
return(-1);
return(-1);
}
/*
@ -254,15 +254,15 @@ retry:
* now bind the socket to that address and listen on it
*/
if (connect(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
close(fd);
if (trials < 3) {
if (virProxyForkServer() < 0)
return(-1);
trials++;
usleep(5000 * trials * trials);
goto retry;
}
return (-1);
close(fd);
if (trials < 3) {
if (virProxyForkServer() < 0)
return(-1);
trials++;
usleep(5000 * trials * trials);
goto retry;
}
return (-1);
}
if (debug > 0)
@ -290,7 +290,7 @@ virProxyCloseClientSocket(int fd) {
if (ret != 0)
fprintf(stderr, _("Failed to close socket %d\n"), fd);
else if (debug > 0)
fprintf(stderr, "Closed socket %d\n", fd);
fprintf(stderr, "Closed socket %d\n", fd);
return(ret);
}
@ -316,18 +316,18 @@ retry:
ret = read(fd, buffer, len);
if (ret < 0) {
if (errno == EINTR) {
if (debug > 0)
fprintf(stderr, "read socket %d interrupted\n", fd);
goto retry;
}
if (!quiet)
if (debug > 0)
fprintf(stderr, "read socket %d interrupted\n", fd);
goto retry;
}
if (!quiet)
fprintf(stderr, _("Failed to read socket %d\n"), fd);
return(-1);
return(-1);
}
if (debug)
fprintf(stderr, "read %d bytes from socket %d\n",
ret, fd);
fprintf(stderr, "read %d bytes from socket %d\n",
ret, fd);
return(ret);
}
@ -352,8 +352,8 @@ virProxyWriteClientSocket(int fd, const char *data, int len) {
return(-1);
}
if (debug)
fprintf(stderr, "wrote %d bytes to socket %d\n",
len, fd);
fprintf(stderr, "wrote %d bytes to socket %d\n",
len, fd);
return(0);
}
@ -434,59 +434,59 @@ xenProxyCommand(virConnectPtr conn, virProxyPacketPtr request,
retry:
if (answer == NULL) {
/* read in situ */
ret = virProxyReadClientSocket(priv->proxy, (char *) request,
sizeof(virProxyPacket), quiet);
if (ret < 0)
return(-1);
if (ret != sizeof(virProxyPacket)) {
fprintf(stderr,
_("Communication error with proxy: got %d bytes of %d\n"),
ret, (int) sizeof(virProxyPacket));
xenProxyClose(conn);
return(-1);
}
res = request;
if (res->len != sizeof(virProxyPacket)) {
fprintf(stderr,
_("Communication error with proxy: expected %d bytes got %d\n"),
(int) sizeof(virProxyPacket), res->len);
xenProxyClose(conn);
return(-1);
}
ret = virProxyReadClientSocket(priv->proxy, (char *) request,
sizeof(virProxyPacket), quiet);
if (ret < 0)
return(-1);
if (ret != sizeof(virProxyPacket)) {
fprintf(stderr,
_("Communication error with proxy: got %d bytes of %d\n"),
ret, (int) sizeof(virProxyPacket));
xenProxyClose(conn);
return(-1);
}
res = request;
if (res->len != sizeof(virProxyPacket)) {
fprintf(stderr,
_("Communication error with proxy: expected %d bytes got %d\n"),
(int) sizeof(virProxyPacket), res->len);
xenProxyClose(conn);
return(-1);
}
} else {
/* read in packet provided */
ret = virProxyReadClientSocket(priv->proxy, (char *) answer,
sizeof(virProxyPacket), quiet);
if (ret < 0)
return(-1);
if (ret != sizeof(virProxyPacket)) {
fprintf(stderr,
_("Communication error with proxy: got %d bytes of %d\n"),
ret, (int) sizeof(virProxyPacket));
xenProxyClose(conn);
return(-1);
}
res = (virProxyPacketPtr) answer;
if ((res->len < sizeof(virProxyPacket)) ||
(res->len > sizeof(virProxyFullPacket))) {
fprintf(stderr,
_("Communication error with proxy: got %d bytes packet\n"),
res->len);
xenProxyClose(conn);
return(-1);
}
if (res->len > sizeof(virProxyPacket)) {
ret = virProxyReadClientSocket(priv->proxy,
(char *) &(answer->extra.arg[0]),
res->len - ret, quiet);
if (ret != (int) (res->len - sizeof(virProxyPacket))) {
fprintf(stderr,
_("Communication error with proxy: got %d bytes of %d\n"),
ret, (int) sizeof(virProxyPacket));
xenProxyClose(conn);
return(-1);
}
}
sizeof(virProxyPacket), quiet);
if (ret < 0)
return(-1);
if (ret != sizeof(virProxyPacket)) {
fprintf(stderr,
_("Communication error with proxy: got %d bytes of %d\n"),
ret, (int) sizeof(virProxyPacket));
xenProxyClose(conn);
return(-1);
}
res = (virProxyPacketPtr) answer;
if ((res->len < sizeof(virProxyPacket)) ||
(res->len > sizeof(virProxyFullPacket))) {
fprintf(stderr,
_("Communication error with proxy: got %d bytes packet\n"),
res->len);
xenProxyClose(conn);
return(-1);
}
if (res->len > sizeof(virProxyPacket)) {
ret = virProxyReadClientSocket(priv->proxy,
(char *) &(answer->extra.arg[0]),
res->len - ret, quiet);
if (ret != (int) (res->len - sizeof(virProxyPacket))) {
fprintf(stderr,
_("Communication error with proxy: got %d bytes of %d\n"),
ret, (int) sizeof(virProxyPacket));
xenProxyClose(conn);
return(-1);
}
}
}
/*
* do more checks on the incoming packet.
@ -500,7 +500,7 @@ retry:
}
if (res->serial != serial) {
TODO /* Asynchronous communication */
fprintf(stderr, _("got asynchronous packet number %d\n"), res->serial);
fprintf(stderr, _("got asynchronous packet number %d\n"), res->serial);
goto retry;
}
return(0);
@ -536,7 +536,7 @@ xenProxyOpen(virConnectPtr conn,
fd = virProxyOpenClientSocket(PROXY_SOCKET_PATH);
if (fd < 0) {
virProxyError(NULL, VIR_ERR_NO_XEN, PROXY_SOCKET_PATH);
virProxyError(NULL, VIR_ERR_NO_XEN, PROXY_SOCKET_PATH);
return(-1);
}
priv->proxy = fd;
@ -546,9 +546,9 @@ xenProxyOpen(virConnectPtr conn,
req.len = sizeof(req);
ret = xenProxyCommand(conn, &req, NULL, 1);
if ((ret < 0) || (req.command != VIR_PROXY_NONE)) {
virProxyError(NULL, VIR_ERR_OPERATION_FAILED, __FUNCTION__);
virProxyError(NULL, VIR_ERR_OPERATION_FAILED, __FUNCTION__);
xenProxyClose(conn);
return(-1);
return(-1);
}
return(0);
}
@ -582,7 +582,7 @@ xenProxyGetVersion(virConnectPtr conn, unsigned long *hvVer)
}
if (hvVer == NULL) {
virProxyError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (-1);
return (-1);
}
memset(&req, 0, sizeof(req));
req.command = VIR_PROXY_VERSION;
@ -590,7 +590,7 @@ xenProxyGetVersion(virConnectPtr conn, unsigned long *hvVer)
ret = xenProxyCommand(conn, &req, NULL, 0);
if (ret < 0) {
xenProxyClose(conn);
return(-1);
return(-1);
}
*hvVer = req.data.larg;
return(0);
@ -620,7 +620,7 @@ xenProxyListDomains(virConnectPtr conn, int *ids, int maxids)
}
if ((ids == NULL) || (maxids <= 0)) {
virProxyError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (-1);
return (-1);
}
memset(&req, 0, sizeof(req));
req.command = VIR_PROXY_LIST;
@ -628,12 +628,12 @@ xenProxyListDomains(virConnectPtr conn, int *ids, int maxids)
ret = xenProxyCommand(conn, &req, &ans, 0);
if (ret < 0) {
xenProxyClose(conn);
return(-1);
return(-1);
}
nb = ans.data.arg;
if ((nb > 1020) || (nb <= 0) ||
(ans.len <= sizeof(virProxyPacket)) ||
(ans.len > sizeof(virProxyFullPacket))) {
(ans.len > sizeof(virProxyFullPacket))) {
virProxyError(conn, VIR_ERR_OPERATION_FAILED, __FUNCTION__);
return(-1);
}
@ -668,7 +668,7 @@ xenProxyNumOfDomains(virConnectPtr conn)
ret = xenProxyCommand(conn, &req, NULL, 0);
if (ret < 0) {
xenProxyClose(conn);
return(-1);
return(-1);
}
return(req.data.arg);
}
@ -717,10 +717,10 @@ static unsigned long
xenProxyDomainGetMaxMemory(virDomainPtr domain)
{
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
if (domain == NULL)
virProxyError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
else
virProxyError(domain->conn, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
if (domain == NULL)
virProxyError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
else
virProxyError(domain->conn, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
return (0);
}
if (domain->id < 0)
@ -801,7 +801,7 @@ xenProxyLookupByID(virConnectPtr conn, int id)
}
if (id < 0) {
virProxyError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (NULL);
return (NULL);
}
memset(&req, 0, sizeof(req));
req.command = VIR_PROXY_LOOKUP_ID;
@ -810,15 +810,15 @@ xenProxyLookupByID(virConnectPtr conn, int id)
ret = xenProxyCommand(conn, &req, &ans, 0);
if (ret < 0) {
xenProxyClose(conn);
return(NULL);
return(NULL);
}
if (ans.data.arg == -1) {
return(NULL);
return(NULL);
}
memcpy(uuid, &ans.extra.str[0], VIR_UUID_BUFLEN);
name = &ans.extra.str[VIR_UUID_BUFLEN];
res = virGetDomain(conn, name, uuid);
if (res) res->id = id;
if (res) res->id = id;
return(res);
}
@ -845,7 +845,7 @@ xenProxyLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
}
if (uuid == NULL) {
virProxyError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (NULL);
return (NULL);
}
memset(&req, 0, sizeof(virProxyPacket));
req.command = VIR_PROXY_LOOKUP_UUID;
@ -855,14 +855,14 @@ xenProxyLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
ret = xenProxyCommand(conn, (virProxyPacketPtr) &req, &req, 0);
if (ret < 0) {
xenProxyClose(conn);
return(NULL);
return(NULL);
}
if (req.data.arg == -1) {
return(NULL);
return(NULL);
}
name = &req.extra.str[0];
res = virGetDomain(conn, name, uuid);
if (res) res->id = req.data.arg;
if (res) res->id = req.data.arg;
return(res);
}
@ -888,12 +888,12 @@ xenProxyLookupByName(virConnectPtr conn, const char *name)
}
if (name == NULL) {
virProxyError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (NULL);
return (NULL);
}
len = strlen(name);
if (len > 1000) {
virProxyError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (NULL);
return (NULL);
}
memset(&req, 0, sizeof(virProxyPacket));
req.command = VIR_PROXY_LOOKUP_NAME;
@ -902,13 +902,13 @@ xenProxyLookupByName(virConnectPtr conn, const char *name)
ret = xenProxyCommand(conn, (virProxyPacketPtr) &req, &req, 0);
if (ret < 0) {
xenProxyClose(conn);
return(NULL);
return(NULL);
}
if (req.data.arg == -1) {
return(NULL);
return(NULL);
}
res = virGetDomain(conn, name, (const unsigned char *)&req.extra.str[0]);
if (res) res->id = req.data.arg;
if (res) res->id = req.data.arg;
return(res);
}
@ -933,7 +933,7 @@ xenProxyNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) {
}
if (info == NULL) {
virProxyError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (-1);
return (-1);
}
memset(&req, 0, sizeof(req));
req.command = VIR_PROXY_NODE_INFO;
@ -942,13 +942,13 @@ xenProxyNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) {
ret = xenProxyCommand(conn, &req, &ans, 0);
if (ret < 0) {
xenProxyClose(conn);
return(-1);
return(-1);
}
if (ans.data.arg == -1) {
return(-1);
return(-1);
}
if (ans.len != sizeof(virProxyPacket) + sizeof(virNodeInfo)) {
return(-1);
return(-1);
}
memcpy(info, &ans.extra.ninfo, sizeof(virNodeInfo));
return(0);
@ -1022,10 +1022,10 @@ xenProxyDomainDumpXML(virDomainPtr domain, int flags ATTRIBUTE_UNUSED)
char *xml;
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
if (domain == NULL)
virProxyError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
else
virProxyError(domain->conn, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
if (domain == NULL)
virProxyError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
else
virProxyError(domain->conn, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
return (NULL);
}
if (domain->id < 0)
@ -1037,15 +1037,15 @@ xenProxyDomainDumpXML(virDomainPtr domain, int flags ATTRIBUTE_UNUSED)
ret = xenProxyCommand(domain->conn, &req, &ans, 0);
if (ret < 0) {
xenProxyClose(domain->conn);
return(NULL);
return(NULL);
}
if (ans.len <= sizeof(virProxyPacket)) {
virProxyError(domain->conn, VIR_ERR_OPERATION_FAILED, __FUNCTION__);
return (NULL);
return (NULL);
}
xmllen = ans.len - sizeof(virProxyPacket);
if (!(xml = malloc(xmllen+1))) {
virProxyError(domain->conn, VIR_ERR_NO_MEMORY, __FUNCTION__);
virProxyError(domain->conn, VIR_ERR_NO_MEMORY, __FUNCTION__);
return NULL;
}
memmove(xml, &ans.extra.dinfo, xmllen);
@ -1073,10 +1073,10 @@ xenProxyDomainGetOSType(virDomainPtr domain)
char *ostype;
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
if (domain == NULL)
virProxyError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
else
virProxyError(domain->conn, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
if (domain == NULL)
virProxyError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
else
virProxyError(domain->conn, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
return (NULL);
}
memset(&req, 0, sizeof(req));
@ -1086,19 +1086,19 @@ xenProxyDomainGetOSType(virDomainPtr domain)
ret = xenProxyCommand(domain->conn, &req, &ans, 0);
if (ret < 0) {
xenProxyClose(domain->conn);
return(NULL);
return(NULL);
}
if ((ans.len == sizeof(virProxyPacket)) && (ans.data.arg < 0)) {
return(NULL);
return(NULL);
}
if (ans.len <= sizeof(virProxyPacket)) {
virProxyError(domain->conn, VIR_ERR_OPERATION_FAILED, __FUNCTION__);
return (NULL);
return (NULL);
}
oslen = ans.len - sizeof(virProxyPacket);
if (!(ostype = malloc(oslen+1))) {
virProxyError(domain->conn, VIR_ERR_NO_MEMORY, __FUNCTION__);
virProxyError(domain->conn, VIR_ERR_NO_MEMORY, __FUNCTION__);
return NULL;
}
memmove(ostype, &ans.extra.dinfo, oslen);

View File

@ -25,18 +25,18 @@ extern "C" {
* the command allowed though the proxy
*/
typedef enum {
VIR_PROXY_NONE = 0,
VIR_PROXY_VERSION = 1,
VIR_PROXY_NODE_INFO = 2,
VIR_PROXY_LIST = 3,
VIR_PROXY_NUM_DOMAIN = 4,
VIR_PROXY_LOOKUP_ID = 5,
VIR_PROXY_LOOKUP_UUID = 6,
VIR_PROXY_LOOKUP_NAME = 7,
VIR_PROXY_MAX_MEMORY = 8,
VIR_PROXY_DOMAIN_INFO = 9,
VIR_PROXY_DOMAIN_XML = 10,
VIR_PROXY_DOMAIN_OSTYPE = 11,
VIR_PROXY_NONE = 0,
VIR_PROXY_VERSION = 1,
VIR_PROXY_NODE_INFO = 2,
VIR_PROXY_LIST = 3,
VIR_PROXY_NUM_DOMAIN = 4,
VIR_PROXY_LOOKUP_ID = 5,
VIR_PROXY_LOOKUP_UUID = 6,
VIR_PROXY_LOOKUP_NAME = 7,
VIR_PROXY_MAX_MEMORY = 8,
VIR_PROXY_DOMAIN_INFO = 9,
VIR_PROXY_DOMAIN_XML = 10,
VIR_PROXY_DOMAIN_OSTYPE = 11,
VIR_PROXY_GET_CAPABILITIES = 12
} virProxyCommand;
@ -97,7 +97,7 @@ extern virDomainPtr xenProxyLookupByName(virConnectPtr conn,
const char *domname);
extern char * xenProxyDomainDumpXML(virDomainPtr domain,
int flags);
int flags);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -1319,7 +1319,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
} else if (!strcmp((char *)prop, "network")) {
def->os.bootDevs[def->os.nBootDevs++] = QEMUD_BOOT_NET;
} else {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("unknown boot device \'%s\'"), (char*)prop);
goto error;
}

View File

@ -1470,12 +1470,12 @@ static const char *qemudProbe(void)
{
if ((virFileExists("/usr/bin/qemu")) ||
(virFileExists("/usr/bin/qemu-kvm")) ||
(virFileExists("/usr/bin/xenner"))) {
(virFileExists("/usr/bin/xenner"))) {
if (getuid() == 0) {
return("qemu:///system");
} else {
return("qemu:///session");
}
return("qemu:///system");
} else {
return("qemu:///session");
}
}
return(NULL);
}

View File

@ -43,7 +43,7 @@ extern struct qparam_set *new_qparam_set (int init_alloc, ...);
/* Appending parameters. */
extern int append_qparams (struct qparam_set *ps, ...);
extern int append_qparam (struct qparam_set *ps,
const char *name, const char *value);
const char *name, const char *value);
/* Get a query string ("name=value&name=value&...") */
extern char *qparam_get_query (const struct qparam_set *ps);

View File

@ -4682,11 +4682,11 @@ static virDriver driver = {
.open = remoteOpen,
.close = remoteClose,
.supports_feature = remoteSupportsFeature,
.type = remoteType,
.version = remoteVersion,
.type = remoteType,
.version = remoteVersion,
.getHostname = remoteGetHostname,
.getMaxVcpus = remoteGetMaxVcpus,
.nodeGetInfo = remoteNodeGetInfo,
.getMaxVcpus = remoteGetMaxVcpus,
.nodeGetInfo = remoteNodeGetInfo,
.getCapabilities = remoteGetCapabilities,
.listDomains = remoteListDomains,
.numOfDomains = remoteNumOfDomains,

View File

@ -483,7 +483,7 @@ sexpr_lookup(const struct sexpr *sexpr, const char *node)
struct sexpr *s = sexpr_lookup_key(sexpr, node);
if (s == NULL)
return NULL;
return NULL;
if (s->kind != SEXPR_CONS || s->u.s.cdr->kind != SEXPR_CONS)
return NULL;
@ -509,7 +509,7 @@ sexpr_has(struct sexpr *sexpr, const char *node)
struct sexpr *s = sexpr_lookup_key(sexpr, node);
if (s == NULL)
return 0;
return 0;
if (s->kind != SEXPR_CONS)
return 0;

View File

@ -16,10 +16,10 @@
#include "xen_unified.h"
extern int xenLinuxDomainBlockStats (xenUnifiedPrivatePtr priv,
virDomainPtr dom, const char *path,
struct _virDomainBlockStats *stats);
virDomainPtr dom, const char *path,
struct _virDomainBlockStats *stats);
extern int linuxDomainInterfaceStats (virConnectPtr conn, const char *path,
struct _virDomainInterfaceStats *stats);
struct _virDomainInterfaceStats *stats);
extern int xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *dev);

View File

@ -15,38 +15,38 @@
/* Like read(), but restarts after EINTR */
int saferead(int fd, void *buf, size_t count)
{
size_t nread = 0;
while (count > 0) {
ssize_t r = read(fd, buf, count);
if (r < 0 && errno == EINTR)
continue;
if (r < 0)
return r;
if (r == 0)
return nread;
buf = (char *)buf + r;
count -= r;
nread += r;
}
return nread;
size_t nread = 0;
while (count > 0) {
ssize_t r = read(fd, buf, count);
if (r < 0 && errno == EINTR)
continue;
if (r < 0)
return r;
if (r == 0)
return nread;
buf = (char *)buf + r;
count -= r;
nread += r;
}
return nread;
}
/* Like write(), but restarts after EINTR */
ssize_t safewrite(int fd, const void *buf, size_t count)
{
size_t nwritten = 0;
while (count > 0) {
ssize_t r = write(fd, buf, count);
size_t nwritten = 0;
while (count > 0) {
ssize_t r = write(fd, buf, count);
if (r < 0 && errno == EINTR)
continue;
if (r < 0)
return r;
if (r == 0)
return nwritten;
buf = (const char *)buf + r;
count -= r;
nwritten += r;
}
return nwritten;
if (r < 0 && errno == EINTR)
continue;
if (r < 0)
return r;
if (r == 0)
return nwritten;
buf = (const char *)buf + r;
count -= r;
nwritten += r;
}
return nwritten;
}

View File

@ -759,10 +759,10 @@ virParseMacAddr(const char* str, unsigned char *addr)
addr[i] = (unsigned char) result;
if ((i == 5) && (*end_ptr == '\0'))
return 0;
if (*end_ptr != ':')
break;
if ((i == 5) && (*end_ptr == '\0'))
return 0;
if (*end_ptr != ':')
break;
str = end_ptr + 1;
}

View File

@ -28,14 +28,14 @@
#include "util-lib.h"
int virExec(virConnectPtr conn, char **argv, int *retpid,
int infd, int *outfd, int *errfd);
int infd, int *outfd, int *errfd);
int virExecNonBlock(virConnectPtr conn, char **argv, int *retpid,
int infd, int *outfd, int *errfd);
int infd, int *outfd, int *errfd);
int virRun(virConnectPtr conn, char **argv, int *status);
int __virFileReadAll(const char *path,
int maxlen,
char **buf);
int maxlen,
char **buf);
#define virFileReadAll(p,m,b) __virFileReadAll((p),(m),(b))
int virFileMatchesNameSuffix(const char *file,
@ -74,9 +74,9 @@ int virStrToLong_ll(char const *s,
int base,
long long *result);
int __virStrToLong_ull(char const *s,
char **end_ptr,
int base,
unsigned long long *result);
char **end_ptr,
int base,
unsigned long long *result);
#define virStrToLong_ull(s,e,b,r) __virStrToLong_ull((s),(e),(b),(r))
int __virMacAddrCompare (const char *mac1, const char *mac2);

View File

@ -25,9 +25,9 @@
int virUUIDGenerate(unsigned char *uuid);
int virUUIDParse(const char *uuidstr,
unsigned char *uuid);
unsigned char *uuid);
void virUUIDFormat(const unsigned char *uuid,
char *uuidstr);
char *uuidstr);
#endif /* __VIR_UUID_H__ */

View File

@ -401,19 +401,19 @@ cmdAutostart(vshControl * ctl, vshCmd * cmd)
if (virDomainSetAutostart(dom, autostart) < 0) {
if (autostart)
vshError(ctl, FALSE, _("Failed to mark domain %s as autostarted"),
vshError(ctl, FALSE, _("Failed to mark domain %s as autostarted"),
name);
else
vshError(ctl, FALSE, _("Failed to unmark domain %s as autostarted"),
else
vshError(ctl, FALSE, _("Failed to unmark domain %s as autostarted"),
name);
virDomainFree(dom);
return FALSE;
}
if (autostart)
vshPrint(ctl, _("Domain %s marked as autostarted\n"), name);
vshPrint(ctl, _("Domain %s marked as autostarted\n"), name);
else
vshPrint(ctl, _("Domain %s unmarked as autostarted\n"), name);
vshPrint(ctl, _("Domain %s unmarked as autostarted\n"), name);
virDomainFree(dom);
return TRUE;
@ -902,7 +902,7 @@ cmdCreate(vshControl * ctl, vshCmd * cmd)
if (dom != NULL) {
vshPrint(ctl, _("Domain %s created from %s\n"),
virDomainGetName(dom), from);
virDomainFree(dom);
virDomainFree(dom);
} else {
vshError(ctl, FALSE, _("Failed to create domain from %s"), from);
ret = FALSE;
@ -1027,7 +1027,7 @@ cmdStart(vshControl * ctl, vshCmd * cmd)
if (virDomainGetID(dom) != (unsigned int)-1) {
vshError(ctl, FALSE, "%s", _("Domain is already active"));
virDomainFree(dom);
virDomainFree(dom);
return FALSE;
}
@ -1176,7 +1176,7 @@ cmdSchedinfo(vshControl * ctl, vshCmd * cmd)
ret = virDomainSetSchedulerParameters(dom, params, inputparams);
if (ret == -1) {
goto cleanup;
}
}
}
free(params);
params = NULL;
@ -1583,15 +1583,15 @@ cmdFreecell(vshControl * ctl, vshCmd * cmd)
if (!cell_given) {
memory = virNodeGetFreeMemory(ctl->conn);
} else {
ret = virNodeGetCellsFreeMemory(ctl->conn, &memory, cell, 1);
if (ret != 1)
return FALSE;
ret = virNodeGetCellsFreeMemory(ctl->conn, &memory, cell, 1);
if (ret != 1)
return FALSE;
}
if (cell == -1)
vshPrint(ctl, "%s: %llu kB\n", _("Total"), memory);
vshPrint(ctl, "%s: %llu kB\n", _("Total"), memory);
else
vshPrint(ctl, "%d: %llu kB\n", cell, memory);
vshPrint(ctl, "%d: %llu kB\n", cell, memory);
return TRUE;
}
@ -1742,7 +1742,7 @@ cmdVcpupin(vshControl * ctl, vshCmd * cmd)
if (virDomainGetInfo(dom, &info) != 0) {
vshError(ctl, FALSE, "%s",
_("vcpupin: failed to get domain informations."));
_("vcpupin: failed to get domain informations."));
virDomainFree(dom);
return FALSE;
}
@ -2290,19 +2290,19 @@ cmdNetworkAutostart(vshControl * ctl, vshCmd * cmd)
if (virNetworkSetAutostart(network, autostart) < 0) {
if (autostart)
vshError(ctl, FALSE, _("failed to mark network %s as autostarted"),
vshError(ctl, FALSE, _("failed to mark network %s as autostarted"),
name);
else
vshError(ctl, FALSE,_("failed to unmark network %s as autostarted"),
else
vshError(ctl, FALSE,_("failed to unmark network %s as autostarted"),
name);
virNetworkFree(network);
return FALSE;
}
if (autostart)
vshPrint(ctl, _("Network %s marked as autostarted\n"), name);
vshPrint(ctl, _("Network %s marked as autostarted\n"), name);
else
vshPrint(ctl, _("Network %s unmarked as autostarted\n"), name);
vshPrint(ctl, _("Network %s unmarked as autostarted\n"), name);
return TRUE;
}
@ -2523,7 +2523,7 @@ cmdNetworkList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
activeNames = vshMalloc(ctl, sizeof(char *) * maxactive);
if ((maxactive = virConnectListNetworks(ctl->conn, activeNames,
maxactive)) < 0) {
maxactive)) < 0) {
vshError(ctl, FALSE, "%s", _("Failed to list active networks"));
free(activeNames);
return FALSE;
@ -2630,7 +2630,7 @@ cmdNetworkName(vshControl * ctl, vshCmd * cmd)
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
if (!(network = vshCommandOptNetworkBy(ctl, cmd, "network", NULL,
VSH_BYUUID)))
VSH_BYUUID)))
return FALSE;
vshPrint(ctl, "%s\n", virNetworkGetName(network));
@ -2741,7 +2741,7 @@ cmdNetworkUuid(vshControl * ctl, vshCmd * cmd)
return FALSE;
if (!(network = vshCommandOptNetworkBy(ctl, cmd, "network", NULL,
VSH_BYNAME)))
VSH_BYNAME)))
return FALSE;
if (virNetworkGetUUIDString(network, uuid) != -1)
@ -2798,19 +2798,19 @@ cmdPoolAutostart(vshControl * ctl, vshCmd * cmd)
if (virStoragePoolSetAutostart(pool, autostart) < 0) {
if (autostart)
vshError(ctl, FALSE, _("failed to mark pool %s as autostarted"),
vshError(ctl, FALSE, _("failed to mark pool %s as autostarted"),
name);
else
vshError(ctl, FALSE,_("failed to unmark pool %s as autostarted"),
else
vshError(ctl, FALSE,_("failed to unmark pool %s as autostarted"),
name);
virStoragePoolFree(pool);
return FALSE;
}
if (autostart)
vshPrint(ctl, _("Pool %s marked as autostarted\n"), name);
vshPrint(ctl, _("Pool %s marked as autostarted\n"), name);
else
vshPrint(ctl, _("Pool %s unmarked as autostarted\n"), name);
vshPrint(ctl, _("Pool %s unmarked as autostarted\n"), name);
return TRUE;
}
@ -3543,7 +3543,7 @@ cmdPoolName(vshControl * ctl, vshCmd * cmd)
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYUUID)))
VSH_BYUUID)))
return FALSE;
vshPrint(ctl, "%s\n", virStoragePoolGetName(pool));
@ -3779,7 +3779,7 @@ cmdPoolUuid(vshControl * ctl, vshCmd * cmd)
return FALSE;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYNAME)))
VSH_BYNAME)))
return FALSE;
if (virStoragePoolGetUUIDString(pool, uuid) != -1)
@ -3823,7 +3823,7 @@ cmdVolCreate(vshControl * ctl, vshCmd * cmd)
return FALSE;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYNAME)))
VSH_BYNAME)))
return FALSE;
from = vshCommandOptString(cmd, "file", &found);
@ -5485,7 +5485,7 @@ vshCommandOptDomainBy(vshControl * ctl, vshCmd * cmd, const char *optname,
static virNetworkPtr
vshCommandOptNetworkBy(vshControl * ctl, vshCmd * cmd, const char *optname,
char **name, int flag)
char **name, int flag)
{
virNetworkPtr network = NULL;
char *n;
@ -5504,7 +5504,7 @@ vshCommandOptNetworkBy(vshControl * ctl, vshCmd * cmd, const char *optname,
/* try it by UUID */
if (network==NULL && (flag & VSH_BYUUID) && strlen(n)==VIR_UUID_STRING_BUFLEN-1) {
vshDebug(ctl, 5, "%s: <%s> trying as network UUID\n",
cmd->def->name, optname);
cmd->def->name, optname);
network = virNetworkLookupByUUIDString(ctl->conn, n);
}
/* try it by NAME */
@ -5541,7 +5541,7 @@ vshCommandOptPoolBy(vshControl * ctl, vshCmd * cmd, const char *optname,
/* try it by UUID */
if (pool==NULL && (flag & VSH_BYUUID) && strlen(n)==VIR_UUID_STRING_BUFLEN-1) {
vshDebug(ctl, 5, "%s: <%s> trying as pool UUID\n",
cmd->def->name, optname);
cmd->def->name, optname);
pool = virStoragePoolLookupByUUIDString(ctl->conn, n);
}
/* try it by NAME */

View File

@ -34,31 +34,31 @@ static void *virUserData = NULL; /* associated data */
int chars; \
char *larger; \
va_list ap; \
\
\
str = (char *) malloc(150); \
if (str != NULL) { \
\
\
size = 150; \
\
\
while (1) { \
va_start(ap, msg); \
chars = vsnprintf(str, size, msg, ap); \
va_end(ap); \
if ((chars > -1) && (chars < size)) { \
if (prev_size == chars) { \
break; \
} else { \
prev_size = chars; \
} \
} \
if (chars > -1) \
size += chars + 1; \
else \
size += 100; \
if ((larger = (char *) realloc(str, size)) == NULL) { \
break; \
} \
str = larger; \
va_start(ap, msg); \
chars = vsnprintf(str, size, msg, ap); \
va_end(ap); \
if ((chars > -1) && (chars < size)) { \
if (prev_size == chars) { \
break; \
} else { \
prev_size = chars; \
} \
} \
if (chars > -1) \
size += chars + 1; \
else \
size += 100; \
if ((larger = (char *) realloc(str, size)) == NULL) { \
break; \
} \
str = larger; \
}} \
}
@ -427,18 +427,18 @@ __virErrorMsg(virErrorNumber error, const char *info)
return (NULL);
case VIR_ERR_INTERNAL_ERROR:
if (info != NULL)
errmsg = _("internal error %s");
errmsg = _("internal error %s");
else
errmsg = _("internal error");
errmsg = _("internal error");
break;
case VIR_ERR_NO_MEMORY:
errmsg = _("out of memory");
break;
case VIR_ERR_NO_SUPPORT:
if (info == NULL)
errmsg = _("this function is not supported by the hypervisor");
else
errmsg = _("this function is not supported by the hypervisor: %s");
errmsg = _("this function is not supported by the hypervisor");
else
errmsg = _("this function is not supported by the hypervisor: %s");
break;
case VIR_ERR_NO_CONNECT:
if (info == NULL)
@ -448,21 +448,21 @@ __virErrorMsg(virErrorNumber error, const char *info)
break;
case VIR_ERR_INVALID_CONN:
if (info == NULL)
errmsg = _("invalid connection pointer in");
else
errmsg = _("invalid connection pointer in %s");
errmsg = _("invalid connection pointer in");
else
errmsg = _("invalid connection pointer in %s");
break;
case VIR_ERR_INVALID_DOMAIN:
if (info == NULL)
errmsg = _("invalid domain pointer in");
else
errmsg = _("invalid domain pointer in %s");
errmsg = _("invalid domain pointer in");
else
errmsg = _("invalid domain pointer in %s");
break;
case VIR_ERR_INVALID_ARG:
if (info == NULL)
errmsg = _("invalid argument in");
else
errmsg = _("invalid argument in %s");
errmsg = _("invalid argument in");
else
errmsg = _("invalid argument in %s");
break;
case VIR_ERR_OPERATION_FAILED:
if (info != NULL)
@ -487,9 +487,9 @@ __virErrorMsg(virErrorNumber error, const char *info)
break;
case VIR_ERR_UNKNOWN_HOST:
if (info != NULL)
errmsg = _("unknown host %s");
else
errmsg = _("unknown host");
errmsg = _("unknown host %s");
else
errmsg = _("unknown host");
break;
case VIR_ERR_SEXPR_SERIAL:
if (info != NULL)
@ -503,7 +503,7 @@ __virErrorMsg(virErrorNumber error, const char *info)
else
errmsg = _("could not use Xen hypervisor entry %s");
break;
case VIR_ERR_NO_XENSTORE:
case VIR_ERR_NO_XENSTORE:
if (info == NULL)
errmsg = _("could not connect to Xen Store");
else
@ -569,150 +569,150 @@ __virErrorMsg(virErrorNumber error, const char *info)
else
errmsg = _("library call %s failed, possibly not supported");
break;
case VIR_ERR_XML_ERROR:
if (info == NULL)
errmsg = _("XML description not well formed or invalid");
else
errmsg = _("XML description for %s is not well formed or invalid");
case VIR_ERR_XML_ERROR:
if (info == NULL)
errmsg = _("XML description not well formed or invalid");
else
errmsg = _("XML description for %s is not well formed or invalid");
break;
case VIR_ERR_DOM_EXIST:
if (info == NULL)
errmsg = _("this domain exists already");
else
errmsg = _("domain %s exists already");
case VIR_ERR_DOM_EXIST:
if (info == NULL)
errmsg = _("this domain exists already");
else
errmsg = _("domain %s exists already");
break;
case VIR_ERR_OPERATION_DENIED:
if (info == NULL)
errmsg = _("operation forbidden for read only access");
else
errmsg = _("operation %s forbidden for read only access");
case VIR_ERR_OPERATION_DENIED:
if (info == NULL)
errmsg = _("operation forbidden for read only access");
else
errmsg = _("operation %s forbidden for read only access");
break;
case VIR_ERR_OPEN_FAILED:
if (info == NULL)
errmsg = _("failed to open configuration file for reading");
else
errmsg = _("failed to open %s for reading");
case VIR_ERR_OPEN_FAILED:
if (info == NULL)
errmsg = _("failed to open configuration file for reading");
else
errmsg = _("failed to open %s for reading");
break;
case VIR_ERR_READ_FAILED:
if (info == NULL)
errmsg = _("failed to read configuration file");
else
errmsg = _("failed to read configuration file %s");
case VIR_ERR_READ_FAILED:
if (info == NULL)
errmsg = _("failed to read configuration file");
else
errmsg = _("failed to read configuration file %s");
break;
case VIR_ERR_PARSE_FAILED:
if (info == NULL)
errmsg = _("failed to parse configuration file");
else
errmsg = _("failed to parse configuration file %s");
case VIR_ERR_PARSE_FAILED:
if (info == NULL)
errmsg = _("failed to parse configuration file");
else
errmsg = _("failed to parse configuration file %s");
break;
case VIR_ERR_CONF_SYNTAX:
if (info == NULL)
errmsg = _("configuration file syntax error");
else
errmsg = _("configuration file syntax error: %s");
case VIR_ERR_CONF_SYNTAX:
if (info == NULL)
errmsg = _("configuration file syntax error");
else
errmsg = _("configuration file syntax error: %s");
break;
case VIR_ERR_WRITE_FAILED:
if (info == NULL)
errmsg = _("failed to write configuration file");
else
errmsg = _("failed to write configuration file: %s");
case VIR_ERR_WRITE_FAILED:
if (info == NULL)
errmsg = _("failed to write configuration file");
else
errmsg = _("failed to write configuration file: %s");
break;
case VIR_ERR_XML_DETAIL:
if (info == NULL)
errmsg = _("parser error");
else
errmsg = "%s";
case VIR_ERR_XML_DETAIL:
if (info == NULL)
errmsg = _("parser error");
else
errmsg = "%s";
break;
case VIR_ERR_INVALID_NETWORK:
if (info == NULL)
errmsg = _("invalid network pointer in");
else
errmsg = _("invalid network pointer in %s");
errmsg = _("invalid network pointer in");
else
errmsg = _("invalid network pointer in %s");
break;
case VIR_ERR_NETWORK_EXIST:
if (info == NULL)
errmsg = _("this network exists already");
else
errmsg = _("network %s exists already");
case VIR_ERR_NETWORK_EXIST:
if (info == NULL)
errmsg = _("this network exists already");
else
errmsg = _("network %s exists already");
break;
case VIR_ERR_SYSTEM_ERROR:
if (info == NULL)
errmsg = _("system call error");
else
errmsg = "%s";
break;
case VIR_ERR_RPC:
if (info == NULL)
errmsg = _("RPC error");
else
errmsg = "%s";
break;
case VIR_ERR_GNUTLS_ERROR:
if (info == NULL)
errmsg = _("GNUTLS call error");
else
errmsg = "%s";
break;
case VIR_WAR_NO_NETWORK:
if (info == NULL)
errmsg = _("Failed to find the network");
else
errmsg = _("Failed to find the network: %s");
break;
case VIR_ERR_NO_DOMAIN:
if (info == NULL)
errmsg = _("Domain not found");
else
errmsg = _("Domain not found: %s");
break;
case VIR_ERR_NO_NETWORK:
if (info == NULL)
errmsg = _("Network not found");
else
errmsg = _("Network not found: %s");
break;
case VIR_ERR_SYSTEM_ERROR:
if (info == NULL)
errmsg = _("system call error");
else
errmsg = "%s";
break;
case VIR_ERR_RPC:
if (info == NULL)
errmsg = _("RPC error");
else
errmsg = "%s";
break;
case VIR_ERR_GNUTLS_ERROR:
if (info == NULL)
errmsg = _("GNUTLS call error");
else
errmsg = "%s";
break;
case VIR_WAR_NO_NETWORK:
if (info == NULL)
errmsg = _("Failed to find the network");
else
errmsg = _("Failed to find the network: %s");
break;
case VIR_ERR_NO_DOMAIN:
if (info == NULL)
errmsg = _("Domain not found");
else
errmsg = _("Domain not found: %s");
break;
case VIR_ERR_NO_NETWORK:
if (info == NULL)
errmsg = _("Network not found");
else
errmsg = _("Network not found: %s");
break;
case VIR_ERR_INVALID_MAC:
if (info == NULL)
errmsg = _("invalid MAC address");
else
errmsg = _("invalid MAC address: %s");
break;
if (info == NULL)
errmsg = _("invalid MAC address");
else
errmsg = _("invalid MAC address: %s");
break;
case VIR_ERR_AUTH_FAILED:
if (info == NULL)
errmsg = _("authentication failed");
else
errmsg = _("authentication failed: %s");
break;
case VIR_ERR_NO_STORAGE_POOL:
if (info == NULL)
errmsg = _("Storage pool not found");
else
errmsg = _("Storage pool not found: %s");
break;
case VIR_ERR_NO_STORAGE_VOL:
if (info == NULL)
errmsg = _("Storage volume not found");
else
errmsg = _("Storage volume not found: %s");
break;
case VIR_ERR_INVALID_STORAGE_POOL:
if (info == NULL)
errmsg = _("invalid storage pool pointer in");
else
errmsg = _("invalid storage pool pointer in %s");
break;
case VIR_ERR_INVALID_STORAGE_VOL:
if (info == NULL)
errmsg = _("invalid storage volume pointer in");
else
errmsg = _("invalid storage volume pointer in %s");
break;
case VIR_WAR_NO_STORAGE:
if (info == NULL)
errmsg = _("Failed to find a storage driver");
else
errmsg = _("Failed to find a storage driver: %s");
break;
if (info == NULL)
errmsg = _("authentication failed");
else
errmsg = _("authentication failed: %s");
break;
case VIR_ERR_NO_STORAGE_POOL:
if (info == NULL)
errmsg = _("Storage pool not found");
else
errmsg = _("Storage pool not found: %s");
break;
case VIR_ERR_NO_STORAGE_VOL:
if (info == NULL)
errmsg = _("Storage volume not found");
else
errmsg = _("Storage volume not found: %s");
break;
case VIR_ERR_INVALID_STORAGE_POOL:
if (info == NULL)
errmsg = _("invalid storage pool pointer in");
else
errmsg = _("invalid storage pool pointer in %s");
break;
case VIR_ERR_INVALID_STORAGE_VOL:
if (info == NULL)
errmsg = _("invalid storage volume pointer in");
else
errmsg = _("invalid storage volume pointer in %s");
break;
case VIR_WAR_NO_STORAGE:
if (info == NULL)
errmsg = _("Failed to find a storage driver");
else
errmsg = _("Failed to find a storage driver: %s");
break;
}
return (errmsg);
}

View File

@ -338,9 +338,9 @@ static int
lock_pages(void *addr, size_t len)
{
#ifdef __linux__
return (mlock(addr, len));
return (mlock(addr, len));
#elif define(__sun)
return (0);
return (0);
#endif
}
@ -348,9 +348,9 @@ static int
unlock_pages(void *addr, size_t len)
{
#ifdef __linux__
return (munlock(addr, len));
return (munlock(addr, len));
#elif define(__sun)
return (0);
return (0);
#endif
}
@ -771,14 +771,14 @@ virXenErrorFunc(virConnectPtr conn,
errmsg = __virErrorMsg(error, info);
if (func != NULL) {
snprintf(fullinfo, 999, "%s: %s", func, info);
fullinfo[999] = 0;
__virRaiseError(conn, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR,
errmsg, fullinfo, NULL, value, 0, errmsg, fullinfo,
value);
fullinfo[999] = 0;
__virRaiseError(conn, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR,
errmsg, fullinfo, NULL, value, 0, errmsg, fullinfo,
value);
} else {
__virRaiseError(conn, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR,
errmsg, info, NULL, value, 0, errmsg, info,
value);
__virRaiseError(conn, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR,
errmsg, info, NULL, value, 0, errmsg, info,
value);
}
}
@ -1090,14 +1090,14 @@ xenHypervisorGetSchedulerType(virDomainPtr domain, int *nparams)
if ((domain == NULL) || (domain->conn == NULL)) {
virXenErrorFunc(NULL, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
"domain or conn is NULL", 0);
"domain or conn is NULL", 0);
return NULL;
}
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (priv->handle < 0 || domain->id < 0) {
virXenErrorFunc(domain->conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
"priv->handle or domain->id invalid", 0);
"priv->handle or domain->id invalid", 0);
return NULL;
}
@ -1108,7 +1108,7 @@ xenHypervisorGetSchedulerType(virDomainPtr domain, int *nparams)
*/
if (dom_interface_version < 5) {
virXenErrorFunc(domain->conn, VIR_ERR_NO_XEN, __FUNCTION__,
"unsupported in dom interface < 5", 0);
"unsupported in dom interface < 5", 0);
return NULL;
}
@ -1120,21 +1120,21 @@ xenHypervisorGetSchedulerType(virDomainPtr domain, int *nparams)
op.cmd = XEN_V2_OP_GETSCHEDULERID;
ret = xenHypervisorDoV2Sys(priv->handle, &op);
if (ret < 0)
return(NULL);
return(NULL);
switch (op.u.getschedulerid.sched_id){
case XEN_SCHEDULER_SEDF:
schedulertype = strdup("sedf");
if (nparams)
*nparams = 6;
break;
case XEN_SCHEDULER_CREDIT:
schedulertype = strdup("credit");
if (nparams)
*nparams = 2;
break;
default:
break;
case XEN_SCHEDULER_SEDF:
schedulertype = strdup("sedf");
if (nparams)
*nparams = 6;
break;
case XEN_SCHEDULER_CREDIT:
schedulertype = strdup("credit");
if (nparams)
*nparams = 2;
break;
default:
break;
}
}
@ -1159,20 +1159,20 @@ static const char *str_cap = "cap";
*/
int
xenHypervisorGetSchedulerParameters(virDomainPtr domain,
virSchedParameterPtr params, int *nparams)
virSchedParameterPtr params, int *nparams)
{
xenUnifiedPrivatePtr priv;
if ((domain == NULL) || (domain->conn == NULL)) {
virXenErrorFunc(NULL, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
"domain or conn is NULL", 0);
"domain or conn is NULL", 0);
return -1;
}
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (priv->handle < 0 || domain->id < 0) {
virXenErrorFunc(domain->conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
"priv->handle or domain->id invalid", 0);
"priv->handle or domain->id invalid", 0);
return -1;
}
@ -1183,7 +1183,7 @@ xenHypervisorGetSchedulerParameters(virDomainPtr domain,
*/
if (dom_interface_version < 5) {
virXenErrorFunc(domain->conn, VIR_ERR_NO_XEN, __FUNCTION__,
"unsupported in dom interface < 5", 0);
"unsupported in dom interface < 5", 0);
return -1;
}
@ -1196,41 +1196,41 @@ xenHypervisorGetSchedulerParameters(virDomainPtr domain,
op_sys.cmd = XEN_V2_OP_GETSCHEDULERID;
ret = xenHypervisorDoV2Sys(priv->handle, &op_sys);
if (ret < 0)
return -1;
return -1;
switch (op_sys.u.getschedulerid.sched_id){
case XEN_SCHEDULER_SEDF:
/* TODO: Implement for Xen/SEDF */
TODO
return(-1);
case XEN_SCHEDULER_CREDIT:
if (*nparams < 2)
return(-1);
memset(&op_dom, 0, sizeof(op_dom));
op_dom.cmd = XEN_V2_OP_SCHEDULER;
op_dom.domain = (domid_t) domain->id;
op_dom.u.getschedinfo.sched_id = XEN_SCHEDULER_CREDIT;
op_dom.u.getschedinfo.cmd = XEN_DOMCTL_SCHEDOP_getinfo;
ret = xenHypervisorDoV2Dom(priv->handle, &op_dom);
if (ret < 0)
return(-1);
case XEN_SCHEDULER_SEDF:
/* TODO: Implement for Xen/SEDF */
TODO
return(-1);
case XEN_SCHEDULER_CREDIT:
if (*nparams < 2)
return(-1);
memset(&op_dom, 0, sizeof(op_dom));
op_dom.cmd = XEN_V2_OP_SCHEDULER;
op_dom.domain = (domid_t) domain->id;
op_dom.u.getschedinfo.sched_id = XEN_SCHEDULER_CREDIT;
op_dom.u.getschedinfo.cmd = XEN_DOMCTL_SCHEDOP_getinfo;
ret = xenHypervisorDoV2Dom(priv->handle, &op_dom);
if (ret < 0)
return(-1);
strncpy (params[0].field, str_weight, VIR_DOMAIN_SCHED_FIELD_LENGTH);
strncpy (params[0].field, str_weight, VIR_DOMAIN_SCHED_FIELD_LENGTH);
params[0].field[VIR_DOMAIN_SCHED_FIELD_LENGTH-1] = '\0';
params[0].type = VIR_DOMAIN_SCHED_FIELD_UINT;
params[0].value.ui = op_dom.u.getschedinfo.u.credit.weight;
params[0].type = VIR_DOMAIN_SCHED_FIELD_UINT;
params[0].value.ui = op_dom.u.getschedinfo.u.credit.weight;
strncpy (params[1].field, str_cap, VIR_DOMAIN_SCHED_FIELD_LENGTH);
strncpy (params[1].field, str_cap, VIR_DOMAIN_SCHED_FIELD_LENGTH);
params[1].field[VIR_DOMAIN_SCHED_FIELD_LENGTH-1] = '\0';
params[1].type = VIR_DOMAIN_SCHED_FIELD_UINT;
params[1].value.ui = op_dom.u.getschedinfo.u.credit.cap;
params[1].type = VIR_DOMAIN_SCHED_FIELD_UINT;
params[1].value.ui = op_dom.u.getschedinfo.u.credit.cap;
*nparams = 2;
break;
default:
*nparams = 2;
break;
default:
virXenErrorFunc(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"Unknown scheduler", op_sys.u.getschedulerid.sched_id);
return -1;
"Unknown scheduler", op_sys.u.getschedulerid.sched_id);
return -1;
}
}
@ -1248,7 +1248,7 @@ xenHypervisorGetSchedulerParameters(virDomainPtr domain,
*/
int
xenHypervisorSetSchedulerParameters(virDomainPtr domain,
virSchedParameterPtr params, int nparams)
virSchedParameterPtr params, int nparams)
{
int i;
unsigned int val;
@ -1257,20 +1257,20 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain,
if ((domain == NULL) || (domain->conn == NULL)) {
virXenErrorFunc (NULL, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
"domain or conn is NULL", 0);
"domain or conn is NULL", 0);
return -1;
}
if ((nparams == 0) || (params == NULL)) {
virXenErrorFunc (domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"Noparameters given", 0);
return(-1);
"Noparameters given", 0);
return(-1);
}
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (priv->handle < 0 || domain->id < 0) {
virXenErrorFunc (domain->conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
"priv->handle or domain->id invalid", 0);
"priv->handle or domain->id invalid", 0);
return -1;
}
@ -1281,7 +1281,7 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain,
*/
if (dom_interface_version < 5) {
virXenErrorFunc(domain->conn, VIR_ERR_NO_XEN, __FUNCTION__,
"unsupported in dom interface < 5", 0);
"unsupported in dom interface < 5", 0);
return -1;
}
@ -1299,7 +1299,7 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain,
case XEN_SCHEDULER_SEDF:
/* TODO: Implement for Xen/SEDF */
TODO
return(-1);
return(-1);
case XEN_SCHEDULER_CREDIT: {
int weight_set = 0;
int cap_set = 0;
@ -1321,37 +1321,37 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain,
memset(&buf, 0, sizeof(buf));
if (STREQ (params[i].field, str_weight) &&
params[i].type == VIR_DOMAIN_SCHED_FIELD_UINT) {
val = params[i].value.ui;
if ((val < 1) || (val > USHRT_MAX)) {
val = params[i].value.ui;
if ((val < 1) || (val > USHRT_MAX)) {
snprintf(buf, sizeof(buf), _("Credit scheduler weight parameter (%d) is out of range (1-65535)"), val);
virXenErrorFunc (domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__, buf, val);
return(-1);
}
return(-1);
}
op_dom.u.getschedinfo.u.credit.weight = val;
weight_set = 1;
} else if (STREQ (params[i].field, str_cap) &&
weight_set = 1;
} else if (STREQ (params[i].field, str_cap) &&
params[i].type == VIR_DOMAIN_SCHED_FIELD_UINT) {
val = params[i].value.ui;
if (val > USHRT_MAX) {
val = params[i].value.ui;
if (val > USHRT_MAX) {
snprintf(buf, sizeof(buf), _("Credit scheduler cap parameter (%d) is out of range (0-65535)"), val);
virXenErrorFunc (domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__, buf, val);
return(-1);
}
return(-1);
}
op_dom.u.getschedinfo.u.credit.cap = val;
cap_set = 1;
} else {
cap_set = 1;
} else {
virXenErrorFunc (domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"Credit scheduler accepts 'cap' and 'weight' integer parameters",
0);
return(-1);
}
0);
return(-1);
}
}
ret = xenHypervisorDoV2Dom(priv->handle, &op_dom);
if (ret < 0)
return -1;
return -1;
break;
}
}
default:
virXenErrorFunc(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"Unknown scheduler", op_sys.u.getschedulerid.sched_id);
@ -1987,7 +1987,7 @@ xenHypervisorInit(void)
ipt = malloc(sizeof(*ipt));
if (ipt == NULL){
virXenError(NULL, VIR_ERR_NO_MEMORY, __FUNCTION__, 0);
virXenError(NULL, VIR_ERR_NO_MEMORY, __FUNCTION__, 0);
return(-1);
}
/* Currently consider RHEL5.0 Fedora7, xen-3.1, and xen-unstable */
@ -2762,8 +2762,8 @@ xenHypervisorGetDomMaxMemory(virConnectPtr conn, int id)
if (kb_per_pages == 0) {
kb_per_pages = sysconf(_SC_PAGESIZE) / 1024;
if (kb_per_pages <= 0)
kb_per_pages = 4;
if (kb_per_pages <= 0)
kb_per_pages = 4;
}
XEN_GETDOMAININFO_CLEAR(dominfo);
@ -2823,8 +2823,8 @@ xenHypervisorGetDomInfo(virConnectPtr conn, int id, virDomainInfoPtr info)
if (kb_per_pages == 0) {
kb_per_pages = sysconf(_SC_PAGESIZE) / 1024;
if (kb_per_pages <= 0)
kb_per_pages = 4;
if (kb_per_pages <= 0)
kb_per_pages = 4;
}
if (conn == NULL)
@ -2846,10 +2846,10 @@ xenHypervisorGetDomInfo(virConnectPtr conn, int id, virDomainInfoPtr info)
domain_flags &= ~DOMFLAGS_HVM; /* Mask out HVM flags */
domain_state = domain_flags & 0xFF; /* Mask out high bits */
switch (domain_state) {
case DOMFLAGS_DYING:
info->state = VIR_DOMAIN_SHUTDOWN;
break;
case DOMFLAGS_SHUTDOWN:
case DOMFLAGS_DYING:
info->state = VIR_DOMAIN_SHUTDOWN;
break;
case DOMFLAGS_SHUTDOWN:
/* The domain is shutdown. Determine the cause. */
domain_shutdown_cause = domain_flags >> DOMFLAGS_SHUTDOWNSHIFT;
switch (domain_shutdown_cause) {
@ -2859,18 +2859,18 @@ xenHypervisorGetDomInfo(virConnectPtr conn, int id, virDomainInfoPtr info)
default:
info->state = VIR_DOMAIN_SHUTOFF;
}
break;
case DOMFLAGS_PAUSED:
info->state = VIR_DOMAIN_PAUSED;
break;
case DOMFLAGS_BLOCKED:
info->state = VIR_DOMAIN_BLOCKED;
break;
case DOMFLAGS_RUNNING:
info->state = VIR_DOMAIN_RUNNING;
break;
default:
info->state = VIR_DOMAIN_NOSTATE;
break;
case DOMFLAGS_PAUSED:
info->state = VIR_DOMAIN_PAUSED;
break;
case DOMFLAGS_BLOCKED:
info->state = VIR_DOMAIN_BLOCKED;
break;
case DOMFLAGS_RUNNING:
info->state = VIR_DOMAIN_RUNNING;
break;
default:
info->state = VIR_DOMAIN_NOSTATE;
}
/*
@ -2949,8 +2949,8 @@ xenHypervisorNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *free
nbNodeCells = xenNbCells(conn);
if (nbNodeCells < 0) {
virXenErrorFunc (conn, VIR_ERR_XEN_CALL, __FUNCTION__,
"cannot determine actual number of cells",0);
return(-1);
"cannot determine actual number of cells",0);
return(-1);
}
if ((maxCells < 1) || (startCell >= nbNodeCells)) {

View File

@ -22,7 +22,7 @@ int xenHypervisorInit (void);
virDomainPtr
xenHypervisorLookupDomainByID (virConnectPtr conn,
int id);
int id);
virDomainPtr
xenHypervisorLookupDomainByUUID(virConnectPtr conn,
const unsigned char *uuid);
@ -30,74 +30,74 @@ char *
xenHypervisorDomainGetOSType (virDomainPtr dom);
int xenHypervisorOpen (virConnectPtr conn,
xmlURIPtr uri,
virConnectAuthPtr auth,
int flags);
xmlURIPtr uri,
virConnectAuthPtr auth,
int flags);
int xenHypervisorClose (virConnectPtr conn);
int xenHypervisorGetVersion (virConnectPtr conn,
unsigned long *hvVer);
unsigned long *hvVer);
char *
xenHypervisorMakeCapabilitiesXML (virConnectPtr conn,
const char *hostmachine,
FILE *cpuinfo,
FILE *capabilities);
const char *hostmachine,
FILE *cpuinfo,
FILE *capabilities);
char *
xenHypervisorGetCapabilities (virConnectPtr conn);
unsigned long
xenHypervisorGetDomMaxMemory (virConnectPtr conn,
int id);
int id);
int xenHypervisorNumOfDomains (virConnectPtr conn);
int xenHypervisorListDomains (virConnectPtr conn,
int *ids,
int maxids);
int *ids,
int maxids);
int xenHypervisorGetMaxVcpus (virConnectPtr conn, const char *type);
int xenHypervisorDestroyDomain (virDomainPtr domain);
int xenHypervisorResumeDomain (virDomainPtr domain);
int xenHypervisorPauseDomain (virDomainPtr domain);
int xenHypervisorGetDomainInfo (virDomainPtr domain,
virDomainInfoPtr info);
virDomainInfoPtr info);
int xenHypervisorGetDomInfo (virConnectPtr conn,
int id,
virDomainInfoPtr info);
int id,
virDomainInfoPtr info);
int xenHypervisorSetMaxMemory (virDomainPtr domain,
unsigned long memory);
unsigned long memory);
int xenHypervisorCheckID (virConnectPtr conn,
int id);
int id);
int xenHypervisorSetVcpus (virDomainPtr domain,
unsigned int nvcpus);
unsigned int nvcpus);
int xenHypervisorPinVcpu (virDomainPtr domain,
unsigned int vcpu,
unsigned char *cpumap,
int maplen);
unsigned int vcpu,
unsigned char *cpumap,
int maplen);
int xenHypervisorGetVcpus (virDomainPtr domain,
virVcpuInfoPtr info,
int maxinfo,
unsigned char *cpumaps,
int maplen);
virVcpuInfoPtr info,
int maxinfo,
unsigned char *cpumaps,
int maplen);
int xenHypervisorGetVcpuMax (virDomainPtr domain);
char * xenHypervisorGetSchedulerType (virDomainPtr domain,
int *nparams);
int *nparams);
int xenHypervisorGetSchedulerParameters (virDomainPtr domain,
virSchedParameterPtr params,
int *nparams);
virSchedParameterPtr params,
int *nparams);
int xenHypervisorSetSchedulerParameters (virDomainPtr domain,
virSchedParameterPtr params,
int nparams);
virSchedParameterPtr params,
int nparams);
int xenHypervisorDomainBlockStats (virDomainPtr domain,
const char *path,
struct _virDomainBlockStats *stats);
const char *path,
struct _virDomainBlockStats *stats);
int xenHypervisorDomainInterfaceStats (virDomainPtr domain,
const char *path,
struct _virDomainInterfaceStats *stats);
const char *path,
struct _virDomainInterfaceStats *stats);
int xenHypervisorNodeGetCellsFreeMemory(virConnectPtr conn,
unsigned long long *freeMems,
int startCell,
int maxCells);
unsigned long long *freeMems,
int startCell,
int maxCells);
#ifdef __cplusplus
}
#endif

View File

@ -185,19 +185,19 @@ xenDomainUsedCpus(virDomainPtr dom)
if ((ncpus = xenUnifiedDomainGetVcpus(dom, cpuinfo, nb_vcpu,
cpumap, cpumaplen)) >= 0) {
for (n = 0 ; n < ncpus ; n++) {
for (m = 0 ; m < nb_cpu; m++) {
if ((cpulist[m] == 0) &&
(VIR_CPU_USABLE(cpumap, cpumaplen, n, m))) {
cpulist[m] = 1;
nb++;
/* if all CPU are used just return NULL */
if (nb == nb_cpu)
goto done;
for (n = 0 ; n < ncpus ; n++) {
for (m = 0 ; m < nb_cpu; m++) {
if ((cpulist[m] == 0) &&
(VIR_CPU_USABLE(cpumap, cpumaplen, n, m))) {
cpulist[m] = 1;
nb++;
/* if all CPU are used just return NULL */
if (nb == nb_cpu)
goto done;
}
}
}
}
}
}
res = virSaveCpuSet(dom->conn, cpulist, nb_cpu);
}
@ -230,7 +230,7 @@ xenUnifiedProbe (void)
FILE *fh;
if (fh = fopen("/dev/xen/domcaps", "r")) {
fclose(fh);
fclose(fh);
return("xen:///");
}
#endif
@ -961,7 +961,7 @@ xenUnifiedDomainDumpXML (virDomainPtr dom, int flags)
char *cpus, *res;
cpus = xenDomainUsedCpus(dom);
res = xenDaemonDomainDumpXML(dom, flags, cpus);
free(cpus);
free(cpus);
return(res);
}
if (priv->opened[XEN_UNIFIED_PROXY_OFFSET])
@ -1138,8 +1138,8 @@ xenUnifiedDomainGetSchedulerType (virDomainPtr dom, int *nparams)
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; i++) {
if (priv->opened[i] && drivers[i]->domainGetSchedulerType) {
schedulertype = drivers[i]->domainGetSchedulerType (dom, nparams);
if (schedulertype != NULL)
return(schedulertype);
if (schedulertype != NULL)
return(schedulertype);
}
}
return(NULL);
@ -1155,9 +1155,9 @@ xenUnifiedDomainGetSchedulerParameters (virDomainPtr dom,
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) {
if (priv->opened[i] && drivers[i]->domainGetSchedulerParameters) {
ret = drivers[i]->domainGetSchedulerParameters(dom, params, nparams);
if (ret == 0)
return(0);
}
if (ret == 0)
return(0);
}
}
return(-1);
}
@ -1172,9 +1172,9 @@ xenUnifiedDomainSetSchedulerParameters (virDomainPtr dom,
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) {
if (priv->opened[i] && drivers[i]->domainSetSchedulerParameters) {
ret = drivers[i]->domainSetSchedulerParameters(dom, params, nparams);
if (ret == 0)
return 0;
}
if (ret == 0)
return 0;
}
}
return(-1);
@ -1230,9 +1230,9 @@ xenUnifiedNodeGetFreeMemory (virConnectPtr conn)
if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET]) {
ret = xenHypervisorNodeGetCellsFreeMemory (conn, &freeMem,
-1, 1);
if (ret != 1)
return (0);
return(freeMem);
if (ret != 1)
return (0);
return(freeMem);
}
xenUnifiedError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);

View File

@ -44,45 +44,45 @@ extern int xenUnifiedRegister (void);
* structure with direct calls in xen_unified.c.
*/
struct xenUnifiedDriver {
virDrvOpen open;
virDrvClose close;
virDrvGetVersion version;
virDrvOpen open;
virDrvClose close;
virDrvGetVersion version;
virDrvGetHostname getHostname;
virDrvGetURI getURI;
virDrvNodeGetInfo nodeGetInfo;
virDrvGetCapabilities getCapabilities;
virDrvListDomains listDomains;
virDrvNumOfDomains numOfDomains;
virDrvDomainCreateLinux domainCreateLinux;
virDrvDomainSuspend domainSuspend;
virDrvDomainResume domainResume;
virDrvDomainShutdown domainShutdown;
virDrvDomainReboot domainReboot;
virDrvDomainDestroy domainDestroy;
virDrvDomainGetOSType domainGetOSType;
virDrvDomainGetMaxMemory domainGetMaxMemory;
virDrvDomainSetMaxMemory domainSetMaxMemory;
virDrvDomainSetMemory domainSetMemory;
virDrvDomainGetInfo domainGetInfo;
virDrvDomainSave domainSave;
virDrvDomainRestore domainRestore;
virDrvDomainCoreDump domainCoreDump;
virDrvDomainSetVcpus domainSetVcpus;
virDrvDomainPinVcpu domainPinVcpu;
virDrvDomainGetVcpus domainGetVcpus;
virDrvDomainGetMaxVcpus domainGetMaxVcpus;
virDrvListDefinedDomains listDefinedDomains;
virDrvNumOfDefinedDomains numOfDefinedDomains;
virDrvDomainCreate domainCreate;
virDrvDomainDefineXML domainDefineXML;
virDrvDomainUndefine domainUndefine;
virDrvDomainAttachDevice domainAttachDevice;
virDrvDomainDetachDevice domainDetachDevice;
virDrvDomainGetAutostart domainGetAutostart;
virDrvDomainSetAutostart domainSetAutostart;
virDrvDomainGetSchedulerType domainGetSchedulerType;
virDrvDomainGetSchedulerParameters domainGetSchedulerParameters;
virDrvDomainSetSchedulerParameters domainSetSchedulerParameters;
virDrvNodeGetInfo nodeGetInfo;
virDrvGetCapabilities getCapabilities;
virDrvListDomains listDomains;
virDrvNumOfDomains numOfDomains;
virDrvDomainCreateLinux domainCreateLinux;
virDrvDomainSuspend domainSuspend;
virDrvDomainResume domainResume;
virDrvDomainShutdown domainShutdown;
virDrvDomainReboot domainReboot;
virDrvDomainDestroy domainDestroy;
virDrvDomainGetOSType domainGetOSType;
virDrvDomainGetMaxMemory domainGetMaxMemory;
virDrvDomainSetMaxMemory domainSetMaxMemory;
virDrvDomainSetMemory domainSetMemory;
virDrvDomainGetInfo domainGetInfo;
virDrvDomainSave domainSave;
virDrvDomainRestore domainRestore;
virDrvDomainCoreDump domainCoreDump;
virDrvDomainSetVcpus domainSetVcpus;
virDrvDomainPinVcpu domainPinVcpu;
virDrvDomainGetVcpus domainGetVcpus;
virDrvDomainGetMaxVcpus domainGetMaxVcpus;
virDrvListDefinedDomains listDefinedDomains;
virDrvNumOfDefinedDomains numOfDefinedDomains;
virDrvDomainCreate domainCreate;
virDrvDomainDefineXML domainDefineXML;
virDrvDomainUndefine domainUndefine;
virDrvDomainAttachDevice domainAttachDevice;
virDrvDomainDetachDevice domainDetachDevice;
virDrvDomainGetAutostart domainGetAutostart;
virDrvDomainSetAutostart domainSetAutostart;
virDrvDomainGetSchedulerType domainGetSchedulerType;
virDrvDomainGetSchedulerParameters domainGetSchedulerParameters;
virDrvDomainSetSchedulerParameters domainSetSchedulerParameters;
};
/* xenUnifiedPrivatePtr:

View File

@ -59,7 +59,7 @@ static int xenDaemonListDefinedDomains(virConnectPtr conn, char **const names, i
static int xenDaemonNumOfDefinedDomains(virConnectPtr conn);
static virDomainPtr xenDaemonCreateLinux(virConnectPtr conn,
const char *xmlDesc,
unsigned int flags);
unsigned int flags);
static char *xenDaemonDomainGetOSType(virDomainPtr domain);
static int xenDaemonAttachDevice(virDomainPtr domain, const char *xml);
static int xenDaemonDetachDevice(virDomainPtr domain, const char *xml);
@ -203,7 +203,7 @@ virXendErrorInt(virConnectPtr conn, virErrorNumber error, int val)
#define foreach(iterator, start) \
for (_for_i = (start), *iterator = (start)->u.s.car; \
for (_for_i = (start), *iterator = (start)->u.s.car; \
_for_i->kind == SEXPR_CONS; \
_for_i = _for_i->u.s.cdr, iterator = _for_i->u.s.car)
@ -613,7 +613,7 @@ xend_op_ext2(virConnectPtr xend, const char *path, char *error,
buf.content = malloc(1000);
if (buf.content == NULL) {
virXendError(xend, VIR_ERR_NO_MEMORY, _("allocate new buffer"));
virXendError(xend, VIR_ERR_NO_MEMORY, _("allocate new buffer"));
return -1;
}
buf.size = 1000;
@ -832,7 +832,7 @@ urlencode(const char *string)
size_t i;
if (buffer == NULL) {
virXendError(NULL, VIR_ERR_NO_MEMORY, _("allocate new buffer"));
virXendError(NULL, VIR_ERR_NO_MEMORY, _("allocate new buffer"));
return (NULL);
}
for (i = 0; i < len; i++) {
@ -1065,7 +1065,7 @@ xenDaemonDomainCreateLinux(virConnectPtr xend, const char *sexpr)
*/
int
xenDaemonDomainLookupByName_ids(virConnectPtr xend, const char *domname,
unsigned char *uuid)
unsigned char *uuid)
{
struct sexpr *root;
const char *value;
@ -1114,9 +1114,9 @@ xenDaemonDomainLookupByName_ids(virConnectPtr xend, const char *domname,
*/
int
xenDaemonDomainLookupByID(virConnectPtr xend,
int id,
char **domname,
unsigned char *uuid)
int id,
char **domname,
unsigned char *uuid)
{
const char *name = NULL;
struct sexpr *root;
@ -1667,7 +1667,7 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
xend has already done this ? */
if ((mode != NULL) && (!strcmp(mode, "r")))
virBufferAddLit(&buf, " <readonly/>\n");
else if ((mode != NULL) && (!strcmp(mode, "w!")))
else if ((mode != NULL) && (!strcmp(mode, "w!")))
virBufferAddLit(&buf, " <shareable/>\n");
virBufferAddLit(&buf, " </disk>\n");
@ -1727,11 +1727,11 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
virBufferVSprintf(&buf, " <graphics type='vnc' port='%d'", port);
if (listenAddr)
virBufferVSprintf(&buf, " listen='%s'", listenAddr);
if (flags & VIR_DOMAIN_XML_SECURE) {
if (flags & VIR_DOMAIN_XML_SECURE) {
vncPasswd = sexpr_node(node, "device/vfb/vncpasswd");
if (vncPasswd)
virBufferVSprintf(&buf, " passwd='%s'", vncPasswd);
}
if (vncPasswd)
virBufferVSprintf(&buf, " passwd='%s'", vncPasswd);
}
if (keymap)
virBufferVSprintf(&buf, " keymap='%s'", keymap);
virBufferAddLit(&buf, "/>\n");
@ -1806,11 +1806,11 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
virBufferVSprintf(&buf, " <graphics type='vnc' port='%d'", port);
if (listenAddr)
virBufferVSprintf(&buf, " listen='%s'", listenAddr);
if (flags & VIR_DOMAIN_XML_SECURE) {
vncPasswd = sexpr_fmt_node(root, "domain/image/%s/vncpasswd", hvm ? "hvm" : "linux");
if (vncPasswd)
virBufferVSprintf(&buf, " passwd='%s'", vncPasswd);
}
if (flags & VIR_DOMAIN_XML_SECURE) {
vncPasswd = sexpr_fmt_node(root, "domain/image/%s/vncpasswd", hvm ? "hvm" : "linux");
if (vncPasswd)
virBufferVSprintf(&buf, " passwd='%s'", vncPasswd);
}
if (keymap)
virBufferVSprintf(&buf, " keymap='%s'", keymap);
virBufferAddLit(&buf, "/>\n");
@ -2237,7 +2237,7 @@ xenDaemonDomainSuspend(virDomainPtr domain)
{
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(-1);
}
if (domain->id < 0)
@ -2259,7 +2259,7 @@ xenDaemonDomainResume(virDomainPtr domain)
{
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(-1);
}
if (domain->id < 0)
@ -2282,7 +2282,7 @@ xenDaemonDomainShutdown(virDomainPtr domain)
{
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(-1);
}
if (domain->id < 0)
@ -2306,7 +2306,7 @@ xenDaemonDomainReboot(virDomainPtr domain, unsigned int flags ATTRIBUTE_UNUSED)
{
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(-1);
}
if (domain->id < 0)
@ -2332,7 +2332,7 @@ xenDaemonDomainDestroy(virDomainPtr domain)
{
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(-1);
}
if (domain->id < 0)
@ -2358,7 +2358,7 @@ xenDaemonDomainGetOSType(virDomainPtr domain)
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(NULL);
}
@ -2402,7 +2402,7 @@ xenDaemonDomainSave(virDomainPtr domain, const char *filename)
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL) ||
(filename == NULL) || (domain->id < 0)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(-1);
}
@ -2434,7 +2434,7 @@ xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename,
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL) ||
(filename == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(-1);
}
if (domain->id < 0)
@ -2483,7 +2483,7 @@ xenDaemonDomainGetMaxMemory(virDomainPtr domain)
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(-1);
}
@ -2523,7 +2523,7 @@ xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(-1);
}
@ -2561,7 +2561,7 @@ xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory)
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(-1);
}
@ -2650,22 +2650,22 @@ xenDaemonDomainDumpXML(virDomainPtr domain, int flags, const char *cpus)
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(NULL);
}
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (domain->id < 0 && priv->xendConfigVersion < 3) {
// fall-through to the next driver to handle
// fall-through to the next driver to handle
return(NULL);
}
if (domain->id < 0)
return xenDaemonDomainDumpXMLByName(domain->conn, domain->name, flags,
cpus);
cpus);
else
return xenDaemonDomainDumpXMLByID(domain->conn, domain->id, flags,
cpus);
cpus);
}
#endif /* !PROXY */
@ -2689,7 +2689,7 @@ xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL) ||
(info == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(-1);
}
@ -2837,7 +2837,7 @@ xenDaemonGetVersion(virConnectPtr conn, unsigned long *hvVer)
}
root = sexpr_get(conn, "/xend/node/");
if (root == NULL)
return(-1);
return(-1);
major = sexpr_int(root, "node/xen_major");
minor = sexpr_int(root, "node/xen_minor");
@ -2888,7 +2888,7 @@ xenDaemonListDomains(virConnectPtr conn, int *ids, int maxids)
}
error:
sexpr_free(root);
sexpr_free(root);
return(ret);
}
@ -2917,11 +2917,11 @@ xenDaemonNumOfDomains(virConnectPtr conn)
_for_i = _for_i->u.s.cdr, node = _for_i->u.s.car) {
if (node->kind != SEXPR_VALUE)
continue;
ret++;
ret++;
}
error:
sexpr_free(root);
sexpr_free(root);
return(ret);
}
#endif /* ! PROXY */
@ -2976,7 +2976,7 @@ xenDaemonDomainSetVcpus(virDomainPtr domain, unsigned int vcpus)
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)
|| (vcpus < 1)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return (-1);
}
@ -3011,7 +3011,7 @@ xenDaemonDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)
|| (cpumap == NULL) || (maplen < 1) || (maplen > (int)sizeof(cpumap_t))) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return (-1);
}
if (domain->id < 0)
@ -3286,7 +3286,7 @@ xenDaemonAttachDevice(virDomainPtr domain, const char *xml)
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return (-1);
}
@ -3341,7 +3341,7 @@ xenDaemonDetachDevice(virDomainPtr domain, const char *xml)
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return (-1);
}
if (virDomainXMLDevID(domain, xml, class, ref, sizeof(ref)))
@ -3567,7 +3567,7 @@ int xenDaemonDomainCreate(virDomainPtr domain)
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(-1);
}
@ -3585,7 +3585,7 @@ int xenDaemonDomainUndefine(virDomainPtr domain)
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(-1);
}

View File

@ -104,19 +104,19 @@ int xenDaemonDomainLookupByName_ids(virConnectPtr xend,
* This method looks up the name/uuid of a domain
*/
int xenDaemonDomainLookupByID(virConnectPtr xend,
int id,
char **name, unsigned char *uuid);
int id,
char **name, unsigned char *uuid);
char *xenDaemonDomainDumpXMLByID(virConnectPtr xend,
int domid,
int flags,
const char *cpus);
int domid,
int flags,
const char *cpus);
char *xenDaemonDomainDumpXMLByName(virConnectPtr xend,
const char *name,
int flags,
const char *cpus);
const char *name,
int flags,
const char *cpus);
/**
* \brief Lookup information about the host machine
@ -207,16 +207,16 @@ int xenDaemonDomainCreate(virDomainPtr domain);
int xenDaemonDomainUndefine(virDomainPtr domain);
int xenDaemonDomainSetVcpus (virDomainPtr domain,
unsigned int vcpus);
unsigned int vcpus);
int xenDaemonDomainPinVcpu (virDomainPtr domain,
unsigned int vcpu,
unsigned char *cpumap,
int maplen);
unsigned int vcpu,
unsigned char *cpumap,
int maplen);
int xenDaemonDomainGetVcpus (virDomainPtr domain,
virVcpuInfoPtr info,
int maxinfo,
unsigned char *cpumaps,
int maplen);
virVcpuInfoPtr info,
int maxinfo,
unsigned char *cpumaps,
int maplen);
/* xen_unified calls through here. */
extern struct xenUnifiedDriver xenDaemonDriver;

View File

@ -674,12 +674,12 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
if (xenXMConfigGetString(conf, "cpus", &str) == 0) {
char *ranges;
ranges = virConvertCpuSet(conn, str, 0);
if (ranges != NULL) {
virBufferVSprintf(buf, " cpuset='%s'", ranges);
free(ranges);
} else
virBufferVSprintf(buf, " cpuset='%s'", str);
ranges = virConvertCpuSet(conn, str, 0);
if (ranges != NULL) {
virBufferVSprintf(buf, " cpuset='%s'", ranges);
free(ranges);
} else
virBufferVSprintf(buf, " cpuset='%s'", str);
}
if (xenXMConfigGetInt(conf, "vcpus", &val) < 0)
val = 1;
@ -771,7 +771,7 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
/* Extract source driver type */
if (!src[0]) {
strcpy(drvName, "phy");
tmp = &src[0];
tmp = &src[0];
} else if (!(tmp = strchr(src, ':')) || !tmp[0]) {
goto skipdisk;
} else {
@ -821,9 +821,9 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
if (!strcmp(head, "r") ||
!strcmp(head, "ro"))
virBufferAddLit(buf, " <readonly/>\n");
else if ((!strcmp(head, "w!")) ||
(!strcmp(head, "!")))
virBufferAddLit(buf, " <shareable/>\n");
else if ((!strcmp(head, "w!")) ||
(!strcmp(head, "!")))
virBufferAddLit(buf, " <shareable/>\n");
virBufferAddLit(buf, " </disk>\n");
skipdisk:
@ -1965,21 +1965,21 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
if (cpus != NULL) {
char *ranges;
ranges = virConvertCpuSet(conn, cpus, 0);
if (ranges != NULL) {
free(cpus);
if (xenXMConfigSetString(conf, "cpus", ranges) < 0) {
free(ranges);
goto error;
}
free(ranges);
} else {
if (xenXMConfigSetString(conf, "cpus", cpus) < 0) {
free(cpus);
goto error;
}
free(cpus);
}
ranges = virConvertCpuSet(conn, cpus, 0);
if (ranges != NULL) {
free(cpus);
if (xenXMConfigSetString(conf, "cpus", ranges) < 0) {
free(ranges);
goto error;
}
free(ranges);
} else {
if (xenXMConfigSetString(conf, "cpus", cpus) < 0) {
free(cpus);
goto error;
}
free(cpus);
}
}
obj = xmlXPathEval(BAD_CAST "string(/domain/os/type)", ctxt);

View File

@ -49,7 +49,7 @@ int xenXMDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
unsigned char *cpumap, int maplen);
virDomainPtr xenXMDomainLookupByName(virConnectPtr conn, const char *domname);
virDomainPtr xenXMDomainLookupByUUID(virConnectPtr conn,
const unsigned char *uuid);
const unsigned char *uuid);
int xenXMListDefinedDomains(virConnectPtr conn, char ** const names, int maxnames);
int xenXMNumOfDefinedDomains(virConnectPtr conn);

View File

@ -276,14 +276,14 @@ virConvertCpuSet(virConnectPtr conn, const char *str, int maxcpu) {
cpuset = calloc(maxcpu, sizeof(*cpuset));
if (cpuset == NULL) {
virXMLError(conn, VIR_ERR_NO_MEMORY, _("allocate buffer"), 0);
return(NULL);
virXMLError(conn, VIR_ERR_NO_MEMORY, _("allocate buffer"), 0);
return(NULL);
}
ret = virParseCpuSet(conn, &cur, 0, cpuset, maxcpu);
if (ret < 0) {
free(cpuset);
return(NULL);
return(NULL);
}
res = virSaveCpuSet(conn, cpuset, maxcpu);
free(cpuset);
@ -803,7 +803,7 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
/* Only XenD <= 3.0.2 wants cdrom config here */
if (xendConfigVersion == 1) {
cur = virXPathNode(
"/domain/devices/disk[@device='cdrom' and target/@dev='hdc']/source",
"/domain/devices/disk[@device='cdrom' and target/@dev='hdc']/source",
ctxt);
if (cur != NULL) {
xmlChar *cdfile;
@ -1653,14 +1653,14 @@ virParseXMLDevice(virConnectPtr conn, const char *xmldesc, int hvm,
goto error;
if (xmlStrEqual(node->name, BAD_CAST "disk")) {
if (virDomainParseXMLDiskDesc(conn, node, &buf, hvm,
xendConfigVersion) != 0)
xendConfigVersion) != 0)
goto error;
/* SXP is not created when device is "floppy". */
else if (buf.use == 0)
goto error;
} else if (xmlStrEqual(node->name, BAD_CAST "interface")) {
if (virDomainParseXMLIfDesc(conn, node, &buf, hvm,
xendConfigVersion) != 0)
xendConfigVersion) != 0)
goto error;
} else {
virXMLError(conn, VIR_ERR_XML_ERROR, (const char *) node->name, 0);

View File

@ -17,46 +17,46 @@ extern "C" {
#endif
int virXPathBoolean (const char *xpath,
xmlXPathContextPtr ctxt);
xmlXPathContextPtr ctxt);
char * virXPathString (const char *xpath,
xmlXPathContextPtr ctxt);
xmlXPathContextPtr ctxt);
int virXPathNumber (const char *xpath,
xmlXPathContextPtr ctxt,
double *value);
xmlXPathContextPtr ctxt,
double *value);
int virXPathLong (const char *xpath,
xmlXPathContextPtr ctxt,
long *value);
xmlXPathContextPtr ctxt,
long *value);
xmlNodePtr virXPathNode (const char *xpath,
xmlXPathContextPtr ctxt);
xmlXPathContextPtr ctxt);
int virXPathNodeSet (const char *xpath,
xmlXPathContextPtr ctxt,
xmlNodePtr **list);
xmlXPathContextPtr ctxt,
xmlNodePtr **list);
#if WITH_XEN
int virParseCpuSet (virConnectPtr conn,
const char **str,
char sep,
char *cpuset,
int maxcpu);
const char **str,
char sep,
char *cpuset,
int maxcpu);
char * virSaveCpuSet (virConnectPtr conn,
char *cpuset,
int maxcpu);
char *cpuset,
int maxcpu);
char * virConvertCpuSet(virConnectPtr conn,
const char *str,
int maxcpu);
const char *str,
int maxcpu);
char * virDomainParseXMLDesc(virConnectPtr conn,
const char *xmldesc,
char **name,
int xendConfigVersion);
const char *xmldesc,
char **name,
int xendConfigVersion);
char * virParseXMLDevice(virConnectPtr conn,
const char *xmldesc,
int hvm,
int xendConfigVersion);
const char *xmldesc,
int hvm,
int xendConfigVersion);
int virDomainXMLDevID(virDomainPtr domain,
const char *xmldesc,
char *class,
char *ref,
int ref_len);
const char *xmldesc,
char *class,
char *ref,
int ref_len);
#endif
#ifdef __cplusplus

View File

@ -50,38 +50,38 @@ static xmlRpcValuePtr xmlRpcValueNew(xmlRpcValueType type)
xmlRpcValuePtr ret = malloc(sizeof(*ret));
if (!ret)
xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate value"), sizeof(*ret));
xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate value"), sizeof(*ret));
else
ret->kind = type;
ret->kind = type;
return ret;
}
static char *xmlGetText(xmlNodePtr node)
{
for (node = node->children; node; node = node->next)
if (node->type == XML_TEXT_NODE) {
char *x = strdup((const char *)node->content);
if (!x)
if (node->type == XML_TEXT_NODE) {
char *x = strdup((const char *)node->content);
if (!x)
xmlRpcError(VIR_ERR_NO_MEMORY, _("copying node content"),
strlen((const char *)node->content));
return x;
}
return x;
}
return NULL;
}
static xmlNodePtr xmlFirstElement(xmlNodePtr node)
{
for (node = node->children; node; node = node->next)
if (node->type == XML_ELEMENT_NODE)
break;
if (node->type == XML_ELEMENT_NODE)
break;
return node;
}
static xmlNodePtr xmlNextElement(xmlNodePtr node)
{
for (node = node->next; node; node = node->next)
if (node->type == XML_ELEMENT_NODE)
break;
if (node->type == XML_ELEMENT_NODE)
break;
return node;
}
@ -127,9 +127,9 @@ static xmlRpcValuePtr xmlRpcValueUnmarshalBoolean(xmlNodePtr node)
if (!ret)
return NULL;
if (value && atoi(value))
ret->value.boolean = true;
ret->value.boolean = true;
else
ret->value.boolean = false;
ret->value.boolean = false;
free(value);
return ret;
}
@ -156,19 +156,19 @@ static xmlRpcValuePtr xmlRpcValueUnmarshalArray(xmlNodePtr node)
return NULL;
for (cur = xmlFirstElement(node); cur; cur = xmlNextElement(cur))
n_elements += 1;
n_elements += 1;
elems = malloc(n_elements * sizeof(*elems));
if (!elems) {
xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate value array"),
n_elements * sizeof(*elems));
free(ret);
return NULL;
free(ret);
return NULL;
}
n_elements = 0;
for (cur = xmlFirstElement(node); cur; cur = xmlNextElement(cur)) {
elems[n_elements] = xmlRpcValueUnmarshal(cur);
n_elements += 1;
elems[n_elements] = xmlRpcValueUnmarshal(cur);
n_elements += 1;
}
ret->value.array.elements = elems;
@ -183,24 +183,24 @@ static xmlRpcValueDictElementPtr xmlRpcValueUnmarshalDictElement(xmlNodePtr node
xmlNodePtr cur;
if (!ret) {
xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate dict"), sizeof(*ret));
return NULL;
xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate dict"), sizeof(*ret));
return NULL;
}
memset(ret, 0, sizeof(*ret));
for (cur = xmlFirstElement(node); cur; cur = xmlNextElement(cur)) {
if (xmlStrEqual(cur->name, BAD_CAST "name")) {
ret->name = xmlGetText(cur);
} else if (xmlStrEqual(cur->name, BAD_CAST "value")) {
ret->value = xmlRpcValueUnmarshal(cur);
} else {
if (xmlStrEqual(cur->name, BAD_CAST "name")) {
ret->name = xmlGetText(cur);
} else if (xmlStrEqual(cur->name, BAD_CAST "value")) {
ret->value = xmlRpcValueUnmarshal(cur);
} else {
xmlRpcError(VIR_ERR_XML_ERROR, _("unexpected dict node"), 0);
free(ret->name);
if (ret->value)
xmlRpcValueFree(ret->value);
free(ret);
return NULL;
}
free(ret->name);
if (ret->value)
xmlRpcValueFree(ret->value);
free(ret);
return NULL;
}
}
ret->next = NULL;
@ -215,17 +215,17 @@ static xmlRpcValuePtr xmlRpcValueUnmarshalDict(xmlNodePtr node)
xmlNodePtr cur;
if (!ret)
return NULL;
return NULL;
ret->value.dict.root = root;
for (cur = xmlFirstElement(node); cur; cur = xmlNextElement(cur)) {
*elem = xmlRpcValueUnmarshalDictElement(cur);
if (*elem==NULL) {
xmlRpcValueFree(ret);
return NULL;
}
elem = &(*elem)->next;
*elem = xmlRpcValueUnmarshalDictElement(cur);
if (*elem==NULL) {
xmlRpcValueFree(ret);
return NULL;
}
elem = &(*elem)->next;
}
return ret;
@ -237,33 +237,33 @@ xmlRpcValuePtr xmlRpcValueUnmarshal(xmlNodePtr node)
xmlRpcValuePtr ret = NULL;
if (xmlStrEqual(node->name, BAD_CAST "value")) {
n = xmlFirstElement(node);
if (n == NULL) {
ret = xmlRpcValueUnmarshalString(node);
} else {
ret = xmlRpcValueUnmarshal(n);
}
n = xmlFirstElement(node);
if (n == NULL) {
ret = xmlRpcValueUnmarshalString(node);
} else {
ret = xmlRpcValueUnmarshal(n);
}
} else if (xmlStrEqual(node->name, BAD_CAST "dateTime.iso8601")) {
ret = xmlRpcValueUnmarshalDateTime(node);
ret = xmlRpcValueUnmarshalDateTime(node);
} else if (xmlStrEqual(node->name, BAD_CAST "string")) {
ret = xmlRpcValueUnmarshalString(node);
ret = xmlRpcValueUnmarshalString(node);
} else if (xmlStrEqual(node->name, BAD_CAST "base64")) {
ret = xmlRpcValueUnmarshalBase64(node);
ret = xmlRpcValueUnmarshalBase64(node);
} else if (xmlStrEqual(node->name, BAD_CAST "i4") ||
xmlStrEqual(node->name, BAD_CAST "int")) {
ret = xmlRpcValueUnmarshalInteger(node);
xmlStrEqual(node->name, BAD_CAST "int")) {
ret = xmlRpcValueUnmarshalInteger(node);
} else if (xmlStrEqual(node->name, BAD_CAST "boolean")) {
ret = xmlRpcValueUnmarshalBoolean(node);
ret = xmlRpcValueUnmarshalBoolean(node);
} else if (xmlStrEqual(node->name, BAD_CAST "double")) {
ret = xmlRpcValueUnmarshalDouble(node);
ret = xmlRpcValueUnmarshalDouble(node);
} else if (xmlStrEqual(node->name, BAD_CAST "array")) {
ret = xmlRpcValueUnmarshal(xmlFirstElement(node));
ret = xmlRpcValueUnmarshal(xmlFirstElement(node));
} else if (xmlStrEqual(node->name, BAD_CAST "data")) {
ret = xmlRpcValueUnmarshalArray(node);
ret = xmlRpcValueUnmarshalArray(node);
} else if (xmlStrEqual(node->name, BAD_CAST "struct")) {
ret = xmlRpcValueUnmarshalDict(node);
ret = xmlRpcValueUnmarshalDict(node);
} else if (xmlStrEqual(node->name, BAD_CAST "nil")) {
ret = xmlRpcValueNew(XML_RPC_NIL);
ret = xmlRpcValueNew(XML_RPC_NIL);
} else {
xmlRpcError(VIR_ERR_XML_ERROR, _("unexpected value node"), 0);
}
@ -277,29 +277,29 @@ void xmlRpcValueFree(xmlRpcValuePtr value)
xmlRpcValueDictElementPtr cur, next;
if (value == NULL)
return;
return;
switch (value->kind) {
case XML_RPC_ARRAY:
for (i = 0; i < value->value.array.n_elements; i++)
xmlRpcValueFree(value->value.array.elements[i]);
free(value->value.array.elements);
break;
for (i = 0; i < value->value.array.n_elements; i++)
xmlRpcValueFree(value->value.array.elements[i]);
free(value->value.array.elements);
break;
case XML_RPC_STRUCT:
next = value->value.dict.root;
while (next) {
cur = next;
next = next->next;
free(cur->name);
xmlRpcValueFree(cur->value);
free(cur);
}
break;
next = value->value.dict.root;
while (next) {
cur = next;
next = next->next;
free(cur->name);
xmlRpcValueFree(cur->value);
free(cur);
}
break;
case XML_RPC_STRING:
free(value->value.string);
break;
free(value->value.string);
break;
default:
break;
break;
}
free(value);
@ -313,58 +313,58 @@ void xmlRpcValueMarshal(xmlRpcValuePtr value, virBufferPtr buf, int indent)
virBufferVSprintf(buf, "%*s<value>", indent, "");
switch (value->kind) {
case XML_RPC_ARRAY:
virBufferStrcat(buf, "<array><data>\n", NULL);
for (i = 0; i < value->value.array.n_elements; i++)
xmlRpcValueMarshal(value->value.array.elements[i], buf, indent+2);
virBufferVSprintf(buf, "%*s</data></array>", indent, "");
break;
virBufferStrcat(buf, "<array><data>\n", NULL);
for (i = 0; i < value->value.array.n_elements; i++)
xmlRpcValueMarshal(value->value.array.elements[i], buf, indent+2);
virBufferVSprintf(buf, "%*s</data></array>", indent, "");
break;
case XML_RPC_STRUCT:
virBufferStrcat(buf, "<struct>\n", NULL);
indent += 2;
for (elem = value->value.dict.root; elem; elem = elem->next) {
virBufferVSprintf(buf, "%*s<member>\n", indent, "");
virBufferVSprintf(buf, "%*s<name>%s</name>\n",
indent + 2, "", elem->name);
xmlRpcValueMarshal(elem->value, buf, indent + 2);
virBufferVSprintf(buf, "%*s</member>\n", indent, "");
}
indent -= 2;
virBufferVSprintf(buf, "%*s</struct>", indent, "");
break;
virBufferStrcat(buf, "<struct>\n", NULL);
indent += 2;
for (elem = value->value.dict.root; elem; elem = elem->next) {
virBufferVSprintf(buf, "%*s<member>\n", indent, "");
virBufferVSprintf(buf, "%*s<name>%s</name>\n",
indent + 2, "", elem->name);
xmlRpcValueMarshal(elem->value, buf, indent + 2);
virBufferVSprintf(buf, "%*s</member>\n", indent, "");
}
indent -= 2;
virBufferVSprintf(buf, "%*s</struct>", indent, "");
break;
case XML_RPC_INTEGER:
virBufferVSprintf(buf, "<int>%d</int>", value->value.integer);
break;
virBufferVSprintf(buf, "<int>%d</int>", value->value.integer);
break;
case XML_RPC_DOUBLE:
virBufferVSprintf(buf, "<double>%f</double>", value->value.real);
break;
virBufferVSprintf(buf, "<double>%f</double>", value->value.real);
break;
case XML_RPC_BOOLEAN:
if (value->value.boolean)
i = 1;
else
i = 0;
virBufferVSprintf(buf, "<boolean>%d</boolean>", i);
break;
if (value->value.boolean)
i = 1;
else
i = 0;
virBufferVSprintf(buf, "<boolean>%d</boolean>", i);
break;
case XML_RPC_DATE_TIME:
/* FIXME */
TODO
break;
/* FIXME */
TODO
break;
case XML_RPC_BASE64:
/* FIXME */
TODO
break;
/* FIXME */
TODO
break;
case XML_RPC_STRING:
virBufferStrcat(buf,
"<string>", value->value.string, "</string>", NULL);
break;
virBufferStrcat(buf,
"<string>", value->value.string, "</string>", NULL);
break;
case XML_RPC_NIL:
virBufferStrcat(buf, "<nil> </nil>", NULL);
break;
virBufferStrcat(buf, "<nil> </nil>", NULL);
break;
}
virBufferStrcat(buf, "</value>\n", NULL);
}
virBufferPtr xmlRpcMarshalRequest(const char *request,
int argc, xmlRpcValuePtr *argv)
int argc, xmlRpcValuePtr *argv)
{
virBufferPtr buf;
int i;
@ -372,97 +372,97 @@ virBufferPtr xmlRpcMarshalRequest(const char *request,
buf = virBufferNew(1024);
virBufferStrcat(buf,
"<?xml version=\"1.0\"?>\n"
"<methodCall>\n"
" <methodName>", request, "</methodName>\n"
" <params>\n", NULL);
"<?xml version=\"1.0\"?>\n"
"<methodCall>\n"
" <methodName>", request, "</methodName>\n"
" <params>\n", NULL);
for (i = 0; i < argc; i++) {
virBufferStrcat(buf,
virBufferStrcat(buf,
" <param>\n", NULL);
xmlRpcValueMarshal(argv[i], buf, 6);
virBufferStrcat(buf,
xmlRpcValueMarshal(argv[i], buf, 6);
virBufferStrcat(buf,
" </param>\n", NULL);
}
virBufferStrcat(buf,
" </params>\n"
"</methodCall>\n", NULL);
"</methodCall>\n", NULL);
return buf;
}
xmlRpcValuePtr xmlRpcUnmarshalResponse(xmlNodePtr node, bool *is_fault)
{
if (!node)
return NULL;
return NULL;
if (!xmlStrEqual(node->name, BAD_CAST "methodResponse"))
return NULL;
return NULL;
node = xmlFirstElement(node);
if (xmlStrEqual(node->name, BAD_CAST "params")) {
node = xmlFirstElement(node);
node = xmlFirstElement(node);
if (!xmlStrEqual(node->name, BAD_CAST "param"))
return NULL;
if (!xmlStrEqual(node->name, BAD_CAST "param"))
return NULL;
*is_fault = false;
return xmlRpcValueUnmarshal(xmlFirstElement(node));
*is_fault = false;
return xmlRpcValueUnmarshal(xmlFirstElement(node));
} else if (xmlStrEqual(node->name, BAD_CAST "fault")) {
*is_fault = true;
return xmlRpcValueUnmarshal(xmlFirstElement(node));
*is_fault = true;
return xmlRpcValueUnmarshal(xmlFirstElement(node));
} else
return NULL;
return NULL;
}
static char *xmlRpcCallRaw(const char *url, const char *request)
{
void *cxt;
char *contentType = (char *) "text/xml";
int len, ret, serrno;
char *response = NULL;
void *cxt;
char *contentType = (char *) "text/xml";
int len, ret, serrno;
char *response = NULL;
cxt = xmlNanoHTTPMethod(url,
"POST",
request,
&contentType,
NULL,
strlen(request));
cxt = xmlNanoHTTPMethod(url,
"POST",
request,
&contentType,
NULL,
strlen(request));
if (cxt == NULL) {
if (cxt == NULL) {
xmlRpcError(VIR_ERR_POST_FAILED, _("send request"), 0);
goto error;
}
goto error;
}
if (contentType && strcmp(contentType, "text/xml") != 0) {
errno = EINVAL;
xmlRpcError(VIR_ERR_POST_FAILED, _("unexpected mime type"), 0);
goto error;
}
if (contentType && strcmp(contentType, "text/xml") != 0) {
errno = EINVAL;
xmlRpcError(VIR_ERR_POST_FAILED, _("unexpected mime type"), 0);
goto error;
}
len = xmlNanoHTTPContentLength(cxt);
response = malloc(len + 1);
if (response == NULL) {
xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate response"), len);
goto error;
}
ret = xmlNanoHTTPRead(cxt, response, len);
if (ret != len) {
errno = EINVAL;
free(response);
response = NULL;
xmlRpcError(VIR_ERR_POST_FAILED, _("read response"), 0);
}
len = xmlNanoHTTPContentLength(cxt);
response = malloc(len + 1);
if (response == NULL) {
xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate response"), len);
goto error;
}
ret = xmlNanoHTTPRead(cxt, response, len);
if (ret != len) {
errno = EINVAL;
free(response);
response = NULL;
xmlRpcError(VIR_ERR_POST_FAILED, _("read response"), 0);
}
response[len] = 0;
response[len] = 0;
error:
serrno = errno;
if (cxt) {
xmlNanoHTTPClose(cxt);
free(contentType);
}
errno = serrno;
serrno = errno;
if (cxt) {
xmlNanoHTTPClose(cxt);
free(contentType);
}
errno = serrno;
return response;
return response;
}
static char **xmlRpcStringArray(xmlRpcValuePtr value)
@ -472,29 +472,29 @@ static char **xmlRpcStringArray(xmlRpcValuePtr value)
size_t size = 0;
if (value->kind != XML_RPC_ARRAY)
return NULL;
return NULL;
size = sizeof(char *) * (value->value.array.n_elements + 1);
for (i = 0; i < value->value.array.n_elements; i++)
if (value->value.array.elements[i]->kind == XML_RPC_STRING)
size += strlen(value->value.array.elements[i]->value.string) + 1;
if (value->value.array.elements[i]->kind == XML_RPC_STRING)
size += strlen(value->value.array.elements[i]->value.string) + 1;
if (!(ptr = malloc(size))) {
xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate string array"), size);
return NULL;
xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate string array"), size);
return NULL;
}
ret = (char **)ptr;
ptr += sizeof(char *) * (value->value.array.n_elements + 1);
for (i = 0; i < value->value.array.n_elements; i++) {
if (value->value.array.elements[i]->kind == XML_RPC_STRING) {
char *s = value->value.array.elements[i]->value.string;
strcpy(ptr, s);
ret[i] = ptr;
ptr += strlen(s) + 1;
} else
ret[i] = (char *) "";
if (value->value.array.elements[i]->kind == XML_RPC_STRING) {
char *s = value->value.array.elements[i]->value.string;
strcpy(ptr, s);
ret[i] = ptr;
ptr += strlen(s) + 1;
} else
ret[i] = (char *) "";
}
ret[i] = NULL;
@ -516,32 +516,32 @@ xmlRpcArgvNew(const char *fmt, va_list ap, int *argc)
}
i = 0;
for (ptr = fmt; *ptr; ptr++) {
switch (*ptr) {
case 'i':
if ((argv[i] = xmlRpcValueNew(XML_RPC_INTEGER)))
argv[i]->value.integer = va_arg(ap, int32_t);
break;
case 'f':
if ((argv[i] = xmlRpcValueNew(XML_RPC_DOUBLE)))
argv[i]->value.real = va_arg(ap, double);
break;
case 'b':
if ((argv[i] = xmlRpcValueNew(XML_RPC_BOOLEAN)))
argv[i]->value.boolean = va_arg(ap, int);
break;
case 's':
if ((argv[i] = xmlRpcValueNew(XML_RPC_STRING)))
argv[i]->value.string = strdup(va_arg(ap, const char *));
break;
default:
argv[i] = NULL;
break;
}
if (argv[i]==NULL) {
xmlRpcArgvFree(i, argv);
return NULL;
}
i++;
switch (*ptr) {
case 'i':
if ((argv[i] = xmlRpcValueNew(XML_RPC_INTEGER)))
argv[i]->value.integer = va_arg(ap, int32_t);
break;
case 'f':
if ((argv[i] = xmlRpcValueNew(XML_RPC_DOUBLE)))
argv[i]->value.real = va_arg(ap, double);
break;
case 'b':
if ((argv[i] = xmlRpcValueNew(XML_RPC_BOOLEAN)))
argv[i]->value.boolean = va_arg(ap, int);
break;
case 's':
if ((argv[i] = xmlRpcValueNew(XML_RPC_STRING)))
argv[i]->value.string = strdup(va_arg(ap, const char *));
break;
default:
argv[i] = NULL;
break;
}
if (argv[i]==NULL) {
xmlRpcArgvFree(i, argv);
return NULL;
}
i++;
}
return argv;
}
@ -551,15 +551,15 @@ xmlRpcArgvFree(int argc, xmlRpcValuePtr *argv)
{
int i;
if (!argv)
return;
return;
for (i = 0; i < argc; i++)
xmlRpcValueFree(argv[i]);
xmlRpcValueFree(argv[i]);
free(argv);
}
int xmlRpcCall(xmlRpcContextPtr context, const char *method,
const char *retfmt, const char *fmt, ...)
const char *retfmt, const char *fmt, ...)
{
va_list ap;
int argc;
@ -575,10 +575,10 @@ int xmlRpcCall(xmlRpcContextPtr context, const char *method,
va_start(ap, fmt);
if (retfmt && *retfmt)
retval = va_arg(ap, void *);
retval = va_arg(ap, void *);
if (!(argv = xmlRpcArgvNew(fmt, ap, &argc)))
return -1;
return -1;
va_end(ap);
@ -587,24 +587,24 @@ int xmlRpcCall(xmlRpcContextPtr context, const char *method,
xmlRpcArgvFree(argc, argv);
if (!buf)
return -1;
return -1;
ret = xmlRpcCallRaw(context->uri, buf->content);
virBufferFree(buf);
if (!ret)
return -1;
return -1;
xml = xmlReadDoc((const xmlChar *)ret, "response.xml", NULL,
XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
free(ret);
if (xml == NULL) {
errno = EINVAL;
xmlRpcError(VIR_ERR_XML_ERROR, _("parse server response failed"), 0);
return -1;
errno = EINVAL;
xmlRpcError(VIR_ERR_XML_ERROR, _("parse server response failed"), 0);
return -1;
}
node = xmlDocGetRootElement(xml);
@ -612,46 +612,46 @@ int xmlRpcCall(xmlRpcContextPtr context, const char *method,
value = xmlRpcUnmarshalResponse(node, &fault);
if (!fault) {
switch (*retfmt) {
case 'i':
if (value->kind == XML_RPC_INTEGER)
*(int32_t *)retval = value->value.integer;
break;
case 'b':
if (value->kind == XML_RPC_BOOLEAN)
*(bool *)retval = value->value.boolean;
break;
case 'f':
if (value->kind == XML_RPC_DOUBLE)
*(double *)retval = value->value.real;
break;
case 's':
if (value->kind == XML_RPC_STRING)
*(char **)retval = strdup(value->value.string);
break;
case 'S':
*(char ***)retval = xmlRpcStringArray(value);
break;
case 'V':
*(xmlRpcValuePtr *)retval = value;
value = NULL;
break;
default:
printf("not supported yet\n");
break;
}
switch (*retfmt) {
case 'i':
if (value->kind == XML_RPC_INTEGER)
*(int32_t *)retval = value->value.integer;
break;
case 'b':
if (value->kind == XML_RPC_BOOLEAN)
*(bool *)retval = value->value.boolean;
break;
case 'f':
if (value->kind == XML_RPC_DOUBLE)
*(double *)retval = value->value.real;
break;
case 's':
if (value->kind == XML_RPC_STRING)
*(char **)retval = strdup(value->value.string);
break;
case 'S':
*(char ***)retval = xmlRpcStringArray(value);
break;
case 'V':
*(xmlRpcValuePtr *)retval = value;
value = NULL;
break;
default:
printf("not supported yet\n");
break;
}
}
xmlFreeDoc(xml);
if (fault) {
/* FIXME we need generic dict routines */
/* FIXME we need faultMessage propagate to libvirt error API */
context->faultCode = value->value.dict.root->value->value.integer;
context->faultMessage = strdup(value->value.dict.root->next->value->value.string);
xmlRpcValueFree(value);
errno = EFAULT;
return -1;
/* FIXME we need generic dict routines */
/* FIXME we need faultMessage propagate to libvirt error API */
context->faultCode = value->value.dict.root->value->value.integer;
context->faultMessage = strdup(value->value.dict.root->next->value->value.string);
xmlRpcValueFree(value);
errno = EFAULT;
return -1;
}
xmlRpcValueFree(value);
@ -664,8 +664,8 @@ xmlRpcContextPtr xmlRpcContextNew(const char *uri)
xmlRpcContextPtr ret = malloc(sizeof(*ret));
if (ret) {
ret->uri = strdup(uri);
ret->faultMessage = NULL;
ret->uri = strdup(uri);
ret->faultMessage = NULL;
} else
xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate new context"), sizeof(*ret));
@ -675,9 +675,9 @@ xmlRpcContextPtr xmlRpcContextNew(const char *uri)
void xmlRpcContextFree(xmlRpcContextPtr context)
{
if (context) {
free(context->uri);
free(context->faultMessage);
free(context);
free(context->uri);
free(context->faultMessage);
free(context);
}
}

View File

@ -73,14 +73,14 @@ struct _xmlRpcValue {
xmlRpcValueType kind;
union {
char *string;
xmlRpcValueArray array;
xmlRpcValueDict dict;
int32_t integer;
double real;
bool boolean;
time_t dateTime;
xmlRpcValueBase64 base64;
char *string;
xmlRpcValueArray array;
xmlRpcValueDict dict;
int32_t integer;
double real;
bool boolean;
time_t dateTime;
xmlRpcValueBase64 base64;
} value;
};
@ -90,7 +90,7 @@ xmlRpcValuePtr *xmlRpcArgvNew(const char *fmt, va_list ap, int *argc);
void xmlRpcArgvFree(int argc, xmlRpcValuePtr *argv);
virBufferPtr xmlRpcMarshalRequest(const char *request,
int argc, xmlRpcValuePtr *argv);
int argc, xmlRpcValuePtr *argv);
xmlRpcValuePtr xmlRpcUnmarshalResponse(xmlNodePtr node, bool *is_fault);
@ -101,7 +101,7 @@ xmlRpcValuePtr xmlRpcValueUnmarshal(xmlNodePtr node);
void xmlRpcValueFree(xmlRpcValuePtr value);
int xmlRpcCall(xmlRpcContextPtr context, const char *method,
const char *retval, const char *fmt, ...);
const char *retval, const char *fmt, ...);
xmlRpcContextPtr xmlRpcContextNew(const char *uri);

View File

@ -313,21 +313,21 @@ xenStoreOpen(virConnectPtr conn,
priv->xshandle = xs_daemon_open_readonly();
#else
if (flags & VIR_CONNECT_RO)
priv->xshandle = xs_daemon_open_readonly();
priv->xshandle = xs_daemon_open_readonly();
else
priv->xshandle = xs_daemon_open();
priv->xshandle = xs_daemon_open();
#endif /* ! PROXY */
if (priv->xshandle == NULL) {
/*
/*
* not being able to connect via the socket as a normal user
* is rather normal, this should fallback to the proxy (or
* remote) mechanism.
*/
*/
if (getuid() == 0) {
virXenStoreError(NULL, VIR_ERR_NO_XEN,
_("failed to connect to Xen Store"));
}
virXenStoreError(NULL, VIR_ERR_NO_XEN,
_("failed to connect to Xen Store"));
}
return (-1);
}
return (0);
@ -382,8 +382,8 @@ xenStoreGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
if ((domain == NULL) || (domain->conn == NULL) || (info == NULL)) {
virXenStoreError(domain ? domain->conn : NULL, VIR_ERR_INVALID_ARG,
__FUNCTION__);
return(-1);
__FUNCTION__);
return(-1);
}
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
@ -448,13 +448,13 @@ xenStoreDomainSetMemory(virDomainPtr domain, unsigned long memory)
if ((domain == NULL) || (domain->conn == NULL) ||
(memory < 1024 * MIN_XEN_GUEST_SIZE)) {
virXenStoreError(domain ? domain->conn : NULL, VIR_ERR_INVALID_ARG,
__FUNCTION__);
return(-1);
__FUNCTION__);
return(-1);
}
if (domain->id == -1)
return(-1);
if ((domain->id == 0) && (memory < (2 * MIN_XEN_GUEST_SIZE * 1024)))
return(-1);
return(-1);
snprintf(value, 19, "%lu", memory);
value[19] = 0;
ret = virDomainDoStoreWrite(domain, "memory/target", &value[0]);
@ -484,8 +484,8 @@ xenStoreDomainGetMaxMemory(virDomainPtr domain)
tmp = virDomainDoStoreQuery(domain->conn, domain->id, "memory/target");
if (tmp != NULL) {
ret = (unsigned long) atol(tmp);
free(tmp);
ret = (unsigned long) atol(tmp);
free(tmp);
}
return(ret);
}
@ -519,7 +519,7 @@ xenStoreNumOfDomains(virConnectPtr conn)
idlist = xs_directory(priv->xshandle, 0, "/local/domain", &num);
if (idlist) {
free(idlist);
ret = num;
ret = num;
}
return(ret);
}
@ -545,7 +545,7 @@ xenStoreListDomains(virConnectPtr conn, int *ids, int maxids)
if ((conn == NULL) || (ids == NULL)) {
virXenStoreError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
return(-1);
}
priv = (xenUnifiedPrivatePtr) conn->privateData;
@ -554,19 +554,19 @@ xenStoreListDomains(virConnectPtr conn, int *ids, int maxids)
idlist = xs_directory (priv->xshandle, 0, "/local/domain", &num);
if (idlist == NULL)
return(-1);
return(-1);
for (ret = 0, i = 0; (i < num) && (ret < maxids); i++) {
id = strtol(idlist[i], &endptr, 10);
if ((endptr == idlist[i]) || (*endptr != 0)) {
ret = -1;
break;
}
id = strtol(idlist[i], &endptr, 10);
if ((endptr == idlist[i]) || (*endptr != 0)) {
ret = -1;
break;
}
#if 0
if (virConnectCheckStoreID(conn, (int) id) < 0)
continue;
if (virConnectCheckStoreID(conn, (int) id) < 0)
continue;
#endif
ids[ret++] = (int) id;
ids[ret++] = (int) id;
}
free(idlist);
return(ret);
@ -595,7 +595,7 @@ xenStoreLookupByName(virConnectPtr conn, const char *name)
if ((conn == NULL) || (name == NULL)) {
virXenStoreError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return(NULL);
return(NULL);
}
priv = (xenUnifiedPrivatePtr) conn->privateData;
@ -604,7 +604,7 @@ xenStoreLookupByName(virConnectPtr conn, const char *name)
idlist = xs_directory(priv->xshandle, 0, "/local/domain", &num);
if (idlist == NULL)
goto done;
goto done;
for (i = 0; i < num; i++) {
id = strtol(idlist[i], &endptr, 10);
@ -635,8 +635,8 @@ xenStoreLookupByName(virConnectPtr conn, const char *name)
ret->id = id;
done:
free(xenddomain);
free(idlist);
free(xenddomain);
free(idlist);
return(ret);
}
@ -656,7 +656,7 @@ xenStoreDomainShutdown(virDomainPtr domain)
{
if ((domain == NULL) || (domain->conn == NULL)) {
virXenStoreError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(-1);
}
if (domain->id == -1 || domain->id == 0)
@ -684,7 +684,7 @@ xenStoreDomainReboot(virDomainPtr domain, unsigned int flags ATTRIBUTE_UNUSED)
{
if ((domain == NULL) || (domain->conn == NULL)) {
virXenStoreError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(-1);
}
if (domain->id == -1 || domain->id == 0)
@ -711,7 +711,7 @@ xenStoreDomainGetOSType(virDomainPtr domain) {
if ((domain == NULL) || (domain->conn == NULL)) {
virXenStoreError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
__FUNCTION__);
__FUNCTION__);
return(NULL);
}
@ -798,7 +798,7 @@ xenStoreDomainGetOSTypeID(virConnectPtr conn, int id) {
if (vm) {
snprintf(query, 199, "%s/image/ostype", vm);
str = xs_read(priv->xshandle, 0, &query[0], &len);
str = xs_read(priv->xshandle, 0, &query[0], &len);
free(vm);
}
if (str == NULL)
@ -843,19 +843,19 @@ xenStoreDomainGetNetworkID(virConnectPtr conn, int id, const char *mac) {
snprintf(dir, sizeof(dir), "/local/domain/0/backend/vif/%d", id);
list = xs_directory(priv->xshandle, 0, dir, &num);
if (list == NULL)
return(NULL);
return(NULL);
for (i = 0; i < num; i++) {
snprintf(path, sizeof(path), "%s/%s/%s", dir, list[i], "mac");
val = xs_read(priv->xshandle, 0, path, &len);
if (val == NULL)
break;
if ((maclen != len) || memcmp(val, mac, len)) {
free(val);
} else {
ret = strdup(list[i]);
free(val);
break;
}
snprintf(path, sizeof(path), "%s/%s/%s", dir, list[i], "mac");
val = xs_read(priv->xshandle, 0, path, &len);
if (val == NULL)
break;
if ((maclen != len) || memcmp(val, mac, len)) {
free(val);
} else {
ret = strdup(list[i]);
free(val);
break;
}
}
free(list);
return(ret);

View File

@ -21,41 +21,41 @@ extern struct xenUnifiedDriver xenStoreDriver;
int xenStoreInit (void);
int xenStoreOpen (virConnectPtr conn,
xmlURIPtr uri,
virConnectAuthPtr auth,
int flags);
xmlURIPtr uri,
virConnectAuthPtr auth,
int flags);
int xenStoreClose (virConnectPtr conn);
int xenStoreGetDomainInfo (virDomainPtr domain,
virDomainInfoPtr info);
virDomainInfoPtr info);
int xenStoreNumOfDomains (virConnectPtr conn);
int xenStoreListDomains (virConnectPtr conn,
int *ids,
int maxids);
int *ids,
int maxids);
virDomainPtr xenStoreLookupByName(virConnectPtr conn,
const char *name);
const char *name);
unsigned long xenStoreGetMaxMemory (virDomainPtr domain);
int xenStoreDomainSetMemory (virDomainPtr domain,
unsigned long memory);
unsigned long memory);
unsigned long xenStoreDomainGetMaxMemory(virDomainPtr domain);
int xenStoreDomainShutdown (virDomainPtr domain);
int xenStoreDomainReboot (virDomainPtr domain,
unsigned int flags);
unsigned int flags);
/* those are entry point for the proxy */
int xenStoreDomainGetVNCPort(virConnectPtr conn,
int domid);
int domid);
char * xenStoreDomainGetConsolePath(virConnectPtr conn,
int domid);
int domid);
char * xenStoreDomainGetOSTypeID(virConnectPtr conn,
int id);
int id);
char * xenStoreDomainGetNetworkID(virConnectPtr conn,
int id,
const char *mac);
int id,
const char *mac);
char * xenStoreDomainGetDiskID(virConnectPtr conn,
int id,
const char *dev);
int id,
const char *dev);
char * xenStoreDomainGetName(virConnectPtr conn,
int id);
int id);
#ifdef __cplusplus
}

View File

@ -15,23 +15,23 @@ int main(int argc, char **argv) {
if (argc != 2) {
fprintf(stderr, "Usage: %s conf_file\n", argv[0]);
exit(1);
exit(1);
}
conf = virConfReadFile(argv[1]);
if (conf == NULL) {
fprintf(stderr, "Failed to process %s\n", argv[1]);
exit(2);
exit(2);
}
ret = virConfWriteMem(&buffer[0], &len, conf);
if (ret < 0) {
fprintf(stderr, "Failed to serialize %s back\n", argv[1]);
exit(3);
exit(3);
}
virConfFree(conf);
if (fwrite(buffer, 1, len, stdout) != len) {
fprintf(stderr, "Write failed: %s\n", strerror (errno));
exit(1);
fprintf(stderr, "Write failed: %s\n", strerror (errno));
exit(1);
}
exit(0);
}

View File

@ -95,7 +95,7 @@ main(int argc, char **argv)
for (i = 0 ; i < (sizeof(nodeData)/sizeof(nodeData[0])) ; i++)
if (virtTestRun(nodeData[i], 1, linuxTestNodeInfo, nodeData[i]) != 0)
ret = -1;
ret = -1;
#endif
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);

View File

@ -8,7 +8,7 @@
#include "internal.h"
static void errorHandler(void *userData ATTRIBUTE_UNUSED,
virErrorPtr error ATTRIBUTE_UNUSED) {
virErrorPtr error ATTRIBUTE_UNUSED) {
}
int main(void) {
@ -22,31 +22,31 @@ int main(void) {
conn = virConnectOpen(NULL);
if (conn == NULL) {
ro = 1;
conn = virConnectOpenReadOnly(NULL);
conn = virConnectOpenReadOnly(NULL);
}
if (conn == NULL) {
fprintf(stderr, "First virConnectOpen() failed\n");
exit(1);
exit(1);
}
dom = virDomainLookupByID(conn, id);
if (dom == NULL) {
fprintf(stderr, "First lookup for domain %d failed\n", id);
exit(1);
exit(1);
}
virDomainFree(dom);
virConnectClose(conn);
if (ro == 1)
conn = virConnectOpenReadOnly(NULL);
conn = virConnectOpenReadOnly(NULL);
else
conn = virConnectOpen(NULL);
conn = virConnectOpen(NULL);
if (conn == NULL) {
fprintf(stderr, "Second virConnectOpen() failed\n");
exit(1);
exit(1);
}
dom = virDomainLookupByID(conn, id);
if (dom == NULL) {
fprintf(stderr, "Second lookup for domain %d failed\n", id);
exit(1);
exit(1);
}
virDomainFree(dom);
virConnectClose(conn);

View File

@ -57,20 +57,20 @@ static int testCompareFiles(const char *xml_rel, const char *sexpr_rel,
static int testComparePVversion1(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-pv.xml",
"sexpr2xmldata/sexpr2xml-pv.sexpr",
1);
"sexpr2xmldata/sexpr2xml-pv.sexpr",
1);
}
static int testCompareFVversion1(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-fv.xml",
"sexpr2xmldata/sexpr2xml-fv.sexpr",
1);
"sexpr2xmldata/sexpr2xml-fv.sexpr",
1);
}
static int testComparePVversion2(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-pv.xml",
"sexpr2xmldata/sexpr2xml-pv.sexpr",
2);
"sexpr2xmldata/sexpr2xml-pv.sexpr",
2);
}
static int testComparePVOrigVFB(const void *data ATTRIBUTE_UNUSED) {
@ -89,105 +89,105 @@ static int testComparePVNewVFB(const void *data ATTRIBUTE_UNUSED) {
static int testCompareFVversion2(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-v2.xml",
"sexpr2xmldata/sexpr2xml-fv-v2.sexpr",
2);
"sexpr2xmldata/sexpr2xml-fv-v2.sexpr",
2);
}
static int testComparePVBootloader(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-pv-bootloader.xml",
"sexpr2xmldata/sexpr2xml-pv-bootloader.sexpr",
2);
"sexpr2xmldata/sexpr2xml-pv-bootloader.sexpr",
2);
}
static int testCompareDiskFile(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-disk-file.xml",
"sexpr2xmldata/sexpr2xml-disk-file.sexpr",
1);
"sexpr2xmldata/sexpr2xml-disk-file.sexpr",
1);
}
static int testCompareDiskBlock(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-disk-block.xml",
"sexpr2xmldata/sexpr2xml-disk-block.sexpr",
1);
"sexpr2xmldata/sexpr2xml-disk-block.sexpr",
1);
}
static int testCompareDiskShareable(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-disk-block-shareable.xml",
"sexpr2xmldata/sexpr2xml-disk-block-shareable.sexpr",
1);
"sexpr2xmldata/sexpr2xml-disk-block-shareable.sexpr",
1);
}
static int testCompareDiskDrvBlktapQcow(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.xml",
"sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.sexpr",
1);
"sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.sexpr",
1);
}
static int testCompareDiskDrvBlktapRaw(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.xml",
"sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.sexpr",
1);
"sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.sexpr",
1);
}
static int testCompareResizedMemory(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-curmem.xml",
"sexpr2xmldata/sexpr2xml-curmem.sexpr",
1);
"sexpr2xmldata/sexpr2xml-curmem.sexpr",
1);
}
static int testCompareNetRouted(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-net-routed.xml",
"sexpr2xmldata/sexpr2xml-net-routed.sexpr",
1);
"sexpr2xmldata/sexpr2xml-net-routed.sexpr",
1);
}
static int testCompareNetBridged(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-net-bridged.xml",
"sexpr2xmldata/sexpr2xml-net-bridged.sexpr",
1);
"sexpr2xmldata/sexpr2xml-net-bridged.sexpr",
1);
}
static int testCompareNoSourceCDRom(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-no-source-cdrom.xml",
"sexpr2xmldata/sexpr2xml-no-source-cdrom.sexpr",
1);
"sexpr2xmldata/sexpr2xml-no-source-cdrom.sexpr",
1);
}
static int testCompareFVInputUSBMouse(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-usbmouse.xml",
"sexpr2xmldata/sexpr2xml-fv-usbmouse.sexpr",
1);
"sexpr2xmldata/sexpr2xml-fv-usbmouse.sexpr",
1);
}
static int testCompareFVInputUSBTablet(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-usbtablet.xml",
"sexpr2xmldata/sexpr2xml-fv-usbtablet.sexpr",
1);
"sexpr2xmldata/sexpr2xml-fv-usbtablet.sexpr",
1);
}
static int testCompareFVclockUTC(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-utc.xml",
"sexpr2xmldata/sexpr2xml-fv-utc.sexpr",
1);
"sexpr2xmldata/sexpr2xml-fv-utc.sexpr",
1);
}
static int testCompareFVclockLocaltime(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-localtime.xml",
"sexpr2xmldata/sexpr2xml-fv-localtime.sexpr",
1);
"sexpr2xmldata/sexpr2xml-fv-localtime.sexpr",
1);
}
static int testCompareFVKernel(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-kernel.xml",
"sexpr2xmldata/sexpr2xml-fv-kernel.sexpr",
1);
"sexpr2xmldata/sexpr2xml-fv-kernel.sexpr",
1);
}
static int testCompareFVLegacyVFB(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-legacy-vfb.xml",
"sexpr2xmldata/sexpr2xml-fv-legacy-vfb.sexpr",
4);
"sexpr2xmldata/sexpr2xml-fv-legacy-vfb.sexpr",
4);
}
@ -199,27 +199,27 @@ main(int argc, char **argv)
progname = argv[0];
if (argc > 1) {
fprintf(stderr, "Usage: %s\n", progname);
exit(EXIT_FAILURE);
fprintf(stderr, "Usage: %s\n", progname);
exit(EXIT_FAILURE);
}
abs_top_srcdir = getenv("abs_top_srcdir");
if (!abs_top_srcdir) {
fprintf(stderr, "missing enviroment variable abs_top_srcdir\n");
exit(EXIT_FAILURE);
exit(EXIT_FAILURE);
}
if (virtTestRun("SEXPR-2-XML PV config (version 1)",
1, testComparePVversion1, NULL) != 0)
ret = -1;
1, testComparePVversion1, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML FV config (version 1)",
1, testCompareFVversion1, NULL) != 0)
ret = -1;
1, testCompareFVversion1, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML PV config (version 2)",
1, testComparePVversion2, NULL) != 0)
ret = -1;
1, testComparePVversion2, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML PV config (Orig VFB)",
1, testComparePVOrigVFB, NULL) != 0)
@ -230,71 +230,71 @@ main(int argc, char **argv)
ret = -1;
if (virtTestRun("SEXPR-2-XML FV config (version 2)",
1, testCompareFVversion2, NULL) != 0)
ret = -1;
1, testCompareFVversion2, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML PV config bootloader",
1, testComparePVBootloader, NULL) != 0)
ret = -1;
1, testComparePVBootloader, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML Disk File config",
1, testCompareDiskFile, NULL) != 0)
ret = -1;
1, testCompareDiskFile, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML Disk Block config",
1, testCompareDiskBlock, NULL) != 0)
ret = -1;
1, testCompareDiskBlock, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML Disk Block shareable",
1, testCompareDiskShareable, NULL) != 0)
ret = -1;
1, testCompareDiskShareable, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML Disk Driver blktap qcow config",
1, testCompareDiskDrvBlktapQcow, NULL) != 0)
ret = -1;
1, testCompareDiskDrvBlktapQcow, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML Disk Driver blktap raw config",
1, testCompareDiskDrvBlktapRaw, NULL) != 0)
ret = -1;
1, testCompareDiskDrvBlktapRaw, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML Resized memory config",
1, testCompareResizedMemory, NULL) != 0)
ret = -1;
1, testCompareResizedMemory, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML net routed",
1, testCompareNetRouted, NULL) != 0)
ret = -1;
1, testCompareNetRouted, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML net bridged",
1, testCompareNetBridged, NULL) != 0)
ret = -1;
1, testCompareNetBridged, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML no source CDRom",
1, testCompareNoSourceCDRom, NULL) != 0)
ret = -1;
1, testCompareNoSourceCDRom, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML USB Mouse",
1, testCompareFVInputUSBMouse, NULL) != 0)
ret = -1;
1, testCompareFVInputUSBMouse, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML USB Tablet",
1, testCompareFVInputUSBTablet, NULL) != 0)
ret = -1;
1, testCompareFVInputUSBTablet, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML clock UTC",
1, testCompareFVclockUTC, NULL) != 0)
ret = -1;
1, testCompareFVclockUTC, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML clock Localtime",
1, testCompareFVclockLocaltime, NULL) != 0)
ret = -1;
1, testCompareFVclockLocaltime, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML FV kernel",
1, testCompareFVKernel, NULL) != 0)
ret = -1;
1, testCompareFVKernel, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML FV legacy VFB",
1, testCompareFVLegacyVFB, NULL) != 0)
ret = -1;
1, testCompareFVLegacyVFB, NULL) != 0)
ret = -1;
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
}

View File

@ -13,7 +13,7 @@ static char *abs_top_srcdir;
#define MAX_FILE 4096
static int testFilterLine(char *buffer,
const char *toRemove) {
const char *toRemove) {
char *start;
char *end;
@ -78,8 +78,8 @@ static int testCompareListDefault(const void *data ATTRIBUTE_UNUSED) {
NULL
};
return testCompareOutput("virshdata/list-default.txt",
NULL,
argv);
NULL,
argv);
}
static int testCompareListCustom(const void *data ATTRIBUTE_UNUSED) {
@ -89,8 +89,8 @@ static int testCompareListCustom(const void *data ATTRIBUTE_UNUSED) {
NULL
};
return testCompareOutput("virshdata/list-custom.txt",
NULL,
argv);
NULL,
argv);
}
@ -101,8 +101,8 @@ static int testCompareNodeinfoDefault(const void *data ATTRIBUTE_UNUSED) {
NULL
};
return testCompareOutput("virshdata/nodeinfo-default.txt",
NULL,
argv);
NULL,
argv);
}
static int testCompareNodeinfoCustom(const void *data ATTRIBUTE_UNUSED) {
@ -112,8 +112,8 @@ static int testCompareNodeinfoCustom(const void *data ATTRIBUTE_UNUSED) {
NULL
};
return testCompareOutput("virshdata/nodeinfo-custom.txt",
NULL,
argv);
NULL,
argv);
}
static int testCompareDominfoByID(const void *data ATTRIBUTE_UNUSED) {
@ -124,8 +124,8 @@ static int testCompareDominfoByID(const void *data ATTRIBUTE_UNUSED) {
NULL
};
return testCompareOutput("virshdata/dominfo-fc4.txt",
"\nCPU time:",
argv);
"\nCPU time:",
argv);
}
@ -137,8 +137,8 @@ static int testCompareDominfoByUUID(const void *data ATTRIBUTE_UNUSED) {
NULL
};
return testCompareOutput("virshdata/dominfo-fc4.txt",
"\nCPU time:",
argv);
"\nCPU time:",
argv);
}
@ -150,8 +150,8 @@ static int testCompareDominfoByName(const void *data ATTRIBUTE_UNUSED) {
NULL
};
return testCompareOutput("virshdata/dominfo-fc4.txt",
"\nCPU time:",
argv);
"\nCPU time:",
argv);
}
@ -163,8 +163,8 @@ static int testCompareDomuuidByID(const void *data ATTRIBUTE_UNUSED) {
NULL
};
return testCompareOutput("virshdata/domuuid-fc4.txt",
NULL,
argv);
NULL,
argv);
}
static int testCompareDomuuidByName(const void *data ATTRIBUTE_UNUSED) {
@ -175,8 +175,8 @@ static int testCompareDomuuidByName(const void *data ATTRIBUTE_UNUSED) {
NULL
};
return testCompareOutput("virshdata/domuuid-fc4.txt",
NULL,
argv);
NULL,
argv);
}
static int testCompareDomidByName(const void *data ATTRIBUTE_UNUSED) {
@ -187,8 +187,8 @@ static int testCompareDomidByName(const void *data ATTRIBUTE_UNUSED) {
NULL
};
return testCompareOutput("virshdata/domid-fc4.txt",
NULL,
argv);
NULL,
argv);
}
@ -200,8 +200,8 @@ static int testCompareDomidByUUID(const void *data ATTRIBUTE_UNUSED) {
NULL
};
return testCompareOutput("virshdata/domid-fc4.txt",
NULL,
argv);
NULL,
argv);
}
@ -213,8 +213,8 @@ static int testCompareDomnameByID(const void *data ATTRIBUTE_UNUSED) {
NULL
};
return testCompareOutput("virshdata/domname-fc4.txt",
NULL,
argv);
NULL,
argv);
}
@ -226,8 +226,8 @@ static int testCompareDomnameByUUID(const void *data ATTRIBUTE_UNUSED) {
NULL
};
return testCompareOutput("virshdata/domname-fc4.txt",
NULL,
argv);
NULL,
argv);
}
static int testCompareDomstateByID(const void *data ATTRIBUTE_UNUSED) {
@ -238,8 +238,8 @@ static int testCompareDomstateByID(const void *data ATTRIBUTE_UNUSED) {
NULL
};
return testCompareOutput("virshdata/domstate-fc4.txt",
NULL,
argv);
NULL,
argv);
}
@ -251,8 +251,8 @@ static int testCompareDomstateByUUID(const void *data ATTRIBUTE_UNUSED) {
NULL
};
return testCompareOutput("virshdata/domstate-fc4.txt",
NULL,
argv);
NULL,
argv);
}
static int testCompareDomstateByName(const void *data ATTRIBUTE_UNUSED) {
@ -263,8 +263,8 @@ static int testCompareDomstateByName(const void *data ATTRIBUTE_UNUSED) {
NULL
};
return testCompareOutput("virshdata/domstate-fc4.txt",
NULL,
argv);
NULL,
argv);
}
@ -290,67 +290,67 @@ main(int argc, char **argv)
}
if (virtTestRun("virsh list (default)",
1, testCompareListDefault, NULL) != 0)
1, testCompareListDefault, NULL) != 0)
ret = -1;
if (virtTestRun("virsh list (custom)",
1, testCompareListCustom, NULL) != 0)
1, testCompareListCustom, NULL) != 0)
ret = -1;
if (virtTestRun("virsh nodeinfo (default)",
1, testCompareNodeinfoDefault, NULL) != 0)
1, testCompareNodeinfoDefault, NULL) != 0)
ret = -1;
if (virtTestRun("virsh nodeinfo (custom)",
1, testCompareNodeinfoCustom, NULL) != 0)
1, testCompareNodeinfoCustom, NULL) != 0)
ret = -1;
if (virtTestRun("virsh dominfo (by id)",
1, testCompareDominfoByID, NULL) != 0)
1, testCompareDominfoByID, NULL) != 0)
ret = -1;
if (virtTestRun("virsh dominfo (by uuid)",
1, testCompareDominfoByUUID, NULL) != 0)
1, testCompareDominfoByUUID, NULL) != 0)
ret = -1;
if (virtTestRun("virsh dominfo (by name)",
1, testCompareDominfoByName, NULL) != 0)
1, testCompareDominfoByName, NULL) != 0)
ret = -1;
if (virtTestRun("virsh domid (by name)",
1, testCompareDomidByName, NULL) != 0)
1, testCompareDomidByName, NULL) != 0)
ret = -1;
if (virtTestRun("virsh domid (by uuid)",
1, testCompareDomidByUUID, NULL) != 0)
1, testCompareDomidByUUID, NULL) != 0)
ret = -1;
if (virtTestRun("virsh domuuid (by id)",
1, testCompareDomuuidByID, NULL) != 0)
1, testCompareDomuuidByID, NULL) != 0)
ret = -1;
if (virtTestRun("virsh domuuid (by name)",
1, testCompareDomuuidByName, NULL) != 0)
1, testCompareDomuuidByName, NULL) != 0)
ret = -1;
if (virtTestRun("virsh domname (by id)",
1, testCompareDomnameByID, NULL) != 0)
1, testCompareDomnameByID, NULL) != 0)
ret = -1;
if (virtTestRun("virsh domname (by uuid)",
1, testCompareDomnameByUUID, NULL) != 0)
1, testCompareDomnameByUUID, NULL) != 0)
ret = -1;
if (virtTestRun("virsh domstate (by id)",
1, testCompareDomstateByID, NULL) != 0)
1, testCompareDomstateByID, NULL) != 0)
ret = -1;
if (virtTestRun("virsh domstate (by uuid)",
1, testCompareDomstateByUUID, NULL) != 0)
1, testCompareDomstateByUUID, NULL) != 0)
ret = -1;
if (virtTestRun("virsh domstate (by name)",
1, testCompareDomstateByName, NULL) != 0)
1, testCompareDomstateByName, NULL) != 0)
ret = -1;
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);

View File

@ -74,23 +74,23 @@ static int testCompareFiles(const char *hostmachine,
static int testXeni686(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("i686",
"xencapsdata/xen-i686.xml",
"xencapsdata/xen-i686.cpuinfo",
"xencapsdata/xen-i686.caps");
"xencapsdata/xen-i686.xml",
"xencapsdata/xen-i686.cpuinfo",
"xencapsdata/xen-i686.caps");
}
static int testXeni686PAE(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("i686",
"xencapsdata/xen-i686-pae.xml",
"xencapsdata/xen-i686-pae.cpuinfo",
"xencapsdata/xen-i686-pae.caps");
"xencapsdata/xen-i686-pae.xml",
"xencapsdata/xen-i686-pae.cpuinfo",
"xencapsdata/xen-i686-pae.caps");
}
static int testXeni686PAEHVM(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("i686",
"xencapsdata/xen-i686-pae-hvm.xml",
"xencapsdata/xen-i686-pae-hvm.cpuinfo",
"xencapsdata/xen-i686-pae-hvm.caps");
"xencapsdata/xen-i686-pae-hvm.xml",
"xencapsdata/xen-i686-pae-hvm.cpuinfo",
"xencapsdata/xen-i686-pae-hvm.caps");
}
/* No PAE + HVM is non-sensical - all VMX capable
@ -98,56 +98,56 @@ static int testXeni686PAEHVM(const void *data ATTRIBUTE_UNUSED) {
/*
static int testXeni686HVM(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("i686",
"xencapsdata/xen-i686-hvm.xml",
"xencapsdata/xen-i686.cpuinfo",
"xencapsdata/xen-i686-hvm.caps");
"xencapsdata/xen-i686-hvm.xml",
"xencapsdata/xen-i686.cpuinfo",
"xencapsdata/xen-i686-hvm.caps");
}
*/
static int testXenx86_64(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("x86_64",
"xencapsdata/xen-x86_64.xml",
"xencapsdata/xen-x86_64.cpuinfo",
"xencapsdata/xen-x86_64.caps");
"xencapsdata/xen-x86_64.xml",
"xencapsdata/xen-x86_64.cpuinfo",
"xencapsdata/xen-x86_64.caps");
}
static int testXenx86_64HVM(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("x86_64",
"xencapsdata/xen-x86_64-hvm.xml",
"xencapsdata/xen-x86_64-hvm.cpuinfo",
"xencapsdata/xen-x86_64-hvm.caps");
"xencapsdata/xen-x86_64-hvm.xml",
"xencapsdata/xen-x86_64-hvm.cpuinfo",
"xencapsdata/xen-x86_64-hvm.caps");
}
static int testXenia64(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("ia64",
"xencapsdata/xen-ia64.xml",
"xencapsdata/xen-ia64.cpuinfo",
"xencapsdata/xen-ia64.caps");
"xencapsdata/xen-ia64.xml",
"xencapsdata/xen-ia64.cpuinfo",
"xencapsdata/xen-ia64.caps");
}
static int testXenia64BE(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("ia64",
"xencapsdata/xen-ia64-be.xml",
"xencapsdata/xen-ia64-be.cpuinfo",
"xencapsdata/xen-ia64-be.caps");
"xencapsdata/xen-ia64-be.xml",
"xencapsdata/xen-ia64-be.cpuinfo",
"xencapsdata/xen-ia64-be.caps");
}
static int testXenia64HVM(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("ia64",
"xencapsdata/xen-ia64-hvm.xml",
"xencapsdata/xen-ia64-hvm.cpuinfo",
"xencapsdata/xen-ia64-hvm.caps");
"xencapsdata/xen-ia64-hvm.xml",
"xencapsdata/xen-ia64-hvm.cpuinfo",
"xencapsdata/xen-ia64-hvm.caps");
}
static int testXenia64BEHVM(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("ia64",
"xencapsdata/xen-ia64-be-hvm.xml",
"xencapsdata/xen-ia64-be-hvm.cpuinfo",
"xencapsdata/xen-ia64-be-hvm.caps");
"xencapsdata/xen-ia64-be-hvm.xml",
"xencapsdata/xen-ia64-be-hvm.cpuinfo",
"xencapsdata/xen-ia64-be-hvm.caps");
}
static int testXenppc64(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("ppc64",
"xencapsdata/xen-ppc64.xml",
"xencapsdata/xen-ppc64.cpuinfo",
"xencapsdata/xen-ppc64.caps");
"xencapsdata/xen-ppc64.xml",
"xencapsdata/xen-ppc64.cpuinfo",
"xencapsdata/xen-ppc64.caps");
}
@ -159,8 +159,8 @@ main(int argc, char **argv)
progname = argv[0];
if (argc > 1) {
fprintf(stderr, "Usage: %s\n", progname);
exit(EXIT_FAILURE);
fprintf(stderr, "Usage: %s\n", progname);
exit(EXIT_FAILURE);
}
abs_top_srcdir = getenv("abs_top_srcdir");
@ -170,51 +170,51 @@ main(int argc, char **argv)
virInitialize();
if (virtTestRun("Capabilities for i686, no PAE, no HVM",
1, testXeni686, NULL) != 0)
ret = -1;
1, testXeni686, NULL) != 0)
ret = -1;
if (virtTestRun("Capabilities for i686, PAE, no HVM",
1, testXeni686PAE, NULL) != 0)
ret = -1;
1, testXeni686PAE, NULL) != 0)
ret = -1;
/* No PAE + HVM is non-sensical - all VMX capable
CPUs have PAE */
/*if (virtTestRun("Capabilities for i686, no PAE, HVM",
1, testXeni686HVM, NULL) != 0)
ret = -1;
1, testXeni686HVM, NULL) != 0)
ret = -1;
*/
if (virtTestRun("Capabilities for i686, PAE, HVM",
1, testXeni686PAEHVM, NULL) != 0)
ret = -1;
1, testXeni686PAEHVM, NULL) != 0)
ret = -1;
if (virtTestRun("Capabilities for x86_64, no HVM",
1, testXenx86_64, NULL) != 0)
ret = -1;
1, testXenx86_64, NULL) != 0)
ret = -1;
if (virtTestRun("Capabilities for x86_64, HVM",
1, testXenx86_64HVM, NULL) != 0)
ret = -1;
1, testXenx86_64HVM, NULL) != 0)
ret = -1;
if (virtTestRun("Capabilities for ia64, no HVM, LE",
1, testXenia64, NULL) != 0)
ret = -1;
1, testXenia64, NULL) != 0)
ret = -1;
if (virtTestRun("Capabilities for ia64, HVM, LE",
1, testXenia64HVM, NULL) != 0)
ret = -1;
1, testXenia64HVM, NULL) != 0)
ret = -1;
if (virtTestRun("Capabilities for ia64, no HVM, BE",
1, testXenia64BE, NULL) != 0)
ret = -1;
1, testXenia64BE, NULL) != 0)
ret = -1;
if (virtTestRun("Capabilities for ia64, HVM, BE",
1, testXenia64BEHVM, NULL) != 0)
ret = -1;
1, testXenia64BEHVM, NULL) != 0)
ret = -1;
if (virtTestRun("Capabilities for ppc64",
1, testXenppc64, NULL) != 0)
ret = -1;
1, testXenppc64, NULL) != 0)
ret = -1;
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);

View File

@ -44,8 +44,8 @@ static int testCompareFiles(const char *xml_rel, const char *sexpr_rel,
if (strcmp(sexprData, gotsexpr)) {
if (getenv("DEBUG_TESTS")) {
printf("Expect %d '%s'\n", (int)strlen(sexprData), sexprData);
printf("Actual %d '%s'\n", (int)strlen(gotsexpr), gotsexpr);
printf("Expect %d '%s'\n", (int)strlen(sexprData), sexprData);
printf("Actual %d '%s'\n", (int)strlen(gotsexpr), gotsexpr);
}
goto fail;
}
@ -67,43 +67,43 @@ static int testCompareFiles(const char *xml_rel, const char *sexpr_rel,
static int testComparePVversion1(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-pv.xml",
"xml2sexprdata/xml2sexpr-pv.sexpr",
"pvtest",
1);
"xml2sexprdata/xml2sexpr-pv.sexpr",
"pvtest",
1);
}
static int testCompareFVversion1(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-fv.xml",
"xml2sexprdata/xml2sexpr-fv.sexpr",
"fvtest",
1);
"xml2sexprdata/xml2sexpr-fv.sexpr",
"fvtest",
1);
}
static int testComparePVversion2(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-pv.xml",
"xml2sexprdata/xml2sexpr-pv.sexpr",
"pvtest",
2);
"xml2sexprdata/xml2sexpr-pv.sexpr",
"pvtest",
2);
}
static int testCompareFVversion2(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-fv.xml",
"xml2sexprdata/xml2sexpr-fv-v2.sexpr",
"fvtest",
2);
"xml2sexprdata/xml2sexpr-fv-v2.sexpr",
"fvtest",
2);
}
static int testCompareFVversion2VNC(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-fv-vncunused.xml",
"xml2sexprdata/xml2sexpr-fv-vncunused.sexpr",
"fvtest",
2);
"xml2sexprdata/xml2sexpr-fv-vncunused.sexpr",
"fvtest",
2);
}
static int testComparePVOrigVFB(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-pv-vfb-orig.xml",
"xml2sexprdata/xml2sexpr-pv-vfb-orig.sexpr",
"pvtest",
"pvtest",
2);
}
@ -111,135 +111,135 @@ static int testComparePVOrigVFB(const void *data ATTRIBUTE_UNUSED) {
static int testComparePVNewVFB(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-pv-vfb-new.xml",
"xml2sexprdata/xml2sexpr-pv-vfb-new.sexpr",
"pvtest",
"pvtest",
3);
}
static int testComparePVBootloader(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-pv-bootloader.xml",
"xml2sexprdata/xml2sexpr-pv-bootloader.sexpr",
"pvtest",
1);
"xml2sexprdata/xml2sexpr-pv-bootloader.sexpr",
"pvtest",
1);
}
static int testCompareDiskFile(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-disk-file.xml",
"xml2sexprdata/xml2sexpr-disk-file.sexpr",
"pvtest",
2);
"xml2sexprdata/xml2sexpr-disk-file.sexpr",
"pvtest",
2);
}
static int testCompareDiskBlock(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-disk-block.xml",
"xml2sexprdata/xml2sexpr-disk-block.sexpr",
"pvtest",
2);
"xml2sexprdata/xml2sexpr-disk-block.sexpr",
"pvtest",
2);
}
static int testCompareDiskShareable(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-disk-block-shareable.xml",
"xml2sexprdata/xml2sexpr-disk-block-shareable.sexpr",
"pvtest",
2);
"xml2sexprdata/xml2sexpr-disk-block-shareable.sexpr",
"pvtest",
2);
}
static int testCompareDiskDrvLoop(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-disk-drv-loop.xml",
"xml2sexprdata/xml2sexpr-disk-drv-loop.sexpr",
"pvtest",
2);
"xml2sexprdata/xml2sexpr-disk-drv-loop.sexpr",
"pvtest",
2);
}
static int testCompareDiskDrvBlkback(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-disk-drv-blkback.xml",
"xml2sexprdata/xml2sexpr-disk-drv-blkback.sexpr",
"pvtest",
2);
"xml2sexprdata/xml2sexpr-disk-drv-blkback.sexpr",
"pvtest",
2);
}
static int testCompareDiskDrvBlktap(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-disk-drv-blktap.xml",
"xml2sexprdata/xml2sexpr-disk-drv-blktap.sexpr",
"pvtest",
2);
"xml2sexprdata/xml2sexpr-disk-drv-blktap.sexpr",
"pvtest",
2);
}
static int testCompareDiskDrvBlktapQcow(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-disk-drv-blktap-qcow.xml",
"xml2sexprdata/xml2sexpr-disk-drv-blktap-qcow.sexpr",
"pvtest",
2);
"xml2sexprdata/xml2sexpr-disk-drv-blktap-qcow.sexpr",
"pvtest",
2);
}
static int testCompareDiskDrvBlktapRaw(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-disk-drv-blktap-raw.xml",
"xml2sexprdata/xml2sexpr-disk-drv-blktap-raw.sexpr",
"pvtest",
2);
"xml2sexprdata/xml2sexpr-disk-drv-blktap-raw.sexpr",
"pvtest",
2);
}
static int testCompareMemoryResize(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-curmem.xml",
"xml2sexprdata/xml2sexpr-curmem.sexpr",
"rhel5",
2);
"xml2sexprdata/xml2sexpr-curmem.sexpr",
"rhel5",
2);
}
static int testCompareNetRouted(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-net-routed.xml",
"xml2sexprdata/xml2sexpr-net-routed.sexpr",
"pvtest",
2);
"xml2sexprdata/xml2sexpr-net-routed.sexpr",
"pvtest",
2);
}
static int testCompareNetBridged(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-net-bridged.xml",
"xml2sexprdata/xml2sexpr-net-bridged.sexpr",
"pvtest",
2);
"xml2sexprdata/xml2sexpr-net-bridged.sexpr",
"pvtest",
2);
}
static int testCompareNoSourceCDRom(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-no-source-cdrom.xml",
"xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr",
"test",
2);
"xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr",
"test",
2);
}
static int testCompareFVclockUTC(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-fv-utc.xml",
"xml2sexprdata/xml2sexpr-fv-utc.sexpr",
"fvtest",
1);
"xml2sexprdata/xml2sexpr-fv-utc.sexpr",
"fvtest",
1);
}
static int testCompareFVclockLocaltime(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-fv-localtime.xml",
"xml2sexprdata/xml2sexpr-fv-localtime.sexpr",
"fvtest",
1);
"xml2sexprdata/xml2sexpr-fv-localtime.sexpr",
"fvtest",
1);
}
static int testCompareFVInputUSBMouse(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-fv-usbmouse.xml",
"xml2sexprdata/xml2sexpr-fv-usbmouse.sexpr",
"fvtest",
1);
"xml2sexprdata/xml2sexpr-fv-usbmouse.sexpr",
"fvtest",
1);
}
static int testCompareFVInputUSBTablet(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-fv-usbtablet.xml",
"xml2sexprdata/xml2sexpr-fv-usbtablet.sexpr",
"fvtest",
1);
"xml2sexprdata/xml2sexpr-fv-usbtablet.sexpr",
"fvtest",
1);
}
static int testCompareFVKernel(const void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-fv-kernel.xml",
"xml2sexprdata/xml2sexpr-fv-kernel.sexpr",
"fvtest",
1);
"xml2sexprdata/xml2sexpr-fv-kernel.sexpr",
"fvtest",
1);
}
@ -254,34 +254,34 @@ main(int argc, char **argv)
abs_top_srcdir = getenv("abs_top_srcdir");
if (!abs_top_srcdir) {
fprintf(stderr, "missing enviroment variable abs_top_srcdir\n");
exit(EXIT_FAILURE);
exit(EXIT_FAILURE);
}
if (argc > 1) {
fprintf(stderr, "Usage: %s\n", progname);
exit(EXIT_FAILURE);
fprintf(stderr, "Usage: %s\n", progname);
exit(EXIT_FAILURE);
}
if (virtTestRun("XML-2-SEXPR PV config (format 1)",
1, testComparePVversion1, NULL) != 0)
ret = -1;
1, testComparePVversion1, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR FV config (format 1)",
1, testCompareFVversion1, NULL) != 0)
ret = -1;
1, testCompareFVversion1, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR PV config (format 2)",
1, testComparePVversion2, NULL) != 0)
ret = -1;
1, testComparePVversion2, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR FV config (format 2)",
1, testCompareFVversion2, NULL) != 0)
ret = -1;
1, testCompareFVversion2, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR FV config (format 2, VNC unused)",
1, testCompareFVversion2VNC, NULL) != 0)
ret = -1;
1, testCompareFVversion2VNC, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR PV config (Orig VFB)",
1, testComparePVOrigVFB, NULL) != 0)
@ -292,75 +292,75 @@ main(int argc, char **argv)
ret = -1;
if (virtTestRun("XML-2-SEXPR PV config with bootloader",
1, testComparePVBootloader, NULL) != 0)
ret = -1;
1, testComparePVBootloader, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR Disk File",
1, testCompareDiskFile, NULL) != 0)
ret = -1;
1, testCompareDiskFile, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR Disk Block",
1, testCompareDiskBlock, NULL) != 0)
ret = -1;
1, testCompareDiskBlock, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR Disk Shareable",
1, testCompareDiskShareable, NULL) != 0)
ret = -1;
1, testCompareDiskShareable, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR Disk Drv Loop",
1, testCompareDiskDrvLoop, NULL) != 0)
ret = -1;
1, testCompareDiskDrvLoop, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR Disk Drv Blkback",
1, testCompareDiskDrvBlkback, NULL) != 0)
ret = -1;
1, testCompareDiskDrvBlkback, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR Disk Drv Blktap",
1, testCompareDiskDrvBlktap, NULL) != 0)
ret = -1;
1, testCompareDiskDrvBlktap, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR Disk Drv Blktap QCow",
1, testCompareDiskDrvBlktapQcow, NULL) != 0)
ret = -1;
1, testCompareDiskDrvBlktapQcow, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR Disk Drv Blktap Raw",
1, testCompareDiskDrvBlktapRaw, NULL) != 0)
ret = -1;
1, testCompareDiskDrvBlktapRaw, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR Memory Resize",
1, testCompareMemoryResize, NULL) != 0)
ret = -1;
1, testCompareMemoryResize, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR Net Routed",
1, testCompareNetRouted, NULL) != 0)
ret = -1;
1, testCompareNetRouted, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR Net Bridged",
1, testCompareNetBridged, NULL) != 0)
ret = -1;
1, testCompareNetBridged, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR No Source CDRom",
1, testCompareNoSourceCDRom, NULL) != 0)
ret = -1;
1, testCompareNoSourceCDRom, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR FV usb mouse)",
1, testCompareFVInputUSBMouse, NULL) != 0)
ret = -1;
1, testCompareFVInputUSBMouse, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR FV usb tablet)",
1, testCompareFVInputUSBTablet, NULL) != 0)
ret = -1;
1, testCompareFVInputUSBTablet, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR clock UTC",
1, testCompareFVclockUTC, NULL) != 0)
ret = -1;
1, testCompareFVclockUTC, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR clock Localtime",
1, testCompareFVclockLocaltime, NULL) != 0)
ret = -1;
1, testCompareFVclockLocaltime, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR FV kernel",
1, testCompareFVKernel, NULL) != 0)
ret = -1;
1, testCompareFVKernel, NULL) != 0)
ret = -1;
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
}

View File

@ -205,29 +205,29 @@ testBufferVSprintf(const void *data ATTRIBUTE_UNUSED)
int
main(int argc, char **argv)
{
xmlRpcContextPtr cxt = NULL;
xmlRpcContextPtr cxt = NULL;
int check = 1;
int ret = 0;
int ret = 0;
const char *url = "http://localhost:8000";
progname = argv[0];
progname = argv[0];
if (argc > 2)
{
fprintf(stderr, "Usage: %s [url]\n", progname);
exit(EXIT_FAILURE);
}
if (argc > 2)
{
fprintf(stderr, "Usage: %s [url]\n", progname);
exit(EXIT_FAILURE);
}
if (argc == 2)
url = argv[1];
/*
* client-server tests
*/
if (!(cxt = xmlRpcContextNew(url)))
{
fprintf(stderr, "%s: failed create new RPC context\n", progname);
exit(EXIT_FAILURE);
}
if (!(cxt = xmlRpcContextNew(url)))
{
fprintf(stderr, "%s: failed create new RPC context\n", progname);
exit(EXIT_FAILURE);
}
if (virtTestRun("XML-RPC methodCall INT+INT",
NLOOPS, testMethodPlusINT, (const void *) cxt) != 0)
@ -237,7 +237,7 @@ main(int argc, char **argv)
NLOOPS, testMethodPlusDOUBLE, (const void *) cxt) != 0)
ret = -1;
xmlRpcContextFree(cxt);
xmlRpcContextFree(cxt);
/*
* regression / performance tests
@ -269,7 +269,7 @@ main(int argc, char **argv)
ret = -1;
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
}