diff options
Diffstat (limited to 'core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include')
-rw-r--r-- | core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include index fd251f04..893835e7 100644 --- a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include +++ b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include @@ -29,10 +29,30 @@ run_plugin() { $(safesource "${QEMU_INCLUDE_DIR}/passthrough-pci.inc") # include mediated device passthrough utils and functions $(safesource "${QEMU_INCLUDE_DIR}/passthrough-mdev.inc") + # include function for creating the rw qcow2 image + $(safesource "${QEMU_INCLUDE_DIR}/create-rw-diskimage.inc") - # setup RW image access for operation local vm_diskfile - if notempty VM_DISKFILE_RO; then + # If admin mode checkbox is set in the vmchooser, create the rw disk for the snapshot + if [ "${VMCHOOSER_ADMIN_MODE}" = TRUE ]; then + # Create tmp dir that survives cleanup + mkdir /tmp/upload + + # Activate cleanup function for uploading + create_rw_diskimage + + # Create snapshot file in upload dir that doesn't get deleted on cleanup + if [ -f /var/lib/lightdm/editsession.id ]; then + EDITID=$(cat /var/lib/lightdm/editsession.id) + vm_diskfile="/tmp/upload/$EDITID.qcow2" + else + writelog "No editid was found at /var/lib/lightdm/editsession.id, using IMGUUID as fallback" + vm_diskfile="/tmp/upload/$IMGUUID.qcow2" + fi + 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}" + # setup RW image access for operation + elif 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')" |