All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] libvirt: uprev to v4.7.0
@ 2018-09-26 19:12 Mark Asselstine
  2018-09-26 19:12 ` [PATCH 2/2] libvirt: backport LXC AB / BA deadlock fix Mark Asselstine
  2018-10-01  1:32 ` [PATCH 1/2] libvirt: uprev to v4.7.0 Bruce Ashfield
  0 siblings, 2 replies; 3+ messages in thread
From: Mark Asselstine @ 2018-09-26 19:12 UTC (permalink / raw)
  To: meta-virtualization

A straight-forward uprev to the latest stable release. As usual basic
runtime sanity tests have been run along with the ptests. The
following is the results of the ptests:

  ====================================
  Testsuite summary for libvirt 4.7.0
  ====================================
  # TOTAL: 120
  # PASS:  117
  # SKIP:  0
  # XFAIL: 0
  # FAIL:  3
  # XPASS: 0
  # ERROR: 0

Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
---
 recipes-extended/libvirt/libvirt-python.inc                     | 4 ++--
 recipes-extended/libvirt/libvirt/runptest.patch                 | 4 ++--
 recipes-extended/libvirt/{libvirt_4.5.0.bb => libvirt_4.7.0.bb} | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
 rename recipes-extended/libvirt/{libvirt_4.5.0.bb => libvirt_4.7.0.bb} (98%)

diff --git a/recipes-extended/libvirt/libvirt-python.inc b/recipes-extended/libvirt/libvirt-python.inc
index cdc5719..be9079d 100644
--- a/recipes-extended/libvirt/libvirt-python.inc
+++ b/recipes-extended/libvirt/libvirt-python.inc
@@ -18,8 +18,8 @@ FILES_${PN}-python = "${bindir}/* ${libdir}/* ${libdir}/${PYTHON_DIR}/*"
 SRC_URI += "http://libvirt.org/sources/python/libvirt-python-${PV}.tar.gz;name=libvirt_python"
 SRC_URI += "file://libvirt_api_xml_path.patch;patchdir=../libvirt-python-${PV}"
 
-SRC_URI[libvirt_python.md5sum] = "0c1b66a8878d6436b036565060707f73"
-SRC_URI[libvirt_python.sha256sum] = "ef35ed6bc24d76563b1ba9b068ef5a048016726dba62a9d057fe6dfbea6b0f60"
+SRC_URI[libvirt_python.md5sum] = "32cf281199367aec2881c96d1bd80dc6"
+SRC_URI[libvirt_python.sha256sum] = "e36fee5898de3550ed7e63d5d0a8447f9d78f06574634855dee59eae27930908"
 
 export LIBVIRT_API_PATH = "${S}/docs/libvirt-api.xml"
 export LIBVIRT_CFLAGS = "-I${S}/include"
diff --git a/recipes-extended/libvirt/libvirt/runptest.patch b/recipes-extended/libvirt/libvirt/runptest.patch
index b900c01..457e821 100644
--- a/recipes-extended/libvirt/libvirt/runptest.patch
+++ b/recipes-extended/libvirt/libvirt/runptest.patch
@@ -89,8 +89,8 @@ index 7b93fbd..edc1eb9 100644
 +	install * $(DEST_DIR)/tools)
 +	install -d $(DEST_DIR)/src/network
 +	cp $(top_srcdir)/src/network/*.xml $(DEST_DIR)/src/network
-+	install -d $(DEST_DIR)/src/cpu
-+	cp $(top_srcdir)/src/cpu/*.xml $(DEST_DIR)/src/cpu
++	install -d $(DEST_DIR)/src/cpu_map
++	cp $(top_srcdir)/src/cpu_map/*.xml $(DEST_DIR)/src/cpu_map
 +	install ../src/libvirt_iohelper $(DEST_DIR)/src
 +	install -D ../src/libvirtd $(DEST_DIR)/src/libvirtd
 +	install -d $(DEST_DIR)/src/remote
diff --git a/recipes-extended/libvirt/libvirt_4.5.0.bb b/recipes-extended/libvirt/libvirt_4.7.0.bb
similarity index 98%
rename from recipes-extended/libvirt/libvirt_4.5.0.bb
rename to recipes-extended/libvirt/libvirt_4.7.0.bb
index 9cfa74a..14565da 100644
--- a/recipes-extended/libvirt/libvirt_4.5.0.bb
+++ b/recipes-extended/libvirt/libvirt_4.7.0.bb
@@ -37,8 +37,8 @@ SRC_URI = "http://libvirt.org/sources/libvirt-${PV}.tar.xz;name=libvirt \
            file://configure.ac-search-for-rpc-rpc.h-in-the-sysroot.patch \
           "
 
-SRC_URI[libvirt.md5sum] = "692b2d00907438ed08a68813d3177cd3"
-SRC_URI[libvirt.sha256sum] = "e7e95edc0ca553046761ed55a8d01a06a3a3a4238bbeaedb3ba34680a277ab09"
+SRC_URI[libvirt.md5sum] = "38da6c33250dcbc0a6d68de5c758262b"
+SRC_URI[libvirt.sha256sum] = "92c279f7321624ac5a37a81f8bbe8c8d2a16781da04c63c99c92d3de035767e4"
 
 inherit autotools gettext update-rc.d pkgconfig ptest systemd
 
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] libvirt: backport LXC AB / BA deadlock fix
  2018-09-26 19:12 [PATCH 1/2] libvirt: uprev to v4.7.0 Mark Asselstine
@ 2018-09-26 19:12 ` Mark Asselstine
  2018-10-01  1:32 ` [PATCH 1/2] libvirt: uprev to v4.7.0 Bruce Ashfield
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Asselstine @ 2018-09-26 19:12 UTC (permalink / raw)
  To: meta-virtualization

This fix will most likely be part of libvirt 4.8.0 but since we took
the time to investigate and fix this issue we are including it now to
prevent others from hitting this issue.

Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
---
 .../lxc_monitor-Avoid-AB-BA-lock-race.patch        | 106 +++++++++++++++++++++
 recipes-extended/libvirt/libvirt_4.7.0.bb          |   1 +
 2 files changed, 107 insertions(+)
 create mode 100644 recipes-extended/libvirt/libvirt/lxc_monitor-Avoid-AB-BA-lock-race.patch

diff --git a/recipes-extended/libvirt/libvirt/lxc_monitor-Avoid-AB-BA-lock-race.patch b/recipes-extended/libvirt/libvirt/lxc_monitor-Avoid-AB-BA-lock-race.patch
new file mode 100644
index 0000000..fc3880f
--- /dev/null
+++ b/recipes-extended/libvirt/libvirt/lxc_monitor-Avoid-AB-BA-lock-race.patch
@@ -0,0 +1,106 @@
+From 7882c6eca53fe9abe253497a50f6c5ae062176d3 Mon Sep 17 00:00:00 2001
+From: Mark Asselstine <mark.asselstine@windriver.com>
+Date: Mon, 24 Sep 2018 11:11:35 -0400
+Subject: [PATCH] lxc_monitor: Avoid AB / BA lock race
+
+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.
+
+Upstream-Status: Backport commit 7882c6eca53f
+
+Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+---
+ src/lxc/lxc_monitor.c | 11 +++++++----
+ 1 file changed, 7 insertions(+), 4 deletions(-)
+
+diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c
+index e765c16..0b18a14 100644
+--- a/src/lxc/lxc_monitor.c
++++ b/src/lxc/lxc_monitor.c
+@@ -161,6 +161,13 @@ 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);
++
++    /* close callback now has its own reference */
++    virObjectRef(mon);
++
+     if (!(mon->program = virNetClientProgramNew(VIR_LXC_MONITOR_PROGRAM,
+                                                 VIR_LXC_MONITOR_PROGRAM_VERSION,
+                                                 virLXCMonitorEvents,
+@@ -175,10 +182,6 @@ virLXCMonitorPtr virLXCMonitorNew(virDomainObjPtr vm,
+     mon->vm = virObjectRef(vm);
+     memcpy(&mon->cb, cb, sizeof(mon->cb));
+ 
+-    virObjectRef(mon);
+-    virNetClientSetCloseCallback(mon->client, virLXCMonitorEOFNotify, mon,
+-                                 virLXCMonitorCloseFreeCallback);
+-
+  cleanup:
+     VIR_FREE(sockpath);
+     return mon;
+-- 
+2.7.4
+
diff --git a/recipes-extended/libvirt/libvirt_4.7.0.bb b/recipes-extended/libvirt/libvirt_4.7.0.bb
index 14565da..47275ae 100644
--- a/recipes-extended/libvirt/libvirt_4.7.0.bb
+++ b/recipes-extended/libvirt/libvirt_4.7.0.bb
@@ -35,6 +35,7 @@ SRC_URI = "http://libvirt.org/sources/libvirt-${PV}.tar.xz;name=libvirt \
            file://install-missing-file.patch \
            file://0001-ptest-Remove-Windows-1252-check-from-esxutilstest.patch \
            file://configure.ac-search-for-rpc-rpc.h-in-the-sysroot.patch \
+           file://lxc_monitor-Avoid-AB-BA-lock-race.patch \
           "
 
 SRC_URI[libvirt.md5sum] = "38da6c33250dcbc0a6d68de5c758262b"
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] libvirt: uprev to v4.7.0
  2018-09-26 19:12 [PATCH 1/2] libvirt: uprev to v4.7.0 Mark Asselstine
  2018-09-26 19:12 ` [PATCH 2/2] libvirt: backport LXC AB / BA deadlock fix Mark Asselstine
@ 2018-10-01  1:32 ` Bruce Ashfield
  1 sibling, 0 replies; 3+ messages in thread
From: Bruce Ashfield @ 2018-10-01  1:32 UTC (permalink / raw)
  To: Mark Asselstine; +Cc: meta-virtualization

merged

Bruce
On Wed, Sep 26, 2018 at 3:12 PM Mark Asselstine
<mark.asselstine@windriver.com> wrote:
>
> A straight-forward uprev to the latest stable release. As usual basic
> runtime sanity tests have been run along with the ptests. The
> following is the results of the ptests:
>
>   ====================================
>   Testsuite summary for libvirt 4.7.0
>   ====================================
>   # TOTAL: 120
>   # PASS:  117
>   # SKIP:  0
>   # XFAIL: 0
>   # FAIL:  3
>   # XPASS: 0
>   # ERROR: 0
>
> Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
> ---
>  recipes-extended/libvirt/libvirt-python.inc                     | 4 ++--
>  recipes-extended/libvirt/libvirt/runptest.patch                 | 4 ++--
>  recipes-extended/libvirt/{libvirt_4.5.0.bb => libvirt_4.7.0.bb} | 4 ++--
>  3 files changed, 6 insertions(+), 6 deletions(-)
>  rename recipes-extended/libvirt/{libvirt_4.5.0.bb => libvirt_4.7.0.bb} (98%)
>
> diff --git a/recipes-extended/libvirt/libvirt-python.inc b/recipes-extended/libvirt/libvirt-python.inc
> index cdc5719..be9079d 100644
> --- a/recipes-extended/libvirt/libvirt-python.inc
> +++ b/recipes-extended/libvirt/libvirt-python.inc
> @@ -18,8 +18,8 @@ FILES_${PN}-python = "${bindir}/* ${libdir}/* ${libdir}/${PYTHON_DIR}/*"
>  SRC_URI += "http://libvirt.org/sources/python/libvirt-python-${PV}.tar.gz;name=libvirt_python"
>  SRC_URI += "file://libvirt_api_xml_path.patch;patchdir=../libvirt-python-${PV}"
>
> -SRC_URI[libvirt_python.md5sum] = "0c1b66a8878d6436b036565060707f73"
> -SRC_URI[libvirt_python.sha256sum] = "ef35ed6bc24d76563b1ba9b068ef5a048016726dba62a9d057fe6dfbea6b0f60"
> +SRC_URI[libvirt_python.md5sum] = "32cf281199367aec2881c96d1bd80dc6"
> +SRC_URI[libvirt_python.sha256sum] = "e36fee5898de3550ed7e63d5d0a8447f9d78f06574634855dee59eae27930908"
>
>  export LIBVIRT_API_PATH = "${S}/docs/libvirt-api.xml"
>  export LIBVIRT_CFLAGS = "-I${S}/include"
> diff --git a/recipes-extended/libvirt/libvirt/runptest.patch b/recipes-extended/libvirt/libvirt/runptest.patch
> index b900c01..457e821 100644
> --- a/recipes-extended/libvirt/libvirt/runptest.patch
> +++ b/recipes-extended/libvirt/libvirt/runptest.patch
> @@ -89,8 +89,8 @@ index 7b93fbd..edc1eb9 100644
>  +      install * $(DEST_DIR)/tools)
>  +      install -d $(DEST_DIR)/src/network
>  +      cp $(top_srcdir)/src/network/*.xml $(DEST_DIR)/src/network
> -+      install -d $(DEST_DIR)/src/cpu
> -+      cp $(top_srcdir)/src/cpu/*.xml $(DEST_DIR)/src/cpu
> ++      install -d $(DEST_DIR)/src/cpu_map
> ++      cp $(top_srcdir)/src/cpu_map/*.xml $(DEST_DIR)/src/cpu_map
>  +      install ../src/libvirt_iohelper $(DEST_DIR)/src
>  +      install -D ../src/libvirtd $(DEST_DIR)/src/libvirtd
>  +      install -d $(DEST_DIR)/src/remote
> diff --git a/recipes-extended/libvirt/libvirt_4.5.0.bb b/recipes-extended/libvirt/libvirt_4.7.0.bb
> similarity index 98%
> rename from recipes-extended/libvirt/libvirt_4.5.0.bb
> rename to recipes-extended/libvirt/libvirt_4.7.0.bb
> index 9cfa74a..14565da 100644
> --- a/recipes-extended/libvirt/libvirt_4.5.0.bb
> +++ b/recipes-extended/libvirt/libvirt_4.7.0.bb
> @@ -37,8 +37,8 @@ SRC_URI = "http://libvirt.org/sources/libvirt-${PV}.tar.xz;name=libvirt \
>             file://configure.ac-search-for-rpc-rpc.h-in-the-sysroot.patch \
>            "
>
> -SRC_URI[libvirt.md5sum] = "692b2d00907438ed08a68813d3177cd3"
> -SRC_URI[libvirt.sha256sum] = "e7e95edc0ca553046761ed55a8d01a06a3a3a4238bbeaedb3ba34680a277ab09"
> +SRC_URI[libvirt.md5sum] = "38da6c33250dcbc0a6d68de5c758262b"
> +SRC_URI[libvirt.sha256sum] = "92c279f7321624ac5a37a81f8bbe8c8d2a16781da04c63c99c92d3de035767e4"
>
>  inherit autotools gettext update-rc.d pkgconfig ptest systemd
>
> --
> 2.7.4
>
> --
> _______________________________________________
> meta-virtualization mailing list
> meta-virtualization@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/meta-virtualization



-- 
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end"


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-01  1:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-26 19:12 [PATCH 1/2] libvirt: uprev to v4.7.0 Mark Asselstine
2018-09-26 19:12 ` [PATCH 2/2] libvirt: backport LXC AB / BA deadlock fix Mark Asselstine
2018-10-01  1:32 ` [PATCH 1/2] libvirt: uprev to v4.7.0 Bruce Ashfield

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.