Re: [libvirt] [PATCH] Replace a gethostname by virGetHostname in libvirtd.c

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

 



On 10/23/2009 07:01 AM, Chris Lalancette wrote:
> Signed-off-by: Chris Lalancette <clalance@xxxxxxxxxx>
> ---
>  daemon/libvirtd.c |   10 +++++++---
>  1 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
> index 4eb33bc..02bd287 100644
> --- a/daemon/libvirtd.c
> +++ b/daemon/libvirtd.c
> @@ -937,15 +937,19 @@ static struct qemud_server *qemudNetworkInit(struct qemud_server *server) {
>          server->mdns = libvirtd_mdns_new();
>  
>          if (!mdns_name) {
> -            char groupname[64], localhost[HOST_NAME_MAX+1], *tmp;
> +            char groupname[64], *localhost, *tmp;
>              /* Extract the host part of the potentially FQDN */
> -            gethostname(localhost, HOST_NAME_MAX);
> -            localhost[HOST_NAME_MAX] = '\0';
> +            localhost = virGetHostname();
> +            if (localhost == NULL) {
> +                virReportOOMError(NULL);
> +                goto cleanup;
> +            }
>              if ((tmp = strchr(localhost, '.')))
>                  *tmp = '\0';
>              snprintf(groupname, sizeof(groupname)-1, "Virtualization Host %s", localhost);
>              groupname[sizeof(groupname)-1] = '\0';
>              group = libvirtd_mdns_add_group(server->mdns, groupname);
> +            VIR_FREE(localhost);
>          } else {
>              group = libvirtd_mdns_add_group(server->mdns, mdns_name);
>          }

ACK

- Cole

--
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]