From f902a28b924ebe7e9e06c0289972672d37f6e8d0 Mon Sep 17 00:00:00 2001 From: Derek Ditch Date: Fri, 9 Nov 2018 08:44:02 -0500 Subject: [PATCH] Adds qemu wrapper to disable pmu in cpu flags When guestfish is called under nested VMware virtualization, it uses the cpu flag of `host`. This alone causes issues under nested VMware virtaulization in the default configuration. This commit removes the default host flags and replaces with `host,pmu=off`. Fixes coreos/coreos-assembler#198 --- src/gf-oemid | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/gf-oemid b/src/gf-oemid index 0e48985813..bb2c72f157 100755 --- a/src/gf-oemid +++ b/src/gf-oemid @@ -21,6 +21,29 @@ oemid="$3" set -x tmpd=$(mktemp -td gf-oemid.XXXXXX) tmp_dest=${tmpd}/box.img + +# Work around for https://github.com/coreos/coreos-assembler/issues/198 +# performance monitoring for nested virtualization doesn't work reliably on +# different hypervisors (VMWare, VirtualBox, etc) so just disable the pmu +qemu_wrapper=${tmpd}/qemu-wrapper.sh +cat <<'EOF' > "${qemu_wrapper}" +#!/usr/bin/bash - +i=0 +while [ $# -gt 0 ]; do + case "$1" in + -cpu) + shift 2;; + *) + args[i]="$1" + (( i++ )) + shift ;; + esac +done +exec qemu-kvm -cpu host,pmu=off "${args[@]}" +EOF +chmod +x "${qemu_wrapper}" +export LIBGUESTFS_HV="${qemu_wrapper}" + cp --reflink=auto "${src}" "${tmp_dest}" # I commonly chmod a-w VM images chmod u+w "${tmp_dest}"