Denis Egorenko | 0d045ae | 2019-06-04 18:23:11 +0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -e |
alexz | 1c02cd6 | 2018-04-15 22:18:03 +0200 | [diff] [blame] | 4 | |
Denis Egorenko | c265640 | 2019-04-19 18:17:50 +0400 | [diff] [blame] | 5 | functionsFile="$(pwd)/functions.sh" |
| 6 | |
| 7 | if [[ ! -f ${functionsFile} ]]; then |
| 8 | echo "ERROR: Can not find 'functions' libfile (${functionsFile}), check your mcp/mcp-common-scripts repo." |
| 9 | exit 1 |
| 10 | else |
| 11 | source ${functionsFile} |
| 12 | fi |
alexz | 1c02cd6 | 2018-04-15 22:18:03 +0200 | [diff] [blame] | 13 | |
| 14 | if [[ -z ${VM_NAME} ]]; then |
| 15 | echo "ERROR: \$VM_NAME not set!" |
| 16 | exit 1 |
| 17 | fi |
Denis Egorenko | c265640 | 2019-04-19 18:17:50 +0400 | [diff] [blame] | 18 | if [[ -z ${VM_SOURCE_DISK} ]] || [[ ! -f ${VM_SOURCE_DISK} ]]; then |
alexz | 1c02cd6 | 2018-04-15 22:18:03 +0200 | [diff] [blame] | 19 | echo "ERROR: \$VM_SOURCE_DISK not set, or file does not exist!" |
| 20 | exit 1 |
| 21 | fi |
Denis Egorenko | c265640 | 2019-04-19 18:17:50 +0400 | [diff] [blame] | 22 | if [[ -z ${VM_CONFIG_DISK} ]] || [[ ! -f ${VM_CONFIG_DISK} ]]; then |
alexz | 1c02cd6 | 2018-04-15 22:18:03 +0200 | [diff] [blame] | 23 | echo "ERROR: \$VM_CONFIG_DISK not set, or file does not exist!" |
| 24 | exit 1 |
| 25 | fi |
| 26 | |
Denis Egorenko | abe23c5 | 2019-05-30 16:53:55 +0400 | [diff] [blame] | 27 | prereq_check |
Denis Egorenko | dcc233d | 2019-03-06 18:09:24 +0400 | [diff] [blame] | 28 | |
Denis Egorenko | abe23c5 | 2019-05-30 16:53:55 +0400 | [diff] [blame] | 29 | #### Make sure that both files are saved to system path which is available for libvirt-qemu:kvm |
| 30 | export VM_SOURCE_DISK=$(place_file_under_libvirt_owned_dir ${VM_SOURCE_DISK} ${NON_DEFAULT_LIBVIRT_DIR}) |
| 31 | export VM_CONFIG_DISK=$(place_file_under_libvirt_owned_dir ${VM_CONFIG_DISK} ${NON_DEFAULT_LIBVIRT_DIR}) |
| 32 | |
| 33 | render_config "${VM_NAME}" "${VM_MEM_KB}" "${VM_CPUS}" "${VM_SOURCE_DISK}" "${VM_CONFIG_DISK}" |
alexz | 1c02cd6 | 2018-04-15 22:18:03 +0200 | [diff] [blame] | 34 | |
| 35 | virsh define $(pwd)/${VM_NAME}-vm.xml |
| 36 | virsh autostart ${VM_NAME} |