libxenlight: write stubdoms logs to file
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 2 Dec 2009 08:45:16 +0000 (08:45 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 2 Dec 2009 08:45:16 +0000 (08:45 +0000)
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.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
tools/libxl/libxl.c
tools/libxl/libxl_utils.c

index 858c17052ec1bc0a872e9282f19e78162e8202b1..8d4411f613cc1f9141180917f9fc27c7c6303b51 100644 (file)
@@ -1352,7 +1352,16 @@ static int libxl_build_xenpv_qemu_args(struct libxl_ctx *ctx,
             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) {
index 4a8f44f814671bcbf2b536553bcb7f5e60012f9e..3d731ce029c31be3167429736d1cc9cf6f72e6e9 100644 (file)
@@ -185,7 +185,7 @@ int libxl_is_stubdom(struct libxl_ctx *ctx, int domid)
 {
     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;
 }