From nobody Sun Feb 8 02:42:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 14915811093311002.8063656148616; Fri, 7 Apr 2017 09:05:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 06958C05B1FD; Fri, 7 Apr 2017 16:05:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9D5BBBAF7D; Fri, 7 Apr 2017 16:05:06 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4154118521CA; Fri, 7 Apr 2017 16:05:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v37G55Dg015956 for ; Fri, 7 Apr 2017 12:05:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 042FA8867A; Fri, 7 Apr 2017 16:05:05 +0000 (UTC) Received: from caroline.brq.redhat.com (dhcp129-198.brq.redhat.com [10.34.129.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 554D68AC42 for ; Fri, 7 Apr 2017 16:05:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 06958C05B1FD Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 06958C05B1FD From: Martin Kletzander To: libvir-list@redhat.com Date: Fri, 7 Apr 2017 18:04:54 +0200 Message-Id: <5d6559beb7d338ec755d4282afaf47675de4838e.1491580983.git.mkletzan@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] conf, docs: Add support for coalesce setting(s) X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 07 Apr 2017 16:05:08 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 or . And in those cases the guest can modify the settings itself. Signed-off-by: Martin Kletzander --- docs/formatdomain.html.in | 24 ++++++ docs/schemas/domaincommon.rng | 3 + docs/schemas/networkcommon.rng | 17 ++++ src/conf/domain_conf.c | 9 +++ src/conf/domain_conf.h | 2 + src/conf/networkcommon_conf.c | 91 ++++++++++++++++++= ++++ src/conf/networkcommon_conf.h | 9 +++ src/libvirt_private.syms | 2 + src/qemu/qemu_domain.c | 31 ++++++++ .../qemuxml2argvdata/qemuxml2argv-net-coalesce.xml | 64 +++++++++++++++ .../qemuxml2xmlout-net-coalesce.xml | 69 ++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 12 files changed, 322 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=3D? /dev/null Since 3.1.0

+
Coalesce settings
+
+...
+<devices>
+  <interface type=3D'network'>
+    <source network=3D'default'/>
+    <target dev=3D'vnet0'/>
+    <coalesce>
+      <rx_max_coalesced_frames>5</rx_max_coalesced_frames>
+    </coalesce>
+  </interface>
+</devices>
+...
+ +

+ This element provides means of setting coalesce settings for some + interface devices (currently only type network + and bridge. Currently there is just one sub-element + named rx_max_coalesced_frames which accepts a non-negat= ive + integer that specifies the maximum number of packets that will be re= ceived + before an interrupt. + Since 3.3.0 +

+
IP configuration
 ...
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index edc225fe50c5..b703515fb897 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2509,6 +2509,9 @@
         
       
       
+        
+      
+      
         
           
             
diff --git a/docs/schemas/networkcommon.rng b/docs/schemas/networkcommon.rng
index 26995556d48d..27e78d13e4a6 100644
--- a/docs/schemas/networkcommon.rng
+++ b/docs/schemas/networkcommon.rng
@@ -275,4 +275,21 @@
       
     
   
+
+  
+    
+      
+        
+        
+          
+            
+          
+        
+      
+    
+  
+
 
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 80baa090a7f8..3cc17b5fd228 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10251,6 +10251,13 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlo=
pt,
         goto error;
     }

+    node =3D virXPathNode("./coalesce", ctxt);
+    if (node) {
+        def->coalesce =3D virNetDevCoalesceParseXML(node, ctxt);
+        if (!def->coalesce)
+            goto error;
+    }
+
  cleanup:
     ctxt->node =3D oldnode;
     VIR_FREE(macaddr);
@@ -22144,6 +22151,8 @@ virDomainNetDefFormat(virBufferPtr buf,
     if (def->mtu)
         virBufferAsprintf(buf, "\n", def->mtu);

+    virNetDevCoalesceFormatXML(buf, def->coalesce);
+
     if (virDomainDeviceInfoFormat(buf, &def->info,
                                   flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT
                                   | VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM) < 0)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 26c0e6b88759..6c3de9cc2cd4 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -41,6 +41,7 @@
 # include "numa_conf.h"
 # include "virnetdevmacvlan.h"
 # include "virsysinfo.h"
+# include "virnetdev.h"
 # include "virnetdevip.h"
 # include "virnetdevvportprofile.h"
 # include "virnetdevbandwidth.h"
@@ -1036,6 +1037,7 @@ struct _virDomainNetDef {
     int trustGuestRxFilters; /* enum virTristateBool */
     int linkstate;
     unsigned int mtu;
+    virNetDevCoalescePtr coalesce;
 };

 /* Used for prefix of ifname of any network name generated dynamically
diff --git a/src/conf/networkcommon_conf.c b/src/conf/networkcommon_conf.c
index 29e978bbdfe5..e0756da6c9ec 100644
--- a/src/conf/networkcommon_conf.c
+++ b/src/conf/networkcommon_conf.c
@@ -328,3 +328,94 @@ virNetDevIPRouteFormat(virBufferPtr buf,
  cleanup:
     return result;
 }
+
+virNetDevCoalescePtr
+virNetDevCoalesceParseXML(xmlNodePtr node,
+                          xmlXPathContextPtr ctxt)
+{
+    virNetDevCoalescePtr ret =3D NULL;
+    xmlNodePtr save =3D NULL;
+    char *str =3D NULL;
+    unsigned long long tmp =3D 0;
+
+    save =3D ctxt->node;
+    ctxt->node =3D node;
+
+#define GET_COALESCE_PARAM(name)                                        \
+    do {                                                                \
+        str =3D virXPathString("string(./" #name ")", ctxt);              \
+        if (!str)                                                       \
+            break;                                                      \
+                                                                        \
+        if (!ret && VIR_ALLOC(ret) < 0)                                 \
+            return NULL;                                                \
+                                                                        \
+        if (virStrToLong_ullp(str, NULL, 10, &tmp) < 0) {               \
+            virReportError(VIR_ERR_XML_DETAIL,                          \
+                           _("cannot parse value '%s' for parameter '%s'")=
, \
+                           str, #name);                                 \
+            VIR_FREE(str);                                              \
+            goto error;                                                 \
+        }                                                               \
+        VIR_FREE(str);                                                  \
+                                                                        \
+        if (tmp > UINT32_MAX) {                                         \
+            virReportError(VIR_ERR_OVERFLOW,                            \
+                           _("value '%llu' is too big for " #name       \
+                             ", maximum is '%lu'"),                     \
+                           tmp, (unsigned long) UINT32_MAX);            \
+            goto error;                                                 \
+        }                                                               \
+                                                                        \
+        ret->name =3D tmp;                                                \
+    } while (0)
+
+    /* Just add more parameters if needed */
+
+    GET_COALESCE_PARAM(rx_max_coalesced_frames);
+
+#undef GET_COALESCE_PARAM
+
+ cleanup:
+    ctxt->node =3D save;
+    return ret;
+
+ error:
+    VIR_FREE(ret);
+    goto cleanup;
+}
+
+void
+virNetDevCoalesceFormatXML(virBufferPtr buf,
+                           virNetDevCoalescePtr coalesce)
+{
+    virBuffer childrenBuf =3D VIR_BUFFER_INITIALIZER;
+    int indent =3D virBufferGetIndent(buf, false);
+
+    if (!coalesce)
+        return;
+
+    virBufferAdjustIndent(&childrenBuf, indent + 2);
+
+#define SET_COALESCE_PARAM(name)                                \
+    do {                                                        \
+        if (coalesce->name) {                                   \
+            virBufferAsprintf(&childrenBuf,                     \
+                              /* TODO: turn %u into something 32-bit compa=
tible */ \
+                              "<" #name ">%u\n",    \
+                              coalesce->name);                  \
+        }                                                       \
+    } while (0)
+
+    /* Just add more parameters if needed */
+
+    SET_COALESCE_PARAM(rx_max_coalesced_frames);
+
+#undef SET_COALESCE_PARAM
+
+    if (virBufferUse(&childrenBuf)) {
+        virBufferAddLit(buf, "\n");
+        virBufferAddBuffer(buf, &childrenBuf);
+        virBufferAddLit(buf, "\n");
+    }
+}
diff --git a/src/conf/networkcommon_conf.h b/src/conf/networkcommon_conf.h
index 70e46793f67b..a842e2075292 100644
--- a/src/conf/networkcommon_conf.h
+++ b/src/conf/networkcommon_conf.h
@@ -32,6 +32,7 @@
 # include "virbuffer.h"
 # include "virsocketaddr.h"
 # include "virnetdevip.h"
+# include "virnetdev.h"

 virNetDevIPRoutePtr
 virNetDevIPRouteCreate(const char *networkName,
@@ -52,4 +53,12 @@ int
 virNetDevIPRouteFormat(virBufferPtr buf,
                        const virNetDevIPRoute *def);

+virNetDevCoalescePtr
+virNetDevCoalesceParseXML(xmlNodePtr node,
+                          xmlXPathContextPtr ctxt);
+
+void
+virNetDevCoalesceFormatXML(virBufferPtr buf,
+                           virNetDevCoalescePtr coalesce);
+
 #endif /* __NETWORKCOMMON_CONF_H__ */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 7ba9b7d98d86..7712e3d0a7f2 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -685,6 +685,8 @@ virNetworkEventStateRegisterID;


 # conf/networkcommon_conf.h
+virNetDevCoalesceFormatXML;
+virNetDevCoalesceParseXML;
 virNetDevIPRouteCreate;
 virNetDevIPRouteFormat;
 virNetDevIPRouteParseXML;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index a3bb7dbc9a25..ac7193c9743f 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2953,6 +2953,30 @@ qemuDomainDefValidate(const virDomainDef *def,
 }


+static bool
+qemuDomainNetSupportsCoalesce(virDomainNetType type)
+{
+    switch (type) {
+    case VIR_DOMAIN_NET_TYPE_NETWORK:
+    case VIR_DOMAIN_NET_TYPE_BRIDGE:
+        return true;
+    case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
+    case VIR_DOMAIN_NET_TYPE_ETHERNET:
+    case VIR_DOMAIN_NET_TYPE_DIRECT:
+    case VIR_DOMAIN_NET_TYPE_HOSTDEV:
+    case VIR_DOMAIN_NET_TYPE_USER:
+    case VIR_DOMAIN_NET_TYPE_SERVER:
+    case VIR_DOMAIN_NET_TYPE_CLIENT:
+    case VIR_DOMAIN_NET_TYPE_MCAST:
+    case VIR_DOMAIN_NET_TYPE_INTERNAL:
+    case VIR_DOMAIN_NET_TYPE_UDP:
+    case VIR_DOMAIN_NET_TYPE_LAST:
+        break;
+    }
+    return false;
+}
+
+
 static int
 qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
                             const virDomainDef *def ATTRIBUTE_UNUSED,
@@ -2987,6 +3011,13 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef=
 *dev,
                            virDomainNetTypeToString(net->type));
             goto cleanup;
         }
+
+        if (net->coalesce && !qemuDomainNetSupportsCoalesce(net->type)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("coalesce settings on interface type %s are n=
ot supported"),
+                           virDomainNetTypeToString(net->type));
+            goto cleanup;
+        }
     }

     ret =3D 0;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-coalesce.xml b/tests/q=
emuxml2argvdata/qemuxml2argv-net-coalesce.xml
new file mode 100644
index 000000000000..0c44cb1c8abc
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-coalesce.xml
@@ -0,0 +1,64 @@
+
+  test
+  15d091de-0181-456b-9554-e4382dc1f1ab
+  1048576
+  1048576
+  1
+  
+    hvm
+    
+    
+    
+  
+  
+  destroy
+  restart
+  restart
+  
+    /usr/bin/qemu
+    
+      
+      
+      
+      
+ + + + + + +
+ + + +
+ + + + + + + + + 7 + + + + + + + + 0 + + + + + + + + + + + + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml b/tes= ts/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml new file mode 100644 index 000000000000..facf3212c79c --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml @@ -0,0 +1,69 @@ + + test + 15d091de-0181-456b-9554-e4382dc1f1ab + 1048576 + 1048576 + 1 + + hvm + + + + + + destroy + restart + restart + + /usr/bin/qemu + + + + +
+ + + + + + +
+ + +
+ + +
+ + +
+ + + + + + + + 7 + +
+ + + + + +
+ + + + + + + + + + +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 252f1ed5f2a8..692b63866e53 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -532,6 +532,7 @@ mymain(void) DO_TEST("net-bandwidth", NONE); DO_TEST("net-bandwidth2", NONE); DO_TEST("net-mtu", NONE); + DO_TEST("net-coalesce", NONE); DO_TEST("serial-vc", NONE); DO_TEST("serial-pty", NONE); --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list