blob: b7c5198d3ca5e4dc1a89ba8b7a3b2e3094e99e9d [file] [log] [blame]
Denis Egorenko0d045ae2019-06-04 18:23:11 +04001#!/bin/bash
2
3set -e
alexz1c02cd62018-04-15 22:18:03 +02004
Denis Egorenkoc2656402019-04-19 18:17:50 +04005functionsFile="$(pwd)/functions.sh"
6
7if [[ ! -f ${functionsFile} ]]; then
8 echo "ERROR: Can not find 'functions' libfile (${functionsFile}), check your mcp/mcp-common-scripts repo."
9 exit 1
10else
11 source ${functionsFile}
12fi
alexz1c02cd62018-04-15 22:18:03 +020013
14if [[ -z ${VM_NAME} ]]; then
15 echo "ERROR: \$VM_NAME not set!"
16 exit 1
17fi
Denis Egorenkoc2656402019-04-19 18:17:50 +040018if [[ -z ${VM_SOURCE_DISK} ]] || [[ ! -f ${VM_SOURCE_DISK} ]]; then
alexz1c02cd62018-04-15 22:18:03 +020019 echo "ERROR: \$VM_SOURCE_DISK not set, or file does not exist!"
20 exit 1
21fi
Denis Egorenkoc2656402019-04-19 18:17:50 +040022if [[ -z ${VM_CONFIG_DISK} ]] || [[ ! -f ${VM_CONFIG_DISK} ]]; then
alexz1c02cd62018-04-15 22:18:03 +020023 echo "ERROR: \$VM_CONFIG_DISK not set, or file does not exist!"
24 exit 1
25fi
26
Denis Egorenkoabe23c52019-05-30 16:53:55 +040027prereq_check
Denis Egorenkodcc233d2019-03-06 18:09:24 +040028
Denis Egorenkoabe23c52019-05-30 16:53:55 +040029#### Make sure that both files are saved to system path which is available for libvirt-qemu:kvm
30export VM_SOURCE_DISK=$(place_file_under_libvirt_owned_dir ${VM_SOURCE_DISK} ${NON_DEFAULT_LIBVIRT_DIR})
31export VM_CONFIG_DISK=$(place_file_under_libvirt_owned_dir ${VM_CONFIG_DISK} ${NON_DEFAULT_LIBVIRT_DIR})
32
33render_config "${VM_NAME}" "${VM_MEM_KB}" "${VM_CPUS}" "${VM_SOURCE_DISK}" "${VM_CONFIG_DISK}"
alexz1c02cd62018-04-15 22:18:03 +020034
35virsh define $(pwd)/${VM_NAME}-vm.xml
36virsh autostart ${VM_NAME}