[libvirt] [PATCH v2 1/3] util: make macvtap/macvlan generated name #defines available to other files

Martin Kletzander mkletzan at redhat.com
Fri Apr 28 09:17:18 UTC 2017


On Tue, Apr 25, 2017 at 02:50:35PM -0400, Laine Stump wrote:
>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
>@@ -236,11 +224,11 @@ virNetDevMacVLanReserveName(const char *name, bool quietFail)
>     if (virNetDevMacVLanInitialize() < 0)
>        return -1;
>
>-    if (STRPREFIX(name, MACVTAP_NAME_PREFIX)) {
>-        idstr = name + strlen(MACVTAP_NAME_PREFIX);
>+    if (STRPREFIX(name, VIR_NET_GENERATED_MACVTAP_PREFIX)) {
>+        idstr = name + strlen(VIR_NET_GENERATED_MACVTAP_PREFIX);
>         flags |= VIR_NETDEV_MACVLAN_CREATE_WITH_TAP;
>-    } else if (STRPREFIX(name, MACVLAN_NAME_PREFIX)) {
>-        idstr = name + strlen(MACVLAN_NAME_PREFIX);
>+    } else if (STRPREFIX(name, VIR_NET_GENERATED_MACVLAN_PREFIX)) {
>+        idstr = name + strlen(VIR_NET_GENERATED_MACVLAN_PREFIX);
>     } else {
>         return -2;
>     }
>@@ -276,11 +264,11 @@ virNetDevMacVLanReleaseName(const char *name)
>     if (virNetDevMacVLanInitialize() < 0)
>        return -1;
>
>-    if (STRPREFIX(name, MACVTAP_NAME_PREFIX)) {
>-        idstr = name + strlen(MACVTAP_NAME_PREFIX);
>+    if (STRPREFIX(name, VIR_NET_GENERATED_MACVTAP_PREFIX)) {
>+        idstr = name + strlen(VIR_NET_GENERATED_MACVTAP_PREFIX);
>         flags |= VIR_NETDEV_MACVLAN_CREATE_WITH_TAP;
>-    } else if (STRPREFIX(name, MACVLAN_NAME_PREFIX)) {
>-        idstr = name + strlen(MACVLAN_NAME_PREFIX);
>+    } else if (STRPREFIX(name, VIR_NET_GENERATED_MACVLAN_PREFIX)) {
>+        idstr = name + strlen(VIR_NET_GENERATED_MACVLAN_PREFIX);

Just a note to someone interested as this is pre-existing, but I think
STRSKIP could make these nicer.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170428/ee02a581/attachment-0001.sig>


More information about the libvir-list mailing list