blob: 543560769d3ed568ff82f52b8167272d75d66032 [file] [log] [blame]
alexz1c02cd62018-04-15 22:18:03 +02001#!/bin/bash -xe
2
Denis Egorenkoc2656402019-04-19 18:17:50 +04003functionsFile="$(pwd)/functions.sh"
4
5if [[ ! -f ${functionsFile} ]]; then
6 echo "ERROR: Can not find 'functions' libfile (${functionsFile}), check your mcp/mcp-common-scripts repo."
7 exit 1
8else
9 source ${functionsFile}
10fi
alexz1c02cd62018-04-15 22:18:03 +020011
12if [[ -z ${VM_NAME} ]]; then
13 echo "ERROR: \$VM_NAME not set!"
14 exit 1
15fi
Denis Egorenkoc2656402019-04-19 18:17:50 +040016if [[ -z ${VM_SOURCE_DISK} ]] || [[ ! -f ${VM_SOURCE_DISK} ]]; then
alexz1c02cd62018-04-15 22:18:03 +020017 echo "ERROR: \$VM_SOURCE_DISK not set, or file does not exist!"
18 exit 1
19fi
Denis Egorenkoc2656402019-04-19 18:17:50 +040020if [[ -z ${VM_CONFIG_DISK} ]] || [[ ! -f ${VM_CONFIG_DISK} ]]; then
alexz1c02cd62018-04-15 22:18:03 +020021 echo "ERROR: \$VM_CONFIG_DISK not set, or file does not exist!"
22 exit 1
23fi
24
Denis Egorenkoabe23c52019-05-30 16:53:55 +040025prereq_check
Denis Egorenkodcc233d2019-03-06 18:09:24 +040026
Denis Egorenkoabe23c52019-05-30 16:53:55 +040027#### Make sure that both files are saved to system path which is available for libvirt-qemu:kvm
28export VM_SOURCE_DISK=$(place_file_under_libvirt_owned_dir ${VM_SOURCE_DISK} ${NON_DEFAULT_LIBVIRT_DIR})
29export VM_CONFIG_DISK=$(place_file_under_libvirt_owned_dir ${VM_CONFIG_DISK} ${NON_DEFAULT_LIBVIRT_DIR})
30
31render_config "${VM_NAME}" "${VM_MEM_KB}" "${VM_CPUS}" "${VM_SOURCE_DISK}" "${VM_CONFIG_DISK}"
alexz1c02cd62018-04-15 22:18:03 +020032
33virsh define $(pwd)/${VM_NAME}-vm.xml
34virsh autostart ${VM_NAME}