Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:olh:xen-4.5
libvirt-4.7.0
libvirt.suse-netcontrol.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File libvirt.suse-netcontrol.patch of Package libvirt-4.7.0
From: Olaf Hering <olaf@aepfle.de> Date: Wed, 21 Feb 2018 10:03:54 +0000 Subject: suse-netcontrol --- configure.ac | 2 ++ m4/virt-driver-interface.m4 | 7 ++++--- m4/virt-netcontrol.m4 | 35 +++++++++++++++++++++++++++++++++++ src/interface/Makefile.inc.am | 5 +++++ src/interface/interface_backend_netcf.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/interface/interface_driver.c | 9 ++++++++- tools/virsh.c | 2 ++ 7 files changed, 110 insertions(+), 5 deletions(-) create mode 100644 m4/virt-netcontrol.m4 --- a/configure.ac +++ b/configure.ac @@ -290,24 +290,25 @@ LIBVIRT_CHECK_FIREWALLD LIBVIRT_CHECK_FUSE LIBVIRT_CHECK_GLUSTER LIBVIRT_CHECK_GNUTLS LIBVIRT_CHECK_HAL LIBVIRT_CHECK_LIBISCSI LIBVIRT_CHECK_LIBNL LIBVIRT_CHECK_LIBPARTED LIBVIRT_CHECK_LIBPCAP LIBVIRT_CHECK_LIBSSH LIBVIRT_CHECK_LIBXML LIBVIRT_CHECK_MACVTAP LIBVIRT_CHECK_NETCF +LIBVIRT_CHECK_NETCONTROL LIBVIRT_CHECK_NLS LIBVIRT_CHECK_NUMACTL LIBVIRT_CHECK_NWFILTER LIBVIRT_CHECK_OPENWSMAN LIBVIRT_CHECK_PCIACCESS LIBVIRT_CHECK_PM_UTILS LIBVIRT_CHECK_POLKIT LIBVIRT_CHECK_PTHREAD LIBVIRT_CHECK_READLINE LIBVIRT_CHECK_SANLOCK LIBVIRT_CHECK_SASL LIBVIRT_CHECK_SELINUX @@ -975,24 +976,25 @@ LIBVIRT_RESULT_FIREWALLD LIBVIRT_RESULT_FUSE LIBVIRT_RESULT_GLUSTER LIBVIRT_RESULT_GNUTLS LIBVIRT_RESULT_HAL LIBVIRT_RESULT_LIBISCSI LIBVIRT_RESULT_LIBNL LIBVIRT_RESULT_LIBPCAP LIBVIRT_RESULT_LIBSSH LIBVIRT_RESULT_LIBXL LIBVIRT_RESULT_LIBXML LIBVIRT_RESULT_MACVTAP LIBVIRT_RESULT_NETCF +LIBVIRT_RESULT_NETCONTROL LIBVIRT_RESULT_NLS LIBVIRT_RESULT_NSS LIBVIRT_RESULT_NUMACTL LIBVIRT_RESULT_OPENWSMAN LIBVIRT_RESULT_PCIACCESS LIBVIRT_RESULT_PM_UTILS LIBVIRT_RESULT_POLKIT LIBVIRT_RESULT_RBD LIBVIRT_RESULT_READLINE LIBVIRT_RESULT_SANLOCK LIBVIRT_RESULT_SASL LIBVIRT_RESULT_SELINUX --- a/m4/virt-driver-interface.m4 +++ b/m4/virt-driver-interface.m4 @@ -22,28 +22,29 @@ AC_DEFUN([LIBVIRT_DRIVER_ARG_INTERFACE], [ ]) AC_DEFUN([LIBVIRT_DRIVER_CHECK_INTERFACE], [ AC_REQUIRE([LIBVIRT_DRIVER_CHECK_LIBVIRTD]) AC_REQUIRE([LIBVIRT_CHECK_NETCF]) AC_REQUIRE([LIBVIRT_CHECK_UDEV]) dnl Don't compile the interface driver without libvirtd if test "$with_libvirtd" = "no" ; then with_interface=no fi - dnl The interface driver depends on the netcf library or udev library - case $with_interface:$with_netcf:$with_udev in + dnl The interface driver depends on the netcf library, netcontrol library, or + dnl udev library + case $with_interface:$with_netcf:$with_netcontrol:$with_udev in check:*yes*) with_interface=yes ;; check:no:no) with_interface=no ;; - yes:no:no) AC_MSG_ERROR([Requested the Interface driver without netcf or udev support]) ;; + yes:no:no) AC_MSG_ERROR([Requested the Interface driver without netcf, netcontrol, or udev support]) ;; esac if test "$with_interface" = "yes" ; then AC_DEFINE_UNQUOTED([WITH_INTERFACE], [1], [whether the interface driver is enabled]) fi AM_CONDITIONAL([WITH_INTERFACE], [test "$with_interface" = "yes"]) ]) AC_DEFUN([LIBVIRT_DRIVER_RESULT_INTERFACE], [ LIBVIRT_RESULT([Interface], [$with_interface]) ]) new file mode 100644 --- /dev/null +++ b/m4/virt-netcontrol.m4 @@ -0,0 +1,35 @@ +dnl The libnetcontrol library +dnl +dnl Copyright (C) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License, or (at your option) any later version. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library. If not, see +dnl <http://www.gnu.org/licenses/>. +dnl + +AC_DEFUN([LIBVIRT_CHECK_NETCONTROL],[ + LIBVIRT_CHECK_PKG([NETCONTROL], [netcontrol], [0.2.0]) + + if test "$with_netcontrol" = "yes" ; then + old_CFLAGS="$CFLAGS" + old_LIBS="$CFLAGS" + CFLAGS="$CFLAGS $NETCONTROL_CFLAGS" + LIBS="$LIBS $NETCONTROL_LIBS" + CFLAGS="$old_CFLAGS" + LIBS="$old_LIBS" + fi +]) + +AC_DEFUN([LIBVIRT_RESULT_NETCONTROL],[ + LIBVIRT_RESULT_LIB([NETCONTROL]) +]) --- a/src/interface/Makefile.inc.am +++ b/src/interface/Makefile.inc.am @@ -29,14 +29,19 @@ libvirt_driver_interface_la_LIBADD = \ $(NULL) libvirt_driver_interface_la_SOURCES = $(INTERFACE_DRIVER_SOURCES) if WITH_NETCF libvirt_driver_interface_la_CFLAGS += $(NETCF_CFLAGS) libvirt_driver_interface_la_LIBADD += $(NETCF_LIBS) libvirt_driver_interface_la_SOURCES += $(INTERFACE_DRIVER_NETCF_SOURCES) endif WITH_NETCF if WITH_UDEV libvirt_driver_interface_la_CFLAGS += $(UDEV_CFLAGS) libvirt_driver_interface_la_LIBADD += $(UDEV_LIBS) libvirt_driver_interface_la_SOURCES += $(INTERFACE_DRIVER_UDEV_SOURCES) endif WITH_UDEV +if WITH_NETCONTROL +libvirt_driver_interface_la_CFLAGS += $(NETCONTROL_CFLAGS) +libvirt_driver_interface_la_LIBADD += $(NETCONTROL_LIBS) +libvirt_driver_interface_la_SOURCES += $(INTERFACE_DRIVER_NETCF_SOURCES) +endif WITH_NETCONTROL libvirt_driver_interface_la_LIBADD += ../gnulib/lib/libgnu.la endif WITH_INTERFACE --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -14,25 +14,30 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see * <http://www.gnu.org/licenses/>. * * Author: Laine Stump <laine@redhat.com> */ #include <config.h> -#include <netcf.h> +#ifdef WITH_NETCONTROL +# include <netcontrol/netcf.h> +# include <netcontrol/logger.h> +#else +# include <netcf.h> +#endif #include "virerror.h" #include "datatypes.h" #include "interface_driver.h" #include "interface_conf.h" #include "viralloc.h" #include "virlog.h" #include "virstring.h" #include "viraccessapicheck.h" #include "virinterfaceobj.h" #define VIR_FROM_THIS VIR_FROM_INTERFACE @@ -56,48 +61,83 @@ static int virNetcfDriverStateOnceInit(void) { if (!VIR_CLASS_NEW(virNetcfDriverState, virClassForObjectLockable())) return -1; return 0; } VIR_ONCE_GLOBAL_INIT(virNetcfDriverState) static virNetcfDriverStatePtr driver; +#ifdef WITH_NETCONTROL +static void +interface_nc_log_driver(const char *category ATTRIBUTE_UNUSED, + int priority, + const char *func, + const char *file, + long long line, + const char *msg, + size_t len ATTRIBUTE_UNUSED) +{ + int vp; + + 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; + } + virLogMessage(&virLogSelf, vp, file, line, func, 0, "%s", msg); +} +#endif static void virNetcfDriverStateDispose(void *obj) { virNetcfDriverStatePtr _driver = obj; if (_driver->netcf) ncf_close(_driver->netcf); } static int netcfStateInitialize(bool privileged, virStateInhibitCallback callback ATTRIBUTE_UNUSED, void *opaque ATTRIBUTE_UNUSED) { if (virNetcfDriverStateInitialize() < 0) return -1; if (!(driver = virObjectLockableNew(virNetcfDriverStateClass))) return -1; driver->privileged = privileged; +#ifdef WITH_NETCONTROL + nc_logger_redirect_to(interface_nc_log_driver); +#endif + /* open netcf */ if (ncf_init(&driver->netcf, NULL) != 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to initialize netcf")); virObjectUnref(driver); driver = NULL; return -1; } return 0; } @@ -1216,20 +1256,33 @@ static virConnectDriver interfaceConnectDriver = { }; static virStateDriver interfaceStateDriver = { .name = INTERFACE_DRIVER_NAME, .stateInitialize = netcfStateInitialize, .stateCleanup = netcfStateCleanup, .stateReload = netcfStateReload, }; int netcfIfaceRegister(void) { + struct netcf *netcf; + + /* Initialization of libnetcontrol will fail if NetworkManager is enabled. + * Skip registration if ncf_init fails. + * TODO: finer-grained check? E.g. is_nm_enabled() + */ + if (ncf_init(&netcf, NULL) != 0) { + VIR_WARN("Failed to intialize libnetcontrol. Management of interface devices is disabled"); + return 0; + } + + ncf_close(netcf); + if (virRegisterConnectDriver(&interfaceConnectDriver, false) < 0) return -1; if (virSetSharedInterfaceDriver(&interfaceDriver) < 0) return -1; if (virRegisterStateDriver(&interfaceStateDriver) < 0) return -1; return 0; } --- a/src/interface/interface_driver.c +++ b/src/interface/interface_driver.c @@ -21,19 +21,26 @@ #include <config.h> #include "interface_driver.h" int interfaceRegister(void) { #ifdef WITH_NETCF /* Attempt to load the netcf based backend first */ if (netcfIfaceRegister() == 0) return 0; #endif /* WITH_NETCF */ +#ifdef WITH_NETCONTROL + /* Attempt to load the netcontrol based backend, which is a slightly + patched netcf backend */ + if (netcfIfaceRegister() == 0) + return 0; +#endif /* WITH_NETCONTROL */ #if WITH_UDEV - /* If there's no netcf or it failed to load, register the udev backend */ + /* If there's no netcf or netcontrol, or it failed to load, register the + udev backend */ if (udevIfaceRegister() == 0) return 0; #endif /* WITH_UDEV */ return -1; } --- a/tools/virsh.c +++ b/tools/virsh.c @@ -566,24 +566,26 @@ virshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED) vshPrint(ctl, " Remote"); #endif #ifdef WITH_NETWORK vshPrint(ctl, " Network"); #endif #ifdef WITH_BRIDGE vshPrint(ctl, " Bridging"); #endif #if defined(WITH_INTERFACE) vshPrint(ctl, " Interface"); # if defined(WITH_NETCF) vshPrint(ctl, " netcf"); +# elif defined(WITH_NETCONTROL) + vshPrint(ctl, " netcontrol"); # elif defined(WITH_UDEV) vshPrint(ctl, " udev"); # endif #endif #ifdef WITH_NWFILTER vshPrint(ctl, " Nwfilter"); #endif #ifdef WITH_VIRTUALPORT vshPrint(ctl, " VirtualPort"); #endif vshPrint(ctl, "\n");
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor