commit bc552800e654d3d4a43b5adf99f8b4833ca43f5c Author: W. David Ashley w.david.ashley@gmail.com Date: Tue Jul 14 11:26:35 2015 -0500
Domain chapter Monitoring performance section - Added examples 36-40 - Added content for devices, disks, input, and other subsections
en-US/Guest_Domains.xml | 61 +++++++++++++++++++++++++++++++----- en-US/extras/Domains-Example-36.py | 27 ++++++++++++++++ en-US/extras/Domains-Example-37.py | 25 +++++++++++++++ en-US/extras/Domains-Example-38.py | 33 +++++++++++++++++++ en-US/extras/Domains-Example-39.py | 33 +++++++++++++++++++ en-US/extras/Domains-Example-40.py | 33 +++++++++++++++++++ 6 files changed, 204 insertions(+), 8 deletions(-) --- diff --git a/en-US/Guest_Domains.xml b/en-US/Guest_Domains.xml index 60ca737..8152f1d 100644 --- a/en-US/Guest_Domains.xml +++ b/en-US/Guest_Domains.xml @@ -908,7 +908,7 @@ <title>vCPU Performance</title>
<para> - To obtain the individual VCPU statistics: + To obtain the individual VCPU statistics use the <literal>getCPUStats</literal> method. </para> <example> <title>Get the individual CPU statistics</title> @@ -918,7 +918,7 @@ The <literal>getCPUStats</literal> takes one parameter, a boolean. When <literal>False</literal> is used the statistics are reported as an aggregate of all the CPUs. Then <literal>True</literal> is used then each CPU reports its individual statistics. Either way a <literal>list</literal> - is returned. The statistics are reported innanoseconds. If a host has four CPUs, there will be + is returned. The statistics are reported in nanoseconds. If a host has four CPUs, there will be four entries in the cpu_stats list. </para> <para> @@ -978,15 +978,29 @@ <title>Device configuration</title>
<para> - TBD + Configuration information for a guest domain can be obtained by using the <literal>XMLSesc</literal> + method. This method returns the current description of a domain as an XML data stream. + This stream can then be parsed to obtain detailed information about the doamin and all the + parts that make up the domain. + </para> + <para> + The following example shows how to obtain soma basic information about the domain. </para> + <example> + <title>Get basic domain information from the domain's XML description</title> + <programlisting language="Python"><xi:include href="extras/Domains-Example-36.py" parse="text" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting> + </example>
<section id="libvirt_application_development_guide_using_python-Guest_Domains-Device_Config-Emulator"> <title>Emulator</title>
<para> - TBD + To discover the guest domain's emulator find and display the content of the emulator XML tag. </para> + <example> + <title>Get domain's emulator information</title> + <programlisting language="Python"><xi:include href="extras/Domains-Example-37.py" parse="text" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting> + </example>
</section>
@@ -994,6 +1008,14 @@ <title>Disks</title>
<para> + To discover the guest domain's disk(s) find and display the content of the emulator XML tag(s). + </para> + <example> + <title>Get domain's disk information</title> + <programlisting language="Python"><xi:include href="extras/Domains-Example-39.py" parse="text" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting> + </example> + + <para> TBD </para>
@@ -1003,8 +1025,12 @@ <title>Networking</title>
<para> - TBD + To discover the guest domain's network interfaces find and display the iterface XML tag. </para> + <example> + <title>Get domain's network interface information</title> + <programlisting language="Python"><xi:include href="extras/Domains-Example-38.py" parse="text" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting> + </example>
</section>
@@ -1018,11 +1044,15 @@ </section>
<section id="libvirt_application_development_guide_using_python-Guest_Domains-Device_Config-Mice"> - <title>Mice & Tablets</title> + <title>Mice, Keyboard & Tablets</title>
<para> - TBD + To discover the guest domain's input devices find and display the input XML tags. </para> + <example> + <title>Get domain's input device information</title> + <programlisting language="Python"><xi:include href="extras/Domains-Example-40.py" parse="text" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting> + </example>
</section>
@@ -1030,7 +1060,22 @@ <title>USB Device Passthrough</title>
<para> - TBD + The USB device passthrough capability allows a physical USB device from + the host machine to be assigned directly to a guest machine. The guest + OS drivers can use the device hardware directly without relying on any + driver capabilities from the host OS. + </para> + <important> + USB devices are only inherited by the guest domain at boot time. USB + devices can not be inherited from the host after the guest domain has booted. + </important> + + <para> + Some caveats apply when using USB device passthrough. When a PCI device is + directly assigned to a guest, migration will not be possible, without + first hot-unplugging the device from the guest. In addition + libvirt does not guarantee that direct device assignment is secure, leaving + security policy decisions to the underlying virtualization technology. </para>
</section> diff --git a/en-US/extras/Domains-Example-36.py b/en-US/extras/Domains-Example-36.py new file mode 100644 index 0000000..a7d468e --- /dev/null +++ b/en-US/extras/Domains-Example-36.py @@ -0,0 +1,27 @@ +# Example-36.py +from __future__ import print_function +import sys +import libvirt +from xml.dom import minidom + +domName = 'Fedora22-x86_64-1' + +conn = libvirt.open('qemu:///system') +if conn == None: + print('Failed to open connection to qemu:///system', file=sys.stderr) + exit(1) + +dom = conn.lookupByID(5) +if dom == None: + print('Failed to find the domain '+domName, file=sys.stderr) + exit(1) + +raw_xml = dom.XMLDesc(0) +xml = minidom.parseString(raw_xml) +domainTypes = xml.getElementsByTagName('type') +for domainType in domainTypes: + print(domainType.getAttribute('machine')) + print(domainType.getAttribute('arch')) + +conn.close() +exit(0) diff --git a/en-US/extras/Domains-Example-37.py b/en-US/extras/Domains-Example-37.py new file mode 100644 index 0000000..019e3b1 --- /dev/null +++ b/en-US/extras/Domains-Example-37.py @@ -0,0 +1,25 @@ +# Example-37.py +from __future__ import print_function +import sys +import libvirt +from xml.dom import minidom + +domName = 'Fedora22-x86_64-1' + +conn = libvirt.open('qemu:///system') +if conn == None: + print('Failed to open connection to qemu:///system', file=sys.stderr) + exit(1) + +dom = conn.lookupByID(5) +if dom == None: + print('Failed to find the domain '+domName, file=sys.stderr) + exit(1) + +raw_xml = dom.XMLDesc(0) +xml = minidom.parseString(raw_xml) +domainEmulator = xml.getElementsByTagName('emulator') +print('emulator: '+domainEmulator[0].firstChild.data) + +conn.close() +exit(0) diff --git a/en-US/extras/Domains-Example-38.py b/en-US/extras/Domains-Example-38.py new file mode 100644 index 0000000..e0bccb9 --- /dev/null +++ b/en-US/extras/Domains-Example-38.py @@ -0,0 +1,33 @@ +# Example-38.py +from __future__ import print_function +import sys +import libvirt +from xml.dom import minidom + +domName = 'Fedora22-x86_64-1' + +conn = libvirt.open('qemu:///system') +if conn == None: + print('Failed to open connection to qemu:///system', file=sys.stderr) + exit(1) + +dom = conn.lookupByID(1) +if dom == None: + print('Failed to find the domain '+domName, file=sys.stderr) + exit(1) + +raw_xml = dom.XMLDesc(0) +xml = minidom.parseString(raw_xml) +interfaceTypes = xml.getElementsByTagName('interface') +for interfaceType in interfaceTypes: + print('interface: type='+interfaceType.getAttribute('type')) + interfaceNodes = interfaceType.childNodes + for interfaceNode in interfaceNodes: + if interfaceNode.nodeName[0:1] != '#': + print(' '+interfaceNode.nodeName) + for attr in interfaceNode.attributes.keys(): + print(' '+interfaceNode.attributes[attr].name+' = '+ + interfaceNode.attributes[attr].value) + +conn.close() +exit(0) diff --git a/en-US/extras/Domains-Example-39.py b/en-US/extras/Domains-Example-39.py new file mode 100644 index 0000000..8adfdcb --- /dev/null +++ b/en-US/extras/Domains-Example-39.py @@ -0,0 +1,33 @@ +# Example-39.py +from __future__ import print_function +import sys +import libvirt +from xml.dom import minidom + +domName = 'Fedora22-x86_64-1' + +conn = libvirt.open('qemu:///system') +if conn == None: + print('Failed to open connection to qemu:///system', file=sys.stderr) + exit(1) + +dom = conn.lookupByID(1) +if dom == None: + print('Failed to find the domain '+domName, file=sys.stderr) + exit(1) + +raw_xml = dom.XMLDesc(0) +xml = minidom.parseString(raw_xml) +diskTypes = xml.getElementsByTagName('disk') +for diskType in diskTypes: + print('disk: type='+diskType.getAttribute('type')+' device='+diskType.getAttribute('device')) + diskNodes = diskType.childNodes + for diskNode in diskNodes: + if diskNode.nodeName[0:1] != '#': + print(' '+diskNode.nodeName) + for attr in diskNode.attributes.keys(): + print(' '+diskNode.attributes[attr].name+' = '+ + diskNode.attributes[attr].value) + +conn.close() +exit(0) diff --git a/en-US/extras/Domains-Example-40.py b/en-US/extras/Domains-Example-40.py new file mode 100644 index 0000000..05764dc --- /dev/null +++ b/en-US/extras/Domains-Example-40.py @@ -0,0 +1,33 @@ +# Example-40.py +from __future__ import print_function +import sys +import libvirt +from xml.dom import minidom + +domName = 'Fedora22-x86_64-1' + +conn = libvirt.open('qemu:///system') +if conn == None: + print('Failed to open connection to qemu:///system', file=sys.stderr) + exit(1) + +dom = conn.lookupByID(1) +if dom == None: + print('Failed to find the domain '+domName, file=sys.stderr) + exit(1) + +raw_xml = dom.XMLDesc(0) +xml = minidom.parseString(raw_xml) +devicesTypes = xml.getElementsByTagName('input') +for inputType in devicesTypes: + print('input: type='+inputType.getAttribute('type')+' bus='+inputType.getAttribute('bus')) + inputNodes = inputType.childNodes + for inputNode in inputNodes: + if inputNode.nodeName[0:1] != '#': + print(' '+inputNode.nodeName) + for attr in inputNode.attributes.keys(): + print(' '+inputNode.attributes[attr].name+' = '+ + inputNode.attributes[attr].value) + +conn.close() +exit(0)
docs-commits@lists.fedoraproject.org