commit 25c2bd67b6731c5f568f8338cef854cb090aa001 Author: W. David Ashley w.david.ashley@gmail.com Date: Sun Jul 5 18:07:21 2015 -0500
Domains Chapter Memory / CPU resources - added complete content - added examples 27-30
en-US/Guest_Domains.xml | 46 ++++++++++++++++++++++++++++------ en-US/extras/Domains-Example-27.xml | 5 ++++ en-US/extras/Domains-Example-28.xml | 7 +++++ en-US/extras/Domains-Example-29.py | 21 ++++++++++++++++ en-US/extras/Domains-Example-30.py | 21 ++++++++++++++++ 5 files changed, 92 insertions(+), 8 deletions(-) --- diff --git a/en-US/Guest_Domains.xml b/en-US/Guest_Domains.xml index ce78e1e..8464d53 100644 --- a/en-US/Guest_Domains.xml +++ b/en-US/Guest_Domains.xml @@ -760,15 +760,45 @@
</section>
- <section id="libvirt_application_development_guide_using_python-Guest_Domains-Domain_Config-Memory_CPU"> - <title>Memory / CPU resources</title> + <section id="libvirt_application_development_guide_using_python-Guest_Domains-Domain_Config-Memory_CPU"> + <title>Memory / CPU resources</title>
- <para> - TBD. Maps to the basic resources section. - - </para> - - </section> + <para> + CPU and memory resources can be set at the time the domain is created or dynamically + while the domain is either active or inactive. + </para> + <para> + CPU resources are set at domain creation using tags in the XML definition of the domain. + The hypervisor defines a limit on the number of virtual CPUs that may not be exceeded + either at domain creation or at a later time. This maximum can be dependent on a number of + resource and hypervisor limits. An example of the CPU XML specification follows. + </para> + <programlisting language="XML"><xi:include href="extras/Domains-Example-27.xml" parse="text" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting> + <para> + Memory resources are also set at domain creation using tags in the XML definition of the domain. + Both the maximum and the current allocation of memory to the domain should be set. + An example of the Memory XML specification follows. + </para> + <programlisting language="XML"><xi:include href="extras/Domains-Example-28.xml" parse="text" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting> + <para> + After the domain has been created the number of virtual CPUs can be increased via the + <literal>setVcpus</literal> or the <literal>setVcpusFlags</literal> methods. The + number CPUs may not exceed the hypervisor maximum discussed above. + </para> + <example> + <title>Set the number of maximum virtual cpus for a domain</title> + <programlisting language="Python"><xi:include href="extras/Domains-Example-29.py" parse="text" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting> + </example> + <para> + Also after the domain has been created the amount of memory can be changes via the + <literal>setMemory</literal> or the <literal>setMemoryFlags</literal> methods. The + amount of memory should be expressed in kilobytes. + </para> + <example> + <title>Set the amount of memory for a domain</title> + <programlisting language="Python"><xi:include href="extras/Domains-Example-30.py" parse="text" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting> + </example> + </section>
<section id="libvirt_application_development_guide_using_python-Guest_Domains-Domain_Config-Lifecycle"> <title>Lifecycle controls</title> diff --git a/en-US/extras/Domains-Example-27.xml b/en-US/extras/Domains-Example-27.xml new file mode 100644 index 0000000..3e617d9 --- /dev/null +++ b/en-US/extras/Domains-Example-27.xml @@ -0,0 +1,5 @@ +<domain> + ... + <vcpu placement='static' cpuset="1-4,^3,6" current="1">2</vcpu> + ... +</domain> diff --git a/en-US/extras/Domains-Example-28.xml b/en-US/extras/Domains-Example-28.xml new file mode 100644 index 0000000..0af025c --- /dev/null +++ b/en-US/extras/Domains-Example-28.xml @@ -0,0 +1,7 @@ +<domain> + ... + <maxMemory slots='16' unit='KiB'>1524288</maxMemory> + <memory unit='KiB'>524288</memory> + <currentMemory unit='KiB'>524288</currentMemory> + ... +</domain> diff --git a/en-US/extras/Domains-Example-29.py b/en-US/extras/Domains-Example-29.py new file mode 100644 index 0000000..51e19d1 --- /dev/null +++ b/en-US/extras/Domains-Example-29.py @@ -0,0 +1,21 @@ +# Example-29.py +from __future__ import print_function +import sys +import libvirt + +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(6) +if dom == None: + print('Failed to find the domain '+domName, file=sys.stderr) + exit(1) + +dom.setVcpus(2) + +conn.close() +exit(0) diff --git a/en-US/extras/Domains-Example-30.py b/en-US/extras/Domains-Example-30.py new file mode 100644 index 0000000..0af77cd --- /dev/null +++ b/en-US/extras/Domains-Example-30.py @@ -0,0 +1,21 @@ +# Example-29.py +from __future__ import print_function +import sys +import libvirt + +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(6) +if dom == None: + print('Failed to find the domain '+domName, file=sys.stderr) + exit(1) + +dom.setMemory(4096) # 4 GigaBytes + +conn.close() +exit(0)
docs-commits@lists.fedoraproject.org