[libvirt] [PATCH for 5.10.0] nss: Don't fail on empty files

Daniel P. Berrangé berrange at redhat.com
Thu Nov 28 13:46:02 UTC 2019


On Thu, Nov 28, 2019 at 02:40:55PM +0100, Michal Privoznik wrote:
> Before we rewrote nss plugin so that it doesn't use libvirt's
> internal functions it used virLeaseReadCustomLeaseFile() to parse
> .status files. After the rewrite it's using read() + yajl_parse()
> + yajl_complete_parse(). There's one catch though,
> virLeaseReadCustomLeaseFile() skipped over empty files.
> 
> An empty .status file is created when a network is started. This
> is because we configure dnsmasq to use our leasehelper. So the
> first thing it does it calls it as follows:
> 
>   DNSMASQ_INTERFACE=virbr0 /usr/libexec/libvirt_leaseshelper init
> 
> which causes the leasehelper to create empty virbr0.status file.
> If there is only one libvirt network then that is no problem -
> there are no other .status files to parse anyway. But if there
> are two or more networks then the first empty .status file causes
> whole parsing process and subsequently the whole name lookup
> process to fail.
> 
> Reported-by: Pavel Hrdina <phrdina at redhat.com>
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  tools/nss/libvirt_nss_leases.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrangé <berrange at redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list