提交 435b9d99 编写于 作者: P Philipp Hahn 提交者: Eric Blake

Xen: Fake versions in xencapstest

virInitialize() → xenRegister() → xenhypervisorInit() determines the
version of the Hypervisor. This breaks xencapstest when building as root
on a dom0 system, since xenHypervisorBuildCapabilities() adds the "hap"
and "viridian" features based on the detected version.

Add an optional parameter to xenhypervisorInit() to disable automatic
detection of the Hypervisor version. The passed in arguments are used
instead.
Signed-off-by: NPhilipp Hahn <hahn@univention.de>
上级 618758c9
...@@ -2272,7 +2272,7 @@ int ...@@ -2272,7 +2272,7 @@ int
xenRegister (void) xenRegister (void)
{ {
/* Ignore failures here. */ /* Ignore failures here. */
(void) xenHypervisorInit (); (void) xenHypervisorInit (NULL);
#ifdef WITH_LIBVIRTD #ifdef WITH_LIBVIRTD
if (virRegisterStateDriver (&state_driver) == -1) return -1; if (virRegisterStateDriver (&state_driver) == -1) return -1;
......
...@@ -1951,12 +1951,16 @@ virXen_getvcpusinfo(int handle, int id, unsigned int vcpu, virVcpuInfoPtr ipt, ...@@ -1951,12 +1951,16 @@ virXen_getvcpusinfo(int handle, int id, unsigned int vcpu, virVcpuInfoPtr ipt,
/** /**
* xenHypervisorInit: * xenHypervisorInit:
* @override_versions: pointer to optional struct xenHypervisorVersions with
* version information used instead of automatic version detection.
* *
* Initialize the hypervisor layer. Try to detect the kind of interface * Initialize the hypervisor layer. Try to detect the kind of interface
* used i.e. pre or post changeset 10277 * used i.e. pre or post changeset 10277
*
* Returns 0 or -1 in case of failure
*/ */
int int
xenHypervisorInit(void) xenHypervisorInit(struct xenHypervisorVersions *override_versions)
{ {
int fd, ret, cmd, errcode; int fd, ret, cmd, errcode;
hypercall_t hc; hypercall_t hc;
...@@ -2007,6 +2011,12 @@ xenHypervisorInit(void) ...@@ -2007,6 +2011,12 @@ xenHypervisorInit(void)
return -1; return -1;
} }
if (override_versions) {
hv_versions = *override_versions;
in_init = 0;
return 0;
}
/* Xen hypervisor version detection begins. */ /* Xen hypervisor version detection begins. */
ret = open(XEN_HYPERVISOR_SOCKET, O_RDWR); ret = open(XEN_HYPERVISOR_SOCKET, O_RDWR);
if (ret < 0) { if (ret < 0) {
...@@ -2188,7 +2198,7 @@ xenHypervisorOpen(virConnectPtr conn, ...@@ -2188,7 +2198,7 @@ xenHypervisorOpen(virConnectPtr conn,
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
if (initialized == 0) if (initialized == 0)
if (xenHypervisorInit() == -1) if (xenHypervisorInit(NULL) == -1)
return -1; return -1;
priv->handle = -1; priv->handle = -1;
......
...@@ -26,7 +26,7 @@ struct xenHypervisorVersions { ...@@ -26,7 +26,7 @@ struct xenHypervisorVersions {
}; };
extern struct xenUnifiedDriver xenHypervisorDriver; extern struct xenUnifiedDriver xenHypervisorDriver;
int xenHypervisorInit (void); int xenHypervisorInit(struct xenHypervisorVersions *override_versions);
virCapsPtr xenHypervisorMakeCapabilities (virConnectPtr conn); virCapsPtr xenHypervisorMakeCapabilities (virConnectPtr conn);
......
...@@ -145,11 +145,21 @@ static int testXenppc64(const void *data ATTRIBUTE_UNUSED) { ...@@ -145,11 +145,21 @@ static int testXenppc64(const void *data ATTRIBUTE_UNUSED) {
} }
/* 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,
};
static int static int
mymain(void) mymain(void)
{ {
int ret = 0; int ret = 0;
xenHypervisorInit(&hv_versions);
virInitialize(); virInitialize();
if (virtTestRun("Capabilities for i686, no PAE, no HVM", if (virtTestRun("Capabilities for i686, no PAE, no HVM",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册