[libvirt] [PATCH] [RFC] net: don't segfault on Martin's setup

Laine Stump laine at laine.org
Thu Aug 14 15:14:25 UTC 2014


On 08/14/2014 10:13 AM, Martin Kletzander wrote:
> No, don't worry, this is not a real commit message, this is more like
> an RFC about how to fix it.  I'm not sure about this part of libvirt
> codebase, so I'm rather asking for help.  Apparently, I have a network
> with netdef->forward.pfs == NULL, I suspect this is a network I have,
> that doesn't have any <forward/> element.

Ouch! Actually it doesn't even need to be that extreme, it just needs to
not have any <pf> elements.

>
> With the following fix, everything works as expected, but I'm almost
> certain this is not enough.
>
> Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
> ---
>  src/network/bridge_driver.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
> index 1ba4c3d..3a40124 100644
> --- a/src/network/bridge_driver.c
> +++ b/src/network/bridge_driver.c
> @@ -2196,6 +2196,9 @@ networkCreateInterfacePool(virNetworkDefPtr netdef)
>      int ret = -1;
>      size_t i;
>
> +    if (!netdef->forward.pfs)
> +        return 0;
> +

This will work, but I notice that all previously existing calls to
networkCreateInterfacePool() check for npfs > 0 and nifs == 0 prior to
calling, so I'll make a patch that removes those checks from the callers
and moves them into networkCreateInterfacePool().

Sorry for the mess, and thanks for debugging the failure.




More information about the libvir-list mailing list