xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: "Ian Jackson" <Ian.Jackson@eu.citrix.com>,
	"Wei Liu" <wei.liu2@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH 2/4] libxc: Provide access to internal handles
Date: Mon, 14 May 2018 18:08:57 +0100	[thread overview]
Message-ID: <1526317739-17572-3-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1526317739-17572-1-git-send-email-ian.jackson@eu.citrix.com>

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 <Ian.Jackson@eu.citrix.com>
---
 tools/libxc/include/xenctrl.h | 10 ++++++++++
 tools/libxc/xc_private.c      |  5 +++++
 2 files changed, 15 insertions(+)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 408fa1c..d7733aa 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 fcda981..dbe367f 100644
--- a/tools/libxc/xc_private.c
+++ b/tools/libxc/xc_private.c
@@ -104,6 +104,11 @@ int xc_interface_close(xc_interface *xch)
     return rc;
 }
 
+xencall_handle *xc_interface_xcall_handle(xc_interface *xch)
+{
+    return xch->xcall;
+}
+
 static pthread_key_t errbuf_pkey;
 static pthread_once_t errbuf_pkey_once = PTHREAD_ONCE_INIT;
 
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-05-14 17:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-14 17:08 [PATCH for-4.12 0/4] tools: Internal fd access, etc Ian Jackson
2018-05-14 17:08 ` [PATCH 1/4] libxc: Drop declarations of osdep_privcmd_open and _close Ian Jackson
2018-05-15  8:37   ` Wei Liu
2018-05-15  8:49   ` Roger Pau Monné
2018-05-14 17:08 ` Ian Jackson [this message]
2018-05-15  8:37   ` [PATCH 2/4] libxc: Provide access to internal handles Wei Liu
2018-05-15  8:58   ` Roger Pau Monné
2018-06-11 13:49     ` Ian Jackson
2018-05-14 17:08 ` [PATCH 3/4] tools: xencall, xengnttab, xengntshr: Provide access to internal fds Ian Jackson
2018-05-14 17:18   ` Andrew Cooper
2018-05-15 11:10     ` Ian Jackson
2018-05-14 17:08 ` [PATCH 4/4] libxl: Provide better error message when qemu restrict user not found Ian Jackson
2018-05-15  8:38   ` Wei Liu
2018-05-15  9:02   ` Roger Pau Monné

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1526317739-17572-3-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).