#ifndef _LIB_PLANETLAB_H_
#define _LIB_PLANETLAB_H_
-/*
- * context create
- */
-typedef struct {
- uint32_t cpu_share;
- uint32_t cpu_sched_flags;
- uint64_t mem_limit;
- uint64_t task_limit;
-} rspec_t;
-
#define VC_VXF_SCHED_FLAGS (VC_VXF_SCHED_HARD | VC_VXF_SCHED_SHARE)
+struct sliver_resources {
+ unsigned long long vs_cpu;
+ struct vc_rlimit vs_rss;
+ struct vc_rlimit vs_as;
+ struct vc_rlimit vs_nproc;
+ struct vc_rlimit vs_openfd;
+};
+
+int adjust_lim(const struct vc_rlimit *vcr, struct rlimit *lim);
+
int
-pl_chcontext(xid_t ctx, uint32_t flags, uint64_t bcaps, const rspec_t *rspec);
+pl_chcontext(xid_t ctx, uint64_t bcaps, const struct sliver_resources *slr);
+
+int
+pl_setup_done(xid_t ctx);
int
pl_setsched(xid_t ctx, uint32_t cpu_share, uint32_t cpu_sched_flags);
+/* scheduler flags */
+#define VS_SCHED_CPU_GUARANTEED 1
+
+/* Null byte made explicit */
+#define NULLBYTE_SIZE 1
+
+void pl_get_limits(const char *, struct sliver_resources *);
+void pl_set_ulimits(const struct sliver_resources *);
+
+static int
+_PERROR(const char *format, char *file, int line, int _errno, ...)
+{
+ va_list ap;
+
+ va_start(ap, _errno);
+ fprintf(stderr, "%s:%d: ", file, line);
+ vfprintf(stderr, format, ap);
+ if (_errno)
+ fprintf(stderr, ": %s (%d)", strerror(_errno), _errno);
+ fputs("\n", stderr);
+ fflush(stderr);
+
+ return _errno;
+}
+
+#define PERROR(format, args...) _PERROR(format, __FILE__, __LINE__, errno, ## args)
#endif