}
+/**
+ * virDomainInterfaceClearQoS
+ * @def: domain definition
+ * @net: a net definition in the VM
+ *
+ * For given interface @net clear its QoS settings in the
+ * host. NOP if @net has no QoS or is of a type that doesn't
+ * support QoS.
+ *
+ * Returns: 0 on success,
+ * -1 otherwise (with appropriate error reported)
+ */
+int
+virDomainInterfaceClearQoS(virDomainDef *def,
+ virDomainNetDef *net)
+{
+ if (!virDomainNetGetActualBandwidth(net))
+ return 0;
+
+ if (!virNetDevSupportsBandwidth(virDomainNetGetActualType(net)))
+ return 0;
+
+ if (virDomainNetDefIsOvsport(net)) {
+ return virNetDevOpenvswitchInterfaceClearQos(net->ifname, def->uuid);
+ }
+
+ return virNetDevBandwidthClear(net->ifname);
+}
+
+
void
virDomainClearNetBandwidth(virDomainDef *def)
{
size_t i;
- virDomainNetType type;
for (i = 0; i < def->nnets; i++) {
- type = virDomainNetGetActualType(def->nets[i]);
- if (virDomainNetGetActualBandwidth(def->nets[i]) &&
- virNetDevSupportsBandwidth(type))
- virNetDevBandwidthClear(def->nets[i]->ifname);
+ virDomainInterfaceClearQoS(def, def->nets[i]);
}
}
virDomainNetDef *net,
bool priv_net_created,
char *stateDir);
+int virDomainInterfaceClearQoS(virDomainDef *def,
+ virDomainNetDef *net);
void virDomainClearNetBandwidth(virDomainDef *def)
ATTRIBUTE_NONNULL(1);
# hypervisor/domain_interface.h
virDomainClearNetBandwidth;
+virDomainInterfaceClearQoS;
virDomainInterfaceDeleteDevice;
virDomainInterfaceEthernetConnect;
virDomainInterfaceIsVnetCompatModel;
actualType = virDomainNetGetActualType(detach);
/* clear network bandwidth */
- if (virDomainNetGetActualBandwidth(detach) &&
- virNetDevSupportsBandwidth(actualType) &&
- virNetDevBandwidthClear(detach->ifname))
- goto cleanup;
+ virDomainInterfaceClearQoS(vm->def, detach);
switch (actualType) {
case VIR_DOMAIN_NET_TYPE_BRIDGE:
goto cleanup;
}
} else {
- /*
- * virNetDevBandwidthSet() doesn't clear any existing
- * setting unless something new is being set.
- */
- virNetDevBandwidthClear(newdev->ifname);
+ if (virDomainInterfaceClearQoS(vm->def, newdev) < 0)
+ goto cleanup;
}
/* If the old bandwidth was cleared out, restore qdisc. */
if (!(charDevAlias = qemuAliasChardevFromDevAlias(net->info.alias)))
return -1;
- if (virNetDevSupportsBandwidth(virDomainNetGetActualType(net))) {
- if (virDomainNetDefIsOvsport(net)) {
- if (virNetDevOpenvswitchInterfaceClearQos(net->ifname, vm->def->uuid) < 0)
- VIR_WARN("cannot clear bandwidth setting for ovs device : %s",
- net->ifname);
- } else if (virNetDevBandwidthClear(net->ifname) < 0) {
- VIR_WARN("cannot clear bandwidth setting for device : %s",
- net->ifname);
- }
- }
+ virDomainInterfaceClearQoS(vm->def, net);
/* deactivate the tap/macvtap device on the host, which could also
* affect the parent device (e.g. macvtap passthrough mode sets