diff --git a/org.jdrupes.vmoperator.runner.qemu/config-sample.yaml b/org.jdrupes.vmoperator.runner.qemu/config-sample.yaml index 7b9bf2b..54d8ee8 100644 --- a/org.jdrupes.vmoperator.runner.qemu/config-sample.yaml +++ b/org.jdrupes.vmoperator.runner.qemu/config-sample.yaml @@ -46,4 +46,17 @@ # "maximumRam": "512M" # "currentRam": "512M" + # CPU settings + # "cpuModel": "host" + # Setting maximumCpus to 1 omits the "-smp" options. The defaults (0) + # cause the corresponding property to be omitted from the "-smp" option. + # If currentCpus is greater than maximumCpus, the latter is adjusted. + # "maximumCpus": 1 + # "currentCpus": 1 + # "cpuSockets": 0 + # "diesPerSocket": 0 + # "coresPerSocket": 0 + # "threadsPerCore": 0 + # "accelertor": "kvm" + \ No newline at end of file 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 9ff7ed8..1d9002c 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 @@ -61,6 +61,14 @@ class Configuration implements Dto { public String bootMode = "uefi"; public String maximumRam; public String currentRam; + public String cpuModel = "host"; + public int maximumCpus = 1; + public int currentCpus = 1; + public int cpuSockets; + public int diesPerSocket; + public int coresPerDie; + public int threadsPerCore; + public String accelerator = "kvm"; } /** @@ -80,6 +88,11 @@ class Configuration implements Dto { return false; } + // Adjust max cpus if necessary + if (vm.currentCpus > vm.maximumCpus) { + vm.maximumCpus = vm.currentCpus; + } + return true; } 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 3ad8456..9e6fae5 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 @@ -52,7 +52,24 @@ # Provide RAM - [ "-object", "memory-backend-ram,id=pc.ram,\ size=${ vm.maximumRam!"512M" }" ] - + <#if vm.useTpm> + # Attach TPM + - [ "-chardev", "socket,id=chrtpm,path=${ runtimeDir }/swtpm-sock" ] + - [ "-tpmdev", "emulator,id=tpm0,chardev=chrtpm" ] + - [ "-device", "tpm-tis,tpmdev=tpm0" ] + + - [ "-cpu", "${ vm.cpuModel }" ] + <#if vm.maximumCpus gt 1> + - [ "-smp", "${ vm.currentCpus },maxcpus=${ vm.maximumCpus }\ + <#if vm.cpuSockets gt 0>,sockets=${ vm.cpuSockets }\ + <#if vm.diesPerSocket gt 0>,cores=${ vm.diesPerSocket }\ + <#if vm.coresPerDie gt 0>,cores=${ vm.coresPerDie }\ + <#if vm.threadsPerCore gt 0>,cores=${ vm.threadsPerCore }" ] + + <#if vm.accelerator != "none"> + - [ "-accel", "${ vm.accelerator }"] + + - [ "-chardev", "socket,id=charmonitor,path=${ runtimeDir }/monitor.sock,server=on,wait=off" ] - [ "-mon", "chardev=charmonitor,id=monitor,mode=control" ] # - [ "-spice", "port=5900,disable-ticketing=on" ]