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)
# "resource": (undefined)
# "display":
# "spice":
# "port": 5900
# "usbRedirects": 2

View file

@ -114,8 +114,12 @@ data:
"device": "/dev/disk-{{ $index }}"
{{- end }}
"display":
"spice":
"port": {{ .Values.vm.spicePort }}
{{- if hasKey .Values.vm "streamingVideo" }}
"streamingVideo": "{{ .Values.vm.streamingVideo }}"
{{- end }}
# "usbRedirects": 2
logging.properties: |

View file

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

View file

@ -179,9 +179,13 @@
</#switch>
</#list>
<#if vm.display??>
<#if vm.display.spice??>
<#assign spice = vm.display.spice/>
# SPICE (display, channels ...)
# 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" ]
- [ "-chardev", "spicevmc,id=vdagentdev,name=vdagent" ]
- [ "-device", "virtserialport,name=com.redhat.spice.0,\
@ -190,7 +194,9 @@
- [ "-audiodev", "driver=spice,id=audio1" ]
- [ "-device", "hda-duplex,audiodev=audio1" ]
# * USB redirection
<#list 0..<vm.spice.usbRedirects as index>
<#list 0..<spice.usbRedirects as index>
- [ "-chardev", "spicevmc,id=charredir${ index },name=usbredir" ]
- [ "-device", "usb-redir,id=redir${ index },chardev=charredir${ index }" ]
</#list>
</#if>
</#if>