]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Replace a gethostname by virGetHostname in libvirtd.c
authorChris Lalancette <clalance@redhat.com>
Fri, 23 Oct 2009 10:05:01 +0000 (12:05 +0200)
committerChris Lalancette <clalance@redhat.com>
Mon, 26 Oct 2009 09:33:20 +0000 (10:33 +0100)
Signed-off-by: Chris Lalancette <clalance@redhat.com>
daemon/libvirtd.c

index 4eb33bcd120775cb41bf44fe9b22860a9eac5ce1..02bd2875ed2d258a8840e8ec89b05de3368ba37c 100644 (file)
@@ -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);
         }