Support more display/spice options.

This commit is contained in:
Michael Lipp 2023-06-18 23:04:57 +02:00
parent 0879e40213
commit 488e6fafdc
4 changed files with 115 additions and 11 deletions

View file

@ -92,7 +92,7 @@
# "bootindex": (undefined) # "bootindex": (undefined)
# "resource": (undefined) # "resource": (undefined)
# "spice": # "display":
# "port": 5900 # "spice":
# "usbRedirects": 2 # "port": 5900
# "usbRedirects": 2

View file

@ -113,10 +113,14 @@ data:
- "type": "raw" - "type": "raw"
"device": "/dev/disk-{{ $index }}" "device": "/dev/disk-{{ $index }}"
{{- end }} {{- end }}
"spice": "display":
"port": {{ .Values.vm.spicePort }} "spice":
# "usbRedirects": 2 "port": {{ .Values.vm.spicePort }}
{{- if hasKey .Values.vm "streamingVideo" }}
"streamingVideo": "{{ .Values.vm.streamingVideo }}"
{{- end }}
# "usbRedirects": 2
logging.properties: | logging.properties: |
handlers=java.util.logging.ConsoleHandler handlers=java.util.logging.ConsoleHandler

View file

@ -33,6 +33,7 @@ import java.util.regex.Pattern;
import org.jdrupes.vmoperator.util.Dto; import org.jdrupes.vmoperator.util.Dto;
import org.jdrupes.vmoperator.util.FsdUtils; import org.jdrupes.vmoperator.util.FsdUtils;
// TODO: Auto-generated Javadoc
/** /**
* The configuration information from the configuration file. * The configuration information from the configuration file.
*/ */
@ -68,14 +69,31 @@ class Configuration implements Dto {
} }
} }
/** The data dir. */
public Path dataDir; public Path dataDir;
/** The runtime dir. */
public Path runtimeDir; public Path runtimeDir;
/** The template. */
public String template; public String template;
/** The update template. */
public boolean updateTemplate; public boolean updateTemplate;
/** The swtpm socket. */
public Path swtpmSocket; public Path swtpmSocket;
/** The monitor socket. */
public Path monitorSocket; public Path monitorSocket;
/** The firmware rom. */
public Path firmwareRom; public Path firmwareRom;
/** The firmware vars. */
public Path firmwareVars; public Path firmwareVars;
/** The vm. */
@SuppressWarnings("PMD.ShortVariable") @SuppressWarnings("PMD.ShortVariable")
public Vm vm; public Vm vm;
@ -113,27 +131,69 @@ class Configuration implements Dto {
@SuppressWarnings({ "PMD.ShortClassName", "PMD.TooManyFields", @SuppressWarnings({ "PMD.ShortClassName", "PMD.TooManyFields",
"PMD.DataClass" }) "PMD.DataClass" })
public static class Vm implements Dto { public static class Vm implements Dto {
/** The name. */
public String name; public String name;
/** The uuid. */
public String uuid; public String uuid;
/** The use tpm. */
public boolean useTpm; public boolean useTpm;
/** The boot menu. */
public boolean bootMenu; public boolean bootMenu;
/** The firmware. */
public String firmware = "uefi"; public String firmware = "uefi";
/** The maximum ram. */
public BigInteger maximumRam; public BigInteger maximumRam;
/** The current ram. */
public BigInteger currentRam; public BigInteger currentRam;
/** The cpu model. */
public String cpuModel = "host"; public String cpuModel = "host";
/** The maximum cpus. */
public int maximumCpus = 1; public int maximumCpus = 1;
/** The current cpus. */
public int currentCpus = 1; public int currentCpus = 1;
/** The cpu sockets. */
public int cpuSockets; public int cpuSockets;
/** The dies per socket. */
public int diesPerSocket; public int diesPerSocket;
/** The cores per die. */
public int coresPerDie; public int coresPerDie;
/** The threads per core. */
public int threadsPerCore; public int threadsPerCore;
/** The accelerator. */
public String accelerator = "kvm"; public String accelerator = "kvm";
/** The rtc base. */
public String rtcBase = "utc"; public String rtcBase = "utc";
/** The rtc clock. */
public String rtcClock = "rt"; public String rtcClock = "rt";
/** The powerdown timeout. */
public int powerdownTimeout = 900; public int powerdownTimeout = 900;
/** The network. */
public Network[] network = { new Network() }; public Network[] network = { new Network() };
/** The drives. */
public Drive[] drives = new Drive[0]; public Drive[] drives = new Drive[0];
public Spice spice;
/** The display. */
public Display display;
/** /**
* Convert value from JSON parser. * Convert value from JSON parser.
@ -158,10 +218,20 @@ class Configuration implements Dto {
* Subsection "network". * Subsection "network".
*/ */
public static class Network implements Dto { public static class Network implements Dto {
/** The type. */
public String type = "tap"; public String type = "tap";
/** The bridge. */
public String bridge; public String bridge;
/** The device. */
public String device = "virtio-net"; public String device = "virtio-net";
/** The mac. */
public String mac; public String mac;
/** The net. */
public String net; public String net;
} }
@ -169,18 +239,42 @@ class Configuration implements Dto {
* Subsection "drive". * Subsection "drive".
*/ */
public static class Drive implements Dto { public static class Drive implements Dto {
/** The type. */
public String type; public String type;
/** The bootindex. */
public Integer bootindex; public Integer bootindex;
/** The device. */
public String device; public String device;
/** The file. */
public String file; public String file;
/** The resource. */
public String resource; public String resource;
} }
/**
* The Class Display.
*/
public static class Display implements Dto {
public Spice spice;
}
/** /**
* Subsection "spice". * Subsection "spice".
*/ */
public static class Spice implements Dto { public static class Spice implements Dto {
/** The port. */
public int port = 5900; public int port = 5900;
/** The streaming video. */
public String streamingVideo;
/** The usb redirects. */
public int usbRedirects = 2; public int usbRedirects = 2;
} }

View file

@ -179,9 +179,13 @@
</#switch> </#switch>
</#list> </#list>
<#if vm.display??>
<#if vm.display.spice??>
<#assign spice = vm.display.spice/>
# SPICE (display, channels ...) # SPICE (display, channels ...)
# https://www.linux-kvm.org/page/SPICE # https://www.linux-kvm.org/page/SPICE
- [ "-spice", "port=${ vm.spice.port?c },disable-ticketing=on\ - [ "-spice", "port=${ spice.port?c },disable-ticketing=on\
<#if spice.streamingVideo??>,streaming-video=${ spice.streamingVideo }</#if>\
,seamless-migration=on" ] ,seamless-migration=on" ]
- [ "-chardev", "spicevmc,id=vdagentdev,name=vdagent" ] - [ "-chardev", "spicevmc,id=vdagentdev,name=vdagent" ]
- [ "-device", "virtserialport,name=com.redhat.spice.0,\ - [ "-device", "virtserialport,name=com.redhat.spice.0,\
@ -190,7 +194,9 @@
- [ "-audiodev", "driver=spice,id=audio1" ] - [ "-audiodev", "driver=spice,id=audio1" ]
- [ "-device", "hda-duplex,audiodev=audio1" ] - [ "-device", "hda-duplex,audiodev=audio1" ]
# * USB redirection # * USB redirection
<#list 0..<vm.spice.usbRedirects as index> <#list 0..<spice.usbRedirects as index>
- [ "-chardev", "spicevmc,id=charredir${ index },name=usbredir" ] - [ "-chardev", "spicevmc,id=charredir${ index },name=usbredir" ]
- [ "-device", "usb-redir,id=redir${ index },chardev=charredir${ index }" ] - [ "-device", "usb-redir,id=redir${ index },chardev=charredir${ index }" ]
</#list> </#list>
</#if>
</#if>