summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2024-10-23 16:26:09 +0200
committerSimon Rettberg2024-10-23 16:26:09 +0200
commit0919f8694d4b10dd37e80aacc5fad54b700017b8 (patch)
treeba4b23fb0a0b890f8ef361cc551127f8bfd8e6fa /src
parent[libvirt] Improve error reporting by not swallowing stack trace (diff)
downloadmaster-sync-shared-master.tar.gz
master-sync-shared-master.tar.xz
master-sync-shared-master.zip
[libvirt] source address in hostdev must not contain attribute "type"HEADmaster
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/openslx/libvirt/domain/device/Device.java10
-rw-r--r--src/main/java/org/openslx/libvirt/domain/device/HostdevPci.java2
-rw-r--r--src/main/java/org/openslx/libvirt/xml/LibvirtXmlNode.java4
3 files changed, 11 insertions, 5 deletions
diff --git a/src/main/java/org/openslx/libvirt/domain/device/Device.java b/src/main/java/org/openslx/libvirt/domain/device/Device.java
index e3adf90..d743522 100644
--- a/src/main/java/org/openslx/libvirt/domain/device/Device.java
+++ b/src/main/java/org/openslx/libvirt/domain/device/Device.java
@@ -192,7 +192,7 @@ public class Device extends LibvirtXmlNode implements HostdevAddressableTarget<H
* @param expression XPath expression to select the XML address element.
* @param address PCI device address for the selected XML address element.
*/
- protected void setPciAddress( final String expression, final HostdevPciDeviceAddress address )
+ protected void setPciAddress( final String expression, final HostdevPciDeviceAddress address, boolean includeType )
{
final String pciDomain = HostdevUtils.appendHexPrefix( address.getPciDomainAsString() );
final String pciBus = HostdevUtils.appendHexPrefix( address.getPciBusAsString() );
@@ -203,7 +203,11 @@ public class Device extends LibvirtXmlNode implements HostdevAddressableTarget<H
this.setXmlElementAttributeValue( expression, "bus", pciBus );
this.setXmlElementAttributeValue( expression, "slot", pciDevice );
this.setXmlElementAttributeValue( expression, "function", pciFunction );
- this.setXmlElementAttributeValue( expression, "type", BusType.PCI.toString() );
+ if ( includeType ) {
+ this.setXmlElementAttributeValue( expression, "type", BusType.PCI.toString() );
+ } else {
+ this.removeXmlElementAttribute( expression, "type" );
+ }
}
/**
@@ -240,7 +244,7 @@ public class Device extends LibvirtXmlNode implements HostdevAddressableTarget<H
public void setPciTarget( HostdevPciDeviceAddress address )
{
- this.setPciAddress( "address", address );
+ this.setPciAddress( "address", address, true );
}
/**
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 1351f26..8197df2 100644
--- a/src/main/java/org/openslx/libvirt/domain/device/HostdevPci.java
+++ b/src/main/java/org/openslx/libvirt/domain/device/HostdevPci.java
@@ -37,7 +37,7 @@ public class HostdevPci extends Hostdev implements HostdevAddressableSource<Host
@Override
public void setSource( HostdevPciDeviceAddress address )
{
- this.setPciAddress( "source/address", address );
+ this.setPciAddress( "source/address", address, false );
}
/**
diff --git a/src/main/java/org/openslx/libvirt/xml/LibvirtXmlNode.java b/src/main/java/org/openslx/libvirt/xml/LibvirtXmlNode.java
index a941acb..7f3818f 100644
--- a/src/main/java/org/openslx/libvirt/xml/LibvirtXmlNode.java
+++ b/src/main/java/org/openslx/libvirt/xml/LibvirtXmlNode.java
@@ -319,7 +319,9 @@ public class LibvirtXmlNode implements LibvirtXmlCreatable, LibvirtXmlEditable
if ( node != null ) {
Node attribute = node.getAttributes().getNamedItem( attributeName );
- node.getAttributes().removeNamedItem( attribute.getNodeName() );
+ if ( attribute != null ) {
+ node.getAttributes().removeNamedItem( attribute.getNodeName() );
+ }
}
}