blob: e066a55c731ef7fd1a5d8afaf49456c7c752c890 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
setup_rw_layer() {
if isempty VM_DISKFILE_RO; then
writelog "No source diskfile found! This should be specified in the given XML file. Is it valid?"
EXIT_TYPE="user" EXIT_REASON="Keine virtuelle Festplatte zu dieser Veranstaltung angegeben!" cleanexit 1
fi
# setup qcow2 backing file for that disk file
writelog "Creating backing file for '${VM_DISKFILE_RO}'..."
declare -rg VM_DISKFILE_RW="${TMPDIR}/$(basename ${VM_DISKFILE_RO}).qcow2"
if qemu-img create -f qcow2 -b "${VM_DISKFILE_RO}" "${VM_DISKFILE_RW}"; then
# all good, use it as main disk drive
# TODO: determine the proper type of controller to use, ideally virtio?
VIRTCMDOPTS="${VIRTCMDOPTS} -drive if=virtio,format=qcow2,file=${VM_DISKFILE_RW}"
else
writelog "Error creating backing file for '${VM_DISKFILE_RO}'"
# TODO use -snapshot as fallback, test it!
VIRTCMDOPTS="${VIRTCMDOPTS} -snapshot"
fi
}
call_post_source setup_rw_layer
|