From e39b0b96622e2d49ad987c4bd0ae061921a69853 Mon Sep 17 00:00:00 2001 From: Luke Browning Date: Mon, 13 Nov 2017 20:55:08 -0600 Subject: [PATCH] Allow the user to disable tmpfs when building guest images This is accomplished through the use of a new environment variable USE_TMPFS. The default action remains to use tmpfs. If the user wishes to disable the use of tmpfs, the environment variable should be set as shown below before invoking Trove to build an image. export USE_TMPFS=false Note tmpfs uses half of the available free memory for a RAM based file system. This can lead to errors in the image building process, for example when large compilations are performed. In these cases, the user can try again with tmpfs disabled simply by setting an environment variable. The alternative is to provision another server or VM that has more memory which is not always possible or desired. Change-Id: I0f990d7866755ccf0537354752cd602fe0582ea0 --- integration/scripts/functions_qemu | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/integration/scripts/functions_qemu b/integration/scripts/functions_qemu index 08807e95b5..aa608e34f6 100644 --- a/integration/scripts/functions_qemu +++ b/integration/scripts/functions_qemu @@ -3,6 +3,13 @@ # Additional functions that would mostly just pertain to a Ubuntu + Qemu setup # +# tmpfs dedicates half the available RAM to an internal cache to speed up +# image building. This can lead to failures when the data doesn't fit into +# the cache, for example when compiling large programs. This flag allows +# tmpfs to be turned off by the caller by setting USE_TMPF=false + +USE_TMPFS=${USE_TMPFS:-true} + function build_vm() { exclaim "Actually building the image, this can take up to 15 minutes" @@ -27,6 +34,15 @@ function build_vm() { EXTRA_ELEMENTS=selinux-permissive fi + case "$USE_TMPFS" in + false|FALSE|False|no|NO|n|N) + TMPFS_ARGS='--no-tmpfs' + ;; + *) + TMPFS_ARGS='' + ;; + esac + export HOST_USERNAME export HOST_SCP_USERNAME export GUEST_USERNAME @@ -47,7 +63,7 @@ function build_vm() { export DIB_APT_CONF_DIR=/etc/apt/apt.conf.d export DIB_CLOUD_INIT_ETC_HOSTS=true local QEMU_IMG_OPTIONS="--qemu-img-options compat=1.1" - disk-image-create -a ${ARCH} -o "${VM}" \ + disk-image-create ${TMPFS_ARGS} -a ${ARCH} -o "${VM}" \ -x ${QEMU_IMG_OPTIONS} ${DISTRO} ${EXTRA_ELEMENTS} vm \ cloud-init-datasources ${DISTRO}-${RELEASE}-guest ${DISTRO}-${RELEASE}-${SERVICE_TYPE} }