[xen staging] libxc: Provide access to internal handles

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen staging] libxc: Provide access to internal handles

patchbot
commit dbb3c4d0a458f4bca91ec50ac81f5f7a739f8729
Author:     Ian Jackson <[hidden email]>
AuthorDate: Fri May 4 16:00:42 2018 +0100
Commit:     Ian Jackson <[hidden email]>
CommitDate: Fri Jul 6 16:27:52 2018 +0100

    libxc: Provide access to internal handles
   
    In order to support auditing of qemu depriv, my audit tool wants to
    know the fd of a privcmd handle on which it can easily make
    hypercalls.  xencall provides such a handle, but has no cooked
    facilities for making hypercalls.  So I open a libxc handle.  That
    means I need to get the privcmd fd out of the libxc handle.
   
    ISTM that it is best to do this by providing an interface to get the
    underlying library handles for a libxc handle.  This kind of interface
    is quite common elsewhere and has not caused problems.
   
    libxc is not a stable API so the downside risk of providing this
    access is not significant.
   
    Signed-off-by: Ian Jackson <[hidden email]>
    Acked-by: Wei Liu <[hidden email]>
    Reviewed-by: Roger Pau Monné <[hidden email]>
---
 tools/libxc/include/xenctrl.h | 10 ++++++++++
 tools/libxc/xc_private.c      | 15 +++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 580d2cdb06..5520c942d1 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -183,6 +183,16 @@ enum xc_open_flags {
  */
 int xc_interface_close(xc_interface *xch);
 
+/**
+ * Return the handles which xch has opened and will use for
+ * hypercalls, foreign memory accesses and device model operations.
+ * These may be used with the corresponding libraries so long as the
+ * xch itself remains open.
+ */
+struct xencall_handle *xc_interface_xcall_handle(xc_interface *xch);
+struct xenforeignmemory_handle *xc_interface_fmem_handle(xc_interface *xch);
+struct xendevicemodel_handle *xc_interface_dmod_handle(xc_interface *xch);
+
 /*
  * HYPERCALL SAFE MEMORY BUFFER
  *
diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c
index e6e3d9913c..90974d572e 100644
--- a/tools/libxc/xc_private.c
+++ b/tools/libxc/xc_private.c
@@ -104,6 +104,21 @@ int xc_interface_close(xc_interface *xch)
     return rc;
 }
 
+xencall_handle *xc_interface_xcall_handle(xc_interface *xch)
+{
+    return xch->xcall;
+}
+
+struct xenforeignmemory_handle *xc_interface_fmem_handle(xc_interface *xch)
+{
+    return xch->fmem;
+}
+
+struct xendevicemodel_handle *xc_interface_dmod_handle(xc_interface *xch)
+{
+    return xch->dmod;
+}
+
 static pthread_key_t errbuf_pkey;
 static pthread_once_t errbuf_pkey_once = PTHREAD_ONCE_INIT;
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog