diff options
author | Simon Rettberg | 2023-06-26 12:19:05 +0200 |
---|---|---|
committer | Simon Rettberg | 2023-06-26 12:19:05 +0200 |
commit | 41126d5da4a87320407885cf2a5eedc1c828dfaa (patch) | |
tree | b8e041a9c1985510b98447185555081215e925e0 /src/main/java/org/openslx/libvirt/domain/device/HostdevPci.java | |
parent | [thrift] Ignore yet another socket exception (diff) | |
download | master-sync-shared-41126d5da4a87320407885cf2a5eedc1c828dfaa.tar.gz master-sync-shared-41126d5da4a87320407885cf2a5eedc1c828dfaa.tar.xz master-sync-shared-41126d5da4a87320407885cf2a5eedc1c828dfaa.zip |
[libvirt] Allow setting PCI address on Device level
Devices like video and disk can be PCI Devices and thus have an
<address> tag that defines where on the PCI bus it sits. Move the
according helper functions for getting/setting this address from
HostDevPci up to Device.
Diffstat (limited to 'src/main/java/org/openslx/libvirt/domain/device/HostdevPci.java')
-rw-r--r-- | src/main/java/org/openslx/libvirt/domain/device/HostdevPci.java | 59 |
1 files changed, 8 insertions, 51 deletions
diff --git a/src/main/java/org/openslx/libvirt/domain/device/HostdevPci.java b/src/main/java/org/openslx/libvirt/domain/device/HostdevPci.java index d2be2d6..1351f26 100644 --- a/src/main/java/org/openslx/libvirt/domain/device/HostdevPci.java +++ b/src/main/java/org/openslx/libvirt/domain/device/HostdevPci.java @@ -8,8 +8,7 @@ import org.openslx.libvirt.xml.LibvirtXmlNode; * @author Manuel Bentele * @version 1.0 */ -public class HostdevPci extends Hostdev implements HostdevAddressableSource<HostdevPciDeviceAddress>, - HostdevAddressableTarget<HostdevPciDeviceAddress> +public class HostdevPci extends Hostdev implements HostdevAddressableSource<HostdevPciDeviceAddress> { /** * Creates an empty hostdev PCI device. @@ -29,46 +28,6 @@ public class HostdevPci extends Hostdev implements HostdevAddressableSource<Host super( xmlNode ); } - /** - * Returns the PCI device address from an address XML element selected by a XPath expression. - * - * @param expression XPath expression to select the XML address element. - * @return PCI device address from the selected XML address element. - */ - private HostdevPciDeviceAddress getPciAddress( final String expression ) - { - String pciDomain = this.getXmlElementAttributeValue( expression, "domain" ); - String pciBus = this.getXmlElementAttributeValue( expression, "bus" ); - String pciDevice = this.getXmlElementAttributeValue( expression, "slot" ); - String pciFunction = this.getXmlElementAttributeValue( expression, "function" ); - - pciDomain = HostdevUtils.removeHexPrefix( pciDomain ); - pciBus = HostdevUtils.removeHexPrefix( pciBus ); - pciDevice = HostdevUtils.removeHexPrefix( pciDevice ); - pciFunction = HostdevUtils.removeHexPrefix( pciFunction ); - - return HostdevPciDeviceAddress.valueOf( pciDomain + ":" + pciBus + ":" + pciDevice + "." + pciFunction ); - } - - /** - * Sets the PCI device address for an XML address element selected by a XPath expression. - * - * @param expression XPath expression to select the XML address element. - * @param address PCI device address for the selected XML address element. - */ - private void setPciAddress( final String expression, final HostdevPciDeviceAddress address ) - { - final String pciDomain = HostdevUtils.appendHexPrefix( address.getPciDomainAsString() ); - final String pciBus = HostdevUtils.appendHexPrefix( address.getPciBusAsString() ); - final String pciDevice = HostdevUtils.appendHexPrefix( address.getPciDeviceAsString() ); - final String pciFunction = HostdevUtils.appendHexPrefix( address.getPciFunctionAsString() ); - - this.setXmlElementAttributeValue( expression, "domain", pciDomain ); - this.setXmlElementAttributeValue( expression, "bus", pciBus ); - this.setXmlElementAttributeValue( expression, "slot", pciDevice ); - this.setXmlElementAttributeValue( expression, "function", pciFunction ); - } - @Override public HostdevPciDeviceAddress getSource() { @@ -81,16 +40,14 @@ public class HostdevPci extends Hostdev implements HostdevAddressableSource<Host this.setPciAddress( "source/address", address ); } - @Override - public HostdevPciDeviceAddress getTarget() - { - return this.getPciAddress( "address" ); - } - - @Override - public void setTarget( HostdevPciDeviceAddress address ) + /** + * Set multifunction mode. + * + * If enabled, the device is said to have multiple functions. + */ + public void setMultifunction( boolean on ) { - this.setPciAddress( "address", address ); + this.setXmlElementAttributeValueOnOff( "address", "multifunction", on ); } /** |