[libvirt] [PATCH 03/12] network: Check for active network during networkGetDHCPLeases
Ján Tomko
jtomko at redhat.com
Fri Sep 11 13:22:00 UTC 2020
On a Friday in 2020, Lin Ma wrote:
>It doesn't make sense querying dhcp leases for interfaces against an inactive
>network, This patch adds a check to see if the network is active.
>
Why would the network need to be active? the leases are still there:
$ virsh net-destroy default
Network default destroyed
$ virsh net-dhcp-leases default
Expiry Time MAC address Protocol IP address Hostname Client ID or DUID
------------------------------------------------------------------------------------------------------------
2020-09-11 16:16:59 52:54:00:55:7c:df ipv4 192.168.122.183/24 - 01:52:54:00:55:7c:df
Jano
>Signed-off-by: Lin Ma <lma at suse.de>
>---
> src/network/bridge_driver.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
>diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
>index 87d7acab06..1dffc2309f 100644
>--- a/src/network/bridge_driver.c
>+++ b/src/network/bridge_driver.c
>@@ -4068,6 +4068,13 @@ networkGetDHCPLeases(virNetworkPtr net,
> if (virNetworkGetDHCPLeasesEnsureACL(net->conn, def) < 0)
> goto cleanup;
>
>+ if (!virNetworkObjIsActive(obj)) {
>+ virReportError(VIR_ERR_OPERATION_INVALID,
>+ _("network '%s' is not active"),
>+ def->name);
>+ goto error;
>+ }
>+
> /* Retrieve custom leases file location */
> custom_lease_file = networkDnsmasqLeaseFileNameCustom(driver, def->bridge);
>
>--
>2.26.0
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20200911/8652ef81/attachment-0001.sig>
More information about the libvir-list
mailing list