daemonName, pid, networkName, signame,
virStrerror(errno, ebuf, sizeof(ebuf)));
}
- goto cleanup;
+ return ret;
}
/* NB: since networks have no reference count like
* domains, there is no safe way to unlock the network
VIR_WARN("Timed out waiting after SIG%s to %s process %d "
"(network '%s')",
signame, daemonName, pid, networkName);
- cleanup:
return ret;
}
unsigned int flags)
{
virNetworkDriverStatePtr driver = networkGetDriver();
- int ret = -1;
virCheckFlags(VIR_CONNECT_LIST_NETWORKS_FILTERS_ALL, -1);
if (virConnectListAllNetworksEnsureACL(conn) < 0)
- goto cleanup;
-
- ret = virNetworkObjListExport(conn, driver->networks, nets,
- virConnectListAllNetworksCheckACL,
- flags);
+ return -1;
- cleanup:
- return ret;
+ return virNetworkObjListExport(conn, driver->networks, nets,
+ virConnectListAllNetworksCheckACL,
+ flags);
}
int ret = -1;
if (virConnectNetworkEventRegisterAnyEnsureACL(conn) < 0)
- goto cleanup;
+ return -1;
if (virNetworkEventStateRegisterID(conn, driver->networkEventState,
net, eventID, callback,
opaque, freecb, &ret) < 0)
ret = -1;
- cleanup:
return ret;
}
int callbackID)
{
virNetworkDriverStatePtr driver = networkGetDriver();
- int ret = -1;
if (virConnectNetworkEventDeregisterAnyEnsureACL(conn) < 0)
- goto cleanup;
+ return -1;
if (virObjectEventStateDeregisterID(conn,
driver->networkEventState,
callbackID, true) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
networkBridgeNameValidate(virNetworkObjListPtr nets,
virNetworkDefPtr def)
{
- int ret = -1;
-
if (def->bridge && !strstr(def->bridge, "%d")) {
if (virNetworkObjBridgeInUse(nets, def->bridge, def->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("bridge name '%s' already in use."),
def->bridge);
- goto cleanup;
+ return -1;
}
} else {
/* Allocate a bridge name */
if (networkFindUnusedBridgeName(nets, def) < 0)
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
virPortGroupDefPtr portgroup = NULL;
virNetworkForwardIfDefPtr dev = NULL;
size_t i;
- int ret = -1;
virNetDevVPortProfilePtr portprofile = NULL;
netdef = virNetworkObjGetDef(obj);
virReportError(VIR_ERR_OPERATION_INVALID,
_("network '%s' is not active"),
netdef->name);
- goto cleanup;
+ return -1;
}
VIR_DEBUG("Interface port group %s", port->group);
if (portgroup && portgroup->bandwidth &&
virNetDevBandwidthCopy(&port->bandwidth,
portgroup->bandwidth) < 0)
- goto cleanup;
+ return -1;
}
if (port->vlan.nTags == 0) {
vlan = &netdef->vlan;
if (vlan && virNetDevVlanCopy(&port->vlan, vlan) < 0)
- goto cleanup;
+ return -1;
}
if (!port->trustGuestRxFilters) {
netdef->virtPortProfile,
portgroup
? portgroup->virtPortProfile : NULL) < 0) {
- goto cleanup;
+ return -1;
}
if (portprofile) {
VIR_FREE(port->virtPortProfile);
"'%s' which uses IP forwarding"),
virNetDevVPortTypeToString(port->virtPortProfile->virtPortType),
netdef->name);
- goto cleanup;
+ return -1;
}
if (networkPlugBandwidth(obj, &port->mac, port->bandwidth, &port->class_id) < 0)
- goto cleanup;
+ return -1;
break;
case VIR_NETWORK_FORWARD_HOSTDEV: {
port->plugtype = VIR_NETWORK_PORT_PLUG_TYPE_HOSTDEV_PCI;
if (networkCreateInterfacePool(netdef) < 0)
- goto cleanup;
+ return -1;
/* pick first dev with 0 connections */
for (i = 0; i < netdef->forward.nifs; i++) {
_("network '%s' requires exclusive access "
"to interfaces, but none are available"),
netdef->name);
- goto cleanup;
+ return -1;
}
port->plug.hostdevpci.addr = dev->device.pci;
port->plug.hostdevpci.driver = netdef->forward.driverName;
"via PCI passthrough"),
virNetDevVPortTypeToString(port->virtPortProfile->virtPortType),
netdef->name);
- goto cleanup;
+ return -1;
}
}
break;
"'%s' which uses a bridge device"),
virNetDevVPortTypeToString(port->virtPortProfile->virtPortType),
netdef->name);
- goto cleanup;
+ return -1;
}
}
if (networkPlugBandwidth(obj, &port->mac, port->bandwidth, &port->class_id) < 0)
- goto cleanup;
+ return -1;
break;
}
"'%s' which uses a macvtap device"),
virNetDevVPortTypeToString(port->virtPortProfile->virtPortType),
netdef->name);
- goto cleanup;
+ return -1;
}
}
_("network '%s' uses a direct mode, but "
"has no forward dev and no interface pool"),
netdef->name);
- goto cleanup;
+ return -1;
} else {
/* pick an interface from the pool */
if (networkCreateInterfacePool(netdef) < 0)
- goto cleanup;
+ return -1;
/* PASSTHROUGH mode, and PRIVATE Mode + 802.1Qbh both
* require exclusive access to a device, so current
_("network '%s' requires exclusive access "
"to interfaces, but none are available"),
netdef->name);
- goto cleanup;
+ return -1;
}
port->plug.direct.linkdev = g_strdup(dev->device.dev);
}
case VIR_NETWORK_FORWARD_LAST:
default:
virReportEnumRangeError(virNetworkForwardType, netdef->forward.type);
- goto cleanup;
+ return -1;
}
if (virNetworkObjMacMgrAdd(obj, driver->dnsmasqStateDir,
port->ownername, &port->mac) < 0)
- goto cleanup;
+ return -1;
if (virNetDevVPortProfileCheckComplete(port->virtPortProfile, true) < 0)
- goto cleanup;
+ return -1;
/* make sure that everything now specified for the device is
* actually supported on this type of network. NB: network,
"is requesting a vlan tag, but that is not "
"supported for this type of network"),
netdef->name);
- goto cleanup;
+ return -1;
}
}
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("bandwidth settings are not supported "
"for hostdev interfaces"));
- goto cleanup;
+ return -1;
}
netdef->connections++;
netdef->connections--;
if (dev)
dev->connections--;
- goto cleanup;
+ return -1;
}
networkLogAllocation(netdef, dev, &port->mac, true);
VIR_DEBUG("Port allocated");
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
virNetworkDefPtr netdef;
virNetworkForwardIfDefPtr dev = NULL;
size_t i;
- int ret = -1;
netdef = virNetworkObjGetDef(obj);
virReportError(VIR_ERR_OPERATION_INVALID,
_("network '%s' is not active"),
netdef->name);
- goto cleanup;
+ return -1;
}
switch (port->plugtype) {
case VIR_NETWORK_PORT_PLUG_TYPE_NONE:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unexpectedly got a network port without a plug"));
- goto cleanup;
+ return -1;
case VIR_NETWORK_PORT_PLUG_TYPE_NETWORK:
case VIR_NETWORK_PORT_PLUG_TYPE_BRIDGE:
if (!netdef->bridge) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unexpectedly got a network port without a network bridge"));
- goto cleanup;
+ return -1;
}
break;
case VIR_NETWORK_PORT_PLUG_TYPE_DIRECT:
if (networkCreateInterfacePool(netdef) < 0)
- goto cleanup;
+ return -1;
/* find the matching interface and increment its connections */
for (i = 0; i < netdef->forward.nifs; i++) {
"in use by network port '%s'"),
netdef->name, port->plug.direct.linkdev,
port->uuid);
- goto cleanup;
+ return -1;
}
/* PASSTHROUGH mode and PRIVATE Mode + 802.1Qbh both require
_("network '%s' claims dev='%s' is already in "
"use by a different port"),
netdef->name, port->plug.direct.linkdev);
- goto cleanup;
+ return -1;
}
break;
case VIR_NETWORK_PORT_PLUG_TYPE_HOSTDEV_PCI:
if (networkCreateInterfacePool(netdef) < 0)
- goto cleanup;
+ return -1;
/* find the matching interface and increment its connections */
for (i = 0; i < netdef->forward.nifs; i++) {
port->plug.hostdevpci.addr.bus,
port->plug.hostdevpci.addr.slot,
port->plug.hostdevpci.addr.function);
- goto cleanup;
+ return -1;
}
/* PASSTHROUGH mode, PRIVATE Mode + 802.1Qbh, and hostdev (PCI
netdef->name,
dev->device.pci.domain, dev->device.pci.bus,
dev->device.pci.slot, dev->device.pci.function);
- goto cleanup;
+ return -1;
}
break;
case VIR_NETWORK_PORT_PLUG_TYPE_LAST:
default:
virReportEnumRangeError(virNetworkPortPlugType, port->plugtype);
- goto cleanup;
+ return -1;
}
netdef->connections++;
if (dev)
dev->connections--;
netdef->connections--;
- goto cleanup;
+ return -1;
}
networkLogAllocation(netdef, dev, &port->mac, true);
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
virNetworkDefPtr netdef;
virNetworkForwardIfDefPtr dev = NULL;
size_t i;
- int ret = -1;
netdef = virNetworkObjGetDef(obj);
case VIR_NETWORK_PORT_PLUG_TYPE_BRIDGE:
if (networkUnplugBandwidth(obj, port->bandwidth,
&port->class_id) < 0)
- goto cleanup;
+ return -1;
break;
case VIR_NETWORK_PORT_PLUG_TYPE_DIRECT:
_("network '%s' uses a direct mode, but "
"has no forward dev and no interface pool"),
netdef->name);
- goto cleanup;
+ return -1;
}
for (i = 0; i < netdef->forward.nifs; i++) {
_("network '%s' doesn't have dev='%s' "
"in use by domain"),
netdef->name, port->plug.direct.linkdev);
- goto cleanup;
+ return -1;
}
break;
_("network '%s' uses a hostdev mode, but "
"has no forward dev and no interface pool"),
netdef->name);
- goto cleanup;
+ return -1;
}
for (i = 0; i < netdef->forward.nifs; i++) {
port->plug.hostdevpci.addr.bus,
port->plug.hostdevpci.addr.slot,
port->plug.hostdevpci.addr.function);
- goto cleanup;
+ return -1;
}
break;
case VIR_NETWORK_PORT_PLUG_TYPE_LAST:
default:
virReportEnumRangeError(virNetworkPortPlugType, port->plugtype);
- goto cleanup;
+ return -1;
}
virNetworkObjMacMgrDel(obj, driver->dnsmasqStateDir, port->ownername, &port->mac);
VIR_HOOK_SUBOP_BEGIN);
networkLogAllocation(netdef, dev, &port->mac, false);
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
virMacAddrPtr ifaceMac,
unsigned long long *new_rate)
{
- int ret = -1;
virNetworkDefPtr def = virNetworkObjGetDef(obj);
virNetDevBandwidthPtr netBand = def->bandwidth;
unsigned long long tmp_floor_sum = virNetworkObjGetFloorSum(obj);
tmp_floor_sum,
netBand->in->peak,
def->name);
- goto cleanup;
+ return -1;
}
} else if (tmp_floor_sum > netBand->in->average) {
/* tmp_floor_sum can be between 'average' and 'peak' iff 'peak' is set.
tmp_floor_sum,
netBand->in->average,
def->name);
- goto cleanup;
+ return -1;
}
if (new_rate)
*new_rate = tmp_new_rate;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
unsigned long long tmp_floor_sum = virNetworkObjGetFloorSum(obj);
ssize_t next_id = 0;
int plug_ret;
- int ret = -1;
/* generate new class_id */
if ((next_id = networkNextClassID(obj)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not generate next class ID"));
- goto cleanup;
+ return -1;
}
plug_ret = virNetDevBandwidthPlug(def->bridge, def->bandwidth,
mac, ifaceBand, next_id);
if (plug_ret < 0) {
ignore_value(virNetDevBandwidthUnplug(def->bridge, next_id));
- goto cleanup;
+ return -1;
}
/* QoS was set, generate new class ID */
virNetworkObjSetFloorSum(obj, tmp_floor_sum);
*class_id = 0;
ignore_value(virNetDevBandwidthUnplug(def->bridge, next_id));
- goto cleanup;
+ return -1;
}
/* update rate for non guaranteed NICs */
new_rate -= tmp_floor_sum;
VIR_WARN("Unable to update rate for 1:2 class on %s bridge",
def->bridge);
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
virNetDevBandwidthPtr ifaceBand,
unsigned int *class_id)
{
- int ret = -1;
int plug_ret;
unsigned long long new_rate = 0;
char ifmac[VIR_MAC_STRING_BUFLEN];
if ((plug_ret = networkCheckBandwidth(obj, ifaceBand, NULL,
mac, &new_rate)) < 0) {
/* helper reported error */
- goto cleanup;
+ return -1;
}
- if (plug_ret > 0) {
+ if (plug_ret > 0)
/* no QoS needs to be set; claim success */
- ret = 0;
- goto cleanup;
- }
+ return 0;
virMacAddrFormat(mac, ifmac);
if (networkPlugBandwidthImpl(obj, mac, ifaceBand, class_id, new_rate) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
if (!def->bandwidth || !def->bandwidth->in) {
VIR_WARN("Network %s has no bandwidth but unplug requested",
def->name);
- goto cleanup;
+ return 0;
}
/* we must remove class from bridge */
new_rate = def->bandwidth->in->average;
ret = virNetDevBandwidthUnplug(def->bridge, *class_id);
if (ret < 0)
- goto cleanup;
+ return ret;
/* update sum of 'floor'-s of attached NICs */
tmp_floor_sum -= ifaceBand->in->floor;
virNetworkObjSetFloorSum(obj, tmp_floor_sum);
tmp_floor_sum += ifaceBand->in->floor;
virNetworkObjSetFloorSum(obj, tmp_floor_sum);
ignore_value(virBitmapSetBit(classIdMap, *class_id));
- goto cleanup;
+ return ret;
}
/* update rate for non guaranteed NICs */
new_rate -= tmp_floor_sum;
*class_id = 0;
}
- cleanup:
return ret;
}