2022-09-02 00:07:34 +02:00
From a2a8fd82918b5d3e8ac5c8fd6f2f97be1d4bdf11 Mon Sep 17 00:00:00 2001
From: Jim Fehlig <jfehlig@suse.com>
Date: Tue, 5 Jul 2022 11:58:35 -0600
Subject: libnetcontrol patch for libvirt
Originally authored by mt@suse.de
---
meson.build | 11 ++++-
meson_options.txt | 1 +
src/interface/interface_backend_netcf.c | 59 ++++++++++++++++++++++++-
src/interface/interface_driver.c | 9 +++-
src/interface/meson.build | 3 +-
tools/virsh.c | 2 +
6 files changed, 80 insertions(+), 5 deletions(-)
Index: libvirt-8.7.0/meson.build
2011-09-16 20:53:58 +02:00
===================================================================
2022-09-02 00:07:34 +02:00
--- libvirt-8.7.0.orig/meson.build
+++ libvirt-8.7.0/meson.build
@@ -1073,6 +1073,12 @@ else
netcf_dep = dependency('', required: false)
endif
+netcontrol_version = '0.2.0'
+netcontrol_dep = dependency('netcontrol', version: '>=' + netcontrol_version, required: get_option('netcontrol'))
+if netcontrol_dep.found()
+ conf.set('WITH_NETCONTROL', 1)
+endif
+
have_gnu_gettext_tools = false
if not get_option('nls').disabled()
have_gettext = cc.has_function('gettext')
@@ -1480,10 +1486,10 @@ elif get_option('driver_hyperv').enabled
error('openwsman is required for the Hyper-V driver')
endif
-if not get_option('driver_interface').disabled() and conf.has('WITH_LIBVIRTD') and (udev_dep.found() or conf.has('WITH_NETCF'))
+if not get_option('driver_interface').disabled() and conf.has('WITH_LIBVIRTD') and (udev_dep.found() or conf.has('WITH_NETCF') or netcontrol_dep.found())
conf.set('WITH_INTERFACE', 1)
elif get_option('driver_interface').enabled()
- error('Requested the Interface driver without netcf or udev and libvirtd support')
+ error('Requested the Interface driver without netcf, netcontrol or udev and libvirtd support')
endif
if not get_option('driver_libxl').disabled() and conf.has('WITH_LIBVIRTD')
@@ -2291,6 +2297,7 @@ libs_summary = {
'libssh2': libssh2_dep.found(),
'libutil': libutil_dep.found(),
'netcf': conf.has('WITH_NETCF'),
+ 'netcontrol': netcontrol_dep.found(),
'NLS': have_gnu_gettext_tools,
'numactl': numactl_dep.found(),
'openwsman': openwsman_dep.found(),
Index: libvirt-8.7.0/meson_options.txt
===================================================================
--- libvirt-8.7.0.orig/meson_options.txt
+++ libvirt-8.7.0/meson_options.txt
@@ -29,6 +29,7 @@ option('libpcap', type: 'feature', value
option('libssh', type: 'feature', value: 'auto', description: 'libssh support')
option('libssh2', type: 'feature', value: 'auto', description: 'libssh2 support')
option('netcf', type: 'feature', value: 'auto', description: 'netcf support')
+option('netcontrol', type: 'feature', value: 'auto', description: 'netcontrol support')
option('nls', type: 'feature', value: 'auto', description: 'nls support')
option('numactl', type: 'feature', value: 'auto', description: 'numactl support')
option('openwsman', type: 'feature', value: 'auto', description: 'openwsman support')
Index: libvirt-8.7.0/src/interface/interface_backend_netcf.c
2012-09-26 00:22:08 +02:00
===================================================================
2022-09-02 00:07:34 +02:00
--- libvirt-8.7.0.orig/src/interface/interface_backend_netcf.c
+++ libvirt-8.7.0/src/interface/interface_backend_netcf.c
2019-01-16 00:46:12 +01:00
@@ -21,7 +21,12 @@
2011-09-16 20:53:58 +02:00
#include <config.h>
2012-09-26 00:22:08 +02:00
-#include <netcf.h>
2011-09-16 20:53:58 +02:00
+#ifdef WITH_NETCONTROL
2012-09-26 00:22:08 +02:00
+# include <netcontrol/netcf.h>
+# include <netcontrol/logger.h>
2011-09-16 20:53:58 +02:00
+#else
2012-09-26 00:22:08 +02:00
+# include <netcf.h>
2011-09-16 20:53:58 +02:00
+#endif
2013-01-30 19:45:29 +01:00
#include "virerror.h"
2011-09-16 20:53:58 +02:00
#include "datatypes.h"
2022-07-06 19:18:39 +02:00
@@ -70,6 +75,37 @@ VIR_ONCE_GLOBAL_INIT(virNetcfDriverState
- Update to libvirt 1.1.4
- Add support for AArch64 architecture
- Various improvements on test code and test driver
- Don't link virt-login-shell against libvirt.so
- Close all non-stdio FDs in virt-login-shell
- Only allow 'stderr' log output when running setuid
- Fix perms for virConnectDomainXML{To,From}Native
- Many incremental improvements and bug fixes, see
http://libvirt.org/news.html
- Drop upstream patches: e7f400a1-CVE-2013-4296.patch,
2dba0323-CVE-2013-4297.patch, db7a5688-CVE-2013-4311.patch,
e65667c0-CVE-2013-4311.patch, 922b7fda-CVE-2013-4311.patch,
e4697b92-CVE-2013-4311.patch, 8294aa0c-CVE-2013-4399.patch,
484cc321-fix-spice-migration.patch,
79552754-libvirtd-chardev-crash.patch,
57687fd6-CVE-2013-4401.patch, ae53e5d1-CVE-2013-4400.patch,
8c3586ea-CVE-2013-4400.patch, b7fcc799a-CVE-2013-4400.patch,
3e2f27e1-CVE-2013-4400.patch, 5a0ea4b7-CVE-2013-4400.patch,
843bdb2f-CVE-2013-4400.patch,
bd773e74-lxc-terminate-machine.patch,
e350826c-python-fix-fd-passing.patch
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=329
2013-11-20 21:02:26 +01:00
2014-12-15 15:16:23 +01:00
static virNetcfDriverStatePtr driver;
2011-09-16 20:53:58 +02:00
+#ifdef WITH_NETCONTROL
2013-07-11 00:06:19 +02:00
+static void
2015-01-20 15:17:38 +01:00
+interface_nc_log_driver(const char *category ATTRIBUTE_UNUSED,
2013-07-11 00:06:19 +02:00
+ int priority,
+ const char *func,
+ const char *file,
+ long long line,
+ const char *msg,
+ size_t len ATTRIBUTE_UNUSED)
2011-09-16 20:53:58 +02:00
+{
2013-07-11 00:06:19 +02:00
+ int vp;
2011-09-16 20:53:58 +02:00
+
2015-01-20 14:32:02 +01:00
+ switch (priority) {
2011-09-16 20:53:58 +02:00
+ case NC_LOG_FATAL:
+ case NC_LOG_ERROR:
+ vp = VIR_LOG_ERROR;
2013-07-11 00:06:19 +02:00
+ break;
2011-09-16 20:53:58 +02:00
+ case NC_LOG_WARN:
+ vp = VIR_LOG_WARN;
2013-07-11 00:06:19 +02:00
+ break;
2011-09-16 20:53:58 +02:00
+ case NC_LOG_INFO:
+ vp = VIR_LOG_INFO;
2013-07-11 00:06:19 +02:00
+ break;
2011-09-16 20:53:58 +02:00
+ case NC_LOG_DEBUG:
+ default:
+ vp = VIR_LOG_DEBUG;
2013-07-11 00:06:19 +02:00
+ break;
2011-09-16 20:53:58 +02:00
+ }
2014-04-02 14:48:46 +02:00
+ virLogMessage(&virLogSelf, vp, file, line, func, 0, "%s", msg);
2011-09-16 20:53:58 +02:00
+}
+#endif
- Update to libvirt 1.1.4
- Add support for AArch64 architecture
- Various improvements on test code and test driver
- Don't link virt-login-shell against libvirt.so
- Close all non-stdio FDs in virt-login-shell
- Only allow 'stderr' log output when running setuid
- Fix perms for virConnectDomainXML{To,From}Native
- Many incremental improvements and bug fixes, see
http://libvirt.org/news.html
- Drop upstream patches: e7f400a1-CVE-2013-4296.patch,
2dba0323-CVE-2013-4297.patch, db7a5688-CVE-2013-4311.patch,
e65667c0-CVE-2013-4311.patch, 922b7fda-CVE-2013-4311.patch,
e4697b92-CVE-2013-4311.patch, 8294aa0c-CVE-2013-4399.patch,
484cc321-fix-spice-migration.patch,
79552754-libvirtd-chardev-crash.patch,
57687fd6-CVE-2013-4401.patch, ae53e5d1-CVE-2013-4400.patch,
8c3586ea-CVE-2013-4400.patch, b7fcc799a-CVE-2013-4400.patch,
3e2f27e1-CVE-2013-4400.patch, 5a0ea4b7-CVE-2013-4400.patch,
843bdb2f-CVE-2013-4400.patch,
bd773e74-lxc-terminate-machine.patch,
e350826c-python-fix-fd-passing.patch
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=329
2013-11-20 21:02:26 +01:00
static void
virNetcfDriverStateDispose(void *obj)
2022-07-06 19:18:39 +02:00
@@ -125,6 +161,10 @@ netcfStateInitialize(bool privileged,
2019-08-13 00:29:28 +02:00
virPidFileAcquire(driver->stateDir, "driver", false, getpid())) < 0)
goto error;
2011-09-16 20:53:58 +02:00
+#ifdef WITH_NETCONTROL
+ nc_logger_redirect_to(interface_nc_log_driver);
2015-03-18 19:17:20 +01:00
+#endif
2011-09-16 20:53:58 +02:00
+
/* open netcf */
2014-12-15 15:16:23 +01:00
if (ncf_init(&driver->netcf, NULL) != 0) {
- Update to libvirt 1.1.4
- Add support for AArch64 architecture
- Various improvements on test code and test driver
- Don't link virt-login-shell against libvirt.so
- Close all non-stdio FDs in virt-login-shell
- Only allow 'stderr' log output when running setuid
- Fix perms for virConnectDomainXML{To,From}Native
- Many incremental improvements and bug fixes, see
http://libvirt.org/news.html
- Drop upstream patches: e7f400a1-CVE-2013-4296.patch,
2dba0323-CVE-2013-4297.patch, db7a5688-CVE-2013-4311.patch,
e65667c0-CVE-2013-4311.patch, 922b7fda-CVE-2013-4311.patch,
e4697b92-CVE-2013-4311.patch, 8294aa0c-CVE-2013-4399.patch,
484cc321-fix-spice-migration.patch,
79552754-libvirtd-chardev-crash.patch,
57687fd6-CVE-2013-4401.patch, ae53e5d1-CVE-2013-4400.patch,
8c3586ea-CVE-2013-4400.patch, b7fcc799a-CVE-2013-4400.patch,
3e2f27e1-CVE-2013-4400.patch, 5a0ea4b7-CVE-2013-4400.patch,
843bdb2f-CVE-2013-4400.patch,
bd773e74-lxc-terminate-machine.patch,
e350826c-python-fix-fd-passing.patch
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=329
2013-11-20 21:02:26 +01:00
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
2022-07-06 19:18:39 +02:00
@@ -1070,6 +1110,7 @@ static int netcfInterfaceIsActive(virInt
2019-11-06 16:48:56 +01:00
return ret;
}
+#ifdef HAVE_NETCF_TRANSACTIONS
static int netcfInterfaceChangeBegin(virConnectPtr conn, unsigned int flags)
{
2022-05-09 18:16:57 +02:00
int ret = -1;
2022-07-06 19:18:39 +02:00
@@ -1141,6 +1182,7 @@ static int netcfInterfaceChangeRollback(
2022-05-09 18:16:57 +02:00
2019-11-06 16:48:56 +01:00
return ret;
}
+#endif /* HAVE_NETCF_TRANSACTIONS */
static virInterfaceDriver interfaceDriver = {
.name = INTERFACE_DRIVER_NAME,
2022-07-06 19:18:39 +02:00
@@ -1157,9 +1199,11 @@ static virInterfaceDriver interfaceDrive
2019-11-06 16:48:56 +01:00
.interfaceCreate = netcfInterfaceCreate, /* 0.7.0 */
.interfaceDestroy = netcfInterfaceDestroy, /* 0.7.0 */
.interfaceIsActive = netcfInterfaceIsActive, /* 0.7.3 */
+#ifdef HAVE_NETCF_TRANSACTIONS
.interfaceChangeBegin = netcfInterfaceChangeBegin, /* 0.9.2 */
.interfaceChangeCommit = netcfInterfaceChangeCommit, /* 0.9.2 */
.interfaceChangeRollback = netcfInterfaceChangeRollback, /* 0.9.2 */
+#endif /* HAVE_NETCF_TRANSACTIONS */
};
2022-07-06 19:18:39 +02:00
@@ -1190,6 +1234,19 @@ static virStateDriver interfaceStateDriv
2015-03-25 17:02:37 +01:00
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) {
2019-09-05 18:31:28 +02:00
+ VIR_WARN("Failed to initialize libnetcontrol. Management of interface devices is disabled");
2015-03-25 17:02:37 +01:00
+ return 0;
+ }
+
+ ncf_close(netcf);
+
Accepting request 583090 from home:jfehlig:branches:Virtualization
- Update to libvirt 4.1.0
- Many incremental improvements and bug fixes, see
http://libvirt.org/news.html
- Dropped patches:
72adaf2f-revert-qemu-monitor-error-report.patch,
71d56a39-nodedev-fix-parse-PCI-address.patch,
68eed56b-conf-smbios-oem-strings.patch,
76977061-qemu-smbios-oem-strings.patch,
0c710a37-libxl-resume-lock-on-mig-failure.patch,
759b4d1b-virlog-determine-the-hostname-on-startup-CVE-2018-67.patch,
c2dc6698-fix-deadlock-obtaining-hostname.patch,
c391e07e-libxl-clock-settings.patch,
ef71caea-libxl-memalign.patch,
suse-apparmor-signal.patch
OBS-URL: https://build.opensuse.org/request/show/583090
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=674
2018-03-05 18:46:32 +01:00
if (virRegisterConnectDriver(&interfaceConnectDriver, false) < 0)
2015-03-25 17:02:37 +01:00
return -1;
Accepting request 583090 from home:jfehlig:branches:Virtualization
- Update to libvirt 4.1.0
- Many incremental improvements and bug fixes, see
http://libvirt.org/news.html
- Dropped patches:
72adaf2f-revert-qemu-monitor-error-report.patch,
71d56a39-nodedev-fix-parse-PCI-address.patch,
68eed56b-conf-smbios-oem-strings.patch,
76977061-qemu-smbios-oem-strings.patch,
0c710a37-libxl-resume-lock-on-mig-failure.patch,
759b4d1b-virlog-determine-the-hostname-on-startup-CVE-2018-67.patch,
c2dc6698-fix-deadlock-obtaining-hostname.patch,
c391e07e-libxl-clock-settings.patch,
ef71caea-libxl-memalign.patch,
suse-apparmor-signal.patch
OBS-URL: https://build.opensuse.org/request/show/583090
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=674
2018-03-05 18:46:32 +01:00
if (virSetSharedInterfaceDriver(&interfaceDriver) < 0)
2022-09-02 00:07:34 +02:00
Index: libvirt-8.7.0/src/interface/interface_driver.c
2013-01-22 05:02:42 +01:00
===================================================================
2022-09-02 00:07:34 +02:00
--- libvirt-8.7.0.orig/src/interface/interface_driver.c
+++ libvirt-8.7.0/src/interface/interface_driver.c
2014-04-08 19:20:15 +02:00
@@ -30,8 +30,15 @@ interfaceRegister(void)
2013-01-22 05:02:42 +01:00
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 */
2013-01-30 19:45:29 +01:00
#if WITH_UDEV
2013-01-22 05:02:42 +01:00
- /* If there's no netcf or it failed to load, register the udev backend */
2013-01-30 19:45:29 +01:00
+ /* If there's no netcf or netcontrol, or it failed to load, register the
+ udev backend */
2013-01-22 05:02:42 +01:00
if (udevIfaceRegister() == 0)
return 0;
2013-01-30 19:45:29 +01:00
#endif /* WITH_UDEV */
2022-09-02 00:07:34 +02:00
Index: libvirt-8.7.0/src/interface/meson.build
2013-01-30 19:45:29 +01:00
===================================================================
2022-09-02 00:07:34 +02:00
--- libvirt-8.7.0.orig/src/interface/meson.build
+++ libvirt-8.7.0/src/interface/meson.build
2020-09-03 00:47:08 +02:00
@@ -2,7 +2,7 @@ interface_driver_sources = [
'interface_driver.c',
]
-if conf.has('WITH_NETCF')
+if conf.has('WITH_NETCF') or conf.has('WITH_NETCONTROL')
interface_driver_sources += 'interface_backend_netcf.c'
endif
@@ -23,6 +23,7 @@ if conf.has('WITH_INTERFACE')
access_dep,
libnl_dep,
netcf_dep,
+ netcontrol_dep,
udev_dep,
],
'link_args': [
2022-09-02 00:07:34 +02:00
Index: libvirt-8.7.0/tools/virsh.c
Accepting request 593871 from home:jfehlig:branches:Virtualization
- util: improvements in error handling
09877303-virSocketAddrParseInternal.patch,
412afdb8-intro-virSocketAddrParseAny.patch
bsc#1080957
- Update to libvirt 4.2.0
- Many incremental improvements and bug fixes, see
http://libvirt.org/news.html
- Dropped patches:
6b3d716e-keycodemap-py3.patch,
33c6eb96-fix-libvirtd-reload-deadlock.patch,
464889ff-rpc-aquire-ref-dispatch.patch,
c6f1d519-rpc-simplify-dispatch.patch,
06e7ebb6-rpc-invoke-dispatch-unlocked.patch,
86cae503-rpc-fix-pre-exec.patch,
eefabb38-rpc-virtlockd-virtlogd-single-thread.patch,
fbf31e1a-CVE-2018-1064.patch,
fb327ac2-virtlockd-admin-socket.patch,
64370c4b-libxl-MigrateBegin.patch,
99486799-libxl-MigrateConfirm.patch,
f5eacf2a-libxl-MigratePerform.patch,
4e6fcdb6-libxl-libxlDomObjFromDomain-cleanup.patch,
fe51dbda-libxl-use-FindByRef.patch,
60b3fcd9-libxl-MigratePrepare.patch,
3c89868c-libxl-lock-after-ListRemove.patch,
13e81fc6-libxl-EndJob-on-error.patch,
594b8b99-libxl-DefineXMLFlags-API-pattern.patch,
c66e344e-libxl-dont-deref-NULL.patch,
83edaf44-libxl-dont-hardcode-sched-weight.patch,
apibuild-py3.patch
OBS-URL: https://build.opensuse.org/request/show/593871
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=683
2018-04-05 23:47:55 +02:00
===================================================================
2022-09-02 00:07:34 +02:00
--- libvirt-8.7.0.orig/tools/virsh.c
+++ libvirt-8.7.0/tools/virsh.c
@@ -545,6 +545,8 @@ virshShowVersion(vshControl *ctl G_GNUC_
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