]> xenbits.xensource.com Git - libvirt.git/commitdiff
Support emulatorpin xml parse.
authorTang Chen <tangchen@cn.fujitsu.com>
Tue, 21 Aug 2012 09:18:32 +0000 (17:18 +0800)
committerDaniel Veillard <veillard@redhat.com>
Wed, 22 Aug 2012 07:51:23 +0000 (15:51 +0800)
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>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
tests/qemuxml2argvdata/qemuxml2argv-cputune.xml

index d87ca6b7fa7c4a32dd36c85767947e082182e2c5..42df928a301273afa39ee4327b8d4690ad197b45 100644 (file)
     &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;
         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
index 8a1782ac7117e2937ec2f26c4227dc6a99087eb2..f4005c51e26d75b736c351154b0c75fc07ec2f73 100644 (file)
               </attribute>
             </element>
           </zeroOrMore>
+          <optional>
+            <element name="emulatorpin">
+              <attribute name="cpuset">
+                <ref name="cpuset"/>
+              </attribute>
+            </element>
+          </optional>
         </element>
       </optional>
 
index ee247f63882a3c74eb28618a007a28ce5ba0cb28..304ab88e78bba564a52b47d2c53c18515c0d01a7 100644 (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 ||
index 9002222369460d8f88bbc832980ac5bd6616a2c5..8cd685e4c34d42fcd91c643670f7ea7b95aeb53b 100644 (file)
@@ -1616,6 +1616,7 @@ struct _virDomainDef {
         long long quota;
         int nvcpupin;
         virDomainVcpuPinDefPtr *vcpupin;
+        virDomainVcpuPinDefPtr emulatorpin;
     } cputune;
 
     virDomainNumatuneDef numatune;
index df3101d6c3b91041fd8bbf58db01876801e63a8b..593e650d7bd0e19ba18b07051ea4f69e9f8234fd 100644 (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>