Blame SOURCES/0087-utils-boot-analysis-Make-handling-of-first-kernel-me.patch

e76f14
From 88f2135d9b788cdeec7dff8ac9c2b882f314009d Mon Sep 17 00:00:00 2001
e76f14
From: "Richard W.M. Jones" <rjones@redhat.com>
e76f14
Date: Tue, 10 May 2016 21:53:59 +0100
e76f14
Subject: [PATCH] utils: boot-analysis: Make handling of first kernel message
e76f14
 more flexible.
e76f14
e76f14
Allows us to disable EDD completely, and still have boot-analysis work.
e76f14
e76f14
(cherry picked from commit b6f5a0cd90c356ab1d7e519c0e24e66bfe33cfcc)
e76f14
---
e76f14
 utils/boot-analysis/boot-analysis-timeline.c | 35 +++++++++++++++++++++-------
e76f14
 1 file changed, 26 insertions(+), 9 deletions(-)
e76f14
e76f14
diff --git a/utils/boot-analysis/boot-analysis-timeline.c b/utils/boot-analysis/boot-analysis-timeline.c
e76f14
index 905d1e3..a4b71a1 100644
e76f14
--- a/utils/boot-analysis/boot-analysis-timeline.c
e76f14
+++ b/utils/boot-analysis/boot-analysis-timeline.c
e76f14
@@ -67,6 +67,7 @@ construct_timeline (void)
e76f14
   size_t i, j, k;
e76f14
   struct pass_data *data;
e76f14
   struct activity *activity;
e76f14
+  const char *first_kernel_message;
e76f14
 
e76f14
   for (i = 0; i < NR_TEST_PASSES; ++i) {
e76f14
     data = &pass_data[i];
e76f14
@@ -217,14 +218,30 @@ construct_timeline (void)
e76f14
                    strstr (data->events[k].message, "libvirt XML:"));
e76f14
 
e76f14
 #if defined(__aarch64__)
e76f14
-#define FIRST_KERNEL_MESSAGE "Booting Linux on physical CPU"
e76f14
 #define FIRST_FIRMWARE_MESSAGE "UEFI firmware starting"
e76f14
 #else
e76f14
 #define SGABIOS_STRING "\033[1;256r\033[256;256H\033[6n"
e76f14
-#define FIRST_KERNEL_MESSAGE "Probing EDD"
e76f14
 #define FIRST_FIRMWARE_MESSAGE SGABIOS_STRING
e76f14
 #endif
e76f14
 
e76f14
+    /* Try to determine the first message that the kernel prints. */
e76f14
+#if defined(__aarch64__)
e76f14
+    first_kernel_message = "Booting Linux on physical CPU";
e76f14
+#else
e76f14
+    first_kernel_message = "Probing EDD";
e76f14
+    for (j = 0; j < data->nr_events; ++j)
e76f14
+      if (data->events[j].source == GUESTFS_EVENT_APPLIANCE &&
e76f14
+          strstr (data->events[j].message, first_kernel_message))
e76f14
+        goto found_first_kernel_message;
e76f14
+    first_kernel_message = "Linux version ";
e76f14
+    for (j = 0; j < data->nr_events; ++j)
e76f14
+      if (data->events[j].source == GUESTFS_EVENT_APPLIANCE &&
e76f14
+          strstr (data->events[j].message, first_kernel_message))
e76f14
+        goto found_first_kernel_message;
e76f14
+    error (EXIT_FAILURE, 0, "could not determine first message printed by the kernel");
e76f14
+  found_first_kernel_message:
e76f14
+#endif
e76f14
+
e76f14
     /* For the libvirt backend, find the overhead of libvirt. */
e76f14
     FIND_OPTIONAL ("libvirt:overhead", 0,
e76f14
                    data->events[j].source == GUESTFS_EVENT_LIBRARY &&
e76f14
@@ -244,7 +261,7 @@ construct_timeline (void)
e76f14
           data->events[j].source == GUESTFS_EVENT_APPLIANCE &&
e76f14
           strstr (data->events[j].message, FIRST_FIRMWARE_MESSAGE),
e76f14
           data->events[k].source == GUESTFS_EVENT_APPLIANCE &&
e76f14
-          strstr (data->events[k].message, FIRST_KERNEL_MESSAGE));
e76f14
+          strstr (data->events[k].message, first_kernel_message));
e76f14
 
e76f14
 #if defined(__i386__) || defined(__x86_64__)
e76f14
     /* SGABIOS (option ROM). */
e76f14
@@ -261,7 +278,7 @@ construct_timeline (void)
e76f14
           data->events[j].source == GUESTFS_EVENT_APPLIANCE &&
e76f14
           strstr (data->events[j].message, "SeaBIOS (version"),
e76f14
           data->events[k].source == GUESTFS_EVENT_APPLIANCE &&
e76f14
-          strstr (data->events[k].message, FIRST_KERNEL_MESSAGE));
e76f14
+          strstr (data->events[k].message, first_kernel_message));
e76f14
 #endif
e76f14
 
e76f14
 #if defined(__i386__) || defined(__x86_64__)
e76f14
@@ -276,23 +293,23 @@ construct_timeline (void)
e76f14
     /* Find where we run the guest kernel. */
e76f14
     FIND ("kernel", LONG_ACTIVITY,
e76f14
           data->events[j].source == GUESTFS_EVENT_APPLIANCE &&
e76f14
-          strstr (data->events[j].message, FIRST_KERNEL_MESSAGE),
e76f14
+          strstr (data->events[j].message, first_kernel_message),
e76f14
           data->events[k].source == GUESTFS_EVENT_CLOSE);
e76f14
 
e76f14
     /* Kernel startup to userspace. */
e76f14
     FIND ("kernel:overhead", 0,
e76f14
           data->events[j].source == GUESTFS_EVENT_APPLIANCE &&
e76f14
-          strstr (data->events[j].message, FIRST_KERNEL_MESSAGE),
e76f14
+          strstr (data->events[j].message, first_kernel_message),
e76f14
           data->events[k].source == GUESTFS_EVENT_APPLIANCE &&
e76f14
           strstr (data->events[k].message, "supermin:") &&
e76f14
           strstr (data->events[k].message, "starting up"));
e76f14
 
e76f14
     /* The time taken to get into start_kernel function. */
e76f14
-    FIND ("kernel:entry", 0,
e76f14
+    FIND_OPTIONAL ("kernel:entry", 0,
e76f14
           data->events[j].source == GUESTFS_EVENT_APPLIANCE &&
e76f14
-          strstr (data->events[j].message, FIRST_KERNEL_MESSAGE),
e76f14
+          strstr (data->events[j].message, first_kernel_message),
e76f14
           data->events[k].source == GUESTFS_EVENT_APPLIANCE &&
e76f14
-          strstr (data->events[k].message, "Linux version"));
e76f14
+          strstr (data->events[k].message, "Linux version "));
e76f14
 
e76f14
 #if defined(__i386__) || defined(__x86_64__)
e76f14
     /* Alternatives patching instructions (XXX not very accurate we
e76f14
-- 
e76f14
1.8.3.1
e76f14