Index: libvirt-1.0.0/configure.ac =================================================================== --- libvirt-1.0.0.orig/configure.ac +++ libvirt-1.0.0/configure.ac @@ -102,6 +102,7 @@ AVAHI_REQUIRED="0.6.0" POLKIT_REQUIRED="0.6" PARTED_REQUIRED="1.8.0" NETCF_REQUIRED="0.1.4" +NETCONTROL_REQUIRED="0.2.0" UDEV_REQUIRED=145 PCIACCESS_REQUIRED=0.10.0 XMLRPC_REQUIRED=1.14.0 @@ -1960,6 +1961,38 @@ AM_CONDITIONAL([WITH_NETCF], [test "$wit AC_SUBST([NETCF_CFLAGS]) AC_SUBST([NETCF_LIBS]) +AC_ARG_WITH([netcontrol], + AC_HELP_STRING([--with-netcontrol], [SUSE netcontrol support to configure physical host network interfaces @<:@default=check@:>@]), + [], + [test "$with_netcontrol" = "yes" && with_netcontrol=no || with_netcontrol=check]) + +NETCONTROL_CFLAGS= +NETCONTROL_LIBS= +if test "$with_netcf" = "yes"; then + if test "$with_netcontrol" = "yes" || test "$with_netcontrol" = "check"; then + AC_MSG_WARN([netcf and netcontrol cannot be used together, disabling netcontrol]) + with_netcontrol=no + fi +fi + +if test "$with_netcontrol" = "yes" || test "$with_netcontrol" = "check"; then + PKG_CHECK_MODULES(NETCONTROL, netcontrol >= $NETCONTROL_REQUIRED, + [with_netcontrol=yes], [ + if test "$with_netcontrol" = "check" ; then + with_netcontrol=no + else + AC_MSG_ERROR( + [You must install netcontrol >= $NETCONTROL_REQUIRED to compile libvirt]) + fi + ]) + if test "$with_netcontrol" = "yes" ; then + AC_DEFINE_UNQUOTED([WITH_NETCONTROL], 1, + [whether libnetcontrol is available to configure physical host network interfaces]) + fi +fi +AM_CONDITIONAL([WITH_NETCONTROL], [test "$with_netcontrol" = "yes"]) +AC_SUBST([NETCONTROL_CFLAGS]) +AC_SUBST([NETCONTROL_LIBS]) AC_ARG_WITH([secrets], AC_HELP_STRING([--with-secrets], [with local secrets management driver @<:@default=yes@:>@]),[],[with_secrets=yes]) @@ -3193,6 +3226,11 @@ AC_MSG_NOTICE([ netcf: $NETCF_CFLAGS $ else AC_MSG_NOTICE([ netcf: no]) fi +if test "$with_netcontrol" = "yes" ; then +AC_MSG_NOTICE([ netctrl: $NETCONTROL_CFLAGS $NETCONTROL_LIBS]) +else +AC_MSG_NOTICE([ netctrl: no]) +fi if test "$with_qemu" = "yes" && test "$LIBPCAP_FOUND" != "no"; then AC_MSG_NOTICE([ pcap: $LIBPCAP_CFLAGS $LIBPCAP_LIBS]) else Index: libvirt-1.0.0/src/Makefile.am =================================================================== --- libvirt-1.0.0.orig/src/Makefile.am +++ libvirt-1.0.0/src/Makefile.am @@ -1064,6 +1064,24 @@ libvirt_driver_interface_la_LIBADD += .. libvirt_driver_interface_la_LDFLAGS += -module -avoid-version endif libvirt_driver_interface_la_SOURCES = $(INTERFACE_DRIVER_SOURCES) +else +if WITH_NETCONTROL +if WITH_DRIVER_MODULES +mod_LTLIBRARIES += libvirt_driver_interface.la +else +noinst_LTLIBRARIES += libvirt_driver_interface.la +libvirt_la_BUILT_LIBADD += libvirt_driver_interface.la +endif +libvirt_driver_interface_la_CFLAGS = $(NETCONTROL_CFLAGS) \ + -I@top_srcdir@/src/conf $(AM_CFLAGS) +libvirt_driver_interface_la_LDFLAGS = $(AM_LDFLAGS) +libvirt_driver_interface_la_LIBADD = $(NETCONTROL_LIBS) +if WITH_DRIVER_MODULES +libvirt_driver_interface_la_LIBADD += ../gnulib/lib/libgnu.la +libvirt_driver_interface_la_LDFLAGS += -module -avoid-version +endif +libvirt_driver_interface_la_SOURCES = $(INTERFACE_DRIVER_SOURCES) +endif endif if WITH_SECRETS Index: libvirt-1.0.0/tools/virsh.c =================================================================== --- libvirt-1.0.0.orig/tools/virsh.c +++ libvirt-1.0.0/tools/virsh.c @@ -2710,6 +2710,8 @@ vshShowVersion(vshControl *ctl ATTRIBUTE vshPrint(ctl, " netcf"); # elif defined(HAVE_UDEV) vshPrint(ctl, " udev"); +# elif defined(WITH_NETCONTROL) + vshPrint(ctl, " netcontrol"); # endif #endif #ifdef WITH_NWFILTER Index: libvirt-1.0.0/src/interface/interface_backend_netcf.c =================================================================== --- libvirt-1.0.0.orig/src/interface/interface_backend_netcf.c +++ libvirt-1.0.0/src/interface/interface_backend_netcf.c @@ -23,7 +23,12 @@ #include -#include +#ifdef WITH_NETCONTROL +# include +# include +#else +# include +#endif #include "virterror_internal.h" #include "datatypes.h" @@ -52,6 +57,39 @@ static void interfaceDriverUnlock(struct virMutexUnlock(&driver->lock); } +#ifdef WITH_NETCONTROL +static void interface_nc_log_driver(const char *category, + int priority, + const char *func, + const char *file ATTRIBUTE_UNUSED, + long long line, + const char *msg, + size_t len ATTRIBUTE_UNUSED) +{ + int vp; + const char *vc; + + switch(priority) { + case NC_LOG_FATAL: + case NC_LOG_ERROR: + vp = VIR_LOG_ERROR; + break; + case NC_LOG_WARN: + vp = VIR_LOG_WARN; + break; + case NC_LOG_INFO: + vp = VIR_LOG_INFO; + break; + case NC_LOG_DEBUG: + default: + vp = VIR_LOG_DEBUG; + break; + } + vc = category ? category : "netcontrol"; + virLogMessage(vc, vp, func, line, 0, "%s", msg); +} +#endif + static int netcf_to_vir_err(int netcf_errcode) { switch (netcf_errcode) @@ -137,6 +175,10 @@ static virDrvOpenStatus interfaceOpenInt goto mutex_error; } +#ifdef WITH_NETCONTROL + nc_logger_redirect_to(interface_nc_log_driver); +#endif + /* open netcf */ if (ncf_init(&driverState->netcf, NULL) != 0) {