mirror of
https://github.com/libvirt/libvirt.git
synced 2026-08-08 04:05:05 -05:00
xml: allow scaled memory on input
Output is still in kibibytes, but input can now be in different scales for ease of typing. * src/conf/domain_conf.c (virDomainParseMemory): New helper. (virDomainDefParseXML): Use it when parsing. * docs/schemas/domaincommon.rng: Expand XML; rename memoryKBElement to memoryElement and update callers. * docs/formatdomain.html.in (elementsMemoryAllocation): Document scaling. * tests/qemuxml2argvdata/qemuxml2argv-memtune.xml: Adjust test. * tests/qemuxml2xmltest.c: Likewise. * tests/qemuxml2xmloutdata/qemuxml2xmlout-memtune.xml: New file.
This commit is contained in:
@@ -415,8 +415,8 @@
|
||||
<pre>
|
||||
<domain>
|
||||
...
|
||||
<memory>524288</memory>
|
||||
<currentMemory>524288</currentMemory>
|
||||
<memory unit='KiB'>524288</memory>
|
||||
<currentMemory unit='KiB'>524288</currentMemory>
|
||||
...
|
||||
</domain>
|
||||
</pre>
|
||||
@@ -424,12 +424,31 @@
|
||||
<dl>
|
||||
<dt><code>memory</code></dt>
|
||||
<dd>The maximum allocation of memory for the guest at boot time.
|
||||
The units for this value are kibibytes (i.e. blocks of 1024 bytes)</dd>
|
||||
The units for this value are determined by the optional
|
||||
atttribute <code>unit</code>, which defaults to "KiB"
|
||||
(kibibytes, 2<sup>10</sup> or blocks of 1024 bytes). Valid
|
||||
units are "b" or "bytes" for bytes, "KB" for kilobytes
|
||||
(10<sup>3</sup> or 1,000 bytes), "k" or "KiB" for kibibytes
|
||||
(1024 bytes), "MB" for megabytes (10<sup>6</sup> or 1,000,000
|
||||
bytes), "M" or "MiB" for mebibytes (2<sup>20</sup> or
|
||||
1,048,576 bytes), "GB" for gigabytes (10<sup>9</sup> or
|
||||
1,000,000,000 bytes), "G" or "GiB" for gibibytes
|
||||
(2<sup>30</sup> or 1,073,741,824 bytes), "TB" for terabytes
|
||||
(10<sup>12</sup> or 1,000,000,000,000 bytes), or "T" or "TiB"
|
||||
for tebibytes (2<sup>40</sup> or 1,099,511,627,776 bytes).
|
||||
However, the value will be rounded up to the nearest kibibyte
|
||||
by libvirt, and may be further rounded to the granularity
|
||||
supported by the hypervisor. Some hypervisors also enforce a
|
||||
minimum, such as
|
||||
4000KiB. <span class='since'><code>unit</code> since
|
||||
0.9.11</span></dd>
|
||||
<dt><code>currentMemory</code></dt>
|
||||
<dd>The actual allocation of memory for the guest. This value can
|
||||
be less than the maximum allocation, to allow for ballooning
|
||||
up the guests memory on the fly. If this is omitted, it defaults
|
||||
to the same value as the <code>memory</code> element</dd>
|
||||
to the same value as the <code>memory</code> element.
|
||||
The <code>unit</code> attribute behaves the same as
|
||||
for <code>memory</code>.</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
@@ -460,10 +479,10 @@
|
||||
<domain>
|
||||
...
|
||||
<memtune>
|
||||
<hard_limit>1048576</hard_limit>
|
||||
<soft_limit>131072</soft_limit>
|
||||
<swap_hard_limit>2097152</swap_hard_limit>
|
||||
<min_guarantee>65536</min_guarantee>
|
||||
<hard_limit unit='G'>1</hard_limit>
|
||||
<soft_limit unit='M'>128</soft_limit>
|
||||
<swap_hard_limit unit='G'>2</swap_hard_limit>
|
||||
<min_guarantee unit='bytes'>67108864</min_guarantee>
|
||||
</memtune>
|
||||
...
|
||||
</domain>
|
||||
@@ -477,7 +496,13 @@
|
||||
parameters are applied to the QEMU process as a whole. Thus, when
|
||||
counting them, one needs to add up guest RAM, guest video RAM, and
|
||||
some memory overhead of QEMU itself. The last piece is hard to
|
||||
determine so one needs guess and try.</dd>
|
||||
determine so one needs guess and try. For each tunable, it
|
||||
is possible to designate which unit the number is in on
|
||||
input, using the same values as
|
||||
for <code><memory></code>. For backwards
|
||||
compatibility, output is always in
|
||||
KiB. <span class='since'><code>unit</code>
|
||||
since 0.9.11</span></dd>
|
||||
<dt><code>hard_limit</code></dt>
|
||||
<dd> The optional <code>hard_limit</code> element is the maximum memory
|
||||
the guest can use. The units for this value are kibibytes (i.e. blocks
|
||||
|
||||
@@ -412,11 +412,11 @@
|
||||
<define name="resources">
|
||||
<interleave>
|
||||
<element name="memory">
|
||||
<ref name='memoryKBElement'/>
|
||||
<ref name='scaledInteger'/>
|
||||
</element>
|
||||
<optional>
|
||||
<element name="currentMemory">
|
||||
<ref name='memoryKBElement'/>
|
||||
<ref name='scaledInteger'/>
|
||||
</element>
|
||||
</optional>
|
||||
<optional>
|
||||
@@ -461,25 +461,25 @@
|
||||
<!-- Maximum memory the VM can use -->
|
||||
<optional>
|
||||
<element name="hard_limit">
|
||||
<ref name='memoryKBElement'/>
|
||||
<ref name='scaledInteger'/>
|
||||
</element>
|
||||
</optional>
|
||||
<!-- Minimum memory ascertained for the VM during contention -->
|
||||
<optional>
|
||||
<element name="soft_limit">
|
||||
<ref name='memoryKBElement'/>
|
||||
<ref name='scaledInteger'/>
|
||||
</element>
|
||||
</optional>
|
||||
<!-- Minimum amount of memory required to start the VM -->
|
||||
<optional>
|
||||
<element name="min_guarantee">
|
||||
<ref name='memoryKBElement'/>
|
||||
<ref name='scaledInteger'/>
|
||||
</element>
|
||||
</optional>
|
||||
<!-- Maximum swap area the VM can use -->
|
||||
<optional>
|
||||
<element name="swap_hard_limit">
|
||||
<ref name='memoryKBElement'/>
|
||||
<ref name='scaledInteger'/>
|
||||
</element>
|
||||
</optional>
|
||||
</element>
|
||||
@@ -3132,17 +3132,6 @@
|
||||
<param name="pattern">[0-9]+</param>
|
||||
</data>
|
||||
</define>
|
||||
<!-- Memory as an element, with optional unit attribute -->
|
||||
<define name='memoryKBElement'>
|
||||
<optional>
|
||||
<attribute name='unit'>
|
||||
<value>KiB</value>
|
||||
</attribute>
|
||||
</optional>
|
||||
<data type='unsignedInt'>
|
||||
<param name='pattern'>[0-9]+</param>
|
||||
</data>
|
||||
</define>
|
||||
<define name="domainName">
|
||||
<data type="string">
|
||||
<!-- Use literal newline instead of \n for bug in libxml2 2.7.6 -->
|
||||
|
||||
Reference in New Issue
Block a user