]> rtime.felk.cvut.cz Git - frescor/frsh.git/blobdiff - resources/cpucg/mngr/frm_cgcpu.c
frm_cgcpu: Fix segmentation fault
[frescor/frsh.git] / resources / cpucg / mngr / frm_cgcpu.c
index 89f6c285f46d5f6a34e6c33c139d29ec11b3a1f3..827b3d2110a8caede3466dceb14304dd6524949a 100644 (file)
 #include <forb.h>
 #include <error.h>
 #include <errno.h>
+#include <getopt.h>
 #include <fres_sa_scenario.h>
 #include <stdbool.h>
 #include <ul_log.h>
+#include <ul_logreg.h>
 #include <stdio.h>
 
 UL_LOG_CUST(ulogd_frm_cpucg);
-ul_log_domain_t ulogd_fra_fwp = {UL_LOGL_DEB, "frm_cpucg"};
+ul_log_domain_t ulogd_frm_cpucg = {UL_LOGL_DEB, "frm_cpucg"};
 
 /**
  * root cgroup`s period
@@ -107,17 +109,46 @@ static int cpucg_admtest(struct fres_sa_scenario *scenario, void *priv,
 static const struct fres_res_manager frm = {
        .res_type = FRSH_RT_PROCESSOR,
        .res_id = 0,
+       .name = "cgroup",
        .admission_test = cpucg_admtest,
        .priv = NULL
 };
 
+static struct option long_opts[] = {
+    { "loglevel", 1, 0, 'l' },
+    { 0, 0, 0, 0}
+};
+
+static void
+usage(void)
+{
+       printf("usage: frm_aqcpu [ options ]\n");
+       printf("  -l, --loglevel <number>|<domain>=<number>,...\n");
+}
+
 int main(int argc, char *argv[])
 {
        forb_orb orb;
        FILE* fd;
        int ret;
+       int  opt;
+       forb_init_attr_t attr = { .orb_id = "org.frescor.frm.cgcpu" };
+
+       ul_logreg_domain(&ulogd_frm_cpucg);
+
+       while ((opt = getopt_long(argc, argv, "l:", &long_opts[0], NULL)) != EOF) {
+               switch (opt) {
+                       case 'l':
+                               ul_log_domain_arg2levels(optarg);
+                               break;
+                       case 'h':
+                       /*default:*/
+                               usage();
+                               exit(opt == 'h' ? 0 : 1);
+               }
+       }
 
-       orb = forb_init(&argc, &argv, "frm_cpucg");
+       orb = forb_init(&argc, &argv, &attr);
        if (!orb) error(1, errno, "forb_init");
        
        if (!(fd = fopen("/proc/sys/kernel/sched_rt_period_us", "r"))) {