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.