Skip to contentSkip to conversation

libxenlight: write stubdoms logs to file

PATCH New Stefano Stabellini 1 participant 1 message Dec 1, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxenlight: write stubdoms logs to file

Hi all,
it turns out that there is a better way to write stubdoms logs to file than using libxl_console_attach: qemu is the one that provides the console backend for stubdoms and qemu is able to redirect a serial to file, so we can use this feature to make sure the first stubdom console is always redirected to a logfile.

---

tools/libxl/libxl.c +10 -1
diff -r ab27d93cf622 tools/libxl/libxl.c
@@ -1352,7 +1352,16 @@
             num++;
     }
     if (num > 0) {
-        info->serial = "pty";
+        uint32_t guest_domid = libxl_is_stubdom(ctx, vfb->domid);
+        if (guest_domid) {
+            char *filename;
+            char *name = libxl_sprintf(ctx, "qemu-dm-%s", libxl_domid_to_name(ctx, guest_domid));
+            libxl_create_logfile(ctx, name, &filename);
+            info->serial = libxl_sprintf(ctx, "file:%s", filename);
+            free(filename);
+        } else {
+            info->serial = "pty";
+        }
         num--;
     }
     if (num > 0) {
tools/libxl/libxl_utils.c +1 -1
diff -r ab27d93cf622 tools/libxl/libxl_utils.c
@@ -185,7 +185,7 @@
 {
     char *target = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/target", libxl_xs_get_dompath(ctx, domid)));
     if (target)
-        return 1;
+        return atoi(target);
     else
         return 0;
 }