From 488e6fafdc5acf4bbcc693d324b6fc36cd2c419f Mon Sep 17 00:00:00 2001 From: "Michael N. Lipp" Date: Sun, 18 Jun 2023 23:04:57 +0200 Subject: [PATCH] Support more display/spice options. --- .../config-sample.yaml | 8 +- .../helm-test/templates/etcConfig.yaml | 12 ++- .../vmoperator/runner/qemu/Configuration.java | 96 ++++++++++++++++++- .../templates/Standard-VM-latest.ftl.yaml | 10 +- 4 files changed, 115 insertions(+), 11 deletions(-) diff --git a/org.jdrupes.vmoperator.runner.qemu/config-sample.yaml b/org.jdrupes.vmoperator.runner.qemu/config-sample.yaml index 8ecddf3..63152bf 100644 --- a/org.jdrupes.vmoperator.runner.qemu/config-sample.yaml +++ b/org.jdrupes.vmoperator.runner.qemu/config-sample.yaml @@ -92,7 +92,7 @@ # "bootindex": (undefined) # "resource": (undefined) - # "spice": - # "port": 5900 - # "usbRedirects": 2 - \ No newline at end of file + # "display": + # "spice": + # "port": 5900 + # "usbRedirects": 2 diff --git a/org.jdrupes.vmoperator.runner.qemu/helm-test/templates/etcConfig.yaml b/org.jdrupes.vmoperator.runner.qemu/helm-test/templates/etcConfig.yaml index 6759d92..94be1d6 100644 --- a/org.jdrupes.vmoperator.runner.qemu/helm-test/templates/etcConfig.yaml +++ b/org.jdrupes.vmoperator.runner.qemu/helm-test/templates/etcConfig.yaml @@ -113,10 +113,14 @@ data: - "type": "raw" "device": "/dev/disk-{{ $index }}" {{- end }} - - "spice": - "port": {{ .Values.vm.spicePort }} - # "usbRedirects": 2 + + "display": + "spice": + "port": {{ .Values.vm.spicePort }} + {{- if hasKey .Values.vm "streamingVideo" }} + "streamingVideo": "{{ .Values.vm.streamingVideo }}" + {{- end }} + # "usbRedirects": 2 logging.properties: | handlers=java.util.logging.ConsoleHandler diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Configuration.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Configuration.java index 7c75f10..dd7dd0f 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Configuration.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Configuration.java @@ -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; } diff --git a/org.jdrupes.vmoperator.runner.qemu/templates/Standard-VM-latest.ftl.yaml b/org.jdrupes.vmoperator.runner.qemu/templates/Standard-VM-latest.ftl.yaml index 9ddc4a8..822eb83 100644 --- a/org.jdrupes.vmoperator.runner.qemu/templates/Standard-VM-latest.ftl.yaml +++ b/org.jdrupes.vmoperator.runner.qemu/templates/Standard-VM-latest.ftl.yaml @@ -179,9 +179,13 @@ + <#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 }\ ,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.. + <#list 0.. - [ "-chardev", "spicevmc,id=charredir${ index },name=usbredir" ] - [ "-device", "usb-redir,id=redir${ index },chardev=charredir${ index }" ] + +