blob: 70336d3d8ec145445a170ad6efc4230e09bd8591 [file] [log] [blame]
azvyagintsev6bb49a72018-03-27 14:37:03 +03001#!/bin/bash -xe
2
3MIRROR_VM_MGM_BRIDGE_NAME=${MIRROR_VM_MGM_BRIDGE_NAME:-"br-mgm"}
Richard Felkldc2ecf62018-03-23 13:09:41 +01004MIRROR_VM_MEM_KB=${MIRROR_VM_MEM_KB:-"4194304"}
5MIRROR_VM_CPUS=${MIRROR_VM_CPUS:-"4"}
azvyagintsev6bb49a72018-03-27 14:37:03 +03006
7if [[ -z ${MIRROR_VM_NAME} ]]; then
8 echo "ERROR: \$MIRROR_VM_NAME not set!"
9 exit 1
10fi
11
12cat <<EOF > $(pwd)/mirror-vm.xml
13<domain type='kvm'>
Richard Felkldc2ecf62018-03-23 13:09:41 +010014 <name>$MIRROR_VM_NAME</name>
15 <memory unit='KiB'>$MIRROR_VM_MEM_KB</memory>
16 <currentMemory unit='KiB'>$MIRROR_VM_MEM_KB</currentMemory>
17 <vcpu placement='static'>$MIRROR_VM_CPUS</vcpu>
18 <resource>
19 <partition>/machine</partition>
20 </resource>
21 <os>
22 <type >hvm</type>
23 <boot dev='hd'/>
24 </os>
25 <features>
26 <acpi/>
Richard Felkldc2ecf62018-03-23 13:09:41 +010027 </features>
28 <clock offset='utc'>
29 <timer name='rtc' tickpolicy='catchup'/>
30 <timer name='pit' tickpolicy='delay'/>
31 <timer name='hpet' present='no'/>
32 </clock>
33 <pm>
34 <suspend-to-mem enabled='no'/>
35 <suspend-to-disk enabled='no'/>
36 </pm>
37 <devices>
38 <emulator>/usr/bin/kvm-spice</emulator>
39 <disk type='file' device='disk'>
40 <driver name='qemu' type='qcow2' cache='none'/>
41 <source file='$MIRROR_VM_SOURCE_DISK'/>
42 <target dev='vda' bus='virtio'/>
Richard Felkldc2ecf62018-03-23 13:09:41 +010043 <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
44 </disk>
45 <disk type='file' device='cdrom'>
46 <driver name='qemu' type='raw'/>
47 <source file='$MIRROR_VM_CONFIG_DISK'/>
48 <backingStore/>
49 <target dev='hda' bus='ide'/>
50 <readonly/>
Richard Felkldc2ecf62018-03-23 13:09:41 +010051 <address type='drive' controller='0' bus='0' target='0' unit='0'/>
52 </disk>
53 <interface type='bridge'>
54 <source bridge='$MIRROR_VM_MGM_BRIDGE_NAME'/>
Richard Felkldc2ecf62018-03-23 13:09:41 +010055 <model type='virtio'/>
Richard Felkldc2ecf62018-03-23 13:09:41 +010056 <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
57 </interface>
58 <serial type='pty'>
59 <source path='/dev/pts/1'/>
60 <target port='0'/>
Richard Felkldc2ecf62018-03-23 13:09:41 +010061 </serial>
62 <console type='pty' tty='/dev/pts/1'>
63 <source path='/dev/pts/1'/>
64 <target type='serial' port='0'/>
Richard Felkldc2ecf62018-03-23 13:09:41 +010065 </console>
66 <graphics type='vnc' port='5900' autoport='yes' listen='127.0.0.1'>
67 <listen type='address' address='127.0.0.1'/>
68 </graphics>
69 </devices>
azvyagintsev6bb49a72018-03-27 14:37:03 +030070</domain>
71EOF
72
73echo "INFO: rendered VM config:"
74cat $(pwd)/mirror-vm.xml
75
76virsh define $(pwd)/mirror-vm.xml
77virsh autostart ${MIRROR_VM_NAME}