mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 14:41:31 +02:00
kvm: set cache type to unsafe if possible, else writeback
We try to set the cache type to unsafe, which is a new kvm feature, else we set the cache type to writeback. The hope is that these cache types will perform better on the bots, especially in the case of the guest trying to flush data to disk. The CL includes code to determine which version of kvm is running, and the cache type is chosen based on that. BUG=chromium-os:20305 TEST=trybot Change-Id: Icf7dbb8f0056a330282ebeb81d0902b3d54f34c5 Reviewed-on: http://gerrit.chromium.org/gerrit/8360 Reviewed-by: David James <davidjames@chromium.org> Tested-by: Andrew de los Reyes <adlr@chromium.org>
This commit is contained in:
parent
faeee5f47c
commit
8e93647f05
@ -37,6 +37,14 @@ function blocking_kill() {
|
||||
! ps -p ${1} > /dev/null
|
||||
}
|
||||
|
||||
function kvm_version_greater_equal() {
|
||||
local test_version="${1}"
|
||||
local kvm_version=$(kvm --version | sed -E 's/^.*version ([0-9\.]*) .*$/\1/')
|
||||
|
||||
[ $(echo -e "${test_version}\n${kvm_version}" | sort -r -V | head -n 1) = \
|
||||
$kvm_version ]
|
||||
}
|
||||
|
||||
# $1: Path to the virtual image to start.
|
||||
function start_kvm() {
|
||||
# Override default pid file.
|
||||
@ -73,6 +81,11 @@ function start_kvm() {
|
||||
net_option="-net nic,model=e1000"
|
||||
fi
|
||||
|
||||
local cache_type="writeback"
|
||||
if kvm_version_greater_equal "0.14"; then
|
||||
cache_type="unsafe"
|
||||
fi
|
||||
|
||||
sudo kvm -m 1024 \
|
||||
-vga std \
|
||||
-pidfile "${KVM_PID_FILE}" \
|
||||
@ -81,7 +94,7 @@ function start_kvm() {
|
||||
${nographics} \
|
||||
${snapshot} \
|
||||
-net user,hostfwd=tcp::${FLAGS_ssh_port}-:22 \
|
||||
-hda "${1}"
|
||||
-drive "file=${1},index=0,media=disk,cache=${cache_type}"
|
||||
|
||||
info "KVM started with pid stored in ${KVM_PID_FILE}"
|
||||
LIVE_VM_IMAGE="${1}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user