summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/libvirt/domain/device/HostdevPci.java
blob: 3b26fb017e2a4fae242e521565437e3c1ea22fe0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package org.openslx.libvirt.domain.device;

import org.openslx.libvirt.xml.LibvirtXmlNode;

/**
 * A hostdev PCI device node in a Libvirt domain XML document for PCI passthrough.
 * 
 * @author Manuel Bentele
 * @version 1.0
 */
public class HostdevPci extends Hostdev
{
	/**
	 * Creates an empty hostdev PCI device.
	 */
	public HostdevPci()
	{
		super();
	}

	/**
	 * Creates a hostdev PCI device representing an existing Libvirt XML hostdev PCI device element.
	 * 
	 * @param xmlNode existing Libvirt XML hostdev PCI device element.
	 */
	public HostdevPci( LibvirtXmlNode xmlNode )
	{
		super( xmlNode );
	}

	/**
	 * Checks if PCI hostdev device is managed.
	 * 
	 * If {@link #isManaged()} returns <code>true</code> the hostdev PCI device is detached from the
	 * host before being passed on to the guest and reattached to the host after the guest exits.
	 * 
	 * @return state whether PCI hostdev device is managed.
	 */
	public boolean isManaged()
	{
		return this.getXmlElementAttributeValueAsBool( "managed" );
	}

	/**
	 * Sets state whether PCI hostdev device is managed.
	 * 
	 * If the <code>managed</code> parameter is set to <code>true</code> the PCI hostdev device is
	 * detached from the host before being passed on to the guest and reattached to the host after
	 * the guest exits.
	 * 
	 * @return state whether PCI hostdev device is managed.
	 */
	public void setManaged( boolean managed )
	{
		this.setXmlElementAttributeValue( "managed", managed );
	}

	/**
	 * Creates a non-existent hostdev PCI device as Libvirt XML device element.
	 * 
	 * @param xmlNode Libvirt XML node of the Libvirt XML device that is created.
	 * @return created hostdev PCI device instance.
	 */
	public static HostdevPci createInstance( LibvirtXmlNode xmlNode )
	{
		return HostdevPci.newInstance( xmlNode );
	}

	/**
	 * Creates a hostdev PCI device representing an existing Libvirt XML hostdev PCI device element.
	 * 
	 * @param xmlNode existing Libvirt XML hostdev PCI device element.
	 * @return hostdev PCI device instance.
	 */
	public static HostdevPci newInstance( LibvirtXmlNode xmlNode )
	{
		return new HostdevPci( xmlNode );
	}
}