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>
|
2008-05-29 23:31:49 +08:00
|
|
|
#include <unistd.h>
|
2007-05-29 22:44:15 +08:00
|
|
|
|
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"
|
2012-12-14 02:13:21 +08:00
|
|
|
#include "virxml.h"
|
2007-03-27 22:45:17 +08:00
|
|
|
#include "testutils.h"
|
Move xen driver code into src/xen/ directory
* src/Makefile.am, src/proxy_internal.c, src/proxy_internal.h
src/sexpr.c, src/sexpr.h, src/xen_unified.c, src/xen_unified.h,
src/xen_internal.c, src/xen_internal.h, src/xen_inotify.c,
src/xen_inotify.h, src/xend_internal.c, src/xend_internal.h,
src/xm_internal.c, src/xm_internal.h, src/xs_internal.c,
src/xs_internal.h: Move to src/xen/ directory
* proxy/Makefile.am, proxy/libvirt_proxy.c, src/Makefile.am,
src/libvirt.c, tests/sexpr2xmltest.c, tests/statstest.c,
tests/xencapstest.c, tests/xmconfigtest.c, tests/xml2sexprtest.c:
Adapt to changed xen location
* src/stats_linux.h, src/stats_linux.c: Remove xen specific block
stats APIs
* src/qemu_driver.c, src/uml_driver.c: Add missing sys/un.h include
uncovered after change to stats_linux.h
* src/xen/block_stats.h, src/xen/block_stats.c: Add xen specific
block stats APIs
2009-09-15 23:38:33 +08:00
|
|
|
#include "xen/xen_hypervisor.h"
|
2011-07-20 02:32:58 +08:00
|
|
|
#include "virfile.h"
|
2013-04-03 18:36:23 +08:00
|
|
|
#include "virstring.h"
|
2007-03-27 22:45:17 +08:00
|
|
|
|
2013-06-07 23:10:28 +08:00
|
|
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
|
|
|
|
2011-04-25 06:25:10 +08:00
|
|
|
static int
|
2012-12-19 03:32:23 +08:00
|
|
|
testCompareFiles(virArch hostmachine, const char *xml_rel,
|
2011-04-25 06:25:10 +08:00
|
|
|
const char *cpuinfo_rel, const char *capabilities_rel)
|
|
|
|
{
|
|
|
|
char *expectxml = NULL;
|
2007-03-27 22:45:17 +08:00
|
|
|
char *actualxml = NULL;
|
|
|
|
FILE *fp1 = NULL, *fp2 = NULL;
|
2008-07-25 21:17:27 +08:00
|
|
|
virCapsPtr caps = NULL;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
int ret = -1;
|
|
|
|
|
2011-04-25 06:25:10 +08:00
|
|
|
char *xml = NULL;
|
|
|
|
char *cpuinfo = NULL;
|
|
|
|
char *capabilities = NULL;
|
2007-11-14 18:35:58 +08:00
|
|
|
|
2011-04-25 06:25:10 +08:00
|
|
|
if (virAsprintf(&xml, "%s/%s", abs_srcdir, xml_rel) < 0 ||
|
|
|
|
virAsprintf(&cpuinfo, "%s/%s", abs_srcdir, cpuinfo_rel) < 0 ||
|
|
|
|
virAsprintf(&capabilities, "%s/%s", abs_srcdir, capabilities_rel) < 0)
|
|
|
|
goto fail;
|
2007-11-14 18:35:58 +08:00
|
|
|
|
2011-04-25 06:25:10 +08:00
|
|
|
if (virtTestLoadFile(xml, &expectxml) < 0)
|
2008-07-25 21:17:27 +08:00
|
|
|
goto fail;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (!(fp1 = fopen(cpuinfo, "r")))
|
2008-07-25 21:17:27 +08:00
|
|
|
goto fail;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (!(fp2 = fopen(capabilities, "r")))
|
2008-07-25 21:17:27 +08:00
|
|
|
goto fail;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
2008-09-05 19:35:43 +08:00
|
|
|
if (!(caps = xenHypervisorMakeCapabilitiesInternal(NULL, hostmachine, fp1, fp2)))
|
2008-07-25 21:17:27 +08:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (!(actualxml = virCapabilitiesFormatXML(caps)))
|
|
|
|
goto fail;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
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:
|
2012-02-03 07:16:43 +08:00
|
|
|
VIR_FREE(expectxml);
|
|
|
|
VIR_FREE(actualxml);
|
|
|
|
VIR_FREE(xml);
|
|
|
|
VIR_FREE(cpuinfo);
|
|
|
|
VIR_FREE(capabilities);
|
2010-11-17 10:13:29 +08:00
|
|
|
VIR_FORCE_FCLOSE(fp1);
|
|
|
|
VIR_FORCE_FCLOSE(fp2);
|
2007-03-27 22:45:17 +08:00
|
|
|
|
2013-02-01 20:26:18 +08:00
|
|
|
virObjectUnref(caps);
|
2007-03-27 22:45:17 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-03-18 16:13:43 +08:00
|
|
|
static int testXeni686(const void *data ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2012-12-19 03:32:23 +08:00
|
|
|
return testCompareFiles(VIR_ARCH_I686,
|
|
|
|
"xencapsdata/xen-i686.xml",
|
|
|
|
"xencapsdata/xen-i686.cpuinfo",
|
|
|
|
"xencapsdata/xen-i686.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
|
|
|
|
2014-03-18 16:13:43 +08:00
|
|
|
static int testXeni686PAE(const void *data ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2012-12-19 03:32:23 +08:00
|
|
|
return testCompareFiles(VIR_ARCH_I686,
|
|
|
|
"xencapsdata/xen-i686-pae.xml",
|
|
|
|
"xencapsdata/xen-i686-pae.cpuinfo",
|
|
|
|
"xencapsdata/xen-i686-pae.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
|
|
|
|
2014-03-18 16:13:43 +08:00
|
|
|
static int testXeni686PAEHVM(const void *data ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2012-12-19 03:32:23 +08:00
|
|
|
return testCompareFiles(VIR_ARCH_I686,
|
|
|
|
"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 */
|
|
|
|
/*
|
2014-03-18 16:13:43 +08:00
|
|
|
static int testXeni686HVM(const void *data ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2012-12-19 03:32:23 +08:00
|
|
|
return testCompareFiles(VIR_ARCH_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
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2014-03-18 16:13:43 +08:00
|
|
|
static int testXenx86_64(const void *data ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2012-12-19 03:32:23 +08:00
|
|
|
return testCompareFiles(VIR_ARCH_X86_64,
|
|
|
|
"xencapsdata/xen-x86_64.xml",
|
|
|
|
"xencapsdata/xen-x86_64.cpuinfo",
|
|
|
|
"xencapsdata/xen-x86_64.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
2014-03-18 16:13:43 +08:00
|
|
|
static int testXenx86_64HVM(const void *data ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2012-12-19 03:32:23 +08:00
|
|
|
return testCompareFiles(VIR_ARCH_X86_64,
|
|
|
|
"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
|
|
|
}
|
|
|
|
|
2014-03-18 16:13:43 +08:00
|
|
|
static int testXenia64(const void *data ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2012-12-19 03:32:23 +08:00
|
|
|
return testCompareFiles(VIR_ARCH_ITANIUM,
|
|
|
|
"xencapsdata/xen-ia64.xml",
|
|
|
|
"xencapsdata/xen-ia64.cpuinfo",
|
|
|
|
"xencapsdata/xen-ia64.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
2014-03-18 16:13:43 +08:00
|
|
|
static int testXenia64BE(const void *data ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2012-12-19 03:32:23 +08:00
|
|
|
return testCompareFiles(VIR_ARCH_ITANIUM,
|
|
|
|
"xencapsdata/xen-ia64-be.xml",
|
|
|
|
"xencapsdata/xen-ia64-be.cpuinfo",
|
|
|
|
"xencapsdata/xen-ia64-be.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
|
|
|
|
2014-03-18 16:13:43 +08:00
|
|
|
static int testXenia64HVM(const void *data ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2012-12-19 03:32:23 +08:00
|
|
|
return testCompareFiles(VIR_ARCH_ITANIUM,
|
|
|
|
"xencapsdata/xen-ia64-hvm.xml",
|
|
|
|
"xencapsdata/xen-ia64-hvm.cpuinfo",
|
|
|
|
"xencapsdata/xen-ia64-hvm.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
2014-03-18 16:13:43 +08:00
|
|
|
static int testXenia64BEHVM(const void *data ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2012-12-19 03:32:23 +08:00
|
|
|
return testCompareFiles(VIR_ARCH_ITANIUM,
|
|
|
|
"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
|
|
|
}
|
|
|
|
|
2014-03-18 16:13:43 +08:00
|
|
|
static int testXenppc64(const void *data ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2012-12-19 03:32:23 +08:00
|
|
|
return testCompareFiles(VIR_ARCH_PPC64,
|
|
|
|
"xencapsdata/xen-ppc64.xml",
|
|
|
|
"xencapsdata/xen-ppc64.cpuinfo",
|
|
|
|
"xencapsdata/xen-ppc64.caps");
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-14 20:10:26 +08:00
|
|
|
/* Fake initialization data for xenHypervisorInit(). Must be initialized
|
|
|
|
* explicitly before the implicit call via virInitialize(). */
|
|
|
|
static struct xenHypervisorVersions hv_versions = {
|
|
|
|
.hv = 0,
|
|
|
|
.hypervisor = 2,
|
|
|
|
.sys_interface = -1,
|
|
|
|
.dom_interface = -1,
|
|
|
|
};
|
|
|
|
|
2008-05-29 23:31:49 +08:00
|
|
|
static int
|
2011-04-30 00:21:20 +08:00
|
|
|
mymain(void)
|
2007-03-27 22:45:17 +08:00
|
|
|
{
|
|
|
|
int ret = 0;
|
2007-11-14 18:35:58 +08:00
|
|
|
|
2011-10-14 20:10:26 +08:00
|
|
|
xenHypervisorInit(&hv_versions);
|
2013-05-16 20:56:56 +08:00
|
|
|
if (virInitialize() < 0)
|
|
|
|
return EXIT_FAILURE;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for i686, no PAE, no HVM",
|
2013-09-21 02:13:35 +08:00
|
|
|
testXeni686, NULL) != 0)
|
2008-04-11 00:54:54 +08:00
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for i686, PAE, no HVM",
|
2013-09-21 02:13:35 +08:00
|
|
|
testXeni686PAE, NULL) != 0)
|
2008-04-11 00:54:54 +08:00
|
|
|
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",
|
2013-09-21 02:13:35 +08:00
|
|
|
testXeni686HVM, NULL) != 0)
|
2008-04-11 00:54:54 +08:00
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for i686, PAE, HVM",
|
2013-09-21 02:13:35 +08:00
|
|
|
testXeni686PAEHVM, NULL) != 0)
|
2008-04-11 00:54:54 +08:00
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for x86_64, no HVM",
|
2013-09-21 02:13:35 +08:00
|
|
|
testXenx86_64, NULL) != 0)
|
2008-04-11 00:54:54 +08:00
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for x86_64, HVM",
|
2013-09-21 02:13:35 +08:00
|
|
|
testXenx86_64HVM, NULL) != 0)
|
2008-04-11 00:54:54 +08:00
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for ia64, no HVM, LE",
|
2013-09-21 02:13:35 +08:00
|
|
|
testXenia64, NULL) != 0)
|
2008-04-11 00:54:54 +08:00
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for ia64, HVM, LE",
|
2013-09-21 02:13:35 +08:00
|
|
|
testXenia64HVM, NULL) != 0)
|
2008-04-11 00:54:54 +08:00
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for ia64, no HVM, BE",
|
2013-09-21 02:13:35 +08:00
|
|
|
testXenia64BE, NULL) != 0)
|
2008-04-11 00:54:54 +08:00
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for ia64, HVM, BE",
|
2013-09-21 02:13:35 +08:00
|
|
|
testXenia64BEHVM, NULL) != 0)
|
2008-04-11 00:54:54 +08:00
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
if (virtTestRun("Capabilities for ppc64",
|
2013-09-21 02:13:35 +08:00
|
|
|
testXenppc64, NULL) != 0)
|
2008-04-11 00:54:54 +08:00
|
|
|
ret = -1;
|
2007-03-27 22:45:17 +08:00
|
|
|
|
|
|
|
|
2014-03-17 17:38:38 +08:00
|
|
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
2007-03-27 22:45:17 +08:00
|
|
|
}
|
2007-05-29 22:44:15 +08:00
|
|
|
|
2008-05-29 23:31:49 +08:00
|
|
|
VIRT_TEST_MAIN(mymain)
|