From 670ef8aabd4d997372554e79f8ca8930df56d2e6 Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Mon, 17 May 2021 13:51:41 +0200 Subject: [qemu] Add viewer representation to render displays of the virtual machine --- .../java/org/openslx/runvirt/viewer/Viewer.java | 118 +++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/viewer/Viewer.java (limited to 'core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/viewer/Viewer.java') diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/viewer/Viewer.java b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/viewer/Viewer.java new file mode 100644 index 00000000..d23a9e11 --- /dev/null +++ b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/viewer/Viewer.java @@ -0,0 +1,118 @@ +package org.openslx.runvirt.viewer; + +import org.openslx.runvirt.virtualization.LibvirtHypervisor; +import org.openslx.runvirt.virtualization.LibvirtVirtualMachine; +import org.openslx.virtualization.Version; + +/** + * Representation of an viewer for virtual machines running on a host system. + * + * @author Manuel Bentele + * @version 1.0 + */ +public abstract class Viewer +{ + /** + * Name of the viewer. + */ + private final String name; + + /** + * Number of supported displays by the viewer. + */ + private final int numSupportedDisplays; + + /** + * The virtual machine to display. + */ + private final LibvirtVirtualMachine machine; + + /** + * Remote (hypervisor) endpoint for the viewer to connect to. + */ + private final LibvirtHypervisor hypervisor; + + /** + * Creates a new viewer for a Libvirt virtual machine running on a Libvirt hypervisor. + * + * @param name textual name of the viewer. + * @param numSupportedDisplays number of supported displays by the viewer. + * @param machine virtual machine to display. + * @param hypervisor remote (hypervisor) endpoint for the viewer to connect to. + */ + public Viewer( String name, int numSupportedDisplays, LibvirtVirtualMachine machine, LibvirtHypervisor hypervisor ) + { + this.name = name; + this.numSupportedDisplays = numSupportedDisplays; + this.machine = machine; + this.hypervisor = hypervisor; + } + + /** + * Returns the name of the viewer. + * + * @return name of the viewer. + */ + public String getName() + { + return this.name; + } + + /** + * Returns the number of supported displays by the viewer. + * + * @return number of supported displays by the viewer. + */ + public int getNumberOfSupportedDisplays() + { + return this.numSupportedDisplays; + } + + /** + * Returns the virtual machine to display. + * + * @return virtual machine to display. + */ + public LibvirtVirtualMachine getMachine() + { + return this.machine; + } + + /** + * Returns the remote (hypervisor) endpoint for the viewer to connect to. + * + * @return remote (hypervisor) endpoint for the viewer to connect to. + */ + public LibvirtHypervisor getHypervisor() + { + return this.hypervisor; + } + + /** + * Displays all virtual machine's displays. + * + * @throws ViewerException failed to display all displays of a virtual machine. + * + * @apiNote A call to this method blocks until the implemented {@link #render()} process + * terminates. + */ + public void display() throws ViewerException + { + this.render(); + } + + /** + * Returns the version of the viewer. + * + * @return version of the viewer. + * @throws ViewerException failed to get version of the viewer. + */ + public abstract Version getVersion() throws ViewerException; + + /** + * Renders the content of all displays from the virtual machine. + * + * @throws ViewerException failed to render all displays of a virtual machine. + */ + protected abstract void render() throws ViewerException; +} -- cgit v1.2.3-55-g7522