tools/libxc: add DECLARE_HYPERCALL_BUFFER_SHADOW()
authorDavid Vrabel <david.vrabel@citrix.com>
Mon, 9 Jun 2014 15:41:10 +0000 (16:41 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 10 Jun 2014 12:47:31 +0000 (13:47 +0100)
DECLARE_HYPERCALL_BUFFER_SHADOW() is like DECLARE_HYPERCALL_BUFFER()
except it is backed by an already allocated hypercall buffer.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxc/xenctrl.h

index 400f0dfe439b20ca11083512dc636d9137986268..b55d85728c5d3533a2c4250dc07e9faa38413bc5 100644 (file)
@@ -265,6 +265,24 @@ typedef struct xc_hypercall_buffer xc_hypercall_buffer_t;
         HYPERCALL_BUFFER_INIT_NO_BOUNCE                        \
     }
 
+/*
+ * Like DECLARE_HYPERCALL_BUFFER() but using an already allocated
+ * hypercall buffer, _hbuf.
+ *
+ * Useful when a hypercall buffer is passed to a function and access
+ * via the user pointer is required.
+ *
+ * See DECLARE_HYPERCALL_BUFFER_ARGUMENT() if the user pointer is not
+ * required.
+ */
+#define DECLARE_HYPERCALL_BUFFER_SHADOW(_type, _name, _hbuf)   \
+    _type *_name = _hbuf->hbuf;                                \
+    xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME(_name) = { \
+        .hbuf = (void *)-1,                                    \
+        .param_shadow = _hbuf,                                 \
+        HYPERCALL_BUFFER_INIT_NO_BOUNCE                        \
+    }
+
 /*
  * Declare the necessary data structure to allow a hypercall buffer
  * passed as an argument to a function to be used in the normal way.