2008-01-30 02:15:54 +08:00
|
|
|
#include <config.h>
|
2007-11-26 20:03:34 +08:00
|
|
|
|
2007-03-27 22:45:17 +08:00
|
|
|
#include <stdio.h>
|
2007-05-29 22:44:15 +08:00
|
|
|
#include <stdlib.h>
|
Wed Dec 5 13:48:00 UTC 2007 Richard W.M. Jones <rjones@redhat.com>
* python/libvir.c, python/libvirt_wrap.h, qemud/qemud.c,
qemud/remote.c, src/internal.h, src/openvz_conf.c,
src/openvz_driver.c, src/proxy_internal.h, src/qemu_conf.c,
src/qemu_driver.c, src/remote_internal.h, src/test.h, src/util.c,
src/xen_unified.c, src/xen_unified.h, tests/nodeinfotest.c,
tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c, tests/reconnect.c,
tests/sexpr2xmltest.c, tests/virshtest.c, tests/xencapstest.c,
tests/xmconfigtest.c, tests/xml2sexprtest.c:
Change #include <> to #include "" for local includes.
Removed many includes from src/internal.h and put them in
the C files which actually use them.
Removed <ansidecl.h> - unused.
Added a comment around __func__.
Removed a clashing redefinition of VERSION symbol.
All limits (PATH_MAX etc) now done in src/internal.h, so we
don't need to include those headers in other files.
2007-12-05 21:56:22 +08:00
|
|
|
#include <string.h>
|
2007-05-29 22:44:15 +08:00
|
|
|
|
|
|
|
#ifdef WITH_XEN
|
|
|
|
|
Wed Dec 5 13:48:00 UTC 2007 Richard W.M. Jones <rjones@redhat.com>
* python/libvir.c, python/libvirt_wrap.h, qemud/qemud.c,
qemud/remote.c, src/internal.h, src/openvz_conf.c,
src/openvz_driver.c, src/proxy_internal.h, src/qemu_conf.c,
src/qemu_driver.c, src/remote_internal.h, src/test.h, src/util.c,
src/xen_unified.c, src/xen_unified.h, tests/nodeinfotest.c,
tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c, tests/reconnect.c,
tests/sexpr2xmltest.c, tests/virshtest.c, tests/xencapstest.c,
tests/xmconfigtest.c, tests/xml2sexprtest.c:
Change #include <> to #include "" for local includes.
Removed many includes from src/internal.h and put them in
the C files which actually use them.
Removed <ansidecl.h> - unused.
Added a comment around __func__.
Removed a clashing redefinition of VERSION symbol.
All limits (PATH_MAX etc) now done in src/internal.h, so we
don't need to include those headers in other files.
2007-12-05 21:56:22 +08:00
|
|
|
#include "internal.h"
|
2007-03-27 22:45:17 +08:00
|
|
|
#include "xml.h"
|
|
|
|
#include "testutils.h"
|
|
|
|
#include "xen_internal.h"
|
|
|
|
|
|
|
|
static char *progname;
|
2007-11-14 18:35:58 +08:00
|
|
|
static char *abs_top_srcdir;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
#define MAX_FILE 4096
|
|
|
|
|
|
|
|
static int testCompareFiles(const char *hostmachine,
|
2007-11-14 18:35:58 +08:00
|
|
|
const char *xml_rel,
|
|
|
|
const char *cpuinfo_rel,
|
|
|
|
const char *capabilities_rel) {
|
2007-03-27 22:45:17 +08:00
|
|
|
char xmlData[MAX_FILE];
|
|
|
|
char *expectxml = &(xmlData[0]);
|
|
|
|
char *actualxml = NULL;
|
|
|
|
FILE *fp1 = NULL, *fp2 = NULL;
|
|
|
|
|
|
|
|
int ret = -1;
|
|
|
|
|
2007-11-14 18:35:58 +08:00
|
|
|
char xml[PATH_MAX];
|
|
|
|
char cpuinfo[PATH_MAX];
|
|
|
|
char capabilities[PATH_MAX];
|
|
|
|
|
|
|
|
snprintf(xml, sizeof xml - 1, "%s/tests/%s",
|
|
|
|
abs_top_srcdir, xml_rel);
|
|
|
|
snprintf(cpuinfo, sizeof cpuinfo - 1, "%s/tests/%s",
|
|
|
|
abs_top_srcdir, cpuinfo_rel);
|
|
|
|
snprintf(capabilities, sizeof capabilities - 1, "%s/tests/%s",
|
|
|
|
abs_top_srcdir, capabilities_rel);
|
|
|
|
|
2007-03-27 22:45:17 +08:00
|
|
|
if (virtTestLoadFile(xml, &expectxml, MAX_FILE) < 0)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (!(fp1 = fopen(cpuinfo, "r")))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (!(fp2 = fopen(capabilities, "r")))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (!(actualxml = xenHypervisorMakeCapabilitiesXML(NULL, hostmachine, fp1, fp2)))
|
|
|
|
goto fail;
|
|
|
|
|
2008-04-18 23:28:33 +08:00
|
|
|
if (STRNEQ(expectxml, actualxml)) {
|
|
|
|
virtTestDifference(stderr, expectxml, actualxml);
|
|
|
|
goto fail;
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
|
2008-01-30 01:41:07 +08:00
|
|
|
free(actualxml);
|
2007-03-27 22:45:17 +08:00
|
|
|
if (fp1)
|
|
|
|
fclose(fp1);
|
|
|
|
if (fp2)
|
|
|
|
fclose(fp2);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-07-19 05:08:22 +08:00
|
|
|
static int testXeni686(const void *data ATTRIBUTE_UNUSED) {
|
2007-03-27 22:45:17 +08:00
|
|
|
return testCompareFiles("i686",
|
2008-04-11 00:54:54 +08:00
|
|
|
"xencapsdata/xen-i686.xml",
|
|
|
|
"xencapsdata/xen-i686.cpuinfo",
|
|
|
|
"xencapsdata/xen-i686.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
|
|
|
|
2007-07-19 05:08:22 +08:00
|
|
|
static int testXeni686PAE(const void *data ATTRIBUTE_UNUSED) {
|
2007-03-27 22:45:17 +08:00
|
|
|
return testCompareFiles("i686",
|
2008-04-11 00:54:54 +08:00
|
|
|
"xencapsdata/xen-i686-pae.xml",
|
|
|
|
"xencapsdata/xen-i686-pae.cpuinfo",
|
|
|
|
"xencapsdata/xen-i686-pae.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
|
|
|
|
2007-07-19 05:08:22 +08:00
|
|
|
static int testXeni686PAEHVM(const void *data ATTRIBUTE_UNUSED) {
|
2007-03-27 22:45:17 +08:00
|
|
|
return testCompareFiles("i686",
|
2008-04-11 00:54:54 +08:00
|
|
|
"xencapsdata/xen-i686-pae-hvm.xml",
|
|
|
|
"xencapsdata/xen-i686-pae-hvm.cpuinfo",
|
|
|
|
"xencapsdata/xen-i686-pae-hvm.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* No PAE + HVM is non-sensical - all VMX capable
|
|
|
|
CPUs have PAE */
|
|
|
|
/*
|
2007-07-19 05:08:22 +08:00
|
|
|
static int testXeni686HVM(const void *data ATTRIBUTE_UNUSED) {
|
2007-03-27 22:45:17 +08:00
|
|
|
return testCompareFiles("i686",
|
2008-04-11 00:54:54 +08:00
|
|
|
"xencapsdata/xen-i686-hvm.xml",
|
|
|
|
"xencapsdata/xen-i686.cpuinfo",
|
|
|
|
"xencapsdata/xen-i686-hvm.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2007-07-19 05:08:22 +08:00
|
|
|
static int testXenx86_64(const void *data ATTRIBUTE_UNUSED) {
|
2007-03-27 22:45:17 +08:00
|
|
|
return testCompareFiles("x86_64",
|
2008-04-11 00:54:54 +08:00
|
|
|
"xencapsdata/xen-x86_64.xml",
|
|
|
|
"xencapsdata/xen-x86_64.cpuinfo",
|
|
|
|
"xencapsdata/xen-x86_64.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
2007-07-19 05:08:22 +08:00
|
|
|
static int testXenx86_64HVM(const void *data ATTRIBUTE_UNUSED) {
|
2007-03-27 22:45:17 +08:00
|
|
|
return testCompareFiles("x86_64",
|
2008-04-11 00:54:54 +08:00
|
|
|
"xencapsdata/xen-x86_64-hvm.xml",
|
|
|
|
"xencapsdata/xen-x86_64-hvm.cpuinfo",
|
|
|
|
"xencapsdata/xen-x86_64-hvm.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
|
|
|
|
2007-07-19 05:08:22 +08:00
|
|
|
static int testXenia64(const void *data ATTRIBUTE_UNUSED) {
|
2007-03-27 22:45:17 +08:00
|
|
|
return testCompareFiles("ia64",
|
2008-04-11 00:54:54 +08:00
|
|
|
"xencapsdata/xen-ia64.xml",
|
|
|
|
"xencapsdata/xen-ia64.cpuinfo",
|
|
|
|
"xencapsdata/xen-ia64.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
2007-07-19 05:08:22 +08:00
|
|
|
static int testXenia64BE(const void *data ATTRIBUTE_UNUSED) {
|
2007-03-27 22:45:17 +08:00
|
|
|
return testCompareFiles("ia64",
|
2008-04-11 00:54:54 +08:00
|
|
|
"xencapsdata/xen-ia64-be.xml",
|
|
|
|
"xencapsdata/xen-ia64-be.cpuinfo",
|
|
|
|
"xencapsdata/xen-ia64-be.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
|
|
|
|
2007-07-19 05:08:22 +08:00
|
|
|
static int testXenia64HVM(const void *data ATTRIBUTE_UNUSED) {
|
2007-03-27 22:45:17 +08:00
|
|
|
return testCompareFiles("ia64",
|
2008-04-11 00:54:54 +08:00
|
|
|
"xencapsdata/xen-ia64-hvm.xml",
|
|
|
|
"xencapsdata/xen-ia64-hvm.cpuinfo",
|
|
|
|
"xencapsdata/xen-ia64-hvm.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
2007-07-19 05:08:22 +08:00
|
|
|
static int testXenia64BEHVM(const void *data ATTRIBUTE_UNUSED) {
|
2007-03-27 22:45:17 +08:00
|
|
|
return testCompareFiles("ia64",
|
2008-04-11 00:54:54 +08:00
|
|
|
"xencapsdata/xen-ia64-be-hvm.xml",
|
|
|
|
"xencapsdata/xen-ia64-be-hvm.cpuinfo",
|
|
|
|
"xencapsdata/xen-ia64-be-hvm.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
|
|
|
|
2007-07-19 05:08:22 +08:00
|
|
|
static int testXenppc64(const void *data ATTRIBUTE_UNUSED) {
|
2007-03-27 22:45:17 +08:00
|
|
|
return testCompareFiles("ppc64",
|
2008-04-11 00:54:54 +08:00
|
|
|
"xencapsdata/xen-ppc64.xml",
|
|
|
|
"xencapsdata/xen-ppc64.cpuinfo",
|
|
|
|
"xencapsdata/xen-ppc64.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
progname = argv[0];
|
|
|
|
|
|
|
|
if (argc > 1) {
|
2008-04-11 00:54:54 +08:00
|
|
|
fprintf(stderr, "Usage: %s\n", progname);
|
|
|
|
exit(EXIT_FAILURE);
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
|
|
|
|
2007-11-14 18:35:58 +08:00
|
|
|
abs_top_srcdir = getenv("abs_top_srcdir");
|
|
|
|
if (!abs_top_srcdir)
|
|
|
|
return 1;
|
|
|
|
|
2007-03-27 22:45:17 +08:00
|
|
|
virInitialize();
|
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for i686, no PAE, no HVM",
|
2008-04-11 00:54:54 +08:00
|
|
|
1, testXeni686, NULL) != 0)
|
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for i686, PAE, no HVM",
|
2008-04-11 00:54:54 +08:00
|
|
|
1, testXeni686PAE, NULL) != 0)
|
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
/* No PAE + HVM is non-sensical - all VMX capable
|
|
|
|
CPUs have PAE */
|
|
|
|
/*if (virtTestRun("Capabilities for i686, no PAE, HVM",
|
2008-04-11 00:54:54 +08:00
|
|
|
1, testXeni686HVM, NULL) != 0)
|
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for i686, PAE, HVM",
|
2008-04-11 00:54:54 +08:00
|
|
|
1, testXeni686PAEHVM, NULL) != 0)
|
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for x86_64, no HVM",
|
2008-04-11 00:54:54 +08:00
|
|
|
1, testXenx86_64, NULL) != 0)
|
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for x86_64, HVM",
|
2008-04-11 00:54:54 +08:00
|
|
|
1, testXenx86_64HVM, NULL) != 0)
|
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for ia64, no HVM, LE",
|
2008-04-11 00:54:54 +08:00
|
|
|
1, testXenia64, NULL) != 0)
|
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for ia64, HVM, LE",
|
2008-04-11 00:54:54 +08:00
|
|
|
1, testXenia64HVM, NULL) != 0)
|
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for ia64, no HVM, BE",
|
2008-04-11 00:54:54 +08:00
|
|
|
1, testXenia64BE, NULL) != 0)
|
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for ia64, HVM, BE",
|
2008-04-11 00:54:54 +08:00
|
|
|
1, testXenia64BEHVM, NULL) != 0)
|
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for ppc64",
|
2008-04-11 00:54:54 +08:00
|
|
|
1, testXenppc64, NULL) != 0)
|
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
|
|
|
}
|
2007-05-29 22:44:15 +08:00
|
|
|
|
|
|
|
#else /* !WITH_XEN */
|
|
|
|
|
|
|
|
int
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
exit (EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* !WITH_XEN */
|