1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
package org.openslx.runvirt.viewer;
import org.openslx.libvirt.domain.device.GraphicsSpice;
import org.openslx.runvirt.virtualization.LibvirtHypervisor;
import org.openslx.runvirt.virtualization.LibvirtVirtualMachine;
import org.openslx.virtualization.Version;
/**
* Looking Glass Client to view the exposed framebuffer (through a shared memory) of a virtual
* machine running the Looking Glass Host application.
*
* @author Manuel Bentele
* @version 1.0
*/
public class ViewerLookingGlassClient extends Viewer
{
/**
* Name of the Looking Glass Client program.
*/
private final static String NAME = "looking-glass-client";
/**
* Maximum number of supported displays by the Looking Glass Client.
*/
private final static int NUM_SUPPORTED_DISPLAYS = 1;
/**
* File name of the shared memory file to receive display content from the Looking Glass Host.
*/
private final static String SHARED_MEMORY_FILENAME = "/dev/shm/looking-glass";
/**
* State whether showing debug information during virtual machine rendering or not.
*/
private final boolean debug;
/**
* Creates a new Looking Glass Client for a Libvirt virtual machine running on a Libvirt
* hypervisor.
*
* @param machine virtual machine to display.
* @param hypervisor remote (hypervisor) endpoint for the viewer to connect to.
*/
public ViewerLookingGlassClient( LibvirtVirtualMachine machine, LibvirtHypervisor hypervisor )
{
this( machine, hypervisor, false );
}
/**
* Creates a new Looking Glass Client for a Libvirt virtual machine running on a Libvirt
* hypervisor.
*
* @param machine virtual machine to display.
* @param hypervisor remote (hypervisor) endpoint for the viewer to connect to.
* @param debug state whether showing debug information during virtual machine rendering or not.
*/
public ViewerLookingGlassClient( LibvirtVirtualMachine machine, LibvirtHypervisor hypervisor, boolean debug )
{
super( ViewerLookingGlassClient.NAME, ViewerLookingGlassClient.NUM_SUPPORTED_DISPLAYS, machine, hypervisor );
this.debug = debug;
}
/**
* Returns the state whether showing debug information during virtual machine rendering or not.
*
* @return state whether showing debug information during virtual machine rendering or not.
*/
public boolean isDebugEnabled()
{
return this.debug;
}
@Override
public Version getVersion() throws ViewerException
{
return null;
}
@Override
public void render() throws ViewerException
{
// execute viewer process with arguments:
// in non-debug mode:
// "looking-glass-client app:renderer=OpenGL app:shmFile=<SHARED-MEM-FILE> win:fullScreen=yes spice:enable=yes spice:host=<SPICE-ADDRESS> spice:port=<SPICE-PORT> win:alerts=no"
// in debug mode:
// "looking-glass-client app:renderer=OpenGL app:shmFile=<SHARED-MEM-FILE> win:fullScreen=yes spice:enable=yes spice:host=<SPICE-ADDRESS> spice:port=<SPICE-PORT> win:alerts=yes win:showFPS=yes"
final String[] viewerParameters;
if ( this.isDebugEnabled() ) {
viewerParameters = new String[] {
"app:renderer=OpenGL",
"app:shmFile=" + "/dev/shm/" + ViewerLookingGlassClient.SHARED_MEMORY_FILENAME,
"win:fullScreen=yes",
"spice:enable=yes",
"spice:host=" + GraphicsSpice.DEFAULT_ADDRESS,
"spice:port=" + GraphicsSpice.DEFAULT_PORT,
"win:alerts=no" };
} else {
viewerParameters = new String[] {
"app:renderer=OpenGL",
"app:shmFile=" + "/dev/shm/" + ViewerLookingGlassClient.SHARED_MEMORY_FILENAME,
"win:fullScreen=yes",
"spice:enable=yes",
"spice:host=" + GraphicsSpice.DEFAULT_ADDRESS,
"spice:port=" + GraphicsSpice.DEFAULT_PORT,
"win:alerts=yes",
"win:showFPS=yes" };
}
ViewerUtils.executeViewer( ViewerLookingGlassClient.NAME, viewerParameters );
}
}
|