summaryrefslogtreecommitdiffstats
path: root/src/launch.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-11-24 13:50:27 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-11-24 14:17:08 +0000
commitaeea803ad0fafe1ed4c7f8e781dfe4fdc150cac0 (patch)
treea5d9276e1a31ad06a5db04fcdd6217865dd66360 /src/launch.c
parent62895440bc13abe1bc7dbccf9f8b412f16d16a7d (diff)
downloadlibguestfs-aeea803ad0fafe1ed4c7f8e781dfe4fdc150cac0.tar.gz
libguestfs-aeea803ad0fafe1ed4c7f8e781dfe4fdc150cac0.tar.xz
libguestfs-aeea803ad0fafe1ed4c7f8e781dfe4fdc150cac0.zip
appliance: Pass lpj=... on the appliance command line (thanks Marcelo Tosatti).
Try to get the host's loops_per_jiffy value and pass this on the command line to the guest. In theory this should avoid the appliance having to recalculate this value in a VM with TCG (which is generally error-prone). This should avoid timing issues. We only do this when we are certain that the guest will be TCG. Currently we only have enough information to do this from the libvirt attach-method. So mostly this will only affect people using Fedora in a VM. The host loops_per_jiffy value is not exported by the kernel. It is only printed by the kernel early during boot, so if boot messages have "scrolled off" the kernel ring buffer, it won't be available. Some operating systems save early kernel messages in /var/log/dmesg but (a) Fedora 18+ seem to have abandoned this file and (b) on Ubuntu this file is unreadable for spurious "security" reasons. I have submitted a patch to make lpj available through /proc/cpuinfo.
Diffstat (limited to 'src/launch.c')
-rw-r--r--src/launch.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/launch.c b/src/launch.c
index cb1d80b6..d5e12f6e 100644
--- a/src/launch.c
+++ b/src/launch.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
+#include <stdbool.h>
#include <inttypes.h>
#include <unistd.h>
#include <string.h>
@@ -794,6 +795,13 @@ guestfs__get_state (guestfs_h *g)
* appliance disk and must have already been adjusted to take into
* account virtio-blk or virtio-scsi; eg "/dev/sdb".
*
+ * The 'flags' parameter can contain the following flags logically
+ * or'd together (or 0):
+ *
+ * GUESTFS___APPLIANCE_COMMAND_LINE_IS_TCG: If we are launching a qemu
+ * TCG guest (ie. KVM is known to be disabled or unavailable). If you
+ * don't know, don't pass this flag.
+ *
* Note that this returns a newly allocated buffer which must be freed
* by the caller.
*/
@@ -804,10 +812,19 @@ guestfs__get_state (guestfs_h *g)
#endif
char *
-guestfs___appliance_command_line (guestfs_h *g, const char *appliance_dev)
+guestfs___appliance_command_line (guestfs_h *g, const char *appliance_dev,
+ int flags)
{
char *term = getenv ("TERM");
char *ret;
+ bool tcg = flags & APPLIANCE_COMMAND_LINE_IS_TCG;
+ char lpj_s[64] = "";
+
+ if (tcg) {
+ int lpj = guestfs___get_lpj (g);
+ if (lpj > 0)
+ snprintf (lpj_s, sizeof lpj_s, " lpj=%d", lpj);
+ }
ret = safe_asprintf
(g,
@@ -815,6 +832,7 @@ guestfs___appliance_command_line (guestfs_h *g, const char *appliance_dev)
" console=" SERIAL_CONSOLE /* serial console */
" udevtimeout=600" /* good for very slow systems (RHBZ#480319) */
" no_timer_check" /* fix for RHBZ#502058 */
+ "%s" /* lpj */
" acpi=off" /* we don't need ACPI, turn it off */
" printk.time=1" /* display timestamp before kernel messages */
" cgroup_disable=memory" /* saves us about 5 MB of RAM */
@@ -823,6 +841,7 @@ guestfs___appliance_command_line (guestfs_h *g, const char *appliance_dev)
"%s" /* verbose */
" TERM=%s" /* TERM environment variable */
"%s%s", /* append */
+ lpj_s,
appliance_dev,
g->selinux ? "selinux=1 enforcing=0" : "selinux=0",
g->verbose ? " guestfs_verbose=1" : "",