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 19 of 25] libxc: add ability to query OS interface fo

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 19 of 25] libxc: add ability to query OS interface for "fakeness"
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Fri, 03 Dec 2010 09:57:23 +0000
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Fri, 03 Dec 2010 02:35:53 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1291370224@xxxxxxxxxxxxxxxxxxxxx>
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1291369007 0
# Node ID 2cca9651106419dc04b2dfebc51da4b3f9143482
# Parent  384d9d7ca3063a32623cb0d6ccdbc258e3541749
libxc: add ability to query OS interface for "fakeness"

i.e. not running on a real hypervisor

Allows users of the library to adjust behaviour. I don't especially
like this violation of the abstraction but both oxenstored and xapi
use this to avoid difficult to simulate operations when running on the
simulator.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 384d9d7ca306 -r 2cca96511064 tools/libxc/xc_linux.c
--- a/tools/libxc/xc_linux.c    Fri Dec 03 09:36:47 2010 +0000
+++ b/tools/libxc/xc_linux.c    Fri Dec 03 09:36:47 2010 +0000
@@ -697,6 +697,7 @@ xc_osdep_info_t xc_osdep_info = {
 xc_osdep_info_t xc_osdep_info = {
     .name = "Linux Native OS interface",
     .init = &linux_osdep_init,
+    .fake = 0,
 };
 
 /*
diff -r 384d9d7ca306 -r 2cca96511064 tools/libxc/xc_minios.c
--- a/tools/libxc/xc_minios.c   Fri Dec 03 09:36:47 2010 +0000
+++ b/tools/libxc/xc_minios.c   Fri Dec 03 09:36:47 2010 +0000
@@ -549,6 +549,7 @@ xc_osdep_info_t xc_osdep_info = {
 xc_osdep_info_t xc_osdep_info = {
     .name = "Minios Native OS interface",
     .init = &minios_osdep_init,
+    .fake = 0,
 };
 
 /*
diff -r 384d9d7ca306 -r 2cca96511064 tools/libxc/xc_netbsd.c
--- a/tools/libxc/xc_netbsd.c   Fri Dec 03 09:36:47 2010 +0000
+++ b/tools/libxc/xc_netbsd.c   Fri Dec 03 09:36:47 2010 +0000
@@ -348,6 +348,7 @@ xc_osdep_info_t xc_osdep_info = {
 xc_osdep_info_t xc_osdep_info = {
     .name = "Netbsd Native OS interface",
     .init = &netbsd_osdep_init,
+    .fake = 0,
 };
 
 /*
diff -r 384d9d7ca306 -r 2cca96511064 tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c  Fri Dec 03 09:36:47 2010 +0000
+++ b/tools/libxc/xc_private.c  Fri Dec 03 09:36:47 2010 +0000
@@ -120,6 +120,19 @@ static int xc_interface_close_common(xc_
 
     free(xch);
     return rc;
+}
+
+int xc_interface_is_fake(void)
+{
+    xc_osdep_info_t info;
+
+    if ( xc_osdep_get_info(NULL, &info) < 0 )
+        return -1;
+
+    /* Have a copy of info so can release the interface now. */
+    xc_osdep_put(&info);
+
+    return info.fake;
 }
 
 xc_interface *xc_interface_open(xentoollog_logger *logger,
diff -r 384d9d7ca306 -r 2cca96511064 tools/libxc/xc_solaris.c
--- a/tools/libxc/xc_solaris.c  Fri Dec 03 09:36:47 2010 +0000
+++ b/tools/libxc/xc_solaris.c  Fri Dec 03 09:36:47 2010 +0000
@@ -321,6 +321,7 @@ xc_osdep_info_t xc_osdep_info = {
 xc_osdep_info_t xc_osdep_info = {
     .name = "Solaris Native OS interface",
     .init = &solaris_osdep_init,
+    .fake = 0,
 };
 
 /*
diff -r 384d9d7ca306 -r 2cca96511064 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Fri Dec 03 09:36:47 2010 +0000
+++ b/tools/libxc/xenctrl.h     Fri Dec 03 09:36:47 2010 +0000
@@ -158,6 +158,15 @@ enum xc_open_flags {
  * @return 0 on success, -1 otherwise.
  */
 int xc_interface_close(xc_interface *xch);
+
+/**
+ * Query the active OS interface (i.e. that which would be returned by
+ * xc_interface_open) to find out if it is fake (i.e. backends onto
+ * something other than an actual Xen hypervisor).
+ *
+ * @return 0 is "real", >0 if fake, -1 on error.
+ */
+int xc_interface_is_fake(void);
 
 /*
  * HYPERCALL SAFE MEMORY BUFFER
diff -r 384d9d7ca306 -r 2cca96511064 tools/libxc/xenctrlosdep.h
--- a/tools/libxc/xenctrlosdep.h        Fri Dec 03 09:36:47 2010 +0000
+++ b/tools/libxc/xenctrlosdep.h        Fri Dec 03 09:36:47 2010 +0000
@@ -122,6 +122,9 @@ struct xc_osdep_info
 
     /* Returns ops function. */
     xc_osdep_init_fn init;
+
+    /* True if this interface backs onto a fake Xen. */
+    int fake;
 };
 typedef struct xc_osdep_info xc_osdep_info_t;
 

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