From: root Date: Tue, 30 Sep 2008 01:06:29 +0000 (+0200) Subject: Second problem; X-Git-Url: https://repo.or.cz/w/handlervirt.git/commitdiff_plain/12bba557870a19a46c2af8005601a8ccd16c19eb Second problem; When only one domain was defined that would be Dom0. Ignored all the code afterwards. Now we can safely assume that if only one domain is defined we should have in fact removed all other domains too. (Otherwise the normal management routines kick in) --- diff --git a/node/publish.c b/node/publish.c index 38b5dca..e3da488 100644 --- a/node/publish.c +++ b/node/publish.c @@ -56,9 +56,15 @@ static AvahiStringList * domainProperties(virDomainPtr thisDomain) { } void remove_everything() { - free(domus); - domus = NULL; - domu_count = 0; + if (domus) { + int i; + for (i = 0; i < domu_count; i++) { + avahi_entry_group_free(domus[i].group); + } + free(domus); + domus = NULL; + domu_count = 0; + } } @@ -77,18 +83,19 @@ void create_services(AvahiClient *c) { domu * domus_old = domus; domus = (domu *) malloc(sizeof(domu) * domu_count_new); const char *type = "_domu._tcp"; + for (i = 0; i < domu_count_new; i++) { int j; domus[i].group = NULL; domus[i].domainid = ids[i+1]; domus[i].keep = 0; - //fprintf(stderr, "Looking for %d\n", domus[i].domainid); + fprintf(stderr, "Looking for %d\n", domus[i].domainid); for (j = 0; j < domu_count; j++) { - //fprintf(stderr, "--> %d\n", domus_old[j].domainid); + fprintf(stderr, "--> %d\n", domus_old[j].domainid); if (ids[i+1] == domus_old[j].domainid) { - //fprintf(stderr, "got it\n"); + fprintf(stderr, "got it\n"); virDomainPtr thisDomain = virDomainLookupByID(conn, domus[i].domainid); domus[i].group = domus_old[j].group; if (thisDomain) { @@ -140,6 +147,8 @@ void create_services(AvahiClient *c) { domu_count = domu_count_new; } free(ids); + } else { + remove_everything(); } virConnectClose(conn); //fprintf(stderr, "exit: %s\n", __func__);