[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XTF PATCH v2 2/2] tests/argo: use event channel to get own domain ID



From: Denis Mukhin <dmukhin@xxxxxxxx>

The existing argo test depends on xenstore to retrieve the domain ID.

Also, test does not perform peer-to-peer communication using Argo hypercall, it
communicates with itself.

Since xenstore currently runs in dom0, xenstore adds unnecessary dependency on
dom0 for the test in x86 QEMU environment.

Use event channel to identify the domain ID which eliminates dom0 dependency
for the test.

Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
Changes since v1:
- dropped hack of hardcoding test's own domain ID to 0, reworked getting own
  domain ID by relying on message channel.

Thanks to Michal Orzel and Andrew Cooper for helping with that.
---
 common/lib.c                | 34 +++++++++++++++++++++++++++++++++-
 include/xen/event_channel.h | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/common/lib.c b/common/lib.c
index 58f4965..c37347a 100644
--- a/common/lib.c
+++ b/common/lib.c
@@ -3,6 +3,7 @@
 #include <xtf/traps.h>
 #include <xtf/hypercall.h>
 #include <xtf/xenstore.h>
+#include <xen/event_channel.h>
 
 #ifndef isdigit
 /* Avoid pulling in all of ctypes just for this. */
@@ -44,12 +45,43 @@ int xtf_probe_sysctl_interface_version(void)
     return -1;
 }
 
+static domid_t get_domid_from_evtchn(void)
+{
+    union {
+        struct evtchn_alloc_unbound alloc;
+        struct evtchn_status status;
+        struct evtchn_close close;
+    } op;
+    evtchn_port_t port;
+    int rc;
+
+    op.alloc.dom = DOMID_SELF;
+    op.alloc.remote_dom = DOMID_SELF;
+    rc = hypercall_event_channel_op(EVTCHNOP_alloc_unbound, &op.alloc);
+    if ( rc )
+        return -1;
+
+    port = op.alloc.port;
+
+    op.status.dom = DOMID_SELF;
+    op.status.port = port;
+    rc = hypercall_event_channel_op(EVTCHNOP_status, &op.status);
+    if ( !rc )
+        rc = op.status.u.unbound.dom;
+
+    op.close.port = port;
+    /* NB: no need to check the return code */
+    (void)hypercall_event_channel_op(EVTCHNOP_close, &op.close);
+
+    return rc;
+}
+
 int xtf_get_domid(void)
 {
     int rc = xenstore_init();
 
     if ( rc )
-        return -1;
+        return get_domid_from_evtchn();
 
     const char *str = xenstore_read("domid");
     unsigned int domid = 0;
diff --git a/include/xen/event_channel.h b/include/xen/event_channel.h
index bef0f46..7d89ac3 100644
--- a/include/xen/event_channel.h
+++ b/include/xen/event_channel.h
@@ -3,7 +3,9 @@
 
 #include <xen/xen.h>
 
+#define EVTCHNOP_close            3
 #define EVTCHNOP_send             4
+#define EVTCHNOP_status           5
 #define EVTCHNOP_alloc_unbound    6
 #define EVTCHNOP_init_control    11
 #define EVTCHNOP_expand_array    12
@@ -32,6 +34,38 @@ struct evtchn_expand_array {
     uint64_t array_gfn;
 };
 
+struct evtchn_close {
+    /* IN parameters. */
+    evtchn_port_t port;
+};
+
+#define EVTCHNSTAT_closed       0  /* Channel is not in use.                 */
+#define EVTCHNSTAT_unbound      1  /* Channel is waiting interdom connection.*/
+#define EVTCHNSTAT_interdomain  2  /* Channel is connected to remote domain. */
+#define EVTCHNSTAT_pirq         3  /* Channel is bound to a phys IRQ line.   */
+#define EVTCHNSTAT_virq         4  /* Channel is bound to a virtual IRQ line */
+#define EVTCHNSTAT_ipi          5  /* Channel is bound to a virtual IPI line */
+
+struct evtchn_status {
+    /* IN parameters */
+    domid_t  dom;
+    evtchn_port_t port;
+    /* OUT parameters */
+    uint32_t status;
+    uint32_t vcpu;                 /* VCPU to which this channel is bound.   */
+    union {
+        struct {
+            domid_t dom;
+        } unbound;                 /* EVTCHNSTAT_unbound */
+        struct {
+            domid_t dom;
+            evtchn_port_t port;
+        } interdomain;             /* EVTCHNSTAT_interdomain */
+        uint32_t pirq;             /* EVTCHNSTAT_pirq        */
+        uint32_t virq;             /* EVTCHNSTAT_virq        */
+    } u;
+};
+
 #endif /* XEN_PUBLIC_EVENT_CHANNEL_H */
 
 /*
-- 
2.34.1





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.