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

Re: [libvirt] [PATCH] Bind to ip_addr support.



About mdns, do you think it would be a good thing to *not* follow the
Avahi advise and explicitly set the host the service is running on? In my
humble opinion I think that would be a wise decision.

host 	The host this services is residing on. We recommend to pass NULL
here, the daemon will than automatically insert the local host name in
that case

I wonder how avahi will decide if the service doesn't run on 0.0.0.0 but
on a specific address. Then we still have domain left, but with a bit
smart implementation upstream that could just work.

The attached patch explicitly sets the host of the mDNS advertisement.


Because of some 'unexpected' behavior... I hoped strdup(NULL) would just
work, but it didn't, I placed it inside an if loop. The debug message
doesn't mind '(null)' but I think 0.0.0.0 is more appropriate.

Sign-off-by: Stefan de Konink <dekonink kinkrsoftware nl>


Stefan
--- qemud/mdns.h.orig	2008-05-10 19:29:18.000000000 +0200
+++ qemud/mdns.h	2008-05-10 19:29:38.000000000 +0200
@@ -83,7 +83,7 @@
  *
  * returns the service record, or NULL upon failure
  */
-struct libvirtd_mdns_entry *libvirtd_mdns_add_entry(struct libvirtd_mdns_group *group, const char *type, int port);
+struct libvirtd_mdns_entry *libvirtd_mdns_add_entry(struct libvirtd_mdns_group *group, const char *type, const char *host, int port);
 
 /**
  * Removes a service entry from a group
--- qemud/mdns.c.orig	2008-05-10 19:22:45.000000000 +0200
+++ qemud/mdns.c	2008-05-10 19:35:10.000000000 +0200
@@ -46,6 +46,7 @@
 
 struct libvirtd_mdns_entry {
     char *type;
+    char *host;
     int port;
     struct libvirtd_mdns_entry *next;
 };
@@ -153,7 +154,7 @@
                                                  group->name,
                                                  entry->type,
                                                  NULL,
-                                                 NULL,
+                                                 entry->host,
                                                  entry->port,
                                                  NULL)) < 0) {
             AVAHI_DEBUG("Failed to add %s service on port %d: %s",
@@ -440,18 +441,28 @@
     }
 }
 
-struct libvirtd_mdns_entry *libvirtd_mdns_add_entry(struct libvirtd_mdns_group *group, const char *type, int port) {
+struct libvirtd_mdns_entry *libvirtd_mdns_add_entry(struct libvirtd_mdns_group *group, const char *type, const char *host, int port) {
     struct libvirtd_mdns_entry *entry = malloc(sizeof(*entry));
 
-    AVAHI_DEBUG("Adding entry %s %d to group %s", type, port, group->name);
+    AVAHI_DEBUG("Adding entry %s %s %d to group %s", type, (host == NULL ? "0.0.0.0" : host), port, group->name);
     if (!entry)
         return NULL;
 
     entry->port = port;
+
     if (!(entry->type = strdup(type))) {
         free(entry);
         return NULL;
     }
+    
+    if (host != NULL) {
+        if (!(entry->host = strdup(host))) {
+	    free(entry->type);
+            free(entry);
+            return NULL;
+        }
+    }
+
     entry->next = group->entry;
     group->entry = entry;
     return entry;
--- qemud/qemud.c.orig2	2008-05-10 19:22:57.000000000 +0200
+++ qemud/qemud.c	2008-05-10 19:26:46.000000000 +0200
@@ -828,7 +828,7 @@
          * Add the primary entry - we choose SSH because its most likely to always
          * be available
          */
-        libvirtd_mdns_add_entry(group, "_libvirt._tcp", port);
+        libvirtd_mdns_add_entry(group, "_libvirt._tcp", ip_addr, port);
         libvirtd_mdns_start(server->mdns);
     }
 #endif

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