|
|
9119d9 |
From d3ad6d0b7d6e4e0b9b8af98c27e88abbf5a69af6 Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <d3ad6d0b7d6e4e0b9b8af98c27e88abbf5a69af6@dist-git>
|
|
|
9119d9 |
From: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
|
|
|
9119d9 |
Date: Sun, 14 Dec 2014 23:44:48 -0500
|
|
|
9119d9 |
Subject: [PATCH] util: Introduce flags field for macvtap creation
|
|
|
9119d9 |
|
|
|
9119d9 |
Prerequisite to fix:
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1081461
|
|
|
9119d9 |
|
|
|
9119d9 |
Currently, there is one flag passed in during macvtap creation
|
|
|
9119d9 |
(withTap) -- Let's convert this field to an unsigned int flag
|
|
|
9119d9 |
field for future expansion.
|
|
|
9119d9 |
|
|
|
9119d9 |
Signed-off-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
|
|
|
9119d9 |
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
|
|
9119d9 |
(cherry picked from commit 7199d2c523feb71be44836e3e3a609b631a26947)
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/lxc/lxc_process.c | 4 ++--
|
|
|
9119d9 |
src/qemu/qemu_command.c | 6 ++++--
|
|
|
9119d9 |
src/util/virnetdevmacvlan.c | 28 +++++++++++++++++-----------
|
|
|
9119d9 |
src/util/virnetdevmacvlan.h | 14 ++++++++++----
|
|
|
9119d9 |
4 files changed, 33 insertions(+), 19 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
|
|
|
9119d9 |
index 6420c0d..6c83fdb 100644
|
|
|
9119d9 |
--- a/src/lxc/lxc_process.c
|
|
|
9119d9 |
+++ b/src/lxc/lxc_process.c
|
|
|
9119d9 |
@@ -331,12 +331,12 @@ char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
|
|
|
9119d9 |
net->ifname, &net->mac,
|
|
|
9119d9 |
virDomainNetGetActualDirectDev(net),
|
|
|
9119d9 |
virDomainNetGetActualDirectMode(net),
|
|
|
9119d9 |
- false, false, def->uuid,
|
|
|
9119d9 |
+ false, def->uuid,
|
|
|
9119d9 |
virDomainNetGetActualVirtPortProfile(net),
|
|
|
9119d9 |
&res_ifname,
|
|
|
9119d9 |
VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
|
|
|
9119d9 |
cfg->stateDir,
|
|
|
9119d9 |
- virDomainNetGetActualBandwidth(net)) < 0)
|
|
|
9119d9 |
+ virDomainNetGetActualBandwidth(net), 0) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
ret = res_ifname;
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
9119d9 |
index 70730ce..cd87812 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_command.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_command.c
|
|
|
9119d9 |
@@ -177,6 +177,7 @@ qemuPhysIfaceConnect(virDomainDefPtr def,
|
|
|
9119d9 |
char *res_ifname = NULL;
|
|
|
9119d9 |
int vnet_hdr = 0;
|
|
|
9119d9 |
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
|
|
9119d9 |
+ unsigned int macvlan_create_flags = VIR_NETDEV_MACVLAN_CREATE_WITH_TAP;
|
|
|
9119d9 |
|
|
|
9119d9 |
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNET_HDR) &&
|
|
|
9119d9 |
net->model && STREQ(net->model, "virtio"))
|
|
|
9119d9 |
@@ -186,11 +187,12 @@ qemuPhysIfaceConnect(virDomainDefPtr def,
|
|
|
9119d9 |
net->ifname, &net->mac,
|
|
|
9119d9 |
virDomainNetGetActualDirectDev(net),
|
|
|
9119d9 |
virDomainNetGetActualDirectMode(net),
|
|
|
9119d9 |
- true, vnet_hdr, def->uuid,
|
|
|
9119d9 |
+ vnet_hdr, def->uuid,
|
|
|
9119d9 |
virDomainNetGetActualVirtPortProfile(net),
|
|
|
9119d9 |
&res_ifname,
|
|
|
9119d9 |
vmop, cfg->stateDir,
|
|
|
9119d9 |
- virDomainNetGetActualBandwidth(net));
|
|
|
9119d9 |
+ virDomainNetGetActualBandwidth(net),
|
|
|
9119d9 |
+ macvlan_create_flags);
|
|
|
9119d9 |
if (rc >= 0) {
|
|
|
9119d9 |
virDomainAuditNetDevice(def, net, res_ifname, true);
|
|
|
9119d9 |
VIR_FREE(net->ifname);
|
|
|
9119d9 |
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
|
|
|
9119d9 |
index 054194b..50aabc5 100644
|
|
|
9119d9 |
--- a/src/util/virnetdevmacvlan.c
|
|
|
9119d9 |
+++ b/src/util/virnetdevmacvlan.c
|
|
|
9119d9 |
@@ -796,26 +796,31 @@ virNetDevMacVLanVPortProfileRegisterCallback(const char *ifname,
|
|
|
9119d9 |
* @res_ifname: Pointer to a string pointer where the actual name of the
|
|
|
9119d9 |
* interface will be stored into if everything succeeded. It is up
|
|
|
9119d9 |
* to the caller to free the string.
|
|
|
9119d9 |
+ * @flags: OR of virNetDevMacVLanCreateFlags.
|
|
|
9119d9 |
*
|
|
|
9119d9 |
- * Returns file descriptor of the tap device in case of success with @withTap,
|
|
|
9119d9 |
- * otherwise returns 0; returns -1 on error.
|
|
|
9119d9 |
+ * Returns file descriptor of the tap device in case of success with
|
|
|
9119d9 |
+ * @flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP, otherwise returns 0; returns
|
|
|
9119d9 |
+ * -1 on error.
|
|
|
9119d9 |
*/
|
|
|
9119d9 |
int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
|
|
|
9119d9 |
const virMacAddr *macaddress,
|
|
|
9119d9 |
const char *linkdev,
|
|
|
9119d9 |
virNetDevMacVLanMode mode,
|
|
|
9119d9 |
- bool withTap,
|
|
|
9119d9 |
int vnet_hdr,
|
|
|
9119d9 |
const unsigned char *vmuuid,
|
|
|
9119d9 |
virNetDevVPortProfilePtr virtPortProfile,
|
|
|
9119d9 |
char **res_ifname,
|
|
|
9119d9 |
virNetDevVPortProfileOp vmOp,
|
|
|
9119d9 |
char *stateDir,
|
|
|
9119d9 |
- virNetDevBandwidthPtr bandwidth)
|
|
|
9119d9 |
+ virNetDevBandwidthPtr bandwidth,
|
|
|
9119d9 |
+ unsigned int flags)
|
|
|
9119d9 |
{
|
|
|
9119d9 |
- const char *type = withTap ? "macvtap" : "macvlan";
|
|
|
9119d9 |
- const char *prefix = withTap ? MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX;
|
|
|
9119d9 |
- const char *pattern = withTap ? MACVTAP_NAME_PATTERN : MACVLAN_NAME_PATTERN;
|
|
|
9119d9 |
+ const char *type = (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
|
|
|
9119d9 |
+ "macvtap" : "macvlan";
|
|
|
9119d9 |
+ const char *prefix = (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
|
|
|
9119d9 |
+ MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX;
|
|
|
9119d9 |
+ const char *pattern = (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
|
|
|
9119d9 |
+ MACVTAP_NAME_PATTERN : MACVLAN_NAME_PATTERN;
|
|
|
9119d9 |
int c, rc;
|
|
|
9119d9 |
char ifname[IFNAMSIZ];
|
|
|
9119d9 |
int retries, do_retry = 0;
|
|
|
9119d9 |
@@ -903,7 +908,7 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
|
|
|
9119d9 |
goto disassociate_exit;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
- if (withTap) {
|
|
|
9119d9 |
+ if (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) {
|
|
|
9119d9 |
if ((rc = virNetDevMacVLanTapOpen(cr_ifname, 10)) < 0)
|
|
|
9119d9 |
goto disassociate_exit;
|
|
|
9119d9 |
|
|
|
9119d9 |
@@ -922,7 +927,7 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
if (virNetDevBandwidthSet(cr_ifname, bandwidth, false) < 0) {
|
|
|
9119d9 |
- if (withTap)
|
|
|
9119d9 |
+ if (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP)
|
|
|
9119d9 |
VIR_FORCE_CLOSE(rc); /* sets rc to -1 */
|
|
|
9119d9 |
else
|
|
|
9119d9 |
rc = -1;
|
|
|
9119d9 |
@@ -1066,15 +1071,16 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *ifname ATTRIBUTE_UNUSED,
|
|
|
9119d9 |
const virMacAddr *macaddress ATTRIBUTE_UNUSED,
|
|
|
9119d9 |
const char *linkdev ATTRIBUTE_UNUSED,
|
|
|
9119d9 |
virNetDevMacVLanMode mode ATTRIBUTE_UNUSED,
|
|
|
9119d9 |
- bool withTap ATTRIBUTE_UNUSED,
|
|
|
9119d9 |
int vnet_hdr ATTRIBUTE_UNUSED,
|
|
|
9119d9 |
const unsigned char *vmuuid ATTRIBUTE_UNUSED,
|
|
|
9119d9 |
virNetDevVPortProfilePtr virtPortProfile ATTRIBUTE_UNUSED,
|
|
|
9119d9 |
char **res_ifname ATTRIBUTE_UNUSED,
|
|
|
9119d9 |
virNetDevVPortProfileOp vmop ATTRIBUTE_UNUSED,
|
|
|
9119d9 |
char *stateDir ATTRIBUTE_UNUSED,
|
|
|
9119d9 |
- virNetDevBandwidthPtr bandwidth ATTRIBUTE_UNUSED)
|
|
|
9119d9 |
+ virNetDevBandwidthPtr bandwidth ATTRIBUTE_UNUSED,
|
|
|
9119d9 |
+ unsigned int flags)
|
|
|
9119d9 |
{
|
|
|
9119d9 |
+ virCheckFlags(0, -1);
|
|
|
9119d9 |
virReportSystemError(ENOSYS, "%s",
|
|
|
9119d9 |
_("Cannot create macvlan devices on this platform"));
|
|
|
9119d9 |
return -1;
|
|
|
9119d9 |
diff --git a/src/util/virnetdevmacvlan.h b/src/util/virnetdevmacvlan.h
|
|
|
9119d9 |
index 9b15a31..41aa4e2 100644
|
|
|
9119d9 |
--- a/src/util/virnetdevmacvlan.h
|
|
|
9119d9 |
+++ b/src/util/virnetdevmacvlan.h
|
|
|
9119d9 |
@@ -40,6 +40,12 @@ typedef enum {
|
|
|
9119d9 |
} virNetDevMacVLanMode;
|
|
|
9119d9 |
VIR_ENUM_DECL(virNetDevMacVLanMode)
|
|
|
9119d9 |
|
|
|
9119d9 |
+typedef enum {
|
|
|
9119d9 |
+ VIR_NETDEV_MACVLAN_CREATE_NONE = 0,
|
|
|
9119d9 |
+ /* Create with a tap device */
|
|
|
9119d9 |
+ VIR_NETDEV_MACVLAN_CREATE_WITH_TAP = 1 << 0,
|
|
|
9119d9 |
+} virNetDevMacVLanCreateFlags;
|
|
|
9119d9 |
+
|
|
|
9119d9 |
int virNetDevMacVLanCreate(const char *ifname,
|
|
|
9119d9 |
const char *type,
|
|
|
9119d9 |
const virMacAddr *macaddress,
|
|
|
9119d9 |
@@ -56,16 +62,16 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *ifname,
|
|
|
9119d9 |
const virMacAddr *macaddress,
|
|
|
9119d9 |
const char *linkdev,
|
|
|
9119d9 |
virNetDevMacVLanMode mode,
|
|
|
9119d9 |
- bool withTap,
|
|
|
9119d9 |
int vnet_hdr,
|
|
|
9119d9 |
const unsigned char *vmuuid,
|
|
|
9119d9 |
virNetDevVPortProfilePtr virtPortProfile,
|
|
|
9119d9 |
char **res_ifname,
|
|
|
9119d9 |
virNetDevVPortProfileOp vmop,
|
|
|
9119d9 |
char *stateDir,
|
|
|
9119d9 |
- virNetDevBandwidthPtr bandwidth)
|
|
|
9119d9 |
- ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(7)
|
|
|
9119d9 |
- ATTRIBUTE_NONNULL(9) ATTRIBUTE_NONNULL(11) ATTRIBUTE_RETURN_CHECK;
|
|
|
9119d9 |
+ virNetDevBandwidthPtr bandwidth,
|
|
|
9119d9 |
+ unsigned int flags)
|
|
|
9119d9 |
+ ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(6)
|
|
|
9119d9 |
+ ATTRIBUTE_NONNULL(8) ATTRIBUTE_NONNULL(10) ATTRIBUTE_RETURN_CHECK;
|
|
|
9119d9 |
|
|
|
9119d9 |
int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
|
|
|
9119d9 |
const virMacAddr *macaddress,
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.2.0
|
|
|
9119d9 |
|