Disable Xen specific functions if Xen driver is disabled

This commit is contained in:
Daniel P. Berrange 2007-11-30 22:51:54 +00:00
parent c3c80a183e
commit 6d3f1d516e
4 changed files with 23 additions and 14 deletions

View File

@ -1,3 +1,9 @@
Fri Nov 30 17:50:34 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/xml.c, src/xml.h: Disable xen specific functions if
Xen driver is disabled.
* tests/xml2sexprtest.c: Disable if xen driver is disabled
Fri Nov 30 16:36:34 CET 2007 Jim Meyering <meyering@redhat.com> Fri Nov 30 16:36:34 CET 2007 Jim Meyering <meyering@redhat.com>
Detect heap allocation failure; factor out some duplication. Detect heap allocation failure; factor out some duplication.

View File

@ -57,7 +57,7 @@ virXMLError(virConnectPtr conn, virErrorNumber error, const char *info,
* Parser and converter for the CPUset strings used in libvirt * * Parser and converter for the CPUset strings used in libvirt *
* * * *
************************************************************************/ ************************************************************************/
#if WITH_XEN
/** /**
* skipSpaces: * skipSpaces:
* @str: pointer to the char pointer used * @str: pointer to the char pointer used
@ -448,6 +448,7 @@ virConvertCpuSet(virConnectPtr conn, const char *str, int maxcpu) {
free(cpuset); free(cpuset);
return (res); return (res);
} }
#endif /* WITH_XEN */
#ifndef PROXY #ifndef PROXY
/************************************************************************ /************************************************************************
@ -694,7 +695,7 @@ virXPathNodeSet(const char *xpath, xmlXPathContextPtr ctxt,
* Converter functions to go from the XML tree to an S-Expr for Xen * * Converter functions to go from the XML tree to an S-Expr for Xen *
* * * *
************************************************************************/ ************************************************************************/
#if WITH_XEN
/** /**
* virtDomainParseXMLGraphicsDescImage: * virtDomainParseXMLGraphicsDescImage:
* @conn: pointer to the hypervisor connection * @conn: pointer to the hypervisor connection
@ -1625,11 +1626,7 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name,
str = virXPathString("string(/domain/vcpu/@cpuset)", ctxt); str = virXPathString("string(/domain/vcpu/@cpuset)", ctxt);
if (str != NULL) { if (str != NULL) {
#ifdef WITH_XEN
int maxcpu = xenNbCpus(conn); int maxcpu = xenNbCpus(conn);
#else
int maxcpu = 64;
#endif
char *cpuset = NULL; char *cpuset = NULL;
char *ranges = NULL; char *ranges = NULL;
const char *cur = str; const char *cur = str;
@ -1879,6 +1876,7 @@ virParseXMLDevice(virConnectPtr conn, const char *xmldesc, int hvm,
goto cleanup; goto cleanup;
} }
/** /**
* virDomainXMLDevID: * virDomainXMLDevID:
* @domain: pointer to domain object * @domain: pointer to domain object
@ -1901,9 +1899,7 @@ virDomainXMLDevID(virDomainPtr domain, const char *xmldesc, char *class,
xmlNodePtr node, cur; xmlNodePtr node, cur;
xmlChar *attr = NULL; xmlChar *attr = NULL;
#ifdef WITH_XEN
char *xref; char *xref;
#endif /* WITH_XEN */
int ret = 0; int ret = 0;
xml = xmlReadDoc((const xmlChar *) xmldesc, "device.xml", NULL, xml = xmlReadDoc((const xmlChar *) xmldesc, "device.xml", NULL,
@ -1925,7 +1921,6 @@ virDomainXMLDevID(virDomainPtr domain, const char *xmldesc, char *class,
attr = xmlGetProp(cur, BAD_CAST "dev"); attr = xmlGetProp(cur, BAD_CAST "dev");
if (attr == NULL) if (attr == NULL)
goto error; goto error;
#ifdef WITH_XEN
xref = xenStoreDomainGetDiskID(domain->conn, domain->id, xref = xenStoreDomainGetDiskID(domain->conn, domain->id,
(char *) attr); (char *) attr);
if (xref != NULL) { if (xref != NULL) {
@ -1934,11 +1929,9 @@ virDomainXMLDevID(virDomainPtr domain, const char *xmldesc, char *class,
ref[ref_len - 1] = '\0'; ref[ref_len - 1] = '\0';
goto cleanup; goto cleanup;
} }
#else /* !WITH_XEN */
/* hack to avoid the warning that domain is unused */ /* hack to avoid the warning that domain is unused */
if (domain->id < 0) if (domain->id < 0)
ret = -1; ret = -1;
#endif /* !WITH_XEN */
goto error; goto error;
} }
@ -1952,7 +1945,6 @@ virDomainXMLDevID(virDomainPtr domain, const char *xmldesc, char *class,
if (attr == NULL) if (attr == NULL)
goto error; goto error;
#ifdef WITH_XEN
xref = xenStoreDomainGetNetworkID(domain->conn, domain->id, xref = xenStoreDomainGetNetworkID(domain->conn, domain->id,
(char *) attr); (char *) attr);
if (xref != NULL) { if (xref != NULL) {
@ -1961,11 +1953,9 @@ virDomainXMLDevID(virDomainPtr domain, const char *xmldesc, char *class,
ref[ref_len - 1] = '\0'; ref[ref_len - 1] = '\0';
goto cleanup; goto cleanup;
} }
#else /* !WITH_XEN */
/* hack to avoid the warning that domain is unused */ /* hack to avoid the warning that domain is unused */
if (domain->id < 0) if (domain->id < 0)
ret = -1; ret = -1;
#endif /* !WITH_XEN */
goto error; goto error;
} }
@ -1981,6 +1971,7 @@ virDomainXMLDevID(virDomainPtr domain, const char *xmldesc, char *class,
xmlFree(attr); xmlFree(attr);
return ret; return ret;
} }
#endif /* WITH_XEN */
#endif /* !PROXY */ #endif /* !PROXY */
/* /*

View File

@ -32,6 +32,7 @@ int virXPathNodeSet (const char *xpath,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
xmlNodePtr **list); xmlNodePtr **list);
#if WITH_XEN
int virParseXenCpuTopology(virConnectPtr conn, int virParseXenCpuTopology(virConnectPtr conn,
virBufferPtr xml, virBufferPtr xml,
const char *str, const char *str,
@ -60,6 +61,7 @@ int virDomainXMLDevID(virDomainPtr domain,
char *class, char *class,
char *ref, char *ref,
int ref_len); int ref_len);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,7 +1,9 @@
#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#include <fcntl.h> #include <fcntl.h>
@ -10,6 +12,8 @@
#include <sys/syslimits.h> #include <sys/syslimits.h>
#endif #endif
#if WITH_XEN
#include "xml.h" #include "xml.h"
#include "testutils.h" #include "testutils.h"
#include "internal.h" #include "internal.h"
@ -354,3 +358,9 @@ main(int argc, char **argv)
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
} }
#else /* WITH_XEN */
int main (void) { exit (77); /* means 'test skipped' for automake */ }
#endif /* ! WITH_XEN */