From nobody Mon Apr 29 07:44:21 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 149753078019163.62662386420607; Thu, 15 Jun 2017 05:46:20 -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 38E9F80C06; Thu, 15 Jun 2017 12:46:18 +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 D5756182DB; Thu, 15 Jun 2017 12:46:17 +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 2AE811841C44; Thu, 15 Jun 2017 12:46:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5FCi9iC028382 for ; Thu, 15 Jun 2017 08:44:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id D03AB80747; Thu, 15 Jun 2017 12:44:09 +0000 (UTC) Received: from caroline.brq.redhat.com (unknown [10.43.2.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3249F182DB for ; Thu, 15 Jun 2017 12:44:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 38E9F80C06 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.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 38E9F80C06 From: Martin Kletzander To: libvir-list@redhat.com Date: Thu, 15 Jun 2017 14:44:02 +0200 Message-Id: <0e1844b2881ea59f27b2a284f9d7653ea34c38c4.1497530642.git.mkletzan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: Allow live-updates of coalesce settings 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.26]); Thu, 15 Jun 2017 12:46:18 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Change the settings from qemuDomainUpdateDeviceLive() as otherwise the call would succeed even though nothing has changed. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1460862 Signed-off-by: Martin Kletzander --- src/qemu/qemu_hotplug.c | 13 ++++++ src/util/virnetdev.c | 103 +++++++++++++++++++++++++++++++-------------= ---- src/util/virnetdev.h | 3 +- src/util/virnetdevtap.c | 2 +- 4 files changed, 83 insertions(+), 38 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 0b8d3d80f173..244dd5e605e6 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2986,6 +2986,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, bool needLinkStateChange =3D false; bool needReplaceDevDef =3D false; bool needBandwidthSet =3D false; + bool needCoalesceChange =3D false; int ret =3D -1; int changeidx =3D -1; @@ -3280,6 +3281,12 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, virDomainNetGetActualBandwidth(newdev))) needBandwidthSet =3D true; + if (!!olddev->coalesce !=3D !!newdev->coalesce || + (olddev->coalesce && newdev->coalesce && + !memcmp(olddev->coalesce, newdev->coalesce, + sizeof(*olddev->coalesce)))) + needCoalesceChange =3D true; + /* FINALLY - actually perform the required actions */ if (needReconnect) { @@ -3315,6 +3322,12 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, needReplaceDevDef =3D true; } + if (needCoalesceChange) { + if (virNetDevSetCoalesce(newdev->ifname, newdev->coalesce, true) <= 0) + goto cleanup; + needReplaceDevDef =3D true; + } + if (needLinkStateChange && qemuDomainChangeNetLinkState(driver, vm, olddev, newdev->linkstate= ) < 0) { goto cleanup; diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index e75a1c970505..90b7bee34ae7 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -3086,7 +3086,8 @@ virNetDevGetEthtoolGFeatures(virBitmapPtr bitmap ATTR= IBUTE_UNUSED, /** * virNetDevSetCoalesce: * @ifname: interface name to modify - * @coalesce: Coalesce settings to set and update + * @coalesce: Coalesce settings to set or update + * @update: Whether this is an update for existing settings or not * * This function sets the various coalesce settings for a given interface * @ifname and updates them back into @coalesce. @@ -3094,40 +3095,44 @@ virNetDevGetEthtoolGFeatures(virBitmapPtr bitmap AT= TRIBUTE_UNUSED, * Returns 0 in case of success or -1 on failure */ int virNetDevSetCoalesce(const char *ifname, - virNetDevCoalescePtr coalesce) + virNetDevCoalescePtr coalesce, + bool update) { int fd =3D -1; int ret =3D -1; struct ifreq ifr; struct ethtool_coalesce coal =3D {0}; - if (!coalesce) + if (!coalesce && !update) 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 (coalesce) { + coal =3D (struct ethtool_coalesce) { + .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_fr= ames_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_fr= ames_irq, + .stats_block_coalesce_usecs =3D coalesce->stats_block_coalesce= _usecs, + .use_adaptive_rx_coalesce =3D coalesce->use_adaptive_rx_coales= ce, + .use_adaptive_tx_coalesce =3D coalesce->use_adaptive_tx_coales= ce, + .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_fr= ames_low, + .tx_coalesce_usecs_low =3D coalesce->tx_coalesce_usecs_low, + .tx_max_coalesced_frames_low =3D coalesce->tx_max_coalesced_fr= ames_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_f= rames_high, + .tx_coalesce_usecs_high =3D coalesce->tx_coalesce_usecs_high, + .tx_max_coalesced_frames_high =3D coalesce->tx_max_coalesced_f= rames_high, + .rate_sample_interval =3D coalesce->rate_sample_interval, + }; + } + + coal.cmd =3D ETHTOOL_SCOALESCE; if ((fd =3D virNetDevSetupControl(ifname, &ifr)) < 0) return -1; @@ -3141,12 +3146,36 @@ int virNetDevSetCoalesce(const char *ifname, goto cleanup; } - coal =3D (struct ethtool_coalesce) { - .cmd =3D ETHTOOL_GCOALESCE, - }; + if (coalesce) { + coal =3D (struct ethtool_coalesce) { + .cmd =3D ETHTOOL_GCOALESCE, + }; - /* Don't fail if the update itself fails */ - virNetDevSendEthtoolIoctl(fd, &ifr); + /* Don't fail if the update itself fails */ + if (virNetDevSendEthtoolIoctl(fd, &ifr) =3D=3D 0) { + coalesce->rx_max_coalesced_frames =3D coal.rx_max_coalesced_fr= ames; + coalesce->rx_coalesce_usecs_irq =3D coal.rx_coalesce_usecs_irq; + coalesce->rx_max_coalesced_frames_irq =3D coal.rx_max_coalesce= d_frames_irq; + coalesce->tx_coalesce_usecs =3D coal.tx_coalesce_usecs; + coalesce->tx_max_coalesced_frames =3D coal.tx_max_coalesced_fr= ames; + coalesce->tx_coalesce_usecs_irq =3D coal.tx_coalesce_usecs_irq; + coalesce->tx_max_coalesced_frames_irq =3D coal.tx_max_coalesce= d_frames_irq; + coalesce->stats_block_coalesce_usecs =3D coal.stats_block_coal= esce_usecs; + coalesce->use_adaptive_rx_coalesce =3D coal.use_adaptive_rx_co= alesce; + coalesce->use_adaptive_tx_coalesce =3D coal.use_adaptive_tx_co= alesce; + coalesce->pkt_rate_low =3D coal.pkt_rate_low; + coalesce->rx_coalesce_usecs_low =3D coal.rx_coalesce_usecs_low; + coalesce->rx_max_coalesced_frames_low =3D coal.rx_max_coalesce= d_frames_low; + coalesce->tx_coalesce_usecs_low =3D coal.tx_coalesce_usecs_low; + coalesce->tx_max_coalesced_frames_low =3D coal.tx_max_coalesce= d_frames_low; + coalesce->pkt_rate_high =3D coal.pkt_rate_high; + coalesce->rx_coalesce_usecs_high =3D coal.rx_coalesce_usecs_hi= gh; + coalesce->rx_max_coalesced_frames_high =3D coal.rx_max_coalesc= ed_frames_high; + coalesce->tx_coalesce_usecs_high =3D coal.tx_coalesce_usecs_hi= gh; + coalesce->tx_max_coalesced_frames_high =3D coal.tx_max_coalesc= ed_frames_high; + coalesce->rate_sample_interval =3D coal.rate_sample_interval; + } + } ret =3D 0; cleanup: @@ -3155,9 +3184,10 @@ int virNetDevSetCoalesce(const char *ifname, } # else int virNetDevSetCoalesce(const char *ifname, - virNetDevCoalescePtr coalesce) + virNetDevCoalescePtr coalesce, + bool update) { - if (!coalesce) + if (!coalesce && !update) return 0; virReportSystemError(ENOSYS, @@ -3216,9 +3246,10 @@ virNetDevGetFeatures(const char *ifname ATTRIBUTE_UN= USED, } int virNetDevSetCoalesce(const char *ifname, - virNetDevCoalescePtr coalesce) + virNetDevCoalescePtr coalesce, + bool update) { - if (!coalesce) + if (!coalesce && !update) return 0; virReportSystemError(ENOSYS, diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h index c7494cd608f3..51fcae544e89 100644 --- a/src/util/virnetdev.h +++ b/src/util/virnetdev.h @@ -180,7 +180,8 @@ int virNetDevRestoreMacAddress(const char *linkdev, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; int virNetDevSetCoalesce(const char *ifname, - virNetDevCoalescePtr coalesce) + virNetDevCoalescePtr coalesce, + bool update) ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; int virNetDevSetMTU(const char *ifname, diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index c8dacfe27b94..175dc2bfaae3 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -663,7 +663,7 @@ int virNetDevTapCreateInBridgePort(const char *brname, if (virNetDevSetOnline(*ifname, !!(flags & VIR_NETDEV_TAP_CREATE_IFUP)= ) < 0) goto error; - if (virNetDevSetCoalesce(*ifname, coalesce) < 0) + if (virNetDevSetCoalesce(*ifname, coalesce, false) < 0) goto error; return 0; --=20 2.13.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list