Blob Blame History Raw
From 180a681da1f2ffa7be27a854b60a5c556288f567 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 2 Apr 2016 11:03:33 +0100
Subject: [PATCH] tests/qemu: boot-analysis: Don't force backend direct.

Current libvirt overhead is 220ms.  That didn't matter when our launch
time was 4000ms.  Now we're launching in 900ms, it really does.

(cherry picked from commit 03b68d436c61e9e0baac7c4fb305b62f41185173)
---
 tests/qemu/boot-analysis-timeline.c | 65 ++++++++++++++++++++++++++++---------
 tests/qemu/boot-analysis.c          | 11 ++-----
 2 files changed, 51 insertions(+), 25 deletions(-)

diff --git a/tests/qemu/boot-analysis-timeline.c b/tests/qemu/boot-analysis-timeline.c
index 8753805..d35fb49 100644
--- a/tests/qemu/boot-analysis-timeline.c
+++ b/tests/qemu/boot-analysis-timeline.c
@@ -176,28 +176,61 @@ construct_timeline (void)
                   "finished building supermin appliance"));
 
     /* Find where we invoke qemu to test features. */
-    FIND ("qemu:feature-detect", 0,
-          data->events[j].source == GUESTFS_EVENT_LIBRARY &&
-          strstr (data->events[j].message,
-                  "begin testing qemu features"),
-          data->events[k].source == GUESTFS_EVENT_LIBRARY &&
-          strstr (data->events[k].message,
-                  "finished testing qemu features"));
+    FIND_OPTIONAL ("qemu:feature-detect", 0,
+                   data->events[j].source == GUESTFS_EVENT_LIBRARY &&
+                   strstr (data->events[j].message,
+                           "begin testing qemu features"),
+                   data->events[k].source == GUESTFS_EVENT_LIBRARY &&
+                   strstr (data->events[k].message,
+                           "finished testing qemu features"));
 
     /* Find where we run qemu. */
-    FIND ("qemu", LONG_ACTIVITY,
-          data->events[j].source == GUESTFS_EVENT_APPLIANCE &&
-          strstr (data->events[j].message, "-nodefconfig"),
-          data->events[k].source == GUESTFS_EVENT_CLOSE);
+    FIND_OPTIONAL ("qemu", LONG_ACTIVITY,
+                   data->events[j].source == GUESTFS_EVENT_APPLIANCE &&
+                   strstr (data->events[j].message, "-nodefconfig"),
+                   data->events[k].source == GUESTFS_EVENT_CLOSE);
+
+    /* For the libvirt backend, connecting to libvirt, getting
+     * capabilities, parsing capabilities etc.
+     */
+    FIND_OPTIONAL ("libvirt:connect", 0,
+                   data->events[j].source == GUESTFS_EVENT_LIBRARY &&
+                   strstr (data->events[j].message, "connect to libvirt"),
+                   data->events[k].source == GUESTFS_EVENT_LIBRARY &&
+                   strstr (data->events[k].message, "successfully opened libvirt handle"));
+    FIND_OPTIONAL ("libvirt:get-libvirt-capabilities", 0,
+                   data->events[j].source == GUESTFS_EVENT_LIBRARY &&
+                   strstr (data->events[j].message, "get libvirt capabilities"),
+                   data->events[k].source == GUESTFS_EVENT_LIBRARY &&
+                   strstr (data->events[k].message, "parsing capabilities XML"));
+
+    FIND_OPTIONAL ("libguestfs:parse-libvirt-capabilities", 0,
+                   data->events[j].source == GUESTFS_EVENT_LIBRARY &&
+                   strstr (data->events[j].message, "parsing capabilities XML"),
+                   data->events[k].source == GUESTFS_EVENT_LIBRARY &&
+                   strstr (data->events[k].message, "get_backend_setting"));
+
+    FIND_OPTIONAL ("libguestfs:create-libvirt-xml", 0,
+                   data->events[j].source == GUESTFS_EVENT_LIBRARY &&
+                   strstr (data->events[j].message, "create libvirt XML"),
+                   data->events[k].source == GUESTFS_EVENT_LIBRARY &&
+                   strstr (data->events[k].message, "libvirt XML:"));
 
 #define SGABIOS_STRING "\033[1;256r\033[256;256H\033[6n"
 
+    /* For the libvirt backend, find the overhead of libvirt. */
+    FIND_OPTIONAL ("libvirt:overhead", 0,
+                   data->events[j].source == GUESTFS_EVENT_LIBRARY &&
+                   strstr (data->events[j].message, "launch libvirt guest"),
+                   data->events[k].source == GUESTFS_EVENT_APPLIANCE &&
+                   strstr (data->events[k].message, SGABIOS_STRING));
+
     /* From starting qemu up to entering the BIOS is the qemu overhead. */
-    FIND ("qemu:overhead", 0,
-          data->events[j].source == GUESTFS_EVENT_APPLIANCE &&
-          strstr (data->events[j].message, "-nodefconfig"),
-          data->events[k].source == GUESTFS_EVENT_APPLIANCE &&
-          strstr (data->events[k].message, SGABIOS_STRING));
+    FIND_OPTIONAL ("qemu:overhead", 0,
+                   data->events[j].source == GUESTFS_EVENT_APPLIANCE &&
+                   strstr (data->events[j].message, "-nodefconfig"),
+                   data->events[k].source == GUESTFS_EVENT_APPLIANCE &&
+                   strstr (data->events[k].message, SGABIOS_STRING));
 
     /* From entering the BIOS to starting the kernel is the BIOS overhead. */
     FIND_OPTIONAL ("bios:overhead", 0,
diff --git a/tests/qemu/boot-analysis.c b/tests/qemu/boot-analysis.c
index f4c1d6c..37d8b3c 100644
--- a/tests/qemu/boot-analysis.c
+++ b/tests/qemu/boot-analysis.c
@@ -292,14 +292,6 @@ create_handle (void)
   g = guestfs_create ();
   if (!g) error (EXIT_FAILURE, errno, "guestfs_create");
 
-  /* We always run these tests using LIBGUESTFS_BACKEND=direct.  It
-   * may be in future we need to test libvirt as well, in case
-   * performance issues are suspected there, but so far libvirt has
-   * not been a bottleneck.
-   */
-  if (guestfs_set_backend (g, "direct") == -1)
-    exit (EXIT_FAILURE);
-
   if (memsize != 0)
     if (guestfs_set_memsize (g, memsize) == -1)
       exit (EXIT_FAILURE);
@@ -622,7 +614,8 @@ check_pass_data (void)
       assert (pass_data[i].events[j].source != 0);
       message = pass_data[i].events[j].message;
       assert (message != NULL);
-      assert (strchr (message, '\n') == NULL);
+      assert (pass_data[i].events[j].source != GUESTFS_EVENT_APPLIANCE ||
+              strchr (message, '\n') == NULL);
       len = strlen (message);
       assert (len == 0 || message[len-1] != '\r');
     }
-- 
1.8.3.1