Support emulatorpin xml parse.

This patch adds a new xml element <emulatorpin>, which is a sibling
to the existing <vcpupin> element under the <cputune>, to pin emulator
threads to specified physical CPUs.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
This commit is contained in:
Tang Chen 2012-08-21 17:18:32 +08:00 committed by Daniel Veillard
parent ed92285095
commit 19630db3e3
5 changed files with 67 additions and 2 deletions

View File

@ -384,6 +384,7 @@
&lt;vcpupin vcpu="1" cpuset="0,1"/&gt;
&lt;vcpupin vcpu="2" cpuset="2,3"/&gt;
&lt;vcpupin vcpu="3" cpuset="0,4"/&gt;
&lt;emulatorpin cpuset="1-3"/%gt;
&lt;shares&gt;2048&lt;/shares&gt;
&lt;period&gt;1000000&lt;/period&gt;
&lt;quota&gt;-1&lt;/quota&gt;
@ -410,6 +411,14 @@
of element <code>vcpu</code>. (NB: Only qemu driver support)
<span class="since">Since 0.9.0</span>
</dd>
<dt><code>emulatorpin</code></dt>
<dd>
The optional <code>emulatorpin</code> element specifies which of host
physical CPUs the "emulator", a subset of a domain not including vcpu,
will be pinned to. If this is ommitted, "emulator" is pinned to all
the physical CPUs by default. It contains one required attribute
<code>cpuset</code> specifying which physical CPUs to pin to.
</dd>
<dt><code>shares</code></dt>
<dd>
The optional <code>shares</code> element specifies the proportional

View File

@ -591,6 +591,13 @@
</attribute>
</element>
</zeroOrMore>
<optional>
<element name="emulatorpin">
<attribute name="cpuset">
<ref name="cpuset"/>
</attribute>
</element>
</optional>
</element>
</optional>

View File

@ -8377,6 +8377,35 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
}
VIR_FREE(nodes);
if ((n = virXPathNodeSet("./cputune/emulatorpin", ctxt, &nodes)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract emulatorpin nodes"));
goto error;
}
if (n) {
if (n > 1) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("only one emulatorpin is supported"));
VIR_FREE(nodes);
goto error;
}
if (VIR_ALLOC(def->cputune.emulatorpin) < 0) {
goto no_memory;
}
virDomainVcpuPinDefPtr emulatorpin = NULL;
emulatorpin = virDomainVcpuPinDefParseXML(nodes[0], ctxt,
def->maxvcpus, 1);
if (!emulatorpin)
goto error;
def->cputune.emulatorpin = emulatorpin;
}
VIR_FREE(nodes);
/* Extract numatune if exists. */
if ((n = virXPathNodeSet("./numatune", ctxt, &nodes)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@ -13001,7 +13030,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virBufferAsprintf(buf, ">%u</vcpu>\n", def->maxvcpus);
if (def->cputune.shares || def->cputune.vcpupin ||
def->cputune.period || def->cputune.quota)
def->cputune.period || def->cputune.quota ||
def->cputune.emulatorpin)
virBufferAddLit(buf, " <cputune>\n");
if (def->cputune.shares)
@ -13033,8 +13063,25 @@ virDomainDefFormatInternal(virDomainDefPtr def,
}
}
if (def->cputune.emulatorpin) {
virBufferAsprintf(buf, " <emulatorpin ");
char *cpumask = NULL;
cpumask = virDomainCpuSetFormat(def->cputune.emulatorpin->cpumask,
VIR_DOMAIN_CPUMASK_LEN);
if (cpumask == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("failed to format cpuset for emulator"));
goto cleanup;
}
virBufferAsprintf(buf, "cpuset='%s'/>\n", cpumask);
VIR_FREE(cpumask);
}
if (def->cputune.shares || def->cputune.vcpupin ||
def->cputune.period || def->cputune.quota)
def->cputune.period || def->cputune.quota ||
def->cputune.emulatorpin)
virBufferAddLit(buf, " </cputune>\n");
if (def->numatune.memory.nodemask ||

View File

@ -1616,6 +1616,7 @@ struct _virDomainDef {
long long quota;
int nvcpupin;
virDomainVcpuPinDefPtr *vcpupin;
virDomainVcpuPinDefPtr emulatorpin;
} cputune;
virDomainNumatuneDef numatune;

View File

@ -10,6 +10,7 @@
<quota>-1</quota>
<vcpupin vcpu='0' cpuset='0'/>
<vcpupin vcpu='1' cpuset='1'/>
<emulatorpin cpuset='1'/>
</cputune>
<os>
<type arch='i686' machine='pc'>hvm</type>