libxc: add ability to query OS interface for "fakeness"
authorIan Campbell <ian.campbell@citrix.com>
Fri, 3 Dec 2010 09:36:47 +0000 (09:36 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 3 Dec 2010 09:36:47 +0000 (09:36 +0000)
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@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson.citrix.com>
tools/libxc/xc_linux.c
tools/libxc/xc_minios.c
tools/libxc/xc_netbsd.c
tools/libxc/xc_private.c
tools/libxc/xc_solaris.c
tools/libxc/xenctrl.h
tools/libxc/xenctrlosdep.h

index 7c62ee375e876197ff285d2b730e913097cbf7f0..a1ed5f450c5156ebe938ba711447193b630cf9ab 100644 (file)
@@ -697,6 +697,7 @@ static struct xc_osdep_ops *linux_osdep_init(xc_interface *xch, enum xc_osdep_ty
 xc_osdep_info_t xc_osdep_info = {
     .name = "Linux Native OS interface",
     .init = &linux_osdep_init,
+    .fake = 0,
 };
 
 /*
index 2d5b43544c0c5be60f8f8a6ec3d6b752fe0e5aea..990f7142ef156950460361644809c99fed1f360c 100644 (file)
@@ -549,6 +549,7 @@ static struct xc_osdep_ops *minios_osdep_init(xc_interface *xch, enum xc_osdep_t
 xc_osdep_info_t xc_osdep_info = {
     .name = "Minios Native OS interface",
     .init = &minios_osdep_init,
+    .fake = 0,
 };
 
 /*
index 47169ee5b465f1eff47f0e9ab2a0609a1aed0446..d3ec9c54e59163cfeb27f0b115bf07f7e9aa12db 100644 (file)
@@ -373,6 +373,7 @@ static struct xc_osdep_ops *netbsd_osdep_init(xc_interface *xch, enum xc_osdep_t
 xc_osdep_info_t xc_osdep_info = {
     .name = "Netbsd Native OS interface",
     .init = &netbsd_osdep_init,
+    .fake = 0,
 };
 
 /*
index aaa0d34ce3dcb5a4d4558913a0d5007238c81966..69b674dabff9069aae3cc8bdd9806df664b41456 100644 (file)
@@ -122,6 +122,19 @@ static int xc_interface_close_common(xc_interface *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,
                                 xentoollog_logger *dombuild_logger,
                                 unsigned open_flags)
index beec2872d4d6d17a1f574b9cc99f470a001c0550..71bbbe62a2a12155d71137681c63ce30a52734dd 100644 (file)
@@ -321,6 +321,7 @@ static struct xc_osdep_ops *solaris_osdep_init(xc_interface *xch, enum xc_osdep_
 xc_osdep_info_t xc_osdep_info = {
     .name = "Solaris Native OS interface",
     .init = &solaris_osdep_init,
+    .fake = 0,
 };
 
 /*
index 18d778bdb1f995f4da156a56be404c9cfa0e0da5..4827303b73303058bd8b0246d352ad45f593186a 100644 (file)
@@ -159,6 +159,15 @@ enum xc_open_flags {
  */
 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
  *
index d862fcff859c0a952dfc5d0342ccc658430a6d34..874fd653b4b6310375b17def40a0ab617eddeeec 100644 (file)
@@ -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;