conf: avoid reporting errors when network driver is disabled

In previous releases all these methods were a no-op if the network
driver is disabled. These helper methods are called unconditionally for
all types of network interface, so must be no-ops if missing. Other code
will already generate an error if the network driver is disabled and a
NIC with type=network is used.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2018-03-23 11:43:53 +00:00
parent da1ade7a52
commit f0fd90d722

View File

@ -28979,11 +28979,13 @@ int
virDomainNetAllocateActualDevice(virDomainDefPtr dom, virDomainNetAllocateActualDevice(virDomainDefPtr dom,
virDomainNetDefPtr iface) virDomainNetDefPtr iface)
{ {
if (!netAllocate) { /* Just silently ignore if network driver isn't present. If something
virReportError(VIR_ERR_NO_SUPPORT, "%s", * has tried to use a NIC with type=network, other code will already
_("Network device allocation not available")); * cause an error. This ensures type=bridge doesn't break when
return -1; * network driver is compiled out.
} */
if (!netAllocate)
return 0;
return netAllocate(dom, iface); return netAllocate(dom, iface);
} }
@ -28992,11 +28994,8 @@ void
virDomainNetNotifyActualDevice(virDomainDefPtr dom, virDomainNetNotifyActualDevice(virDomainDefPtr dom,
virDomainNetDefPtr iface) virDomainNetDefPtr iface)
{ {
if (!netNotify) { if (!netNotify)
virReportError(VIR_ERR_NO_SUPPORT, "%s",
_("Network device notification not available"));
return; return;
}
netNotify(dom, iface); netNotify(dom, iface);
} }
@ -29006,11 +29005,8 @@ int
virDomainNetReleaseActualDevice(virDomainDefPtr dom, virDomainNetReleaseActualDevice(virDomainDefPtr dom,
virDomainNetDefPtr iface) virDomainNetDefPtr iface)
{ {
if (!netRelease) { if (!netRelease)
virReportError(VIR_ERR_NO_SUPPORT, "%s", return 0;
_("Network device release not available"));
return -1;
}
return netRelease(dom, iface); return netRelease(dom, iface);
} }
@ -29019,11 +29015,8 @@ bool
virDomainNetBandwidthChangeAllowed(virDomainNetDefPtr iface, virDomainNetBandwidthChangeAllowed(virDomainNetDefPtr iface,
virNetDevBandwidthPtr newBandwidth) virNetDevBandwidthPtr newBandwidth)
{ {
if (!netBandwidthChangeAllowed) { if (!netBandwidthChangeAllowed)
virReportError(VIR_ERR_NO_SUPPORT, "%s", return 0;
_("Network device bandwidth change query not available"));
return -1;
}
return netBandwidthChangeAllowed(iface, newBandwidth); return netBandwidthChangeAllowed(iface, newBandwidth);
} }
@ -29032,11 +29025,8 @@ int
virDomainNetBandwidthUpdate(virDomainNetDefPtr iface, virDomainNetBandwidthUpdate(virDomainNetDefPtr iface,
virNetDevBandwidthPtr newBandwidth) virNetDevBandwidthPtr newBandwidth)
{ {
if (!netBandwidthUpdate) { if (!netBandwidthUpdate)
virReportError(VIR_ERR_NO_SUPPORT, "%s", return 0;
_("Network device bandwidth update not available"));
return -1;
}
return netBandwidthUpdate(iface, newBandwidth); return netBandwidthUpdate(iface, newBandwidth);
} }