[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH v2.1 09/21] Support emulatorpin xml parse.



On Tue, Aug 21, 2012 at 05:18:32PM +0800, Hu Tao wrote:
> From: Tang Chen <tangchen cn fujitsu com>
> 
> 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                       |    9 ++++
>  docs/schemas/domaincommon.rng                   |    7 ++++
>  src/conf/domain_conf.c                          |   50 ++++++++++++++++++++++-
>  src/conf/domain_conf.h                          |    1 +
>  tests/qemuxml2argvdata/qemuxml2argv-cputune.xml |    1 +
>  5 files changed, 66 insertions(+), 2 deletions(-)
> 
> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> index 8e07489..81ec2cd 100644
> --- a/docs/formatdomain.html.in
> +++ b/docs/formatdomain.html.in
> @@ -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
> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
> index 401b76b..b02ad96 100644
> --- a/docs/schemas/domaincommon.rng
> +++ b/docs/schemas/domaincommon.rng
> @@ -591,6 +591,13 @@
>                </attribute>
>              </element>
>            </zeroOrMore>
> +          <optional>
> +            <element name="emulatorpin">
> +              <attribute name="cpuset">
> +                <ref name="cpuset"/>
> +              </attribute>
> +            </element>
> +          </optional>
>          </element>
>        </optional>
>  
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 62ba9de..94ec095 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -8330,6 +8330,34 @@ 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, 0);
> +
> +        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,
> @@ -12930,7 +12958,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)
> @@ -12962,8 +12991,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 ||
> diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
> index 025c7fe..a7b2ff6 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -1600,6 +1600,7 @@ struct _virDomainDef {
>          long long quota;
>          int nvcpupin;
>          virDomainVcpuPinDefPtr *vcpupin;
> +        virDomainVcpuPinDefPtr emulatorpin;
>      } cputune;
>  
>      virDomainNumatuneDef numatune;
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cputune.xml b/tests/qemuxml2argvdata/qemuxml2argv-cputune.xml
> index df3101d..593e650 100644
> --- a/tests/qemuxml2argvdata/qemuxml2argv-cputune.xml
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-cputune.xml
> @@ -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>

  ACK, but it needed the following fixup to cope with the fix for patch 8

Daniel

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 59f22ac..304ab88 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8396,7 +8396,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
         }
 
         virDomainVcpuPinDefPtr emulatorpin = NULL;
-        emulatorpin = virDomainVcpuPinDefParseXML(nodes[0], ctxt, 0);
+        emulatorpin = virDomainVcpuPinDefParseXML(nodes[0], ctxt,
+                                                  def->maxvcpus, 1);
 
         if (!emulatorpin)
             goto error;

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]