summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2025-03-17 10:52:29 +0100
committerSimon Rettberg2025-03-17 10:52:29 +0100
commit01cff6b45d968035fa41dee63fc901e5436253c2 (patch)
treefac6b9711251e9fab996598f22acd57b606dcd99
parent[qemu] Remove os loader tag if firmware=efi (diff)
downloadmltk-01cff6b45d968035fa41dee63fc901e5436253c2.tar.gz
mltk-01cff6b45d968035fa41dee63fc901e5436253c2.tar.xz
mltk-01cff6b45d968035fa41dee63fc901e5436253c2.zip
[qemu] vgamem needs to be power of two
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/Util.java20
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuGraphics.java17
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuPciPassthrough.java18
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuGraphicsTest.java2
4 files changed, 38 insertions, 19 deletions
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/Util.java b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/Util.java
new file mode 100644
index 00000000..b328f17a
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/Util.java
@@ -0,0 +1,20 @@
+package org.openslx.runvirt.plugin.qemu;
+
+public class Util
+{
+
+ /**
+ * Round up to nearest power of two
+ */
+ public static long roundToNearestPowerOf2( long value )
+ {
+ long k = 1;
+
+ while ( k < value ) {
+ k *= 2;
+ }
+
+ return k;
+ }
+
+}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuGraphics.java b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuGraphics.java
index 682a0fe8..802e0754 100644
--- a/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuGraphics.java
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuGraphics.java
@@ -10,6 +10,7 @@ import org.openslx.libvirt.domain.device.GraphicsSpice.StreamingMode;
import org.openslx.libvirt.domain.device.GraphicsVnc;
import org.openslx.libvirt.domain.device.Video;
import org.openslx.libvirt.domain.device.Video.Model;
+import org.openslx.runvirt.plugin.qemu.Util;
import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
import org.openslx.runvirt.plugin.qemu.virtualization.LibvirtHypervisorQemu;
import org.openslx.virtualization.configuration.transformation.TransformationException;
@@ -25,8 +26,8 @@ public class TransformationSpecificQemuGraphics
extends TransformationSpecific<Domain, CommandLineArgs, LibvirtHypervisorQemu>
{
+ // TODO: Configurable, calculate in run-virt, maybe support multiple heads
public static final int MIN_VGA_MEM = 48 * 1024;
- public static final int MIN_RAM = 16 * 1024;
/**
* Name of the configuration transformation.
@@ -91,10 +92,18 @@ public class TransformationSpecificQemuGraphics
if ( dev.getModel() == Model.QXL || dev.getVgaMem() > 0 ) {
// See https://lists.gnu.org/archive/html/qemu-devel/2012-06/msg01898.html
if ( dev.getVgaMem() < MIN_VGA_MEM ) {
- dev.setVgaMem( MIN_VGA_MEM );
+ dev.setVgaMem( Util.roundToNearestPowerOf2( MIN_VGA_MEM ) );
}
- if ( dev.getRam() < dev.getVgaMem() + MIN_RAM ) {
- dev.setRam( dev.getVgaMem() + MIN_RAM );
+ // * 4 is recommended on newer linux (KMS) according to https://www.ovirt.org/develop/internal/video-ram.html
+ if ( dev.getRam() < dev.getVgaMem() * 4 ) {
+ dev.setRam( Util.roundToNearestPowerOf2( dev.getVgaMem() * 4 ) );
+ }
+ // Windows can't really make good use of it. 2025-03-17, re-check every now and then...
+ String os = config.getLibOsInfoOsId();
+ if ( os != null && os.contains( "microsoft.com/" ) ) {
+ dev.setVRam( 8192 );
+ } else {
+ dev.setVRam( Util.roundToNearestPowerOf2( dev.getVgaMem() * 2 ) );
}
}
}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuPciPassthrough.java b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuPciPassthrough.java
index 3f67bed5..97bb17f2 100644
--- a/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuPciPassthrough.java
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuPciPassthrough.java
@@ -14,6 +14,7 @@ import org.openslx.libvirt.domain.device.HostdevPciDeviceAddress;
import org.openslx.libvirt.domain.device.HostdevPciDeviceDescription;
import org.openslx.libvirt.domain.device.Shmem;
import org.openslx.libvirt.domain.device.Video;
+import org.openslx.runvirt.plugin.qemu.Util;
import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
import org.openslx.runvirt.plugin.qemu.virtualization.LibvirtHypervisorQemu;
import org.openslx.runvirt.virtualization.LibvirtHypervisorException;
@@ -167,29 +168,18 @@ public class TransformationSpecificQemuPciPassthrough
return capabilities;
}
- private static BigInteger roundToNearestPowerOf2( BigInteger value )
- {
- BigInteger k = BigInteger.valueOf( 1 );
-
- while ( k.compareTo( value ) == -1 ) {
- k = k.multiply( BigInteger.valueOf( 2 ) );
- }
-
- return k;
- }
-
/**
* Calculates the framebuffer memory size for the Looking Glass shared memory device.
*
* @return framebuffer memory size in bytes for the Looking Glass shared memory device.
*/
- private static BigInteger calculateFramebufferSize()
+ private static long calculateFramebufferSize()
{
final long totalBytesFramebuffer = MAX_DISPLAY_WIDTH * MAX_DISPLAY_HEIGHT * 4 * 2;
final long totalBytesReserved = RESERVED_MEMORY_FRAMEBUFFER * 1048576;
// round sum of total memory in bytes to nearest power of two
- return roundToNearestPowerOf2( BigInteger.valueOf( totalBytesFramebuffer + totalBytesReserved ) );
+ return Util.roundToNearestPowerOf2( totalBytesFramebuffer + totalBytesReserved );
}
@Override
@@ -243,7 +233,7 @@ public class TransformationSpecificQemuPciPassthrough
final Shmem shmemDevice = config.addShmemDevice();
shmemDevice.setName( "looking-glass" );
shmemDevice.setModel( Shmem.Model.IVSHMEM_PLAIN );
- shmemDevice.setSize( TransformationSpecificQemuPciPassthrough.calculateFramebufferSize() );
+ shmemDevice.setSize( BigInteger.valueOf( TransformationSpecificQemuPciPassthrough.calculateFramebufferSize() ) );
// disable all software video devices if device passthrough debug mode is not enabled
if ( !args.isDebugDevicePassthroughEnabled() ) {
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuGraphicsTest.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuGraphicsTest.java
index 0347bb75..369641be 100644
--- a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuGraphicsTest.java
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuGraphicsTest.java
@@ -63,7 +63,7 @@ public class TransformationSpecificQemuGraphicsTest
for ( Video dev : config.getVideoDevices() ) {
if ( dev.getModel() == Model.QXL ) {
assertTrue( dev.getVgaMem() >= TransformationSpecificQemuGraphics.MIN_VGA_MEM );
- assertTrue( dev.getRam() >= dev.getVgaMem() + TransformationSpecificQemuGraphics.MIN_RAM );
+ assertTrue( dev.getRam() >= dev.getVgaMem() * 4 );
}
}