]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Xen: Fake versions in xencapstest
authorPhilipp Hahn <hahn@univention.de>
Fri, 14 Oct 2011 12:10:26 +0000 (14:10 +0200)
committerEric Blake <eblake@redhat.com>
Fri, 14 Oct 2011 15:42:38 +0000 (09:42 -0600)
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: Philipp Hahn <hahn@univention.de>
src/xen/xen_driver.c
src/xen/xen_hypervisor.c
src/xen/xen_hypervisor.h
tests/xencapstest.c

index 9c96fcab461fcf77d4dd1f70286e263848820f34..68abb1759aa22e4389e969dcd980bfd1e7798549 100644 (file)
@@ -2272,7 +2272,7 @@ int
 xenRegister (void)
 {
     /* Ignore failures here. */
-    (void) xenHypervisorInit ();
+    (void) xenHypervisorInit (NULL);
 
 #ifdef WITH_LIBVIRTD
     if (virRegisterStateDriver (&state_driver) == -1) return -1;
index b552e4745da1afc14a122a84f7a7d23eb63fd87c..58ae6a3edb35ef3ecadff5c4e0d5aea8b36c2295 100644 (file)
@@ -1951,12 +1951,16 @@ virXen_getvcpusinfo(int handle, int id, unsigned int vcpu, virVcpuInfoPtr ipt,
 
 /**
  * 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
  * used i.e. pre or post changeset 10277
+ *
+ * Returns 0 or -1 in case of failure
  */
 int
-xenHypervisorInit(void)
+xenHypervisorInit(struct xenHypervisorVersions *override_versions)
 {
     int fd, ret, cmd, errcode;
     hypercall_t hc;
@@ -2007,6 +2011,12 @@ xenHypervisorInit(void)
         return -1;
     }
 
+    if (override_versions) {
+      hv_versions = *override_versions;
+      in_init = 0;
+      return 0;
+    }
+
     /* Xen hypervisor version detection begins. */
     ret = open(XEN_HYPERVISOR_SOCKET, O_RDWR);
     if (ret < 0) {
@@ -2188,7 +2198,7 @@ xenHypervisorOpen(virConnectPtr conn,
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
     if (initialized == 0)
-        if (xenHypervisorInit() == -1)
+        if (xenHypervisorInit(NULL) == -1)
             return -1;
 
     priv->handle = -1;
index cf8153ef06b23f27eba8cd765e2dbce6b0d72cd6..77c6f747257a8e04341f7fff50f7c8d891d7f08a 100644 (file)
@@ -26,7 +26,7 @@ struct xenHypervisorVersions {
 };
 
 extern struct xenUnifiedDriver xenHypervisorDriver;
-int    xenHypervisorInit                 (void);
+int xenHypervisorInit(struct xenHypervisorVersions *override_versions);
 
 virCapsPtr xenHypervisorMakeCapabilities (virConnectPtr conn);
 
index 9c1eba4d39769122c29c3185dd883a58047371af..ca9385751657c9faa33d66e5d07aee127a88d44d 100644 (file)
@@ -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
 mymain(void)
 {
     int ret = 0;
 
+    xenHypervisorInit(&hv_versions);
     virInitialize();
 
     if (virtTestRun("Capabilities for i686, no PAE, no HVM",