[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libvir] [PATCH] Add Xen Interface Version Check



Add Xen Interface version Check
XEN_SYSCTL_INTERFACE_VERSION
XEN_DOMCTL_INTERFACE_VERSION

Currently following distribution is considered.
              sys dom
RHEL5.0       2   3
Fedora 7      2   4
Xen-unstable  3   5

Please check virVcpuInfoPtr ipt; error message is collect or not
+        fprintf(stderr, "Memory allocation failed at xenHypervisorIniti()\n");

Signed-off-by: Atsushi SAKAI <sakaia jp fujitsu com>

Thanks
Atsushi SAKAI




--- libvirt-0.2.1/src/xen_internal.c	2007-03-16 06:36:41.000000000 +0900
+++ libvirt-0.2.1.hyper/src/xen_internal.c	2007-03-19 19:09:08.000000000 +0900
@@ -655,7 +655,6 @@
     return (0);
 }
 
-#ifndef PROXY
 /**
  * xenHypervisorDoV2Dom:
  * @handle: the handle to the Xen hypervisor
@@ -697,7 +696,6 @@
 
     return (0);
 }
-#endif /* PROXY */
 
 /**
  * virXen_getdomaininfolist:
@@ -1057,6 +1055,8 @@
     }
     return(ret);
 }
+#endif /* !PROXY*/
+
 /**
  * virXen_getvcpusinfo:
  * @handle: the hypervisor handle
@@ -1169,7 +1169,6 @@
     }
     return(ret);
 }
-#endif /* !PROXY*/
 
 /**
  * xenHypervisorInit:
@@ -1184,6 +1183,7 @@
     hypercall_t hc;
     v0_hypercall_t v0_hc;
     xen_getdomaininfo info;
+    virVcpuInfoPtr ipt;
 
     if (initialized) {
         if (hypervisor_version == -1)
@@ -1291,15 +1291,47 @@
      * or the old ones
      */
     hypervisor_version = 2;
-    /* TODO: one probably will need to autodetect thse subversions too */
+
+    ipt = malloc(sizeof(virVcpuInfo));
+    if (ipt == NULL){
+#ifdef DEBUG
+        fprintf(stderr, "Memory allocation failed at xenHypervisorIniti()\n");
+#endif
+        return(-1);
+    }
+    /* Currently consider RHEL5.0 Fedora7 and xen-unstable */
     sys_interface_version = 2; /* XEN_SYSCTL_INTERFACE_VERSION */
-    dom_interface_version = 3; /* XEN_DOMCTL_INTERFACE_VERSION */
     if (virXen_getdomaininfo(fd, 0, &info) == 1) {
+        /* RHEL 5.0 */
+        dom_interface_version = 3; /* XEN_DOMCTL_INTERFACE_VERSION */
+        if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
 #ifdef DEBUG
-        fprintf(stderr, "Using hypervisor call v2, sys version 2\n");
+            fprintf(stderr, "Using hypervisor call v2, sys ver2 dom ver3\n");
 #endif
-        goto done;
+            goto done;
+        }
+        /* Fedora 7 */
+        dom_interface_version = 4; /* XEN_DOMCTL_INTERFACE_VERSION */
+        if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
+#ifdef DEBUG
+            fprintf(stderr, "Using hypervisor call v2, sys ver2 dom ver4\n");
+#endif
+            goto done;
+        }
     }
+
+    sys_interface_version = 3; /* XEN_SYSCTL_INTERFACE_VERSION */
+    if (virXen_getdomaininfo(fd, 0, &info) == 1) {
+        /* xen-unstable */
+        dom_interface_version = 5; /* XEN_DOMCTL_INTERFACE_VERSION */
+        if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
+#ifdef DEBUG
+            fprintf(stderr, "Using hypervisor call v2, sys ver3 dom ver5\n");
+#endif
+            goto done;
+        }
+    }
+
     hypervisor_version = 1;
     sys_interface_version = -1;
     if (virXen_getdomaininfo(fd, 0, &info) == 1) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]