From nobody Sat May 4 21:44:24 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 1493146247720569.2761582877953; Tue, 25 Apr 2017 11:50:47 -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 3DF686371B; Tue, 25 Apr 2017 18:50:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1AA1F17148; Tue, 25 Apr 2017 18:50:46 +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 CA9425EC62; Tue, 25 Apr 2017 18:50:45 +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 v3PIohDY030926 for ; Tue, 25 Apr 2017 14:50:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id F329D17CC1; Tue, 25 Apr 2017 18:50:42 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-65.phx2.redhat.com [10.3.116.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D47B84E1D; Tue, 25 Apr 2017 18:50:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3DF686371B Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=laine.org Authentication-Results: ext-mx10.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 3DF686371B From: Laine Stump To: libvir-list@redhat.com Date: Tue, 25 Apr 2017 14:50:35 -0400 Message-Id: <20170425185037.14805-2-laine@laine.org> In-Reply-To: <20170425185037.14805-1-laine@laine.org> References: <20170425185037.14805-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Martin Kletzander Subject: [libvirt] [PATCH v2 1/3] util: make macvtap/macvlan generated name #defines available to other files 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.39]); Tue, 25 Apr 2017 18:50:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" MACVTAP_NAME_PREFIX and MACVLAN_NAME_PREFIX could be useful to other files if they were defined in virnetdevmacvlan.h instead of virnetdevmacvlan.c, so do that (while slightly renaming them and also adding yet another #define that chooses between macvlan/macvtap based on flags). This is a prerequisite to fix: https://bugzilla.redhat.com/1335798 --- src/util/virnetdevmacvlan.c | 65 ++++++++++++++++++-----------------------= ---- src/util/virnetdevmacvlan.h | 6 +++++ 2 files changed, 32 insertions(+), 39 deletions(-) diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index 7222b0f..97c8770 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -68,11 +68,11 @@ VIR_ENUM_IMPL(virNetDevMacVLanMode, VIR_NETDEV_MACVLAN_= MODE_LAST, =20 VIR_LOG_INIT("util.netdevmacvlan"); =20 -# define MACVTAP_NAME_PREFIX "macvtap" -# define MACVTAP_NAME_PATTERN "macvtap%d" - -# define MACVLAN_NAME_PREFIX "macvlan" -# define MACVLAN_NAME_PATTERN "macvlan%d" +# define VIR_NET_GENERATED_MACVTAP_PATTERN VIR_NET_GENERATED_MACVTAP_PREFI= X "%d" +# define VIR_NET_GENERATED_MACVLAN_PATTERN VIR_NET_GENERATED_MACVLAN_PREFI= X "%d" +# define VIR_NET_GENERATED_PREFIX \ + ((flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ? \ + VIR_NET_GENERATED_MACVTAP_PREFIX : VIR_NET_GENERATED_MACVLAN_PREFIX) =20 # define MACVLAN_MAX_ID 8191 =20 @@ -124,9 +124,7 @@ virNetDevMacVLanReserveID(int id, unsigned int flags, if (id > MACVLAN_MAX_ID) { virReportError(VIR_ERR_INTERNAL_ERROR, _("can't use name %s%d - out of range 0-%d"), - (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ? - MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX, - id, MACVLAN_MAX_ID); + VIR_NET_GENERATED_PREFIX, id, MACVLAN_MAX_ID); return -1; } =20 @@ -134,21 +132,18 @@ virNetDevMacVLanReserveID(int id, unsigned int flags, (id =3D virBitmapNextClearBit(bitmap, id)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("no unused %s names available"), - (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ? - MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX); + VIR_NET_GENERATED_PREFIX); return -1; } =20 if (virBitmapIsBitSet(bitmap, id)) { if (quietFail) { VIR_INFO("couldn't reserve name %s%d - already in use", - (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ? - MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX, id); + VIR_NET_GENERATED_PREFIX, id); } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("couldn't reserve name %s%d - already in use"= ), - (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ? - MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX, id); + VIR_NET_GENERATED_PREFIX, id); } return -1; } @@ -156,14 +151,11 @@ virNetDevMacVLanReserveID(int id, unsigned int flags, if (virBitmapSetBit(bitmap, id) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("couldn't mark %s%d as used"), - (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ? - MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX, id); + VIR_NET_GENERATED_PREFIX, id); return -1; } =20 - VIR_INFO("reserving device %s%d", - (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ? - MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX, id); + VIR_INFO("reserving device %s%d", VIR_NET_GENERATED_PREFIX, id); return id; } =20 @@ -188,9 +180,7 @@ virNetDevMacVLanReleaseID(int id, unsigned int flags) if (id > MACVLAN_MAX_ID) { virReportError(VIR_ERR_INTERNAL_ERROR, _("can't free name %s%d - out of range 0-%d"), - (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ? - MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX, - id, MACVLAN_MAX_ID); + VIR_NET_GENERATED_PREFIX, id, MACVLAN_MAX_ID); return -1; } =20 @@ -199,14 +189,12 @@ virNetDevMacVLanReleaseID(int id, unsigned int flags) =20 VIR_INFO("releasing %sdevice %s%d", virBitmapIsBitSet(bitmap, id) ? "" : "unreserved", - (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ? - MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX, id); + VIR_NET_GENERATED_PREFIX, id); =20 if (virBitmapClearBit(bitmap, id) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("couldn't mark %s%d as unused"), - (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ? - MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX, id); + VIR_NET_GENERATED_PREFIX, id); return -1; } return 0; @@ -236,11 +224,11 @@ virNetDevMacVLanReserveName(const char *name, bool qu= ietFail) if (virNetDevMacVLanInitialize() < 0) return -1; =20 - if (STRPREFIX(name, MACVTAP_NAME_PREFIX)) { - idstr =3D name + strlen(MACVTAP_NAME_PREFIX); + if (STRPREFIX(name, VIR_NET_GENERATED_MACVTAP_PREFIX)) { + idstr =3D name + strlen(VIR_NET_GENERATED_MACVTAP_PREFIX); flags |=3D VIR_NETDEV_MACVLAN_CREATE_WITH_TAP; - } else if (STRPREFIX(name, MACVLAN_NAME_PREFIX)) { - idstr =3D name + strlen(MACVLAN_NAME_PREFIX); + } else if (STRPREFIX(name, VIR_NET_GENERATED_MACVLAN_PREFIX)) { + idstr =3D name + strlen(VIR_NET_GENERATED_MACVLAN_PREFIX); } else { return -2; } @@ -276,11 +264,11 @@ virNetDevMacVLanReleaseName(const char *name) if (virNetDevMacVLanInitialize() < 0) return -1; =20 - if (STRPREFIX(name, MACVTAP_NAME_PREFIX)) { - idstr =3D name + strlen(MACVTAP_NAME_PREFIX); + if (STRPREFIX(name, VIR_NET_GENERATED_MACVTAP_PREFIX)) { + idstr =3D name + strlen(VIR_NET_GENERATED_MACVTAP_PREFIX); flags |=3D VIR_NETDEV_MACVLAN_CREATE_WITH_TAP; - } else if (STRPREFIX(name, MACVLAN_NAME_PREFIX)) { - idstr =3D name + strlen(MACVLAN_NAME_PREFIX); + } else if (STRPREFIX(name, VIR_NET_GENERATED_MACVLAN_PREFIX)) { + idstr =3D name + strlen(VIR_NET_GENERATED_MACVLAN_PREFIX); } else { return 0; } @@ -985,10 +973,9 @@ virNetDevMacVLanCreateWithVPortProfile(const char *ifn= ameRequested, size_t tapfdSize, unsigned int flags) { - const char *type =3D (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ? - MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX; + const char *type =3D VIR_NET_GENERATED_PREFIX; const char *pattern =3D (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ? - MACVTAP_NAME_PATTERN : MACVLAN_NAME_PATTERN; + VIR_NET_GENERATED_MACVTAP_PATTERN : VIR_NET_GENERATED_MACVLAN_PATT= ERN; int reservedID =3D -1; char ifname[IFNAMSIZ]; int retries, do_retry =3D 0; @@ -1031,8 +1018,8 @@ virNetDevMacVLanCreateWithVPortProfile(const char *if= nameRequested, if (ifnameRequested) { int rc; bool isAutoName - =3D (STRPREFIX(ifnameRequested, MACVTAP_NAME_PREFIX) || - STRPREFIX(ifnameRequested, MACVLAN_NAME_PREFIX)); + =3D (STRPREFIX(ifnameRequested, VIR_NET_GENERATED_MACVTAP_PREF= IX) || + STRPREFIX(ifnameRequested, VIR_NET_GENERATED_MACVLAN_PREFIX= )); =20 VIR_INFO("Requested macvtap device name: %s", ifnameRequested); virMutexLock(&virNetDevMacVLanCreateMutex); diff --git a/src/util/virnetdevmacvlan.h b/src/util/virnetdevmacvlan.h index c40f23e..a7c4b6d 100644 --- a/src/util/virnetdevmacvlan.h +++ b/src/util/virnetdevmacvlan.h @@ -51,6 +51,12 @@ typedef enum { VIR_NETDEV_MACVLAN_VNET_HDR =3D 1 << 2, } virNetDevMacVLanCreateFlags; =20 +/* libvirt will start macvtap/macvlan interface names with one of + * these prefixes when it auto-generates the name + */ +# define VIR_NET_GENERATED_MACVTAP_PREFIX "macvtap" +# define VIR_NET_GENERATED_MACVLAN_PREFIX "macvlan" + int virNetDevMacVLanReserveName(const char *name, bool quietfail); int virNetDevMacVLanReleaseName(const char *name); =20 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 21:44:24 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 1493146249613215.17976336266497; Tue, 25 Apr 2017 11:50:49 -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 9ABCF80487; Tue, 25 Apr 2017 18:50:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 703FF79C79; Tue, 25 Apr 2017 18:50:47 +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 22D445EC66; Tue, 25 Apr 2017 18:50: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 v3PIoh4o030931 for ; Tue, 25 Apr 2017 14:50:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 85DE67F599; Tue, 25 Apr 2017 18:50:43 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-65.phx2.redhat.com [10.3.116.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 290A317CC1; Tue, 25 Apr 2017 18:50:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9ABCF80487 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=laine.org Authentication-Results: ext-mx04.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 9ABCF80487 From: Laine Stump To: libvir-list@redhat.com Date: Tue, 25 Apr 2017 14:50:36 -0400 Message-Id: <20170425185037.14805-3-laine@laine.org> In-Reply-To: <20170425185037.14805-1-laine@laine.org> References: <20170425185037.14805-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Martin Kletzander Subject: [libvirt] [PATCH v2 2/3] conf: don't ignore for macvtap 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 25 Apr 2017 18:50:48 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The parser had been clearing out *all* suggested device names for type=3D'direct' (aka macvtap) interfaces. All of the code implementing macvtap allows for a user-specified device name, so we should allow it. In the case that an interface name starts with "macvtap" or "macvlan" though, we do still clear it out, just as we do with "vnet" (which is the prefix used for automatically generated tap device names), since those are the prefixes for the names we autogenerate for macvtap and macvlan devices. Resolves: https://bugzilla.redhat.com/1335798 squash --- docs/formatdomain.html.in | 6 +++--- src/conf/domain_conf.c | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index e31a271..58cd3cf 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5175,9 +5175,9 @@ qemu-kvm -net nic,model=3D? /dev/null If no target is specified, certain hypervisors will automatically generate a name for the created tun device. This name can be manually specified, however the name should not - start with either 'vnet' or 'vif', which are prefixes - reserved by libvirt and certain hypervisors. Manually specified - targets using these prefixes may be ignored. + start with either 'vnet', 'vif', 'macvtap', or 'macvlan', + which are prefixes reserved by libvirt and certain hypervisors. + Manually specified targets using these prefixes may be ignored.

=20

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index fe9b7c7..36644b8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -55,6 +55,7 @@ #include "virtpm.h" #include "virstring.h" #include "virnetdev.h" +#include "virnetdevmacvlan.h" #include "virhostdev.h" #include "virmdev.h" =20 @@ -10028,8 +10029,12 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlo= pt, def->data.direct.linkdev =3D dev; dev =3D NULL; =20 - if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) + if (ifname && + flags & VIR_DOMAIN_DEF_PARSE_INACTIVE && + (STRPREFIX(ifname, VIR_NET_GENERATED_MACVTAP_PREFIX) || + STRPREFIX(ifname, VIR_NET_GENERATED_MACVTAP_PREFIX))) { VIR_FREE(ifname); + } =20 break; =20 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 21:44:24 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 1493146252773543.4827685581829; Tue, 25 Apr 2017 11:50:52 -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 67287C03BD62; Tue, 25 Apr 2017 18:50:51 +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 3DFFD7BE40; Tue, 25 Apr 2017 18:50:51 +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 E8CAE18523D4; Tue, 25 Apr 2017 18:50:50 +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 v3PIoiiZ030939 for ; Tue, 25 Apr 2017 14:50:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1E7D47F599; Tue, 25 Apr 2017 18:50:44 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-65.phx2.redhat.com [10.3.116.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2FF417CC1; Tue, 25 Apr 2017 18:50:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 67287C03BD62 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=laine.org Authentication-Results: ext-mx07.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 67287C03BD62 From: Laine Stump To: libvir-list@redhat.com Date: Tue, 25 Apr 2017 14:50:37 -0400 Message-Id: <20170425185037.14805-4-laine@laine.org> In-Reply-To: <20170425185037.14805-1-laine@laine.org> References: <20170425185037.14805-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Martin Kletzander Subject: [libvirt] [PATCH v2 3/3] util: rename/move VIR_NET_GENERATED_PREFIX to be consistent 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.31]); Tue, 25 Apr 2017 18:50:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" ... with VIR_NET_GENERATED_MACV???_PREFIX, which is defined in util/virnetdevmacvlan.h. Since VIR_NET_GENERATED_PREFIX is used for plain tap devices, it is renamed to VIR_NET_GENERATED_TAP_PREFIX and moved to virnetdev.h --- src/bhyve/bhyve_command.c | 4 ++-- src/conf/domain_conf.c | 4 ++-- src/conf/domain_conf.h | 4 ---- src/interface/interface_backend_udev.c | 2 +- src/qemu/qemu_interface.c | 8 ++++---- src/uml/uml_conf.c | 4 ++-- src/util/virnetdev.h | 5 +++++ 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index e9c072b..eae5cb3 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -88,10 +88,10 @@ bhyveBuildNetArgStr(virConnectPtr conn, } =20 if (!net->ifname || - STRPREFIX(net->ifname, VIR_NET_GENERATED_PREFIX) || + STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) || strchr(net->ifname, '%')) { VIR_FREE(net->ifname); - if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_PREFIX "%d") < 0) + if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_TAP_PREFIX "%d") < 0) goto cleanup; } =20 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 36644b8..236e028 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9745,7 +9745,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, ifname =3D virXMLPropString(cur, "dev"); if (ifname && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && - (STRPREFIX(ifname, VIR_NET_GENERATED_PREFIX) || + (STRPREFIX(ifname, VIR_NET_GENERATED_TAP_PREFIX) || (prefix && STRPREFIX(ifname, prefix)))) { /* An auto-generated target name, blank it out */ VIR_FREE(ifname); @@ -22150,7 +22150,7 @@ virDomainNetDefFormat(virBufferPtr buf, =20 if (def->ifname && !((flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) && - (STRPREFIX(def->ifname, VIR_NET_GENERATED_PREFIX) || + (STRPREFIX(def->ifname, VIR_NET_GENERATED_TAP_PREFIX) || (prefix && STRPREFIX(def->ifname, prefix))))) { /* Skip auto-generated target names for inactive config. */ virBufferEscapeString(buf, "\n", def->ifname); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3b6b174..95848f7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1040,10 +1040,6 @@ struct _virDomainNetDef { virNetDevCoalescePtr coalesce; }; =20 -/* Used for prefix of ifname of any network name generated dynamically - * by libvirt, and cannot be used for a persistent network name. */ -# define VIR_NET_GENERATED_PREFIX "vnet" - typedef enum { VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT =3D 0, VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED, diff --git a/src/interface/interface_backend_udev.c b/src/interface/interfa= ce_backend_udev.c index 18a45fa..1cd8406 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -570,7 +570,7 @@ udevBridgeScanDirFilter(const struct dirent *entry) * vnet%d. Improvements to this check are welcome. */ if (strlen(entry->d_name) >=3D 5) { - if (STRPREFIX(entry->d_name, VIR_NET_GENERATED_PREFIX) && + if (STRPREFIX(entry->d_name, VIR_NET_GENERATED_TAP_PREFIX) && c_isdigit(entry->d_name[4])) return 0; } diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index d0850c0..d8a678b 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -428,10 +428,10 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def, } =20 if (!net->ifname || - STRPREFIX(net->ifname, VIR_NET_GENERATED_PREFIX) || + STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) || strchr(net->ifname, '%')) { VIR_FREE(net->ifname); - if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_PREFIX "%d") < 0) + if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_TAP_PREFIX "%d") < 0) goto cleanup; /* avoid exposing vnet%d in getXMLDesc or error outputs */ template_ifname =3D true; @@ -528,10 +528,10 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def, } =20 if (!net->ifname || - STRPREFIX(net->ifname, VIR_NET_GENERATED_PREFIX) || + STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) || strchr(net->ifname, '%')) { VIR_FREE(net->ifname); - if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_PREFIX "%d") < 0) + if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_TAP_PREFIX "%d") < 0) goto cleanup; /* avoid exposing vnet%d in getXMLDesc or error outputs */ template_ifname =3D true; diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index bdef783..9bd4f11 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -112,10 +112,10 @@ umlConnectTapDevice(virDomainDefPtr vm, int tapfd =3D -1; =20 if (!net->ifname || - STRPREFIX(net->ifname, VIR_NET_GENERATED_PREFIX) || + STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) || strchr(net->ifname, '%')) { VIR_FREE(net->ifname); - if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_PREFIX "%d") < 0) + if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_TAP_PREFIX "%d") < 0) goto error; /* avoid exposing vnet%d in getXMLDesc or error outputs */ template_ifname =3D true; diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h index 19036cc..c7494cd 100644 --- a/src/util/virnetdev.h +++ b/src/util/virnetdev.h @@ -37,6 +37,11 @@ typedef struct ifreq virIfreq; typedef void virIfreq; # endif =20 +/* Used for prefix of ifname of any tap device name generated + * dynamically by libvirt, cannot be used for a persistent network name. + */ +# define VIR_NET_GENERATED_TAP_PREFIX "vnet" + typedef enum { VIR_NETDEV_RX_FILTER_MODE_NONE =3D 0, VIR_NETDEV_RX_FILTER_MODE_NORMAL, --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list