Re: [PATCH v2 2/3] conf, docs: Add support for coalesce setting(s)

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

 



On 04/20/2017 02:21 PM, Martin Kletzander wrote:
We are currently parsing only rx_max_coalesced_frames because that's
the only value that makes sense for us.  The tun device just added
support for this one and the others are only supported by hardware
devices which we don't need to worry about as the only way we'd pass
those to the domain is using <hostdev/> or <interface type='hostdev'/>.
And in those cases the guest can modify the settings itself.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 docs/formatdomain.html.in                          |  24 ++++
 docs/schemas/domaincommon.rng                      | 131 +++++++++++++++++++++
 src/conf/domain_conf.c                             |  80 +++++++++++++
 src/conf/domain_conf.h                             |   2 +
 src/qemu/qemu_domain.c                             |  31 +++++
 .../qemuxml2argvdata/qemuxml2argv-net-coalesce.xml |  68 +++++++++++
 .../qemuxml2xmlout-net-coalesce.xml                |  71 +++++++++++
 tests/qemuxml2xmltest.c                            |   1 +
 8 files changed, 408 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-coalesce.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index b1e38f00e423..ea64b7fd1193 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5405,6 +5405,30 @@ qemu-kvm -net nic,model=? /dev/null
       <span class="since">Since 3.1.0</span>
     </p>

+    <h5><a name="coalesce">Coalesce settings</a></h5>
+<pre>
+...
+&lt;devices&gt;
+  &lt;interface type='network'&gt;
+    &lt;source network='default'/&gt;
+    &lt;target dev='vnet0'/&gt;
+    <b>&lt;coalesce&gt;
+      &lt;rx_max_coalesced_frames&gt;5&lt;/rx_max_coalesced_frames&gt;
+    &lt;/coalesce&gt;</b>
+  &lt;/interface&gt;
+&lt;/devices&gt;
+...</pre>
+
+    <p>
+      This element provides means of setting coalesce settings for some
+      interface devices (currently only type <code>network</code>
+      and <code>bridge</code>.  Currently there is just one sub-element
+      named <code>rx_max_coalesced_frames</code> which accepts a non-negative
+      integer that specifies the maximum number of packets that will be received
+      before an interrupt.
+      <span class="since">Since 3.3.0</span>
+    </p>

This does not correspond to the schema or tests introduced later in the patch.

+
     <h5><a name="ipconfig">IP configuration</a></h5>
 <pre>
 ...
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index edc225fe50c5..eb4b0f7437ba 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2509,6 +2509,9 @@
         <ref name="mtu"/>
       </optional>
       <optional>
+        <ref name="coalesce"/>
+      </optional>
+      <optional>
         <element name="target">
           <attribute name="dev">
             <ref name="deviceName"/>
@@ -5743,4 +5746,132 @@
       </choice>
     </attribute>
   </define>
+
+  <define name="coalesce">
+    <element name="coalesce">
+      <interleave>
+        <optional>
+          <element name="rx">
+            <optional>
+              <element name="frames">
+                <optional>
+                  <attribute name="max">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+                <!--
+                    This is how we'd add more Rx-related settings for
+                    frames, like irq, high, and low
+
+                <optional>
+                  <attribute name="irq">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+                <optional>
+                  <attribute name="high">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+                <optional>
+                  <attribute name="low">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+
+              -->
+              </element>
+            </optional>
+            <!--
+                This is how we'd add more Rx-related settings, like
+                usecs
+
+            <optional>
+              <element name="usecs">
+                <optional>
+                  <attribute name="max">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+                <optional>
+                  <attribute name="irq">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+                <optional>
+                  <attribute name="high">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+                <optional>
+                  <attribute name="low">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+              </element>
+            </optional>
+              -->
+          </element>
+        </optional>
+        <!--
+            This is how you would add more coalesce settings, like
+            Tx-related ones
+
+        <optional>
+          <element name="tx">
+            <optional>
+              <element name="frames">
+                <optional>
+                  <attribute name="max">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+                <optional>
+                  <attribute name="irq">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+                <optional>
+                  <attribute name="high">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+                <optional>
+                  <attribute name="low">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+              </element>
+            </optional>
+            <optional>
+              <element name="usecs">
+                <optional>
+                  <attribute name="max">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+                <optional>
+                  <attribute name="irq">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+                <optional>
+                  <attribute name="high">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+                <optional>
+                  <attribute name="low">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+              </element>
+            </optional>
+          </element>
+        </optional>
+        -->
+      </interleave>
+    </element>
+  </define>
+
 </grammar>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 705deb39a1bf..cbeebdc56880 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6772,6 +6772,77 @@ virDomainNetIPInfoParseXML(const char *source,
     return ret;
 }

+
+static virNetDevCoalescePtr
+virDomainNetDefCoalesceParseXML(xmlNodePtr node,
+                                xmlXPathContextPtr ctxt)
+{
+    virNetDevCoalescePtr ret = NULL;
+    xmlNodePtr save = NULL;
+    char *str = NULL;
+    unsigned long long tmp = 0;
+
+    save = ctxt->node;
+    ctxt->node = node;
+
+    str = virXPathString("string(./rx/frames/@max)", ctxt);
+    if (!str)
+        goto cleanup;
+
+    if (!ret && VIR_ALLOC(ret) < 0)
+        goto cleanup;
+
+    if (virStrToLong_ullp(str, NULL, 10, &tmp) < 0) {
+        virReportError(VIR_ERR_XML_DETAIL,
+                       _("cannot parse value '%s' for coalesce parameter"),
+                       str);
+        VIR_FREE(str);
+        goto error;
+    }
+    VIR_FREE(str);
+
+    if (tmp > UINT32_MAX) {
+        virReportError(VIR_ERR_OVERFLOW,
+                       _("value '%llu' is too big for coalesce "
+                         "parameter, maximum is '%lu'"),
+                       tmp, (unsigned long) UINT32_MAX);
+        goto error;
+    }
+    ret->rx_max_coalesced_frames = tmp;

I wonder if we can turn this into a macro (despite some of us hating them) because potentially we'll parse all the 32 coalesce attributes (or how many there are). But for now, this is okay as is.

+
+ cleanup:
+    ctxt->node = save;
+    return ret;
+
+ error:
+    VIR_FREE(ret);
+    goto cleanup;
+}

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux