1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

build: add stubs so mdns code can be unconditionally compiled

The recent changes to the testsuite to validate exported symbols
flushed out a case of unconditionally exporting symbols that
were only conditionally compiled under HAVE_AVAHI.

* src/Makefile.am (libvirt_net_rpc_server_la_SOURCES): Compile
virnetservermdns unconditionally.
* configure.ac (HAVE_AVAHI): Drop unused automake conditional.
* src/rpc/virnetservermdns.c: Add fallbacks when Avahi is not
present.
This commit is contained in:
Eric Blake 2012-08-01 17:42:51 -06:00
parent 54b6334714
commit 1f6f723ce1
3 changed files with 91 additions and 16 deletions

View File

@ -1305,7 +1305,6 @@ if test "x$with_avahi" = "xyes" || test "x$with_avahi" = "xcheck"; then
[whether Avahi is used to broadcast server presense]) [whether Avahi is used to broadcast server presense])
fi fi
fi fi
AM_CONDITIONAL([HAVE_AVAHI], [test "x$with_avahi" = "xyes"])
AC_SUBST([AVAHI_CFLAGS]) AC_SUBST([AVAHI_CFLAGS])
AC_SUBST([AVAHI_LIBS]) AC_SUBST([AVAHI_LIBS])

View File

@ -1533,14 +1533,8 @@ libvirt_net_rpc_server_la_SOURCES = \
rpc/virnetserverprogram.h rpc/virnetserverprogram.c \ rpc/virnetserverprogram.h rpc/virnetserverprogram.c \
rpc/virnetserverservice.h rpc/virnetserverservice.c \ rpc/virnetserverservice.h rpc/virnetserverservice.c \
rpc/virnetserverclient.h rpc/virnetserverclient.c \ rpc/virnetserverclient.h rpc/virnetserverclient.c \
rpc/virnetservermdns.h rpc/virnetservermdns.c \
rpc/virnetserver.h rpc/virnetserver.c rpc/virnetserver.h rpc/virnetserver.c
if HAVE_AVAHI
libvirt_net_rpc_server_la_SOURCES += \
rpc/virnetservermdns.h rpc/virnetservermdns.c
else
EXTRA_DIST += \
rpc/virnetservermdns.h rpc/virnetservermdns.c
endif
libvirt_net_rpc_server_la_CFLAGS = \ libvirt_net_rpc_server_la_CFLAGS = \
$(AVAHI_CFLAGS) \ $(AVAHI_CFLAGS) \
$(XDR_CFLAGS) \ $(XDR_CFLAGS) \

View File

@ -1,7 +1,7 @@
/* /*
* virnetservermdns.c: advertise server sockets * virnetservermdns.c: advertise server sockets
* *
* Copyright (C) 2011 Red Hat, Inc. * Copyright (C) 2011-2012 Red Hat, Inc.
* Copyright (C) 2007 Daniel P. Berrange * Copyright (C) 2007 Daniel P. Berrange
* *
* Derived from Avahi example service provider code. * Derived from Avahi example service provider code.
@ -29,14 +29,16 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <avahi-client/client.h> #if HAVE_AVAHI
#include <avahi-client/publish.h> # include <avahi-client/client.h>
# include <avahi-client/publish.h>
#include <avahi-common/alternative.h> # include <avahi-common/alternative.h>
#include <avahi-common/simple-watch.h> # include <avahi-common/simple-watch.h>
#include <avahi-common/malloc.h> # include <avahi-common/malloc.h>
#include <avahi-common/error.h> # include <avahi-common/error.h>
#include <avahi-common/timeval.h> # include <avahi-common/timeval.h>
#endif
#include "virnetservermdns.h" #include "virnetservermdns.h"
#include "event.h" #include "event.h"
@ -55,18 +57,23 @@ struct _virNetServerMDNSEntry {
struct _virNetServerMDNSGroup { struct _virNetServerMDNSGroup {
virNetServerMDNSPtr mdns; virNetServerMDNSPtr mdns;
#if HAVE_AVAHI
AvahiEntryGroup *handle; AvahiEntryGroup *handle;
#endif
char *name; char *name;
virNetServerMDNSEntryPtr entry; virNetServerMDNSEntryPtr entry;
virNetServerMDNSGroupPtr next; virNetServerMDNSGroupPtr next;
}; };
struct _virNetServerMDNS { struct _virNetServerMDNS {
#if HAVE_AVAHI
AvahiClient *client; AvahiClient *client;
AvahiPoll *poller; AvahiPoll *poller;
#endif
virNetServerMDNSGroupPtr group; virNetServerMDNSGroupPtr group;
}; };
#if HAVE_AVAHI
/* Avahi API requires this struct name in the app :-( */ /* Avahi API requires this struct name in the app :-( */
struct AvahiWatch { struct AvahiWatch {
int watch; int watch;
@ -612,3 +619,78 @@ void virNetServerMDNSEntryFree(virNetServerMDNSEntryPtr entry)
VIR_FREE(entry->type); VIR_FREE(entry->type);
VIR_FREE(entry); VIR_FREE(entry);
} }
#else /* ! HAVE_AVAHI */
static const char *unsupported = N_("avahi not available at build time");
virNetServerMDNS *
virNetServerMDNSNew(void)
{
VIR_DEBUG("%s", _(unsupported));
return NULL;
}
int
virNetServerMDNSStart(virNetServerMDNS *mdns ATTRIBUTE_UNUSED)
{
VIR_DEBUG("%s", _(unsupported));
return -1;
}
virNetServerMDNSGroupPtr
virNetServerMDNSAddGroup(virNetServerMDNS *mdns ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED)
{
VIR_DEBUG("%s", _(unsupported));
return NULL;
}
void
virNetServerMDNSRemoveGroup(virNetServerMDNSPtr mdns ATTRIBUTE_UNUSED,
virNetServerMDNSGroupPtr group ATTRIBUTE_UNUSED)
{
VIR_DEBUG("%s", _(unsupported));
}
virNetServerMDNSEntryPtr
virNetServerMDNSAddEntry(virNetServerMDNSGroupPtr group ATTRIBUTE_UNUSED,
const char *type ATTRIBUTE_UNUSED,
int port ATTRIBUTE_UNUSED)
{
VIR_DEBUG("%s", _(unsupported));
return NULL;
}
void
virNetServerMDNSRemoveEntry(virNetServerMDNSGroupPtr group ATTRIBUTE_UNUSED,
virNetServerMDNSEntryPtr entry ATTRIBUTE_UNUSED)
{
VIR_DEBUG("%s", _(unsupported));
}
void
virNetServerMDNSStop(virNetServerMDNSPtr mdns ATTRIBUTE_UNUSED)
{
VIR_DEBUG("%s", _(unsupported));
}
void
virNetServerMDNSFree(virNetServerMDNSPtr mdns ATTRIBUTE_UNUSED)
{
VIR_DEBUG("%s", _(unsupported));
}
void
virNetServerMDNSGroupFree(virNetServerMDNSGroupPtr grp ATTRIBUTE_UNUSED)
{
VIR_DEBUG("%s", _(unsupported));
}
void
virNetServerMDNSEntryFree(virNetServerMDNSEntryPtr entry ATTRIBUTE_UNUSED)
{
VIR_DEBUG("%s", _(unsupported));
}
#endif /* ! HAVE_AVAHI */