# 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
|