From: Chris Lalancette Date: Fri, 23 Oct 2009 10:05:01 +0000 (+0200) Subject: Replace a gethostname by virGetHostname in libvirtd.c X-Git-Tag: v0.7.3~188 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2af10cd4950c9424b89c87fc83a586dcd8bf29b;p=thirdparty%2Flibvirt.git Replace a gethostname by virGetHostname in libvirtd.c Signed-off-by: Chris Lalancette --- diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 4eb33bcd12..02bd2875ed 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); }