From 7c146604159ee51902f4cf40ae46d158a286ec98 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 11 Mar 2025 14:22:57 +0100 Subject: [libvirt] Video: Add methods to adjust video memory --- .../org/openslx/libvirt/domain/device/Video.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/main') diff --git a/src/main/java/org/openslx/libvirt/domain/device/Video.java b/src/main/java/org/openslx/libvirt/domain/device/Video.java index a674715..3bb607f 100644 --- a/src/main/java/org/openslx/libvirt/domain/device/Video.java +++ b/src/main/java/org/openslx/libvirt/domain/device/Video.java @@ -1,6 +1,7 @@ package org.openslx.libvirt.domain.device; import org.openslx.libvirt.xml.LibvirtXmlNode; +import org.openslx.util.Util; /** * A video (GPU) device node in a Libvirt domain XML document. @@ -194,4 +195,39 @@ public class Video extends Device return null; } } + + /** + * Get size of VGA memory in KB, or 0 if unset/invalid. + */ + public int getVgaMem() + { + String mem = this.getXmlElementAttributeValue( "model", "vgamem" ); + return mem == null ? 0 : Util.parseInt( mem, 0 ); + } + + /** + * Set size of VGA memory, in KB + */ + public void setVgaMem( int kb ) + { + this.setXmlElementAttributeValue( "model", "vgamem", Integer.toString( kb ) ); + } + + /** + * Get total RAM of video card in KB, or 0 if unset/invalid. + */ + public int getRam() + { + String mem = this.getXmlElementAttributeValue( "model", "ram" ); + return mem == null ? 0 : Util.parseInt( mem, 0 ); + } + + /** + * Set size of video card RAM, in KB. + */ + public void setRam( int kb ) + { + this.setXmlElementAttributeValue( "model", "ram", Integer.toString( kb ) ); + } + } -- cgit v1.2.3-55-g7522