uint32_t macvtapMode;
int vf = -1;
bool vnet_hdr = flags & VIR_NETDEV_MACVLAN_VNET_HDR;
+ virNetDevGenNameType type;
macvtapMode = modeMap[mode];
}
if (ifnameRequested) {
- int rc;
- bool isAutoName
- = (STRPREFIX(ifnameRequested, VIR_NET_GENERATED_MACVTAP_PREFIX) ||
- STRPREFIX(ifnameRequested, VIR_NET_GENERATED_MACVLAN_PREFIX));
-
VIR_INFO("Requested macvtap device name: %s", ifnameRequested);
-
- if ((rc = virNetDevExists(ifnameRequested)) < 0)
- return -1;
-
- if (rc) {
- /* ifnameRequested is already being used */
-
- if (!isAutoName) {
- virReportSystemError(EEXIST,
- _("Unable to create device '%s'"),
- ifnameRequested);
- return -1;
- }
- } else {
-
- /* ifnameRequested is available. try to open it */
-
- virNetDevReserveName(ifnameRequested);
-
- if (virNetDevMacVLanCreate(ifnameRequested, macaddress,
- linkdev, macvtapMode, flags) == 0) {
-
- /* virNetDevMacVLanCreate() was successful - use this name */
- ifname = g_strdup(ifnameRequested);
-
- } else if (!isAutoName) {
- /* couldn't open ifnameRequested, but it wasn't an
- * autogenerated named, so there is nothing else to
- * try - fail and return.
- */
- return -1;
- }
- }
+ ifname = g_strdup(ifnameRequested);
}
- if (!ifname) {
- /* ifnameRequested was NULL, or it was an already in use
- * autogenerated name, so now we look for an unused
- * autogenerated name.
- */
- virNetDevGenNameType type;
- if (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP)
- type = VIR_NET_DEV_GEN_NAME_MACVTAP;
- else
- type = VIR_NET_DEV_GEN_NAME_MACVLAN;
+ if (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP)
+ type = VIR_NET_DEV_GEN_NAME_MACVTAP;
+ else
+ type = VIR_NET_DEV_GEN_NAME_MACVLAN;
- if (virNetDevGenerateName(&ifname, type) < 0 ||
- virNetDevMacVLanCreate(ifname, macaddress,
- linkdev, macvtapMode, flags) < 0)
- return -1;
+ if (virNetDevGenerateName(&ifname, type) < 0 ||
+ virNetDevMacVLanCreate(ifname, macaddress,
+ linkdev, macvtapMode, flags) < 0) {
+ return -1;
}
- /* all done creating the device */
-
if (virNetDevVPortProfileAssociate(ifname,
virtPortProfile,
macaddress,