This really should have been introduced along with xenstore_read(), but the
problem only becomes apparent when booting an XTF test as the initial domain.
The presence of xenstore must not be assumed.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
int xtf_get_domid(void)
{
+ int rc = xenstore_init();
+
+ if ( rc )
+ return -1;
+
const char *str = xenstore_read("domid");
unsigned int domid = 0;
}
}
+int xenstore_init(void)
+{
+ /* Nothing to initialise. Report the presence of the xenbus ring. */
+ return xb_port ? 0 : -ENODEV;
+}
+
const char *xenstore_read(const char *path)
{
struct xenstore_msg_hdr hdr = {
#ifndef XTF_XENSTORE_H
#define XTF_XENSTORE_H
+/**
+ * Initialise XTF ready for xenstore communication. May fail if there is no
+ * xenbus ring found.
+ */
+int xenstore_init(void);
+
/**
* Issue a #XS_READ operation for @p key, waiting synchronously for the reply.
*
#include <arch/segment.h>
const char test_title[] = "XTF Selftests";
+bool has_xenstore = true;
static void test_xenstore(void)
{
xtf_failure("Fail: apic_init() returned %d\n", rc);
}
+ rc = xenstore_init();
+ has_xenstore = !rc;
+ if ( rc && rc != -ENODEV )
+ xtf_failure("Fail: xenstore_init() returned %d\n", rc);
+
rc = xtf_init_grant_table(1);
if ( rc )
xtf_failure("Fail: xtf_init_grant_table(1) returned %d\n", rc);
write_cr4(cr4);
}
- test_xenstore();
test_extable();
test_exlog();
test_exec_user();
test_custom_idte();
test_driver_init();
+ if ( has_xenstore )
+ test_xenstore();
+
xtf_success(NULL);
}