diff options
author | Manuel Bentele | 2021-06-10 10:47:03 +0200 |
---|---|---|
committer | Manuel Bentele | 2021-06-10 11:14:27 +0200 |
commit | f7d38bc10b11abadbcd9b12b1784d7108f0a5d7e (patch) | |
tree | f2a2e0d3b022d0de5af13b89ccf0cb254d91f108 /core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/App.java | |
parent | [qemu] Add unit tests for Libvirt configuration transformations (diff) | |
download | mltk-f7d38bc10b11abadbcd9b12b1784d7108f0a5d7e.tar.gz mltk-f7d38bc10b11abadbcd9b12b1784d7108f0a5d7e.tar.xz mltk-f7d38bc10b11abadbcd9b12b1784d7108f0a5d7e.zip |
[qemu] Implement passthrough of NVIDIA GPUs
The implementation adds specified PCI devics of a NVIDIA GPU on the host
system to the final Libvirt domain XML configuration for a NVIDIA GPU
passthrough. In addition to that, the implementation adds support for
the Looking Glass Client to display the framebuffer of the NVIDIA GPU
on the host system through a shared memory device.
Diffstat (limited to 'core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/App.java')
-rw-r--r-- | core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/App.java | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/App.java b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/App.java index a3e1c5b7..5ea7b720 100644 --- a/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/App.java +++ b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/App.java @@ -1,6 +1,7 @@ package org.openslx.runvirt.plugin.qemu; import java.io.File; +import java.util.Arrays; import org.apache.log4j.BasicConfigurator; import org.apache.log4j.LogManager; @@ -29,6 +30,7 @@ import org.openslx.runvirt.plugin.qemu.virtualization.LibvirtHypervisorQemu; import org.openslx.runvirt.plugin.qemu.virtualization.LibvirtHypervisorQemu.QemuSessionType; import org.openslx.runvirt.viewer.Viewer; import org.openslx.runvirt.viewer.ViewerException; +import org.openslx.runvirt.viewer.ViewerLookingGlassClient; import org.openslx.runvirt.viewer.ViewerVirtManager; import org.openslx.runvirt.viewer.ViewerVirtViewer; import org.openslx.runvirt.virtualization.LibvirtHypervisor; @@ -185,12 +187,18 @@ public class App // create specific viewer to display Libvirt VM final Viewer vmViewer; - if ( cmdLn.isDebugEnabled() ) { - // create specific Virtual Machine Manager viewer if debug mode is enabled - vmViewer = new ViewerVirtManager( vm, hypervisor ); + if ( cmdLn.isNvidiaGpuPassthroughEnabled() ) { + // viewer for GPU passthrough (framebuffer access) is required + vmViewer = new ViewerLookingGlassClient( vm, hypervisor, cmdLn.isDebugEnabled() ); } else { - // create Virtual Viewer if debug mode is disabled - vmViewer = new ViewerVirtViewer( vm, hypervisor ); + // viewer for non-GPU passthrough (no framebuffer access) is required + if ( cmdLn.isDebugEnabled() ) { + // create specific Virtual Machine Manager viewer if debug mode is enabled + vmViewer = new ViewerVirtManager( vm, hypervisor ); + } else { + // create Virtual Viewer if debug mode is disabled + vmViewer = new ViewerVirtViewer( vm, hypervisor ); + } } // display Libvirt VM with the specific viewer on the screen @@ -258,16 +266,20 @@ public class App for ( CmdLnOption option : CmdLnOption.values() ) { final String paddedLongOption = String.format( "%-" + longOptionLengthMax + "s", option.getLongOption() ); - final String longOptionArgument; + String[] longOptionArguments; // only request and log argument if option has an command line argument - if ( option.hasArgument() ) { - longOptionArgument = cmdLn.getArgument( option ); + if ( option.getNumArguments() > 0 ) { + longOptionArguments = cmdLn.getArguments( option ); + + if ( longOptionArguments == null ) { + longOptionArguments = new String[] { "no argument specified" }; + } } else { - longOptionArgument = new String( "[option has no argument]" ); + longOptionArguments = new String[] { "option has no argument" }; } - LOGGER.debug( "\t" + paddedLongOption + ": " + longOptionArgument ); + LOGGER.debug( "\t" + paddedLongOption + ": " + Arrays.toString( longOptionArguments ) ); } } } |