WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 2 of 3] [xen-detect] Return 0 if no Xen detected; 1

To: xen-devel@xxxxxxxxxxxxxxxxxxx, keir.fraser@xxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 2 of 3] [xen-detect] Return 0 if no Xen detected; 1 if running in PV context; and 2 if in HVM context
From: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Date: Tue, 22 Dec 2009 16:48:57 -0000
Cc: konrad.wilk@xxxxxxxxxx
Delivery-date: Tue, 22 Dec 2009 11:25:29 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1261500535@xxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1261500535@xxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.3
# HG changeset patch
# User konrad@xxxxxxxxxxxxxxxxxxx
# Date 1261438342 18000
# Node ID fc27db3a2ddb3f0843841748684547f6e2ed1f02
# Parent  402aa73665eddb3f7b3ede0a8894acd24397218d
[xen-detect] Return 0 if no Xen detected; 1 if running in PV context; and 2 if 
in HVM context.

On top of printing whether we are in HVM or PV context (or none
at all), also return a value.

diff -r 402aa73665ed -r fc27db3a2ddb tools/misc/xen-detect.c
--- a/tools/misc/xen-detect.c   Mon Dec 21 17:50:08 2009 -0500
+++ b/tools/misc/xen-detect.c   Mon Dec 21 18:32:22 2009 -0500
@@ -68,7 +68,8 @@
     cpuid(base + 1, &eax, &ebx, &ecx, &edx, pv_context);
     printf("Running in %s context on Xen v%d.%d.\n",
            pv_context ? "PV" : "HVM", (uint16_t)(eax >> 16), (uint16_t)eax);
-    return 1;
+
+    return pv_context ? 1 : 2;
 }
 
 static jmp_buf sigill_jmp;
@@ -79,9 +80,12 @@
 
 int main(void)
 {
+    /* 0 - no Xen, 1 - PV Xen, 2 - HVM Xen */
+    int rc = 0;
+
     /* Check for execution in HVM context. */
-    if ( check_for_xen(0) )
-        return 0;
+    if ( (rc = check_for_xen(0)) )
+        return rc;
 
     /*
      * Set up a signal handler to test the paravirtualised CPUID instruction.
@@ -90,8 +94,8 @@
      */
     if ( !setjmp(sigill_jmp)
          && (signal(SIGILL, sigill_handler) != SIG_ERR)
-         && check_for_xen(1) )
-        return 0;
+         && (rc = check_for_xen(1)) )
+        return rc;
 
     printf("Not running on Xen.\n");
     return 0;



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel