]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Add support for emulatorsched
authorMartin Kletzander <mkletzan@redhat.com>
Mon, 15 Apr 2019 08:45:38 +0000 (10:45 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 16 Apr 2019 11:46:17 +0000 (13:46 +0200)
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
tests/genericxml2xmlindata/cputune.xml [new file with mode: 0644]
tests/genericxml2xmloutdata/cputune.xml [new file with mode: 0644]
tests/genericxml2xmltest.c

index 50847a4470044ed9eb613e1bed6b121990f11e66..d27ab07cbb1893455c5c5e22b751d04837095185 100644 (file)
         <span class="since">Only QEMU driver support since 2.1.0</span>
       </dd>
 
-      <dt><code>vcpusched</code> and <code>iothreadsched</code></dt>
+      <dt><code>vcpusched</code>, <code>iothreadsched</code>
+      and <code>emulatorsched</code></dt>
       <dd>
-        The optional <code>vcpusched</code> and <code>iothreadsched</code>
-        elements specify the scheduler type
+        The optional
+        <code>vcpusched</code>, <code>iothreadsched</code>
+        and <code>emulatorsched</code> elements specify the scheduler type
         (values <code>batch</code>, <code>idle</code>, <code>fifo</code>,
-        <code>rr</code>) for particular vCPU and IOThread threads respecively.
-        The attributes <code>vcpus</code> and <code>iothreads</code> select
+        <code>rr</code>) for particular vCPU, IOThread and emulator threads
+        respecively.  For <code>vcpusched</code> and <code>iothreadsched</code>
+        the attributes <code>vcpus</code> and <code>iothreads</code> select
         which vCPUs/IOThreads this setting applies to, leaving them out sets the
-        default.  Valid <code>vcpus</code> values start at 0 through one less
+        default.  The element <code>emulatorsched</code> does not have that
+        attribute. Valid <code>vcpus</code> values start at 0 through one less
         than the number of vCPU's defined for the
         domain. Valid <code>iothreads</code> values are described in
         the <code>iothreadids</code>
         well (and is ignored for non-real-time ones). The value range
         for the priority depends on the host kernel (usually 1-99).
         <span class="since">Since 1.2.13</span>
+        <code>emulatorsched</code> <span class="since">since 5.3.0</span>
       </dd>
 
       <dt><code>cachetune</code><span class="since">Since 4.1.0</span></dt>
index 623ef28719df5e240f6a3d6bcce546354b143cc6..111b85c36fd37953c56b06c38b2f1141c945b43c 100644 (file)
             <ref name="schedparam"/>
           </element>
         </zeroOrMore>
+        <optional>
+          <element name="emulatorsched">
+            <ref name="schedparam"/>
+          </element>
+        </optional>
         <zeroOrMore>
           <element name="cachetune">
             <attribute name="vcpus">
index e7b8b51aad0e30278b0dbf25277ba63ddeaf1bce..17e8975be3999e496200de983a66b2b223ddbfdf 100644 (file)
@@ -3396,6 +3396,7 @@ void virDomainDefFree(virDomainDefPtr def)
     virDomainIOThreadIDDefArrayFree(def->iothreadids, def->niothreadids);
 
     virBitmapFree(def->cputune.emulatorpin);
+    VIR_FREE(def->cputune.emulatorsched);
 
     virDomainNumaFree(def->numa);
 
@@ -18483,6 +18484,25 @@ virDomainSchedulerParseCommonAttrs(xmlNodePtr node,
 }
 
 
+static int
+virDomainEmulatorSchedParse(xmlNodePtr node,
+                            virDomainDefPtr def)
+{
+    VIR_AUTOFREE(virDomainThreadSchedParamPtr) sched = NULL;
+
+    if (VIR_ALLOC(sched) < 0)
+        return -1;
+
+    if (virDomainSchedulerParseCommonAttrs(node,
+                                           &sched->policy,
+                                           &sched->priority) < 0)
+        return -1;
+
+    VIR_STEAL_PTR(def->cputune.emulatorsched, sched);
+    return 0;
+}
+
+
 static virBitmapPtr
 virDomainSchedulerParse(xmlNodePtr node,
                         const char *name,
@@ -19913,6 +19933,25 @@ virDomainDefParseXML(xmlDocPtr xml,
     }
     VIR_FREE(nodes);
 
+    if ((n = virXPathNodeSet("./cputune/emulatorsched", ctxt, &nodes)) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("cannot extract emulatorsched nodes"));
+        goto error;
+    }
+
+    if (n) {
+        if (n > 1) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("only one emulatorsched is supported"));
+            VIR_FREE(nodes);
+            goto error;
+        }
+
+        if (virDomainEmulatorSchedParse(nodes[0], def) < 0)
+            goto error;
+    }
+    VIR_FREE(nodes);
+
     if ((n = virXPathNodeSet("./cputune/cachetune", ctxt, &nodes)) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("cannot extract cachetune nodes"));
@@ -27490,6 +27529,11 @@ virDomainCputuneDefFormat(virBufferPtr buf,
         VIR_FREE(cpumask);
     }
 
+    if (def->cputune.emulatorsched) {
+        virDomainSchedulerFormat(&childrenBuf, "emulator",
+                                 def->cputune.emulatorsched, 0, false);
+    }
+
     for (i = 0; i < def->maxvcpus; i++) {
         virDomainSchedulerFormat(&childrenBuf, "vcpu",
                                  &def->vcpus[i]->sched, i, true);
index 12eb71c1977e0404ca175fb363af8c7fa88ef4e2..988ef90f1189ef31f40efa16785ff029d5cc3fb6 100644 (file)
@@ -2159,6 +2159,7 @@ struct _virDomainCputune {
     unsigned long long iothread_period;
     long long iothread_quota;
     virBitmapPtr emulatorpin;
+    virDomainThreadSchedParamPtr emulatorsched;
 };
 
 
diff --git a/tests/genericxml2xmlindata/cputune.xml b/tests/genericxml2xmlindata/cputune.xml
new file mode 100644 (file)
index 0000000..999c8ce
--- /dev/null
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>4</vcpu>
+  <iothreads>4</iothreads>
+  <cputune>
+    <shares>2048</shares>
+    <period>1000000</period>
+    <quota>-1</quota>
+    <vcpupin vcpu='0' cpuset='0'/>
+    <vcpupin vcpu='1' cpuset='1'/>
+    <emulatorpin cpuset='1'/>
+    <emulatorsched scheduler='fifo' priority='2'/>
+    <vcpusched vcpus='0-1' scheduler='fifo' priority='1'/>
+    <vcpusched vcpus='1-3,^1' scheduler='idle'/>
+    <iothreadsched iothreads='1,3' scheduler='batch'/>
+    <iothreadsched iothreads='2' scheduler='rr' priority='99'/>
+  </cputune>
+  <os>
+    <type arch='x86_64' machine='q35'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <features>
+    <smm state='on'>
+      <tseg unit='MiB'>48</tseg>
+    </smm>
+  </features>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
+  </devices>
+</domain>
diff --git a/tests/genericxml2xmloutdata/cputune.xml b/tests/genericxml2xmloutdata/cputune.xml
new file mode 100644 (file)
index 0000000..f9f99a4
--- /dev/null
@@ -0,0 +1,40 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>4</vcpu>
+  <iothreads>4</iothreads>
+  <cputune>
+    <shares>2048</shares>
+    <period>1000000</period>
+    <quota>-1</quota>
+    <vcpupin vcpu='0' cpuset='0'/>
+    <vcpupin vcpu='1' cpuset='1'/>
+    <emulatorpin cpuset='1'/>
+    <emulatorsched scheduler='fifo' priority='2'/>
+    <vcpusched vcpus='0' scheduler='fifo' priority='1'/>
+    <vcpusched vcpus='1' scheduler='fifo' priority='1'/>
+    <vcpusched vcpus='2' scheduler='idle'/>
+    <vcpusched vcpus='3' scheduler='idle'/>
+    <iothreadsched iothreads='1' scheduler='batch'/>
+    <iothreadsched iothreads='2' scheduler='rr' priority='99'/>
+    <iothreadsched iothreads='3' scheduler='batch'/>
+  </cputune>
+  <os>
+    <type arch='x86_64' machine='q35'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <features>
+    <smm state='on'>
+      <tseg unit='MiB'>48</tseg>
+    </smm>
+  </features>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
+  </devices>
+</domain>
index 4393d444641df0a610ea4a0b9d7727a9af4afc93..1840d6e6a8f995c2601cf175a53598598317c371 100644 (file)
@@ -149,6 +149,8 @@ mymain(void)
 
     DO_TEST("launch-security-sev");
 
+    DO_TEST_DIFFERENT("cputune");
+
     virObjectUnref(caps);
     virObjectUnref(xmlopt);