From nobody Mon Apr 29 06:20:33 2024 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 1492691344118817.3320036946568; Thu, 20 Apr 2017 05:29:04 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F7F38BA65; Thu, 20 Apr 2017 12:29:02 +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 0542C81412; Thu, 20 Apr 2017 12:29:02 +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 AA8FB18523C7; Thu, 20 Apr 2017 12:28:43 +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 v3KCLpsq020750 for ; Thu, 20 Apr 2017 08:21:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id D844A189F3; Thu, 20 Apr 2017 12:21:51 +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 60E1F81411 for ; Thu, 20 Apr 2017 12:21:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3F7F38BA65 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.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 3F7F38BA65 From: Martin Kletzander To: libvir-list@redhat.com Date: Thu, 20 Apr 2017 14:21:44 +0200 Message-Id: <9bed42851128762737af2fbf0ec1cfa9741626f7.1492690857.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 v2 1/3] util: Add virNetDevSetCoalesce function 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 20 Apr 2017 12:29:02 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" That function is able to configure coalesce settings for an interface, similarly to 'ethtool -C'. This function also updates back the structure so that it contains actual data on the device (if the device doesn't support some settings kernel might just return 0 and not set whatever is not supported), so this way we'll have up-to-date information in the live domain XML. Signed-off-by: Martin Kletzander --- configure.ac | 3 +- src/libvirt_private.syms | 1 + src/util/virnetdev.c | 83 ++++++++++++++++++++++++++++++++++++++++++++= ++++ src/util/virnetdev.h | 34 ++++++++++++++++++++ 4 files changed, 120 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 383493836bff..5f7a07a2a67a 100644 --- a/configure.ac +++ b/configure.ac @@ -347,7 +347,8 @@ AC_CHECK_TYPE([struct sockpeercred], ]]) AC_CHECK_DECLS([ETH_FLAG_TXVLAN, ETH_FLAG_NTUPLE, ETH_FLAG_RXHASH, ETH_FLA= G_LRO, - ETHTOOL_GGSO, ETHTOOL_GGRO, ETHTOOL_GFLAGS, ETHTOOL_GFEATU= RES], + ETHTOOL_GGSO, ETHTOOL_GGRO, ETHTOOL_GFLAGS, ETHTOOL_GFEATU= RES, + ETHTOOL_SCOALESCE, ETHTOOL_GCOALESCE], [], [], [[#include ]]) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 181e178753a4..83e979a2bdaa 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2077,6 +2077,7 @@ virNetDevRxFilterModeTypeFromString; virNetDevRxFilterModeTypeToString; virNetDevRxFilterNew; virNetDevSaveNetConfig; +virNetDevSetCoalesce; virNetDevSetMAC; virNetDevSetMTU; virNetDevSetMTUFromDevice; diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 170e34827f12..6ff1b489857d 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -3078,6 +3078,89 @@ virNetDevGetEthtoolGFeatures(virBitmapPtr bitmap ATT= RIBUTE_UNUSED, # endif +# if HAVE_DECL_ETHTOOL_SCOALESCE && HAVE_DECL_ETHTOOL_GCOALESCE +/** + * virNetDevSetCoalesce: + * @ifname: interface name to modify + * @coalesce: Coalesce settings to set and update + * + * This function sets the various coalesce settings for a given interface + * @ifname and updates them back into @coalesce. + * + * Returns 0 in case of success or -1 on failure + */ +int virNetDevSetCoalesce(const char *ifname, + virNetDevCoalescePtr coalesce) +{ + int fd =3D -1; + int ret =3D -1; + struct ifreq ifr; + struct ethtool_coalesce coal =3D {0}; + + if (!coalesce) + return 0; + + coal =3D (struct ethtool_coalesce) { + .cmd =3D ETHTOOL_SCOALESCE, + .rx_max_coalesced_frames =3D coalesce->rx_max_coalesced_frames, + .rx_coalesce_usecs_irq =3D coalesce->rx_coalesce_usecs_irq, + .rx_max_coalesced_frames_irq =3D coalesce->rx_max_coalesced_frames= _irq, + .tx_coalesce_usecs =3D coalesce->tx_coalesce_usecs, + .tx_max_coalesced_frames =3D coalesce->tx_max_coalesced_frames, + .tx_coalesce_usecs_irq =3D coalesce->tx_coalesce_usecs_irq, + .tx_max_coalesced_frames_irq =3D coalesce->tx_max_coalesced_frames= _irq, + .stats_block_coalesce_usecs =3D coalesce->stats_block_coalesce_use= cs, + .use_adaptive_rx_coalesce =3D coalesce->use_adaptive_rx_coalesce, + .use_adaptive_tx_coalesce =3D coalesce->use_adaptive_tx_coalesce, + .pkt_rate_low =3D coalesce->pkt_rate_low, + .rx_coalesce_usecs_low =3D coalesce->rx_coalesce_usecs_low, + .rx_max_coalesced_frames_low =3D coalesce->rx_max_coalesced_frames= _low, + .tx_coalesce_usecs_low =3D coalesce->tx_coalesce_usecs_low, + .tx_max_coalesced_frames_low =3D coalesce->tx_max_coalesced_frames= _low, + .pkt_rate_high =3D coalesce->pkt_rate_high, + .rx_coalesce_usecs_high =3D coalesce->rx_coalesce_usecs_high, + .rx_max_coalesced_frames_high =3D coalesce->rx_max_coalesced_frame= s_high, + .tx_coalesce_usecs_high =3D coalesce->tx_coalesce_usecs_high, + .tx_max_coalesced_frames_high =3D coalesce->tx_max_coalesced_frame= s_high, + .rate_sample_interval =3D coalesce->rate_sample_interval, + }; + + if ((fd =3D virNetDevSetupControl(ifname, &ifr)) < 0) + return -1; + + ifr.ifr_data =3D (void *) &coal; + + if (virNetDevSendEthtoolIoctl(fd, &ifr) < 0) { + virReportSystemError(errno, + _("Cannot set coalesce info on '%s'"), + ifname); + goto cleanup; + } + + coal =3D (struct ethtool_coalesce) { + .cmd =3D ETHTOOL_GCOALESCE, + }; + + /* Don't fail if the update itself fails */ + virNetDevSendEthtoolIoctl(fd, &ifr); + + ret =3D 0; + cleanup: + VIR_FORCE_CLOSE(fd); + return ret; +} +# else +int virNetDevSetCoalesce(const char *ifname, + virNetDevCoalescePtr coalesce ATTRIBUTE_UNUSED) +{ + virReportSystemError(ENOSYS, + _("Cannot set coalesce info on interface '%s'"), + ifname); + return -1; +} +# endif + + /** * virNetDevGetFeatures: * This function gets the nic offloads features available for ifname diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h index 12a31236c546..19036cca25c0 100644 --- a/src/util/virnetdev.h +++ b/src/util/virnetdev.h @@ -112,6 +112,36 @@ typedef enum { VIR_ENUM_DECL(virNetDevFeature) +/* Modeled after struct ethtool_coalesce, see linux/ethtool.h for explanat= ions + * of particular fields */ +typedef struct _virNetDevCoalesce virNetDevCoalesce; +typedef virNetDevCoalesce *virNetDevCoalescePtr; +struct _virNetDevCoalesce { + uint32_t rx_coalesce_usecs; + uint32_t rx_max_coalesced_frames; + uint32_t rx_coalesce_usecs_irq; + uint32_t rx_max_coalesced_frames_irq; + uint32_t tx_coalesce_usecs; + uint32_t tx_max_coalesced_frames; + uint32_t tx_coalesce_usecs_irq; + uint32_t tx_max_coalesced_frames_irq; + uint32_t stats_block_coalesce_usecs; + uint32_t use_adaptive_rx_coalesce; + uint32_t use_adaptive_tx_coalesce; + uint32_t pkt_rate_low; + uint32_t rx_coalesce_usecs_low; + uint32_t rx_max_coalesced_frames_low; + uint32_t tx_coalesce_usecs_low; + uint32_t tx_max_coalesced_frames_low; + uint32_t pkt_rate_high; + uint32_t rx_coalesce_usecs_high; + uint32_t rx_max_coalesced_frames_high; + uint32_t tx_coalesce_usecs_high; + uint32_t tx_max_coalesced_frames_high; + uint32_t rate_sample_interval; +}; + + int virNetDevSetupControl(const char *ifname, virIfreq *ifr) ATTRIBUTE_RETURN_CHECK; @@ -144,6 +174,10 @@ int virNetDevRestoreMacAddress(const char *linkdev, const char *stateDir) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; +int virNetDevSetCoalesce(const char *ifname, + virNetDevCoalescePtr coalesce) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; + int virNetDevSetMTU(const char *ifname, int mtu) ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 06:20:33 2024 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 1492691366650105.96429482413794; Thu, 20 Apr 2017 05:29:26 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9A4912E6066; Thu, 20 Apr 2017 12:29:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 68587189F3; Thu, 20 Apr 2017 12:29:24 +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 175DE5EC67; Thu, 20 Apr 2017 12:29: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 v3KCLqwZ020758 for ; Thu, 20 Apr 2017 08:21:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id CF69A5B80D; Thu, 20 Apr 2017 12:21:52 +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 2F154189F3 for ; Thu, 20 Apr 2017 12:21:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9A4912E6066 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.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 9A4912E6066 From: Martin Kletzander To: libvir-list@redhat.com Date: Thu, 20 Apr 2017 14:21:45 +0200 Message-Id: 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 v2 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 20 Apr 2017 12:29:25 +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 | 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=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..eb4b0f7437ba 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2509,6 +2509,9 @@
         
       
       
+        
+      
+      
         
           
             
@@ -5743,4 +5746,132 @@
       
     
   
+
+  
+    
+      
+        
+          
+            
+              
+                
+                  
+                    
+                  
+                
+                
+              
+            
+            
+          
+        
+        
+      
+    
+  
+
 
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 =3D NULL;
+    xmlNodePtr save =3D NULL;
+    char *str =3D NULL;
+    unsigned long long tmp =3D 0;
+
+    save =3D ctxt->node;
+    ctxt->node =3D node;
+
+    str =3D 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 =3D tmp;
+
+ cleanup:
+    ctxt->node =3D save;
+    return ret;
+
+ error:
+    VIR_FREE(ret);
+    goto cleanup;
+}
+
+static void
+virDomainNetDefCoalesceFormatXML(virBufferPtr buf,
+                                 virNetDevCoalescePtr coalesce)
+{
+    if (!coalesce || !coalesce->rx_max_coalesced_frames)
+        return;
+
+    virBufferAddLit(buf, "\n");
+    virBufferAdjustIndent(buf, 2);
+
+    virBufferAddLit(buf, "\n");
+    virBufferAdjustIndent(buf, 2);
+
+    virBufferAsprintf(buf, "\n",
+                      coalesce->rx_max_coalesced_frames);
+
+    virBufferAdjustIndent(buf, -2);
+    virBufferAddLit(buf, "\n");
+
+    virBufferAdjustIndent(buf, -2);
+    virBufferAddLit(buf, "\n");
+}
+
+
 static int
 virDomainHostdevDefParseXMLCaps(xmlNodePtr node ATTRIBUTE_UNUSED,
                                 xmlXPathContextPtr ctxt,
@@ -10255,6 +10326,13 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlo=
pt,
         goto error;
     }

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

+    virDomainNetDefCoalesceFormatXML(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 7da554f8ee28..3b6b17451618 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/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index b3e1573c690d..d906fe6fdd4f 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2984,6 +2984,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,
@@ -3018,6 +3042,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..b510324427d3
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-coalesce.xml
@@ -0,0 +1,68 @@
+
+  test
+  15d091de-0181-456b-9554-e4382dc1f1ab
+  1048576
+  1048576
+  1
+  
+    hvm
+    
+    
+    
+  
+  
+  destroy
+  restart
+  restart
+  
+    /usr/bin/qemu-system-x86_64
+    
+      
+      
+      
+      
+ + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml b/tes= ts/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml new file mode 100644 index 000000000000..fd5fdbece528 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml @@ -0,0 +1,71 @@ + + test + 15d091de-0181-456b-9554-e4382dc1f1ab + 1048576 + 1048576 + 1 + + hvm + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + + + +
+ + + + + + +
+ + +
+ + +
+ + +
+ + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index e4b510fd31ee..2dccde746ef1 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -528,6 +528,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 From nobody Mon Apr 29 06:20:33 2024 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 1492690953590398.5261894849418; Thu, 20 Apr 2017 05:22:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7EB26C05683F; Thu, 20 Apr 2017 12:22:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C23D8FF72; Thu, 20 Apr 2017 12:22:31 +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 BADF1B3183; Thu, 20 Apr 2017 12:22:12 +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 v3KCLrH2020766 for ; Thu, 20 Apr 2017 08:21:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9DCC0189F3; Thu, 20 Apr 2017 12:21:53 +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 271D781411 for ; Thu, 20 Apr 2017 12:21:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7EB26C05683F 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 7EB26C05683F From: Martin Kletzander To: libvir-list@redhat.com Date: Thu, 20 Apr 2017 14:21:46 +0200 Message-Id: <657b77d17b52622eca9df738bc2447e37931809f.1492690857.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 v2 3/3] Set coalesce settings for domain interfaces 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 20 Apr 2017 12:22:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch makes use of the virNetDevSetCoalesce() function to make appropriate settings effective for devices that support them. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1414627 Signed-off-by: Martin Kletzander --- src/bhyve/bhyve_command.c | 2 +- src/network/bridge_driver.c | 2 +- src/qemu/qemu_interface.c | 2 +- src/uml/uml_conf.c | 2 +- src/util/virnetdevtap.c | 5 +++++ src/util/virnetdevtap.h | 2 ++ tests/bhyvexml2argvmock.c | 1 + 7 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index e0528ed77a2c..e9c072b9f578 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -100,7 +100,7 @@ bhyveBuildNetArgStr(virConnectPtr conn, def->uuid, NULL, NULL, 0, virDomainNetGetActualVirtPortPr= ofile(net), virDomainNetGetActualVlan(net), - 0, NULL, + NULL, 0, NULL, VIR_NETDEV_TAP_CREATE_IFUP | VI= R_NETDEV_TAP_CREATE_PERSIST) < 0) { goto cleanup; } diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 45abe16964b8..d2d8557d280d 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -2311,7 +2311,7 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr d= river, if (virNetDevTapCreateInBridgePort(network->def->bridge, &macTapIfName, &network->def->m= ac, NULL, NULL, &tapfd, 1, NULL, NU= LL, - network->def->mtu, NULL, + NULL, network->def->mtu, NULL, VIR_NETDEV_TAP_CREATE_USE_MAC_F= OR_BRIDGE | VIR_NETDEV_TAP_CREATE_IFUP | VIR_NETDEV_TAP_CREATE_PERSIST) = < 0) { diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index c5dca60f1f65..2057ac9293f2 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -545,7 +545,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def, def->uuid, tunpath, tapfd, *tap= fdSize, virDomainNetGetActualVirtPortPr= ofile(net), virDomainNetGetActualVlan(net), - net->mtu, mtu, + net->coalesce, net->mtu, mtu, tap_create_flags) < 0) { virDomainAuditNetDevice(def, net, tunpath, false); goto cleanup; diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index 871653c5a64c..bdef78324385 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -125,7 +125,7 @@ umlConnectTapDevice(virDomainDefPtr vm, vm->uuid, net->backend.tap, &tapfd,= 1, virDomainNetGetActualVirtPortProfil= e(net), virDomainNetGetActualVlan(net), - 0, NULL, + NULL, 0, NULL, VIR_NETDEV_TAP_CREATE_IFUP | VIR_NETDEV_TAP_CREATE_PERSIST) < 0)= { if (template_ifname) diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index 02ef7fd24047..4d333d75e4c5 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -584,6 +584,7 @@ virNetDevTapAttachBridge(const char *tapname, * @tapfd: array of file descriptor return value for the new tap device * @tapfdSize: number of file descriptors in @tapfd * @virtPortProfile: bridge/port specific configuration + * @coalesce: optional coalesce parameters * @mtu: requested MTU for port (or 0 for "default") * @actualMTU: MTU actually set for port (after accounting for bridge's MT= U) * @flags: OR of virNetDevTapCreateFlags: @@ -616,6 +617,7 @@ int virNetDevTapCreateInBridgePort(const char *brname, size_t tapfdSize, virNetDevVPortProfilePtr virtPortProfil= e, virNetDevVlanPtr virtVlan, + virNetDevCoalescePtr coalesce, unsigned int mtu, unsigned int *actualMTU, unsigned int flags) @@ -661,6 +663,9 @@ int virNetDevTapCreateInBridgePort(const char *brname, if (virNetDevSetOnline(*ifname, !!(flags & VIR_NETDEV_TAP_CREATE_IFUP)= ) < 0) goto error; + if (virNetDevSetCoalesce(*ifname, coalesce) < 0) + goto error; + return 0; error: diff --git a/src/util/virnetdevtap.h b/src/util/virnetdevtap.h index 311f0698b155..0b17feb8d94d 100644 --- a/src/util/virnetdevtap.h +++ b/src/util/virnetdevtap.h @@ -24,6 +24,7 @@ # define __VIR_NETDEV_TAP_H__ # include "internal.h" +# include "virnetdev.h" # include "virnetdevvportprofile.h" # include "virnetdevvlan.h" @@ -83,6 +84,7 @@ int virNetDevTapCreateInBridgePort(const char *brname, size_t tapfdSize, virNetDevVPortProfilePtr virtPortProfil= e, virNetDevVlanPtr virtVlan, + virNetDevCoalescePtr coalesce, unsigned int mtu, unsigned int *actualMTU, unsigned int flags) diff --git a/tests/bhyvexml2argvmock.c b/tests/bhyvexml2argvmock.c index fd714694f0bd..7afa0e34c43c 100644 --- a/tests/bhyvexml2argvmock.c +++ b/tests/bhyvexml2argvmock.c @@ -28,6 +28,7 @@ int virNetDevTapCreateInBridgePort(const char *brname ATT= RIBUTE_UNUSED, size_t tapfdSize ATTRIBUTE_UNUSED, virNetDevVPortProfilePtr virtPortProfil= e ATTRIBUTE_UNUSED, virNetDevVlanPtr virtVlan ATTRIBUTE_UNU= SED, + virNetDevCoalescePtr coalesce ATTRIBUTE= _UNUSED, unsigned int mtu ATTRIBUTE_UNUSED, unsigned int *actualMTU ATTRIBUTE_UNUSE= D, unsigned int fakeflags ATTRIBUTE_UNUSED) --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list