From d8edab02d5c5b814abb24375d3c2e6d2189c5917 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 1 Jul 2021 12:12:50 +0200 Subject: [run-virt] Update README --- core/modules/run-virt/README | 6 ++++++ 1 file changed, 6 insertions(+) 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. -- cgit v1.2.3-55-g7522 From e209314e79220b6f1f7a6d3f5ea322b4e03c329e Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Mon, 5 Jul 2021 08:59:45 +0200 Subject: [qemu] Add QEMU bridge helper to access bridges from user session --- core/modules/qemu/data/etc/qemu/bridge.conf | 3 +++ core/modules/qemu/module.build | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 core/modules/qemu/data/etc/qemu/bridge.conf 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/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 } -- cgit v1.2.3-55-g7522 From 280e8247eefc721c8c450b92990dde2a1714452b Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Mon, 5 Jul 2021 09:00:10 +0200 Subject: [qemu] Fix hard-coded path to run-virt Java tool --- .../qemu/data/opt/openslx/vmchooser/plugins/qemu/run-virt.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..f35afd04 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 @@ -28,7 +28,7 @@ run_plugin() { # 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}" ) -- cgit v1.2.3-55-g7522 From df503b8ea498a7d69ce622425a36424a2594457d Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Mon, 5 Jul 2021 09:00:55 +0200 Subject: [qemu] Fix usage of wrong run-virt variables --- .../openslx/vmchooser/plugins/qemu/run-virt.include | 20 ++++++++++++++++---- core/modules/qemu/module.conf.ubuntu | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) 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 f35afd04..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,6 +23,18 @@ 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" @@ -34,14 +46,14 @@ run_plugin() { 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.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 " -- cgit v1.2.3-55-g7522