diff options
author | Manuel Bentele | 2021-07-05 09:02:53 +0200 |
---|---|---|
committer | Manuel Bentele | 2021-07-05 09:02:53 +0200 |
commit | 91696ba9eba0f5254412fa0cb796b737ffb9f2ac (patch) | |
tree | 01d7a209a5670b3e8f16c54bc284f719b4d6d911 | |
parent | Merge branch 'master' into installer (diff) | |
parent | [qemu] Fix usage of wrong run-virt variables (diff) | |
download | mltk-91696ba9eba0f5254412fa0cb796b737ffb9f2ac.tar.gz mltk-91696ba9eba0f5254412fa0cb796b737ffb9f2ac.tar.xz mltk-91696ba9eba0f5254412fa0cb796b737ffb9f2ac.zip |
Merge branch 'master' into installer
-rw-r--r-- | core/modules/qemu/data/etc/qemu/bridge.conf | 3 | ||||
-rw-r--r-- | core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/run-virt.include | 22 | ||||
-rw-r--r-- | core/modules/qemu/module.build | 7 | ||||
-rw-r--r-- | core/modules/qemu/module.conf.ubuntu | 1 | ||||
-rw-r--r-- | core/modules/run-virt/README | 6 |
5 files changed, 33 insertions, 6 deletions
diff --git a/core/modules/qemu/data/etc/qemu/bridge.conf b/core/modules/qemu/data/etc/qemu/bridge.conf new file mode 100644 index 00000000..829df227 --- /dev/null +++ b/core/modules/qemu/data/etc/qemu/bridge.conf @@ -0,0 +1,3 @@ +allow br0 +allow nat1 +allow vsw2 diff --git a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/run-virt.include b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/run-virt.include index c9d2856c..c3dfd21d 100644 --- a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/run-virt.include +++ b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/run-virt.include @@ -23,25 +23,37 @@ declare -rg QEMU_INCLUDE_DIR="${QEMU_PLUGIN_DIR}/includes" declare -rg PLUGIN_FEATURES="firewall printer usb slxfloppy sound netshares" run_plugin() { + # setup RW image access for operation + local vm_diskfile + if notempty VM_DISKFILE_RO; then + # create copy-on-write layer for readonly image + vm_diskfile="${TMPDIR}/$(basename ${VM_DISKFILE_RO}).cow.qcow2" + local vm_diskfile_type="$(qemu-img info --output=json ${VM_DISKFILE_RO} | jq -r '.format')" + qemu-img create -F "${vm_diskfile_type}" -b "${VM_DISKFILE_RO}" -f qcow2 "${vm_diskfile}" + elif notempty VM_DISKFILE_RW; then + # use supplied RW disk image from run-virt + vm_diskfile="${VM_DISKFILE_RW}" + fi + # write finalized config to temporary folder for debugging purposes local vm_final_run_file="/tmp/qemu-last-config.xml" # call the Libvirt Java tool to finalize configuration and start VM declare -rg VIRTCMD="java" - VIRTCMDOPTS=( "-jar" "/opt/openslx/vmchooser/plugins/qemu/runvirt-plugin-qemu.jar" ) + VIRTCMDOPTS=( "-jar" "${QEMU_PLUGIN_DIR}/runvirt-plugin-qemu.jar" ) notempty DEBUG && VIRTCMDOPTS+=( "-debug" "${DEBUG}" ) notempty VM_CLEANNAME && VIRTCMDOPTS+=( "-vmname" "${VM_CLEANNAME}" ) notempty VM_DISPLAYNAME && VIRTCMDOPTS+=( "-vmdsplname" "${VM_DISPLAYNAME}" ) notempty VM_OS_TYPE && VIRTCMDOPTS+=( "-vmos" "${VM_OS_TYPE}" ) - notempty VM_RUN_FILE && VIRTCMDOPTS+=( "-vmcfginp" "${VM_RUN_FILE}" ) + notempty TMPCONFIG && VIRTCMDOPTS+=( "-vmcfginp" "${TMPCONFIG}" ) notempty vm_final_run_file && VIRTCMDOPTS+=( "-vmcfgout" "${vm_final_run_file}" ) notempty IMGUUID && VIRTCMDOPTS+=( "-vmuuid" "${IMGUUID}" ) - notempty CPU_CORES && VIRTCMDOPTS+=( "-vmncpus" "${CPU_CORES}" ) + notempty HW_CORES && VIRTCMDOPTS+=( "-vmncpus" "${HW_CORES}" ) notempty VM_MEM && VIRTCMDOPTS+=( "-vmmem" "${VM_MEM}" ) notempty VM_MAC_ADDR && VIRTCMDOPTS+=( "-vmmac0" "${VM_MAC_ADDR}" ) - notempty VM_DISKFILE_RO && VIRTCMDOPTS+=( "-vmhdd0" "${VM_DISKFILE_RO}" ) - notempty FLOPPY_0 && VIRTCMDOPTS+=( "-vmfloppy0" "${FLOPPY_0}" ) + notempty vm_diskfile && VIRTCMDOPTS+=( "-vmhdd0" "${vm_diskfile}" ) + VIRTCMDOPTS+=( "-vmfloppy0" "${FLOPPY_0}" ) notempty SLX_FLOPPY_IMG && VIRTCMDOPTS+=( "-vmfloppy1" "${SLX_FLOPPY_IMG}" ) notempty CDROM_0 && VIRTCMDOPTS+=( "-vmcdrom0" "${CDROM_0}" ) notempty CDROM_1 && VIRTCMDOPTS+=( "-vmcdrom1" "${CDROM_1}" ) diff --git a/core/modules/qemu/module.build b/core/modules/qemu/module.build index 6a980dd9..2a7952e8 100644 --- a/core/modules/qemu/module.build +++ b/core/modules/qemu/module.build @@ -22,5 +22,10 @@ build() { } post_copy() { - : + # change access rights of the qemu bridge helper config + chown root:kvm /etc/qemu/bridge.conf + chmod 0664 /etc/qemu/bridge.conf + + # set UID to avoid operation not permitted errors + chmod u+s /usr/lib/qemu/qemu-bridge-helper } diff --git a/core/modules/qemu/module.conf.ubuntu b/core/modules/qemu/module.conf.ubuntu index 3b1089e0..360c6c18 100644 --- a/core/modules/qemu/module.conf.ubuntu +++ b/core/modules/qemu/module.conf.ubuntu @@ -14,4 +14,5 @@ REQUIRED_CONTENT_PACKAGES=" qemu-utils seabios ovmf + jq " diff --git a/core/modules/run-virt/README b/core/modules/run-virt/README index b04dd07e..45178bbc 100644 --- a/core/modules/run-virt/README +++ b/core/modules/run-virt/README @@ -18,6 +18,12 @@ mount, startup scripts, ... Set to either "true" or "false" so it can simply be used like this: if $DEBUG; then .... +# $HW_CORES +Number of physical CPU cores of host machine. + +# $HW_THREADS +Number of logical CPUs (SMT) of host machine. + # $IMGUUID The UUID of this VM/lecture, extracted from the passed $XMLFILE. Used to fetch meta data for the VM, like vmx, netrules, netshares, etc. |