[libvirt] [PATCH v3 0/3] fix build failure in vircgroup code
by Pavel Hrdina
Chagnes in v3:
- removed VIR_CGROUP_SUPPORTED
- include system headers only on linux
Pavel Hrdina (3):
vircgroup: remove VIR_CGROUP_SUPPORTED
vircgroup: include system headers only on linux
vircgroupv1: fix build on non-linux OSes
src/util/vircgroup.c | 38 ++++++++++++++++----------------------
src/util/vircgroupv1.c | 20 +++++++++++++++-----
2 files changed, 31 insertions(+), 27 deletions(-)
--
2.17.1
6 years, 3 months
[libvirt] [tck PATCH] Fix typo in StrictHostKeyChecking setting
by Laine Stump
This was inadvertantly changed from "no" to "off" in commit 685bf11b.
Signed-off-by: Laine Stump <laine(a)laine.org>
---
... and noticed soon after, but apparently nobody took the time to push a fix.
Pushed under the trivial rule.
scripts/nwfilter/210-no-mac-spoofing.t | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/nwfilter/210-no-mac-spoofing.t b/scripts/nwfilter/210-no-mac-spoofing.t
index 87c19e7..78c500c 100644
--- a/scripts/nwfilter/210-no-mac-spoofing.t
+++ b/scripts/nwfilter/210-no-mac-spoofing.t
@@ -97,7 +97,7 @@ my $ssh = Net::OpenSSH->new($guestip,
user => "root",
password => $tck->root_password(),
master_opts => [-o => "UserKnownHostsFile=/dev/null",
- -o => "StrictHostKeyChecking=off"]);
+ -o => "StrictHostKeyChecking=no"]);
# now bring eth0 down, change MAC and bring it up again
diag "fiddling with mac";
--
2.17.1
6 years, 3 months
[libvirt] [PATCH] tests: libxl: skip tests with nested_hvm
by Ján Tomko
Commit 95d19cd unconditionally adjusted the tests to account for
the conditional move of the nested_hvm setting location.
Run the affected tests only for the new setup (witnessed by
LIBXL_HAVE_BUILDINFO_NESTED_HVM).
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
Technically a build breaker fix, but I'd love to hear any ideas
that would easily let us test both versions.
Also, my app-emulation/xen-tools-4.9.2-r1 on Gentoo
does not seem to have LIBXL_HAVE_BUILDINFO_NESTED_HVM in libxl.h,
even though it was introduced in 4.9.0-rc7-831-g3c44f8ed44
tests/libxlxml2domconfigtest.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c
index 0eba5814b1..6b1f9826d0 100644
--- a/tests/libxlxml2domconfigtest.c
+++ b/tests/libxlxml2domconfigtest.c
@@ -207,9 +207,16 @@ mymain(void)
DO_TEST("cpu-shares-hvm");
DO_TEST("variable-clock-hvm");
DO_TEST("moredevs-hvm");
+
+# ifdef LIBXL_HAVE_BUILDINFO_NESTED_HVM
DO_TEST("vnuma-hvm");
+# endif
+
DO_TEST("multiple-ip");
+
+# ifdef LIBXL_HAVE_BUILDINFO_NESTED_HVM
DO_TEST("fullvirt-cpuid");
+# endif
unlink("libxl-driver.log");
--
2.16.4
6 years, 3 months
[libvirt] [PATCH v2] vircgroupv1: add ifdef around cgroup code
by Pavel Hrdina
Cgroups are supported only on linux.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
changed in v2:
- define moved to vircgrouppriv.h
- fixed alternative virCgroupV1Register function
src/util/vircgroup.c | 5 -----
src/util/vircgrouppriv.h | 8 ++++++++
src/util/vircgroupv1.c | 13 +++++++++++++
3 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 23957c82c7..aae699db0e 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -66,11 +66,6 @@ VIR_LOG_INIT("util.cgroup");
#define CGROUP_NB_TOTAL_CPU_STAT_PARAM 3
#define CGROUP_NB_PER_CPU_STAT_PARAM 1
-#if defined(__linux__) && defined(HAVE_GETMNTENT_R) && \
- defined(_DIRENT_HAVE_D_TYPE) && defined(_SC_CLK_TCK)
-# define VIR_CGROUP_SUPPORTED
-#endif
-
VIR_ENUM_IMPL(virCgroupController, VIR_CGROUP_CONTROLLER_LAST,
"cpu", "cpuacct", "cpuset", "memory", "devices",
"freezer", "blkio", "net_cls", "perf_event",
diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h
index c50a25f195..5a19f965c2 100644
--- a/src/util/vircgrouppriv.h
+++ b/src/util/vircgrouppriv.h
@@ -29,9 +29,17 @@
#ifndef __VIR_CGROUP_PRIV_H__
# define __VIR_CGROUP_PRIV_H__
+# include <dirent.h>
+# include <unistd.h>
+
# include "vircgroup.h"
# include "vircgroupbackend.h"
+# if defined(__linux__) && defined(HAVE_GETMNTENT_R) && \
+ defined(_DIRENT_HAVE_D_TYPE) && defined(_SC_CLK_TCK)
+# define VIR_CGROUP_SUPPORTED
+# endif
+
struct _virCgroupV1Controller {
int type;
char *mountPoint;
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 62a6e5c448..a00dd06148 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -55,6 +55,8 @@ VIR_ENUM_IMPL(virCgroupV1Controller, VIR_CGROUP_CONTROLLER_LAST,
"name=systemd");
+#ifdef VIR_CGROUP_SUPPORTED
+
/* We're looking for at least one 'cgroup' fs mount,
* which is *not* a named mount. */
static bool
@@ -2099,3 +2101,14 @@ virCgroupV1Register(void)
{
virCgroupBackendRegister(&virCgroupV1Backend);
}
+
+#else /* !VIR_CGROUP_SUPPORTED */
+
+void
+virCgroupV1Register(void)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Control groups not supported on this platform"));
+}
+
+#endif /* !VIR_CGROUP_SUPPORTED */
--
2.17.1
6 years, 3 months
[libvirt] [PATCH v3] qemu: Remove network type limitation for qemuARPGetInterfaces
by Lin Ma
Let's ignore the checking of interface type when we call the function
qemuARPGetInterfaces to get IP from host's arp table.
Based on suggestion from Laine.
https://www.redhat.com/archives/libvir-list/2018-September/msg00684.html
Signed-off-by: Lin Ma <lma(a)suse.com>
---
src/qemu/qemu_driver.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 10d6bca186..3110e74e0e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20945,9 +20945,6 @@ qemuARPGetInterfaces(virDomainObjPtr vm,
goto cleanup;
for (i = 0; i < vm->def->nnets; i++) {
- if (vm->def->nets[i]->type != VIR_DOMAIN_NET_TYPE_NETWORK)
- continue;
-
virMacAddrFormat(&(vm->def->nets[i]->mac), macaddr);
for (j = 0; j < table->n; j++) {
virArpTableEntry entry = table->t[j];
--
2.19.0
6 years, 3 months
[libvirt] [PATCH] virsh: Require explicit --domain for domxml-to-native
by Jiri Denemark
The domxml-to-native virsh command accepts either --xml or --domain
option followed by a file or domain name respectively. The --domain
option is documented as required, which means an argument with no option
is treated as --xml. Commit v4.3.0-127-gd86531daf2 broke this by making
--domain optional and thus an argument with no option was treated as
--domain.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
tools/virsh-domain.c | 6 +++---
tools/virsh.h | 8 +++++---
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index cfb0095333..372bdb95d3 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9509,7 +9509,7 @@ static const vshCmdInfo info_qemu_monitor_event[] = {
static const vshCmdOptDef opts_qemu_monitor_event[] = {
VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("filter by domain name, id or uuid"),
- 0),
+ 0, 0),
{.name = "event",
.type = VSH_OT_STRING,
.help = N_("filter by event name")
@@ -10062,7 +10062,7 @@ static const vshCmdOptDef opts_domxmltonative[] = {
.flags = VSH_OFLAG_REQ,
.help = N_("target config data type format")
},
- VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(0),
+ VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(VSH_OFLAG_REQ_OPT, 0),
{.name = "xml",
.type = VSH_OT_STRING,
.help = N_("xml data file to export from")
@@ -13312,7 +13312,7 @@ static const vshCmdInfo info_event[] = {
static const vshCmdOptDef opts_event[] = {
VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("filter by domain name, id or uuid"),
- 0),
+ 0, 0),
{.name = "event",
.type = VSH_OT_STRING,
.completer = virshDomainEventNameCompleter,
diff --git a/tools/virsh.h b/tools/virsh.h
index af0d6ce686..6ff5c74b5e 100644
--- a/tools/virsh.h
+++ b/tools/virsh.h
@@ -107,16 +107,18 @@
.help = _helpstr \
}
-# define VIRSH_COMMON_OPT_DOMAIN_OT_STRING(_helpstr, cflags) \
+# define VIRSH_COMMON_OPT_DOMAIN_OT_STRING(_helpstr, oflags, cflags) \
{.name = "domain", \
.type = VSH_OT_STRING, \
+ .flags = oflags, \
.help = _helpstr, \
.completer = virshDomainNameCompleter, \
.completer_flags = cflags, \
}
-# define VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(cflags) \
- VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("domain name, id or uuid"), cflags)
+# define VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(oflags, cflags) \
+ VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("domain name, id or uuid"), \
+ oflags, cflags)
# define VIRSH_COMMON_OPT_DOMAIN_OT_ARGV(_helpstr, cflags) \
{.name = "domain", \
--
2.19.0
6 years, 3 months
[libvirt] [PATCH 0/7] configure: remove some unused checks
by Ján Tomko
Ján Tomko (7):
configure: split common header and function checks
configure: sort AC_CHECK_HEADERS argument list
configure: remove duplicit check for sys/un.h
configure: remove check for regex.h
configure: remove check for poll.h
configure: do not check for kill
configure: remove regexec and getgrnam_r checks
configure.ac | 50 +++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 41 insertions(+), 9 deletions(-)
--
2.16.4
6 years, 3 months
[libvirt] [PATCH 0/4] Small changes to virdbus
by Marc Hartmayer
Marc Hartmayer (4):
virdbus: Grab a ref as long as the while loop is executed
virdbus: Unref the D-Bus connection when closing
virdbus: Report a debug message that dbus_watch_handle() has failed
virdbus: Use the mnemonic macros for dbus_bool_t values
src/util/virdbus.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
--
2.17.0
6 years, 3 months
[libvirt] [PATCH] lxc_monitor: Avoid AB / BA lock race
by Mark Asselstine
A deadlock situation can occur when autostarting a LXC domain 'guest'
due to two threads attempting to take opposing locks while holding
opposing locks (AB BA problem). Thread A takes and holds the 'vm' lock
while attempting to take the 'client' lock, meanwhile, thread B takes
and holds the 'client' lock while attempting to take the 'vm' lock.
The potential for this can be seen as follows:
Thread A:
virLXCProcessAutostartDomain (takes vm lock)
--> virLXCProcessStart
--> virLXCProcessConnectMonitor
--> virLXCMonitorNew
--> virNetClientSetCloseCallback (wants client lock)
Thread B:
virNetClientIncomingEvent (takes client lock)
--> virNetClientIOHandleInput
--> virNetClientCallDispatch
--> virNetClientCallDispatchMessage
--> virNetClientProgramDispatch
--> virLXCMonitorHandleEventInit
--> virLXCProcessMonitorInitNotify (wants vm lock)
Since these threads are scheduled independently and are preemptible it
is possible for the deadlock scenario to occur where each thread locks
their first lock but both will fail to get their second lock and just
spin forever. You get something like:
virLXCProcessAutostartDomain (takes vm lock)
--> virLXCProcessStart
--> virLXCProcessConnectMonitor
--> virLXCMonitorNew
<...>
virNetClientIncomingEvent (takes client lock)
--> virNetClientIOHandleInput
--> virNetClientCallDispatch
--> virNetClientCallDispatchMessage
--> virNetClientProgramDispatch
--> virLXCMonitorHandleEventInit
--> virLXCProcessMonitorInitNotify (wants vm lock but spins)
<...>
--> virNetClientSetCloseCallback (wants client lock but spins)
Neither thread ever gets the lock it needs to be able to continue
while holding the lock that the other thread needs.
The actual window for preemption which can cause this deadlock is
rather small, between the calls to virNetClientProgramNew() and
execution of virNetClientSetCloseCallback(), both in
virLXCMonitorNew(). But it can be seen in real world use that this
small window is enough.
By moving the call to virNetClientSetCloseCallback() ahead of
virNetClientProgramNew() we can close any possible chance of the
deadlock taking place. There should be no other implications to the
move since the close callback (in the unlikely event was called) will
spin on the vm lock. The remaining work that takes place between the
old call location of virNetClientSetCloseCallback() and the new
location is unaffected by the move.
Signed-off-by: Mark Asselstine <mark.asselstine(a)windriver.com>
---
NOTE I am not intimately familiar with the libvirt code, so although I
am confident of the cause of the issue I am not sure this is the best
solution. So I am really curious what people who do know this code
think and as such I am definitely open to discussions and suggestions
on how to rework things to properly address the issue.
src/lxc/lxc_monitor.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c
index e765c16..218f426 100644
--- a/src/lxc/lxc_monitor.c
+++ b/src/lxc/lxc_monitor.c
@@ -161,6 +161,10 @@ virLXCMonitorPtr virLXCMonitorNew(virDomainObjPtr vm,
if (virNetClientRegisterAsyncIO(mon->client) < 0)
goto error;
+ /* avoid deadlock by making this call before assigning virLXCMonitorEvents */
+ virNetClientSetCloseCallback(mon->client, virLXCMonitorEOFNotify, mon,
+ virLXCMonitorCloseFreeCallback);
+
if (!(mon->program = virNetClientProgramNew(VIR_LXC_MONITOR_PROGRAM,
VIR_LXC_MONITOR_PROGRAM_VERSION,
virLXCMonitorEvents,
@@ -176,8 +180,6 @@ virLXCMonitorPtr virLXCMonitorNew(virDomainObjPtr vm,
memcpy(&mon->cb, cb, sizeof(mon->cb));
virObjectRef(mon);
- virNetClientSetCloseCallback(mon->client, virLXCMonitorEOFNotify, mon,
- virLXCMonitorCloseFreeCallback);
cleanup:
VIR_FREE(sockpath);
--
2.7.4
6 years, 3 months