Blob Blame History Raw
From b385c694f1028413c36188ae99279ed0d56bccd5 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 5 Aug 2013 16:35:47 +0100
Subject: [PATCH] launch: direct: Specify -cpu host,+kvmclock.

'-cpu host' makes the CPU look like the host CPU.  This is useful
because it means the appliance can use all the host CPU's features,
eg. for fast checksumming or MD XORing.

'kvmclock' is the paravirtualized clock for qemu/KVM.  It's much more
stable than relying on tsc or a virtualized device such as HPET, and
clock instability is one of the problems we have encountered when
running libguestfs on a heavily loaded machine, especially in a nested VM.

Note that we require qemu >= 1.2 (and have for a while) which has long
supported both of these options.

(cherry picked from commit 038ed0a08eaed33e62a27c9f91780a25de0bc08c)
---
 TODO                | 8 --------
 src/launch-direct.c | 4 ++++
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/TODO b/TODO
index 0a8cf57..61cde40 100644
--- a/TODO
+++ b/TODO
@@ -477,14 +477,6 @@ image would be replaced by equivalent files of zeroes, thus minimizing
 the size of the debug image that needs to be shipped to us by the
 customer.
 
-Optimize the appliance
-----------------------
-
-Pass -cpu host.  Anything else?
-
-[The libvirt backend uses 'host-model' which is basically
-the same as this]
-
 Sort out partitioning
 ---------------------
 
diff --git a/src/launch-direct.c b/src/launch-direct.c
index f1edb53..90d0df9 100644
--- a/src/launch-direct.c
+++ b/src/launch-direct.c
@@ -315,6 +315,10 @@ launch_direct (guestfs_h *g, const char *arg)
         add_cmdline (g, "-enable-kvm");
     }
 
+    /* Specify the host CPU for speed, and kvmclock for stability. */
+    add_cmdline (g, "-cpu");
+    add_cmdline (g, "host,+kvmclock");
+
     if (g->smp > 1) {
       snprintf (buf, sizeof buf, "%d", g->smp);
       add_cmdline (g, "-smp");
-- 
1.8.3.1