mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-26 16:11:56 +02:00
Move vm constants into their own file. This will make it easier to share these constants.
Also fixed get latest image logic in image_to_vm and allowed for using the most recent image in cros_run_vm_test to follow other shell convention of using latest. Change-Id: I60ed4c03d609500da7f6ae34ef57ba2e32f4b0bb BUG= TEST=Tested by running image_to_vm with --full and cros_run_vm_test with suite_Smoke Review URL: http://codereview.chromium.org/3597001
This commit is contained in:
parent
3b65e8dd6f
commit
45bec936f6
@ -8,6 +8,7 @@
|
||||
|
||||
. "$(dirname $0)/../common.sh"
|
||||
. "$(dirname $0)/../lib/cros_vm_lib.sh"
|
||||
. "$(dirname "$0")/../lib/cros_vm_constants.sh"
|
||||
|
||||
DEFINE_string image_path "" "Full path of the VM image"
|
||||
DEFINE_string test_case "" "Name of the test case to run"
|
||||
@ -18,8 +19,16 @@ set -e
|
||||
FLAGS "$@" || exit 1
|
||||
eval set -- "${FLAGS_ARGV}"
|
||||
|
||||
[ -n "${FLAGS_image_path}" ] || die "You must specify a path to an image"
|
||||
[ -n "${FLAGS_test_case}" ] || die "You must specify a test case"
|
||||
# Use latest if not specified.
|
||||
if [ -z "${FLAGS_image_path}" ]; then
|
||||
LATEST_IMAGE="$(${SCRIPTS_DIR}/get_latest_image.sh)/${DEFAULT_QEMU_IMAGE}"
|
||||
info "Using latest vm image ${LATEST_IMAGE}"
|
||||
FLAGS_image_path=${LATEST_IMAGE}
|
||||
fi
|
||||
|
||||
[ -e "${FLAGS_image_path}" ] || die "Image ${FLAGS_image_path} does not exist."
|
||||
|
||||
[ -n "${FLAGS_test_case}" ] || die "You must specify a test case."
|
||||
|
||||
trap stop_kvm EXIT
|
||||
start_kvm "${FLAGS_image_path}"
|
||||
|
@ -11,22 +11,11 @@
|
||||
# The path to common.sh should be relative to your script's location.
|
||||
. "$(dirname "$0")/common.sh"
|
||||
. "$(dirname "$0")/chromeos-common.sh"
|
||||
. "$(dirname "$0")/lib/cros_vm_constants.sh"
|
||||
|
||||
get_default_board
|
||||
assert_inside_chroot
|
||||
|
||||
DEFAULT_MEM="1024"
|
||||
DEFAULT_VMDK="ide.vmdk"
|
||||
DEFAULT_VMX="chromiumos.vmx"
|
||||
DEFAULT_VBOX_DISK="os.vdi"
|
||||
DEFAULT_QEMU_IMAGE="chromiumos_qemu_image.bin"
|
||||
|
||||
# Minimum sizes for full size vm images -- needed for update.
|
||||
MIN_VDISK_SIZE_FULL=6072
|
||||
MIN_STATEFUL_FS_SIZE_FULL=2048
|
||||
|
||||
MOD_SCRIPTS_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts"
|
||||
|
||||
# Flags
|
||||
DEFINE_string board "${DEFAULT_BOARD}" \
|
||||
"Board for which the image was built"
|
||||
@ -85,7 +74,7 @@ fi
|
||||
IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}"
|
||||
# Default to the most recent image
|
||||
if [ -z "${FLAGS_from}" ] ; then
|
||||
FLAGS_from="${IMAGES_DIR}/$(ls -t $IMAGES_DIR | head -1)"
|
||||
FLAGS_from="$(./get_latest_image.sh)"
|
||||
else
|
||||
pushd "${FLAGS_from}" && FLAGS_from=`pwd` && popd
|
||||
fi
|
||||
|
16
lib/cros_vm_constants.sh
Normal file
16
lib/cros_vm_constants.sh
Normal file
@ -0,0 +1,16 @@
|
||||
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# Common constants for vm scripts.
|
||||
|
||||
# Default values for creating VM's.
|
||||
DEFAULT_MEM="1024"
|
||||
DEFAULT_VMDK="ide.vmdk"
|
||||
DEFAULT_VMX="chromiumos.vmx"
|
||||
DEFAULT_VBOX_DISK="os.vdi"
|
||||
DEFAULT_QEMU_IMAGE="chromiumos_qemu_image.bin"
|
||||
|
||||
# Minimum sizes for full size vm images -- needed for update.
|
||||
MIN_VDISK_SIZE_FULL=6072
|
||||
MIN_STATEFUL_FS_SIZE_FULL=2048
|
@ -4,6 +4,8 @@
|
||||
#
|
||||
# Common vm functions for use in crosutils.
|
||||
|
||||
. "$(dirname "$0")/cros_vm_constants.sh"
|
||||
|
||||
DEFINE_string kvm_pid "" \
|
||||
"Use this pid file. If it exists and is set, use the vm specified by pid."
|
||||
DEFINE_boolean no_graphics ${FLAGS_FALSE} "Runs the KVM instance silently."
|
||||
@ -11,7 +13,6 @@ DEFINE_boolean persist "${FLAGS_FALSE}" "Persist vm."
|
||||
DEFINE_boolean snapshot ${FLAGS_FALSE} "Don't commit changes to image."
|
||||
DEFINE_integer ssh_port 9222 "Port to tunnel ssh traffic over."
|
||||
|
||||
|
||||
KVM_PID_FILE=/tmp/kvm.$$.pid
|
||||
|
||||
function get_pid() {
|
||||
@ -47,7 +48,7 @@ function start_kvm() {
|
||||
snapshot="-snapshot"
|
||||
fi
|
||||
|
||||
sudo kvm -m 1024 \
|
||||
sudo kvm -m ${DEFAULT_MEM} \
|
||||
-vga std \
|
||||
-pidfile "${KVM_PID_FILE}" \
|
||||
-daemonize \
|
||||
|
Loading…
x
Reference in New Issue
Block a user