#include <xtf/lib.h>
#include <xtf/traps.h>
#include <xtf/hypercall.h>
+#include <xtf/xenstore.h>
+
+#ifndef isdigit
+/* Avoid pulling in all of ctypes just for this. */
+static int isdigit(int c)
+{
+ return c >= '0' && c <= '9';
+}
+#endif
void __noreturn panic(const char *fmt, ...)
{
return -1;
}
+int xtf_get_domid(void)
+{
+ const char *str = xenstore_read("domid");
+ unsigned int domid = 0;
+
+ if ( !str || !isdigit(*str) )
+ return -1;
+
+ while ( isdigit(*str) )
+ {
+ domid = domid * 10 + (*str - '0');
+ str++;
+ }
+
+ if ( domid >= DOMID_FIRST_RESERVED )
+ return -1;
+
+ return domid;
+}
+
/*
* Local variables:
* mode: C
typedef uint16_t domid_t;
#endif
+#define DOMID_FIRST_RESERVED (0x7ff0U)
#define DOMID_SELF (0x7ff0U)
/* Commands to HYPERVISOR_console_io */
*/
int xtf_probe_sysctl_interface_version(void);
+/**
+ * Obtain the current domid.
+ * @returns domid, or -1 on failure.
+ */
+int xtf_get_domid(void);
+
#endif /* XTF_LIB_H */
/*