From nobody Sun Feb 8 19:54:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1486480876567542.1682702911473; Tue, 7 Feb 2017 07:21:16 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v17FH1bc027205; Tue, 7 Feb 2017 10:17:01 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v17FH0gS023382 for ; Tue, 7 Feb 2017 10:17:00 -0500 Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v17FH0P7019248 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 7 Feb 2017 10:17:00 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 23670C05AA42 for ; Tue, 7 Feb 2017 15:16:59 +0000 (UTC) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v17FCMnb048415 for ; Tue, 7 Feb 2017 10:16:57 -0500 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 28feqjf1x3-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 07 Feb 2017 10:16:57 -0500 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 Feb 2017 15:16:54 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 7 Feb 2017 15:16:48 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 2E6DC17D805A; Tue, 7 Feb 2017 15:19:51 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v17FGlg34718880; Tue, 7 Feb 2017 15:16:47 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB2E6AE04D; Tue, 7 Feb 2017 14:14:41 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9E68BAE045; Tue, 7 Feb 2017 14:14:41 +0000 (GMT) Received: from fiuczyvm.boeblingen.de.ibm.com (unknown [9.152.222.92]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 7 Feb 2017 14:14:41 +0000 (GMT) From: Boris Fiuczynski To: libvir-list@redhat.com, mprivozn@redhat.com, laine@laine.org Date: Tue, 7 Feb 2017 16:16:43 +0100 In-Reply-To: <1486480604-29957-1-git-send-email-fiuczy@linux.vnet.ibm.com> References: <1486480604-29957-1-git-send-email-fiuczy@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17020715-0008-0000-0000-000003E3EEFA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020715-0009-0000-0000-00001C60E30F Message-Id: <1486480604-29957-3-git-send-email-fiuczy@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-07_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702070145 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 200 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 07 Feb 2017 15:16:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 07 Feb 2017 15:16:59 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'fiuczy@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -1.787 (BAYES_50, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-loop: libvir-list@redhat.com Cc: stzi@linux.vnet.ibm.com Subject: [libvirt] [PATCH v3 2/3] network: allow to specify timeout for openvswitch calls 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patchs allows to set the timeout value used for all openvswitch calls. The default timeout value remains as before at 5 seconds. Signed-off-by: Boris Fiuczynski Reviewed-by: Bjoern Walk --- src/libvirt_private.syms | 1 + src/util/virnetdevopenvswitch.c | 64 +++++++++++++++++++++++++++++++++++--= ---- src/util/virnetdevopenvswitch.h | 4 +++ 3 files changed, 61 insertions(+), 8 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d556c7d..0a7de9a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2078,6 +2078,7 @@ virNetDevOpenvswitchGetVhostuserIfname; virNetDevOpenvswitchInterfaceStats; virNetDevOpenvswitchRemovePort; virNetDevOpenvswitchSetMigrateData; +virNetDevOpenvswitchSetTimeout; =20 =20 # util/virnetdevtap.h diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index e6cb096..3a11fb4 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -1,6 +1,7 @@ /* * Copyright (C) 2013 Red Hat, Inc. * Copyright (C) 2012 Nicira, Inc. + * Copyright (C) 2017 IBM Corporation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,6 +21,7 @@ * Dan Wendlandt * Kyle Mestery * Ansis Atteka + * Boris Fiuczynski */ =20 #include @@ -38,6 +40,23 @@ =20 VIR_LOG_INIT("util.netdevopenvswitch"); =20 +/* + * Set openvswitch default timout + */ +static unsigned int virNetDevOpenvswitchTimeout =3D VIR_NETDEV_OVS_DEFAULT= _TIMEOUT; + +/** + * virNetDevOpenvswitchSetTimeout: + * @timeout: the timeout in seconds + * + * Set the openvswitch timeout + */ +void +virNetDevOpenvswitchSetTimeout(unsigned int timeout) +{ + virNetDevOpenvswitchTimeout =3D timeout; +} + /** * virNetDevOpenvswitchAddPort: * @brname: the bridge name @@ -66,6 +85,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, const= char *ifname, char *ifaceid_ex_id =3D NULL; char *profile_ex_id =3D NULL; char *vmid_ex_id =3D NULL; + char *ovs_timeout =3D NULL; virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 virMacAddrFormat(macaddr, macaddrstr); @@ -86,10 +106,12 @@ int virNetDevOpenvswitchAddPort(const char *brname, co= nst char *ifname, ovsport->profileID) < 0) goto cleanup; } + if (virAsprintf(&ovs_timeout, "--timeout=3D%d", virNetDevOpenvswitchTi= meout) < 0) + goto cleanup; =20 cmd =3D virCommandNew(OVSVSCTL); =20 - virCommandAddArgList(cmd, "--timeout=3D5", "--", "--if-exists", "del-p= ort", + virCommandAddArgList(cmd, ovs_timeout, "--", "--if-exists", "del-port", ifname, "--", "add-port", brname, ifname, NULL); =20 if (virtVlan && virtVlan->nTags > 0) { @@ -165,6 +187,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, con= st char *ifname, VIR_FREE(ifaceid_ex_id); VIR_FREE(vmid_ex_id); VIR_FREE(profile_ex_id); + VIR_FREE(ovs_timeout); virCommandFree(cmd); return ret; } @@ -181,9 +204,13 @@ int virNetDevOpenvswitchRemovePort(const char *brname = ATTRIBUTE_UNUSED, const ch { int ret =3D -1; virCommandPtr cmd =3D NULL; + char *ovs_timeout =3D NULL; + + if (virAsprintf(&ovs_timeout, "--timeout=3D%d", virNetDevOpenvswitchTi= meout) < 0) + goto cleanup; =20 cmd =3D virCommandNew(OVSVSCTL); - virCommandAddArgList(cmd, "--timeout=3D5", "--", "--if-exists", "del-p= ort", ifname, NULL); + virCommandAddArgList(cmd, ovs_timeout, "--", "--if-exists", "del-port"= , ifname, NULL); =20 if (virCommandRun(cmd, NULL) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -194,6 +221,7 @@ int virNetDevOpenvswitchRemovePort(const char *brname A= TTRIBUTE_UNUSED, const ch ret =3D 0; cleanup: virCommandFree(cmd); + VIR_FREE(ovs_timeout); return ret; } =20 @@ -211,8 +239,12 @@ int virNetDevOpenvswitchGetMigrateData(char **migrate,= const char *ifname) virCommandPtr cmd =3D NULL; size_t len; int ret =3D -1; + char *ovs_timeout =3D NULL; =20 - cmd =3D virCommandNewArgList(OVSVSCTL, "--timeout=3D5", "--if-exists",= "get", "Interface", + if (virAsprintf(&ovs_timeout, "--timeout=3D%d", virNetDevOpenvswitchTi= meout) < 0) + goto cleanup; + + cmd =3D virCommandNewArgList(OVSVSCTL, ovs_timeout, "--if-exists", "ge= t", "Interface", ifname, "external_ids:PortData", NULL); =20 virCommandSetOutputBuffer(cmd, migrate); @@ -233,6 +265,7 @@ int virNetDevOpenvswitchGetMigrateData(char **migrate, = const char *ifname) ret =3D 0; cleanup: virCommandFree(cmd); + VIR_FREE(ovs_timeout); return ret; } =20 @@ -249,13 +282,17 @@ int virNetDevOpenvswitchSetMigrateData(char *migrate,= const char *ifname) { virCommandPtr cmd =3D NULL; int ret =3D -1; + char *ovs_timeout =3D NULL; =20 if (!migrate) { VIR_DEBUG("No OVS port data for interface %s", ifname); return 0; } =20 - cmd =3D virCommandNewArgList(OVSVSCTL, "--timeout=3D5", "set", + if (virAsprintf(&ovs_timeout, "--timeout=3D%d", virNetDevOpenvswitchTi= meout) < 0) + goto cleanup; + + cmd =3D virCommandNewArgList(OVSVSCTL, ovs_timeout, "set", "Interface", ifname, NULL); virCommandAddArgFormat(cmd, "external_ids:PortData=3D%s", migrate); =20 @@ -270,6 +307,7 @@ int virNetDevOpenvswitchSetMigrateData(char *migrate, c= onst char *ifname) ret =3D 0; cleanup: virCommandFree(cmd); + VIR_FREE(ovs_timeout); return ret; } =20 @@ -297,9 +335,13 @@ virNetDevOpenvswitchInterfaceStats(const char *ifname, long long tx_errs; long long tx_drop; int ret =3D -1; + char *ovs_timeout =3D NULL; + + if (virAsprintf(&ovs_timeout, "--timeout=3D%d", virNetDevOpenvswitchTi= meout) < 0) + goto cleanup; =20 /* Just ensure the interface exists in ovs */ - cmd =3D virCommandNewArgList(OVSVSCTL, "--timeout=3D5", + cmd =3D virCommandNewArgList(OVSVSCTL, ovs_timeout, "get", "Interface", ifname, "name", NULL); virCommandSetOutputBuffer(cmd, &output); @@ -314,7 +356,7 @@ virNetDevOpenvswitchInterfaceStats(const char *ifname, VIR_FREE(output); virCommandFree(cmd); =20 - cmd =3D virCommandNewArgList(OVSVSCTL, "--timeout=3D5", + cmd =3D virCommandNewArgList(OVSVSCTL, ovs_timeout, "get", "Interface", ifname, "statistics:rx_bytes", "statistics:rx_packets", @@ -345,7 +387,7 @@ virNetDevOpenvswitchInterfaceStats(const char *ifname, VIR_FREE(output); virCommandFree(cmd); =20 - cmd =3D virCommandNewArgList(OVSVSCTL, "--timeout=3D5", + cmd =3D virCommandNewArgList(OVSVSCTL, ovs_timeout, "get", "Interface", ifname, "statistics:rx_errors", "statistics:rx_dropped", @@ -375,6 +417,7 @@ virNetDevOpenvswitchInterfaceStats(const char *ifname, cleanup: VIR_FREE(output); virCommandFree(cmd); + VIR_FREE(ovs_timeout); return ret; } =20 @@ -399,6 +442,7 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path, size_t ntokens =3D 0; int status; int ret =3D -1; + char *ovs_timeout =3D NULL; =20 /* Openvswitch vhostuser path are hardcoded to * //openvswitch/ @@ -412,7 +456,10 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *pat= h, goto cleanup; } =20 - cmd =3D virCommandNewArgList(OVSVSCTL, "--timeout=3D5", "get", "Interf= ace", + if (virAsprintf(&ovs_timeout, "--timeout=3D%d", virNetDevOpenvswitchTi= meout) < 0) + goto cleanup; + + cmd =3D virCommandNewArgList(OVSVSCTL, ovs_timeout, "get", "Interface", tmpIfname, "name", NULL); if (virCommandRun(cmd, &status) < 0 || status) { @@ -428,5 +475,6 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path, cleanup: virStringListFreeCount(tokens, ntokens); virCommandFree(cmd); + VIR_FREE(ovs_timeout); return ret; } diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitc= h.h index 01f6233..4f62be1 100644 --- a/src/util/virnetdevopenvswitch.h +++ b/src/util/virnetdevopenvswitch.h @@ -1,6 +1,7 @@ /* * Copyright (C) 2013 Red Hat, Inc. * Copyright (C) 2012 Nicira, Inc. + * Copyright (C) 2017 IBM Corporation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,6 +21,7 @@ * Dan Wendlandt * Kyle Mestery * Ansis Atteka + * Boris Fiuczynski */ =20 #ifndef __VIR_NETDEV_OPENVSWITCH_H__ @@ -31,6 +33,8 @@ =20 # define VIR_NETDEV_OVS_DEFAULT_TIMEOUT 5 =20 +void virNetDevOpenvswitchSetTimeout(unsigned int timeout); + int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname, const virMacAddr *macaddr, --=20 2.5.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list