Re: [PATCH v4 3/5] qemu: Implement virDomainGetHostnameFlags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 10, 2020 at 03:19:16PM +0100, Michal Privoznik wrote:
> On 1/10/20 2:05 PM, Erik Skultety wrote:
> > On Thu, Jan 09, 2020 at 01:45:58PM +0100, Michal Privoznik wrote:
> > > From: Julio Faracco <jcfaracco@xxxxxxxxx>
> > >
> > > We have to keep the default - querying the agent if no flag is
> > > set.
> > >
> > > Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> > > Signed-off-by: Julio Faracco <jcfaracco@xxxxxxxxx>
> > > ---
> > ...
> >
> > > +
> > > +static int
> > > +qemuDomainGetHostnameLease(virQEMUDriverPtr driver,
> > > +                           virDomainObjPtr vm,
> > > +                           char **hostname)
> > ...
> >
> > > +
> > > +        if ((n_leases = virNetworkGetDHCPLeases(network, macaddr,
> > > +                                                &leases, 0)) < 0)
> > > +            goto endjob;
> > > +
> > > +        for (j = 0; j < n_leases; j++) {
> > > +            virNetworkDHCPLeasePtr lease = leases[j];
> > > +            if (lease->hostname && !*hostname)
> > > +                *hostname = g_strdup(lease->hostname);
> >
> > Not a big deal, but why not doing a break once you extract the first hostname?
>
> We need to free all leases to avoid memleak. Instead of doing that in two
> separate loops (one where we'd look for the hostname, the other just for
> freeing), I find it simpler if done in a single loop.

Aaah, shoot, you're right, please ignore my comment then.

Erik

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux