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