mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virNetDevMacVLanCreateWithVPortProfile: Drop @rc
This variable is very misleading. We use VIR_FORCE_CLOSE to set it to -1 and returning it even though it does not refer to a FD at all. It merely holds 0 or -1. Drop it completely. Also, at the same time some corner cases are fixed too. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
96e2486156
commit
42712002fd
@ -989,7 +989,7 @@ virNetDevMacVLanCreateWithVPortProfile(const char *ifnameRequested,
|
|||||||
MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX;
|
MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX;
|
||||||
const char *pattern = (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
|
const char *pattern = (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
|
||||||
MACVTAP_NAME_PATTERN : MACVLAN_NAME_PATTERN;
|
MACVTAP_NAME_PATTERN : MACVLAN_NAME_PATTERN;
|
||||||
int rc, reservedID = -1;
|
int reservedID = -1;
|
||||||
char ifname[IFNAMSIZ];
|
char ifname[IFNAMSIZ];
|
||||||
int retries, do_retry = 0;
|
int retries, do_retry = 0;
|
||||||
uint32_t macvtapMode;
|
uint32_t macvtapMode;
|
||||||
@ -1079,9 +1079,8 @@ virNetDevMacVLanCreateWithVPortProfile(const char *ifnameRequested,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
snprintf(ifname, sizeof(ifname), pattern, reservedID);
|
snprintf(ifname, sizeof(ifname), pattern, reservedID);
|
||||||
rc = virNetDevMacVLanCreate(ifname, type, macaddress, linkdev,
|
if (virNetDevMacVLanCreate(ifname, type, macaddress, linkdev,
|
||||||
macvtapMode, &do_retry);
|
macvtapMode, &do_retry) < 0) {
|
||||||
if (rc < 0) {
|
|
||||||
virNetDevMacVLanReleaseID(reservedID, flags);
|
virNetDevMacVLanReleaseID(reservedID, flags);
|
||||||
virMutexUnlock(&virNetDevMacVLanCreateMutex);
|
virMutexUnlock(&virNetDevMacVLanCreateMutex);
|
||||||
if (!do_retry)
|
if (!do_retry)
|
||||||
@ -1107,36 +1106,26 @@ virNetDevMacVLanCreateWithVPortProfile(const char *ifnameRequested,
|
|||||||
macaddress,
|
macaddress,
|
||||||
linkdev,
|
linkdev,
|
||||||
vf,
|
vf,
|
||||||
vmuuid, vmOp, false) < 0) {
|
vmuuid, vmOp, false) < 0)
|
||||||
rc = -1;
|
|
||||||
goto link_del_exit;
|
goto link_del_exit;
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & VIR_NETDEV_MACVLAN_CREATE_IFUP) {
|
if (flags & VIR_NETDEV_MACVLAN_CREATE_IFUP) {
|
||||||
if (virNetDevSetOnline(ifnameCreated, true) < 0) {
|
if (virNetDevSetOnline(ifnameCreated, true) < 0)
|
||||||
rc = -1;
|
|
||||||
goto disassociate_exit;
|
goto disassociate_exit;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) {
|
if (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) {
|
||||||
if (virNetDevMacVLanTapOpen(ifnameCreated, tapfd, tapfdSize, 10) < 0) {
|
if (virNetDevMacVLanTapOpen(ifnameCreated, tapfd, tapfdSize, 10) < 0)
|
||||||
rc = -1;
|
|
||||||
goto disassociate_exit;
|
goto disassociate_exit;
|
||||||
}
|
|
||||||
|
|
||||||
if (virNetDevMacVLanTapSetup(tapfd, tapfdSize, vnet_hdr) < 0) {
|
if (virNetDevMacVLanTapSetup(tapfd, tapfdSize, vnet_hdr) < 0)
|
||||||
VIR_FORCE_CLOSE(rc); /* sets rc to -1 */
|
|
||||||
goto disassociate_exit;
|
goto disassociate_exit;
|
||||||
}
|
|
||||||
if (VIR_STRDUP(*ifnameResult, ifnameCreated) < 0) {
|
if (VIR_STRDUP(*ifnameResult, ifnameCreated) < 0)
|
||||||
VIR_FORCE_CLOSE(rc); /* sets rc to -1 */
|
|
||||||
goto disassociate_exit;
|
goto disassociate_exit;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (VIR_STRDUP(*ifnameResult, ifnameCreated) < 0)
|
if (VIR_STRDUP(*ifnameResult, ifnameCreated) < 0)
|
||||||
goto disassociate_exit;
|
goto disassociate_exit;
|
||||||
rc = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vmOp == VIR_NETDEV_VPORT_PROFILE_OP_CREATE ||
|
if (vmOp == VIR_NETDEV_VPORT_PROFILE_OP_CREATE ||
|
||||||
@ -1149,10 +1138,10 @@ virNetDevMacVLanCreateWithVPortProfile(const char *ifnameRequested,
|
|||||||
linkdev, vmuuid,
|
linkdev, vmuuid,
|
||||||
virtPortProfile,
|
virtPortProfile,
|
||||||
vmOp) < 0)
|
vmOp) < 0)
|
||||||
goto disassociate_exit;
|
goto disassociate_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return 0;
|
||||||
|
|
||||||
disassociate_exit:
|
disassociate_exit:
|
||||||
ignore_value(virNetDevVPortProfileDisassociate(ifnameCreated,
|
ignore_value(virNetDevVPortProfileDisassociate(ifnameCreated,
|
||||||
@ -1168,7 +1157,7 @@ virNetDevMacVLanCreateWithVPortProfile(const char *ifnameRequested,
|
|||||||
ignore_value(virNetDevMacVLanDelete(ifnameCreated));
|
ignore_value(virNetDevMacVLanDelete(ifnameCreated));
|
||||||
virNetDevMacVLanReleaseName(ifnameCreated);
|
virNetDevMacVLanReleaseName(ifnameCreated);
|
||||||
|
|
||||||
return rc;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user