From nobody Mon Apr 29 10:02:13 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.zohomail.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 1500306890286303.86564612410643; Mon, 17 Jul 2017 08:54:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 751F0356DC; Mon, 17 Jul 2017 15:54:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3AD825C8BA; Mon, 17 Jul 2017 15:54:48 +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 D0FBD41F78; Mon, 17 Jul 2017 15:54:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6HFnNTG032563 for ; Mon, 17 Jul 2017 11:49:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4D5AB77BE8; Mon, 17 Jul 2017 15:49:23 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2878F779D2 for ; Mon, 17 Jul 2017 15:49:20 +0000 (UTC) Received: from smtp-1.arkena.net (smtp-1.arkena.net [95.81.173.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 475E4C058EA9 for ; Mon, 17 Jul 2017 15:49:18 +0000 (UTC) Received: from fool.tdf.fr (unknown [95.81.166.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-1.arkena.net (Postfix) with ESMTPSA id 3xB7576BHrzMcS1; Mon, 17 Jul 2017 15:49:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 751F0356DC Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=tdf.fr Authentication-Results: ext-mx06.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 751F0356DC DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 475E4C058EA9 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=tdf.fr Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=antoine.millet@tdf.fr DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 475E4C058EA9 From: Antoine Millet To: libvir-list@redhat.com Date: Mon, 17 Jul 2017 17:48:59 +0200 Message-Id: <20170717154900.23761-2-antoine.millet@tdf.fr> In-Reply-To: <20170717154900.23761-1-antoine.millet@tdf.fr> References: <20170717154900.23761-1-antoine.millet@tdf.fr> 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]); Mon, 17 Jul 2017 15:49:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 17 Jul 2017 15:49:19 +0000 (UTC) for IP:'95.81.173.12' DOMAIN:'smtp-1.arkena.net' HELO:'smtp-1.arkena.net' FROM:'antoine.millet@tdf.fr' RCPT:'' X-RedHat-Spam-Score: 0.77 (BAYES_50, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL) 95.81.173.12 smtp-1.arkena.net 95.81.173.12 smtp-1.arkena.net X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Mon, 17 Jul 2017 11:53:13 -0400 Cc: Antoine Millet , laine@laine.org Subject: [libvirt] [PATCH 1/2] Refactored OVS VLAN configuration 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 17 Jul 2017 15:54:49 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Moved OVS VLAN configuration arguments construction into a separated function to be reused. --- src/util/virnetdevopenvswitch.c | 104 ++++++++++++++++++++++++------------= ---- src/util/virnetdevopenvswitch.h | 5 ++ 2 files changed, 68 insertions(+), 41 deletions(-) diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index a5ecfb691..89ed0c91c 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -64,6 +64,67 @@ virNetDevOpenvswitchAddTimeout(virCommandPtr cmd) } =20 /** + * virNetDevOpenvswitchConstructVlans: + * @cmd: command to construct + * @virtVlan: VLAN configuration to be applied + * + * Construct the VLAN configuration parameters to be passed to ovs-vsctl c= ommand. + * + * Returns 0 in case of success or -1 in case of failure. + */ +int virNetDevOpenvswitchConstructVlans(virCommandPtr cmd, virNetDevVlanPtr= virtVlan) +{ + int ret =3D -1; + size_t i =3D 0; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + + if (virtVlan && virtVlan->nTags > 0) { + + switch (virtVlan->nativeMode) { + case VIR_NATIVE_VLAN_MODE_TAGGED: + virCommandAddArg(cmd, "vlan_mode=3Dnative-tagged"); + virCommandAddArgFormat(cmd, "tag=3D%d", virtVlan->nativeTag); + break; + case VIR_NATIVE_VLAN_MODE_UNTAGGED: + virCommandAddArg(cmd, "vlan_mode=3Dnative-untagged"); + virCommandAddArgFormat(cmd, "tag=3D%d", virtVlan->nativeTag); + break; + case VIR_NATIVE_VLAN_MODE_DEFAULT: + default: + break; + } + + if (virtVlan->trunk) { + virBufferAddLit(&buf, "trunk=3D"); + + /* + * Trunk ports have at least one VLAN. Do the first one + * outside the "for" loop so we can put a "," at the + * start of the for loop if there are more than one VLANs + * on this trunk port. + */ + virBufferAsprintf(&buf, "%d", virtVlan->tag[i]); + + for (i =3D 1; i < virtVlan->nTags; i++) { + virBufferAddLit(&buf, ","); + virBufferAsprintf(&buf, "%d", virtVlan->tag[i]); + } + + if (virBufferCheckError(&buf) < 0) + goto cleanup; + virCommandAddArg(cmd, virBufferCurrentContent(&buf)); + } else if (virtVlan->nTags) { + virCommandAddArgFormat(cmd, "tag=3D%d", virtVlan->tag[0]); + } + } + + ret =3D 0; + cleanup: + virBufferFreeAndReset(&buf); + return ret; +} + +/** * virNetDevOpenvswitchAddPort: * @brname: the bridge name * @ifname: the network interface name @@ -82,7 +143,6 @@ int virNetDevOpenvswitchAddPort(const char *brname, cons= t char *ifname, virNetDevVlanPtr virtVlan) { int ret =3D -1; - size_t i =3D 0; virCommandPtr cmd =3D NULL; char macaddrstr[VIR_MAC_STRING_BUFLEN]; char ifuuidstr[VIR_UUID_STRING_BUFLEN]; @@ -91,7 +151,6 @@ int virNetDevOpenvswitchAddPort(const char *brname, cons= t char *ifname, char *ifaceid_ex_id =3D NULL; char *profile_ex_id =3D NULL; char *vmid_ex_id =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 virMacAddrFormat(macaddr, macaddrstr); virUUIDFormat(ovsport->interfaceID, ifuuidstr); @@ -117,44 +176,8 @@ int virNetDevOpenvswitchAddPort(const char *brname, co= nst char *ifname, virCommandAddArgList(cmd, "--", "--if-exists", "del-port", ifname, "--", "add-port", brname, ifname, NULL); =20 - if (virtVlan && virtVlan->nTags > 0) { - - switch (virtVlan->nativeMode) { - case VIR_NATIVE_VLAN_MODE_TAGGED: - virCommandAddArg(cmd, "vlan_mode=3Dnative-tagged"); - virCommandAddArgFormat(cmd, "tag=3D%d", virtVlan->nativeTag); - break; - case VIR_NATIVE_VLAN_MODE_UNTAGGED: - virCommandAddArg(cmd, "vlan_mode=3Dnative-untagged"); - virCommandAddArgFormat(cmd, "tag=3D%d", virtVlan->nativeTag); - break; - case VIR_NATIVE_VLAN_MODE_DEFAULT: - default: - break; - } - - if (virtVlan->trunk) { - virBufferAddLit(&buf, "trunk=3D"); - - /* - * Trunk ports have at least one VLAN. Do the first one - * outside the "for" loop so we can put a "," at the - * start of the for loop if there are more than one VLANs - * on this trunk port. - */ - virBufferAsprintf(&buf, "%d", virtVlan->tag[i]); - - for (i =3D 1; i < virtVlan->nTags; i++) { - virBufferAddLit(&buf, ","); - virBufferAsprintf(&buf, "%d", virtVlan->tag[i]); - } - - if (virBufferCheckError(&buf) < 0) - goto cleanup; - virCommandAddArg(cmd, virBufferCurrentContent(&buf)); - } else if (virtVlan->nTags) { - virCommandAddArgFormat(cmd, "tag=3D%d", virtVlan->tag[0]); - } + if (virNetDevOpenvswitchConstructVlans(cmd, virtVlan) < 0) { + goto cleanup; } =20 if (ovsport->profileID[0] =3D=3D '\0') { @@ -185,7 +208,6 @@ int virNetDevOpenvswitchAddPort(const char *brname, con= st char *ifname, =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&buf); VIR_FREE(attachedmac_ex_id); VIR_FREE(ifaceid_ex_id); VIR_FREE(vmid_ex_id); diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitc= h.h index 51bb1dd00..94b4c695b 100644 --- a/src/util/virnetdevopenvswitch.h +++ b/src/util/virnetdevopenvswitch.h @@ -30,11 +30,16 @@ # include "internal.h" # include "virnetdevvportprofile.h" # include "virnetdevvlan.h" +# include "vircommand.h" + =20 # define VIR_NETDEV_OVS_DEFAULT_TIMEOUT 5 =20 void virNetDevOpenvswitchSetTimeout(unsigned int timeout); =20 +int virNetDevOpenvswitchConstructVlans(virCommandPtr cmd, virNetDevVlanPtr= virtVlan) + ATTRIBUTE_RETURN_CHECK; + int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname, const virMacAddr *macaddr, --=20 2.13.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:02:13 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.zohomail.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 150030689569966.06550874528853; Mon, 17 Jul 2017 08:54:55 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E7E1AC058ED4; Mon, 17 Jul 2017 15:54:53 +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 C5D8C5E24A; Mon, 17 Jul 2017 15:54:53 +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 587911803B26; Mon, 17 Jul 2017 15:54:53 +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 v6HFnNu4032564 for ; Mon, 17 Jul 2017 11:49:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6661C7D934; Mon, 17 Jul 2017 15:49:23 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5EE3F7D932 for ; Mon, 17 Jul 2017 15:49:20 +0000 (UTC) Received: from smtp-1.arkena.net (smtp-1.arkena.net [95.81.173.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 535927F6B1 for ; Mon, 17 Jul 2017 15:49:18 +0000 (UTC) Received: from fool.tdf.fr (unknown [95.81.166.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-1.arkena.net (Postfix) with ESMTPSA id 3xB7576WV0zMcSh; Mon, 17 Jul 2017 15:49:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E7E1AC058ED4 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=tdf.fr 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 E7E1AC058ED4 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 535927F6B1 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=tdf.fr Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=antoine.millet@tdf.fr DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 535927F6B1 From: Antoine Millet To: libvir-list@redhat.com Date: Mon, 17 Jul 2017 17:49:00 +0200 Message-Id: <20170717154900.23761-3-antoine.millet@tdf.fr> In-Reply-To: <20170717154900.23761-1-antoine.millet@tdf.fr> References: <20170717154900.23761-1-antoine.millet@tdf.fr> 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.25]); Mon, 17 Jul 2017 15:49:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 17 Jul 2017 15:49:19 +0000 (UTC) for IP:'95.81.173.12' DOMAIN:'smtp-1.arkena.net' HELO:'smtp-1.arkena.net' FROM:'antoine.millet@tdf.fr' RCPT:'' X-RedHat-Spam-Score: 0.77 (BAYES_50, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL) 95.81.173.12 smtp-1.arkena.net 95.81.173.12 smtp-1.arkena.net X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Mon, 17 Jul 2017 11:53:13 -0400 Cc: Antoine Millet , laine@laine.org Subject: [libvirt] [PATCH 2/2] Handle hotplug change on VLAN configuration using OVS 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 17 Jul 2017 15:54:54 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" A new function virNetDevOpenvswitchUpdateVlan has been created to instruct OVS of the changes. qemuDomainChangeNet has been modified to handle the update of the VLAN configuration for a running guest and rely on virNetDevOpenvswitchUpdateVlan to do the actual update if needed. --- src/libvirt_private.syms | 1 + src/qemu/qemu_hotplug.c | 16 +++++++++++++--- src/util/virnetdevopenvswitch.c | 41 +++++++++++++++++++++++++++++++++++++= ++++ src/util/virnetdevopenvswitch.h | 4 ++++ 4 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 187b12b32..36caf6fbf 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2206,6 +2206,7 @@ virNetDevOpenvswitchInterfaceStats; virNetDevOpenvswitchRemovePort; virNetDevOpenvswitchSetMigrateData; virNetDevOpenvswitchSetTimeout; +virNetDevOpenvswitchUpdateVlan; =20 =20 # util/virnetdevtap.h diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 4bc49720b..b9ad9e6c8 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2998,6 +2998,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, bool needReplaceDevDef =3D false; bool needBandwidthSet =3D false; bool needCoalesceChange =3D false; + bool needVlanUpdate =3D false; int ret =3D -1; int changeidx =3D -1; =20 @@ -3279,12 +3280,15 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, virDomainNetGetActualDirectDev(newdev)) || virDomainNetGetActualDirectMode(olddev) !=3D virDomainNetGetActual= DirectMode(newdev) || !virNetDevVPortProfileEqual(virDomainNetGetActualVirtPortProfile(o= lddev), - virDomainNetGetActualVirtPortProfile(n= ewdev)) || - !virNetDevVlanEqual(virDomainNetGetActualVlan(olddev), - virDomainNetGetActualVlan(newdev))) { + virDomainNetGetActualVirtPortProfile(n= ewdev))) { needReconnect =3D true; } =20 + if (!virNetDevVlanEqual(virDomainNetGetActualVlan(olddev), + virDomainNetGetActualVlan(newdev))) { + needVlanUpdate =3D true; + } + if (olddev->linkstate !=3D newdev->linkstate) needLinkStateChange =3D true; =20 @@ -3344,6 +3348,12 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, goto cleanup; } =20 + if (needVlanUpdate) { + if (virNetDevOpenvswitchUpdateVlan(newdev->ifname, &newdev->vlan) = < 0) + goto cleanup; + needReplaceDevDef =3D true; + } + if (needReplaceDevDef) { /* the changes above warrant replacing olddev with newdev in * the domain's nets list. diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index 89ed0c91c..a12bc3dbc 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -459,3 +459,44 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *pat= h, VIR_FREE(ovs_timeout); return ret; } + +/** + * virNetDevOpenvswitchUpdateVlan: + * @ifname: the network interface name + * @virtVlan: VLAN configuration to be applied + * + * Update VLAN configuration of an OVS port. + * + * Returns 0 in case of success or -1 in case of failure. + */ +int virNetDevOpenvswitchUpdateVlan(const char *ifname, + virNetDevVlanPtr virtVlan) +{ + int ret =3D -1; + virCommandPtr cmd =3D NULL; + + cmd =3D virCommandNew(OVSVSCTL); + virNetDevOpenvswitchAddTimeout(cmd); + virCommandAddArgList(cmd, + "--", "--if-exists", "clear", "Port", ifname, "ta= g", + "--", "--if-exists", "clear", "Port", ifname, "tr= unk", + "--", "--if-exists", "clear", "Port", ifname, "vl= an_mode", + "--", "--if-exists", "set", "Port", ifname, NULL); + + if (virNetDevOpenvswitchConstructVlans(cmd, virtVlan) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to construct vlan configuration for port = %s"), ifname); + goto cleanup; + } + + if (virCommandRun(cmd, NULL) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to set vlan configuration on port %s"), i= fname); + goto cleanup; + } + + ret =3D 0; + cleanup: + virCommandFree(cmd); + return ret; +} diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitc= h.h index 94b4c695b..aa69ade6a 100644 --- a/src/util/virnetdevopenvswitch.h +++ b/src/util/virnetdevopenvswitch.h @@ -66,4 +66,8 @@ int virNetDevOpenvswitchGetVhostuserIfname(const char *pa= th, char **ifname) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NOINLINE; =20 +int virNetDevOpenvswitchUpdateVlan(const char *ifname, + virNetDevVlanPtr virtVlan) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; + #endif /* __VIR_NETDEV_OPENVSWITCH_H__ */ --=20 2.13.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list