diff options
author | ralph isenmann | 2021-11-10 15:06:33 +0100 |
---|---|---|
committer | ralph isenmann | 2021-11-10 15:06:33 +0100 |
commit | 4bff50ef7597453b94420b912b2859d06c00c060 (patch) | |
tree | 752c88e61eb3da3002826678d5c3301e983f357e /src/main/java/org/openslx/libvirt/domain/device | |
parent | [container] refactoring (diff) | |
parent | Enumerate target names of disk devices correctly (diff) | |
download | master-sync-shared-4bff50ef7597453b94420b912b2859d06c00c060.tar.gz master-sync-shared-4bff50ef7597453b94420b912b2859d06c00c060.tar.xz master-sync-shared-4bff50ef7597453b94420b912b2859d06c00c060.zip |
Merge branch 'master' of git.openslx.org:bwlp/master-sync-shared
Diffstat (limited to 'src/main/java/org/openslx/libvirt/domain/device')
4 files changed, 102 insertions, 7 deletions
diff --git a/src/main/java/org/openslx/libvirt/domain/device/Graphics.java b/src/main/java/org/openslx/libvirt/domain/device/Graphics.java index d10eb3f..3fd2f81 100644 --- a/src/main/java/org/openslx/libvirt/domain/device/Graphics.java +++ b/src/main/java/org/openslx/libvirt/domain/device/Graphics.java @@ -1,5 +1,8 @@ package org.openslx.libvirt.domain.device; +import java.net.InetAddress; +import java.net.UnknownHostException; + import org.openslx.libvirt.xml.LibvirtXmlNode; /** @@ -50,6 +53,66 @@ public class Graphics extends Device } /** + * Returns the listen address of the graphics device. + * + * @return listen address of the graphics device. + */ + public InetAddress getListenAddress() + { + InetAddress parsedListenAddress = null; + + if ( this.getListenType() == ListenType.ADDRESS ) { + // only read listen address, if address listen type is set + final String rawListenAddress = this.getXmlElementAttributeValue( "listen", "address" ); + + try { + parsedListenAddress = InetAddress.getByName( rawListenAddress ); + } catch ( UnknownHostException e ) { + parsedListenAddress = null; + } + } + + return parsedListenAddress; + } + + /** + * Sets the listen address for the graphics device. + * + * @param listenAddress listen address for the graphics device. + */ + public void setListenAddress( InetAddress listenAddress ) + { + if ( this.getListenType() == ListenType.ADDRESS && listenAddress != null ) { + // only set listen address, if address listen type is set + this.setXmlElementAttributeValue( "listen", "address", listenAddress.getHostAddress() ); + } + } + + /** + * Returns the listen port of the graphics device. + * + * @return listen port of the graphics device. + */ + public int getListenPort() + { + final String listenPort = this.getXmlElementAttributeValue( "port" ); + return Integer.valueOf( listenPort ); + } + + /** + * Sets the listen port for the graphics device. + * + * @param listenPort listen port for the graphics device. + */ + public void setListenPort( int listenPort ) + { + if ( this.getListenType() == ListenType.ADDRESS ) { + // only set listen port, if address listen type is set + this.setXmlElementAttributeValue( "port", Integer.toString( listenPort ) ); + } + } + + /** * Creates a non-existent graphics device as Libvirt XML device element. * * @param graphics graphics device that is created. diff --git a/src/main/java/org/openslx/libvirt/domain/device/GraphicsSpice.java b/src/main/java/org/openslx/libvirt/domain/device/GraphicsSpice.java index fbd115b..2c6068a 100644 --- a/src/main/java/org/openslx/libvirt/domain/device/GraphicsSpice.java +++ b/src/main/java/org/openslx/libvirt/domain/device/GraphicsSpice.java @@ -1,5 +1,7 @@ package org.openslx.libvirt.domain.device; +import java.net.InetAddress; + import org.openslx.libvirt.xml.LibvirtXmlNode; /** @@ -11,6 +13,16 @@ import org.openslx.libvirt.xml.LibvirtXmlNode; public class GraphicsSpice extends Graphics { /** + * Default address of a SPICE graphics listener. + */ + public static final InetAddress DEFAULT_ADDRESS = InetAddress.getLoopbackAddress(); + + /** + * Default port of a SPICE graphics listener. + */ + public static final int DEFAULT_PORT = 5900; + + /** * Creates an empty graphics SPICE device. */ public GraphicsSpice() diff --git a/src/main/java/org/openslx/libvirt/domain/device/Hostdev.java b/src/main/java/org/openslx/libvirt/domain/device/Hostdev.java index 11e74c3..dc9cf5e 100644 --- a/src/main/java/org/openslx/libvirt/domain/device/Hostdev.java +++ b/src/main/java/org/openslx/libvirt/domain/device/Hostdev.java @@ -78,7 +78,7 @@ public class Hostdev extends Device if ( hostdev instanceof HostdevMdev ) { xmlNode.setXmlElementAttributeValue( "type", Type.MDEV.toString() ); - addedHostdev = HostdevPci.createInstance( xmlNode ); + addedHostdev = HostdevMdev.createInstance( xmlNode ); } else if ( hostdev instanceof HostdevPci ) { xmlNode.setXmlElementAttributeValue( "type", Type.PCI.toString() ); addedHostdev = HostdevPci.createInstance( xmlNode ); diff --git a/src/main/java/org/openslx/libvirt/domain/device/HostdevMdev.java b/src/main/java/org/openslx/libvirt/domain/device/HostdevMdev.java index d25a6eb..082ea5b 100644 --- a/src/main/java/org/openslx/libvirt/domain/device/HostdevMdev.java +++ b/src/main/java/org/openslx/libvirt/domain/device/HostdevMdev.java @@ -50,6 +50,26 @@ public class HostdevMdev extends Hostdev implements HostdevAddressableSource<Hos } /** + * Checks whether the hostdev mediated device memory framebuffer is on or off. + * + * @return state whether the hostdev mediated device memory framebuffer is on or off. + */ + public boolean isMemoryFramebufferOn() + { + return this.getXmlElementAttributeValueAsBool( "ramfb" ); + } + + /** + * Sets the state of the hostdev mediated device memory framebuffer. + * + * @param on state whether the hostdev mediated device memory framebuffer is on or off. + */ + public void setMemoryFramebufferOn( boolean on ) + { + this.setXmlElementAttributeValueOnOff( "ramfb", on ); + } + + /** * Returns the hostdev mediated device model. * * @return hostdev mediated device model. @@ -80,7 +100,7 @@ public class HostdevMdev extends Hostdev implements HostdevAddressableSource<Hos @Override public void setSource( HostdevMdevDeviceAddress source ) { - this.setXmlElementAttributeValue( "source/address", "domain", source.getDeviceAddressAsString() ); + this.setXmlElementAttributeValue( "source/address", "uuid", source.getDeviceAddressAsString() ); } /** @@ -89,9 +109,9 @@ public class HostdevMdev extends Hostdev implements HostdevAddressableSource<Hos * @param xmlNode Libvirt XML node of the Libvirt XML device that is created. * @return created hostdev mediated device instance. */ - public static HostdevPci createInstance( LibvirtXmlNode xmlNode ) + public static HostdevMdev createInstance( LibvirtXmlNode xmlNode ) { - return HostdevPci.newInstance( xmlNode ); + return HostdevMdev.newInstance( xmlNode ); } /** @@ -101,9 +121,9 @@ public class HostdevMdev extends Hostdev implements HostdevAddressableSource<Hos * @param xmlNode existing Libvirt XML hostdev mediated device element. * @return hostdev mediated device instance. */ - public static HostdevPci newInstance( LibvirtXmlNode xmlNode ) + public static HostdevMdev newInstance( LibvirtXmlNode xmlNode ) { - return new HostdevPci( xmlNode ); + return new HostdevMdev( xmlNode ); } /** @@ -112,7 +132,7 @@ public class HostdevMdev extends Hostdev implements HostdevAddressableSource<Hos * @author Manuel Bentele * @version 1.0 */ - enum Model + public enum Model { // @formatter:off VFIO_PCI( "vfio-pci" ), |