[meta-virtualization] [PATCH] libvirt: add patch to fix thread safety in lxc callback

Bruce Ashfield bruce.ashfield at gmail.com
Fri May 24 09:35:55 PDT 2013


On Fri, May 24, 2013 at 10:24 AM, Bogdan Purcareata
<bogdan.purcareata at freescale.com> wrote:
> From: Bogdan Purcareata <bogdan.purcareata at freescale.net>
>
> Patch has been submitted upstream (22 mar 2013) after the release of
> Libvirt 1.0.3 (5 mar 2013). Updated to work against libvirt 1.0.3.
> Please see http://www.redhat.com/archives/libvir-list/2013-March/msg01353.html
> for original patch.

Good information in the commit log. We'll have to bump our libvirt
version soon, but
we can merge this for now, and drop it on that update.

I've staged the change.

Bruce

>
> Signed-off-by: Bogdan Purcareata <bogdan.purcareata at freescale.net>
> ---
>  ...ix-thread-safety-in-lxc-callback-handling.patch | 63 ++++++++++++++++++++++
>  recipes-extended/libvirt/libvirt_1.0.3.bb          |  1 +
>  2 files changed, 64 insertions(+)
>  create mode 100644 recipes-extended/libvirt/libvirt/libvirt-1.0.3-fix-thread-safety-in-lxc-callback-handling.patch
>
> diff --git a/recipes-extended/libvirt/libvirt/libvirt-1.0.3-fix-thread-safety-in-lxc-callback-handling.patch b/recipes-extended/libvirt/libvirt/libvirt-1.0.3-fix-thread-safety-in-lxc-callback-handling.patch
> new file mode 100644
> index 0000000..558d5ef
> --- /dev/null
> +++ b/recipes-extended/libvirt/libvirt/libvirt-1.0.3-fix-thread-safety-in-lxc-callback-handling.patch
> @@ -0,0 +1,63 @@
> +From ad5d9cee87357f9f38f62583119606ef95ba10df Mon Sep 17 00:00:00 2001
> +From: Bogdan Purcareata <bogdan.purcareata at freescale.com>
> +Date: Fri, 24 May 2013 16:46:00 +0300
> +Subject: [PATCH] Fix thread safety in LXC callback handling
> +
> +Signed-off-by: Bogdan Purcareata <bogdan.purcareata at freescale.com>
> +---
> + src/lxc/lxc_process.c | 18 +++++++++++++++++-
> + 1 file changed, 17 insertions(+), 1 deletion(-)
> +
> +diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
> +index aaa81a7..0eadc67 100644
> +--- a/src/lxc/lxc_process.c
> ++++ b/src/lxc/lxc_process.c
> +@@ -609,8 +609,13 @@ static void virLXCProcessMonitorExitNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED
> +                                            virLXCProtocolExitStatus status,
> +                                            virDomainObjPtr vm)
> + {
> ++    virLXCDriverPtr driver = lxc_driver;
> +     virLXCDomainObjPrivatePtr priv = vm->privateData;
> +
> ++    lxcDriverLock(driver);
> ++    virObjectLock(vm);
> ++    lxcDriverUnlock(driver);
> ++
> +     switch (status) {
> +     case VIR_LXC_PROTOCOL_EXIT_STATUS_SHUTDOWN:
> +         priv->stopReason = VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN;
> +@@ -628,6 +633,8 @@ static void virLXCProcessMonitorExitNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED
> +     }
> +     VIR_DEBUG("Domain shutoff reason %d (from status %d)",
> +               priv->stopReason, status);
> ++
> ++    virObjectUnlock(vm);
> + }
> +
> + /* XXX a little evil */
> +@@ -636,12 +643,21 @@ static void virLXCProcessMonitorInitNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED
> +                                            pid_t initpid,
> +                                            virDomainObjPtr vm)
> + {
> +-    virLXCDomainObjPrivatePtr priv = vm->privateData;
> ++    virLXCDriverPtr driver = lxc_driver;
> ++    virLXCDomainObjPrivatePtr priv;
> ++
> ++    lxcDriverLock(driver);
> ++    virObjectLock(vm);
> ++    lxcDriverUnlock(driver);
> ++
> ++    priv = vm->privateData;
> +     priv->initpid = initpid;
> +     virDomainAuditInit(vm, initpid);
> +
> +     if (virDomainSaveStatus(lxc_driver->caps, lxc_driver->stateDir, vm) < 0)
> +         VIR_WARN("Cannot update XML with PID for LXC %s", vm->def->name);
> ++
> ++    virObjectUnlock(vm);
> + }
> +
> + static virLXCMonitorCallbacks monitorCallbacks = {
> +--
> +1.7.11.7
> +
> diff --git a/recipes-extended/libvirt/libvirt_1.0.3.bb b/recipes-extended/libvirt/libvirt_1.0.3.bb
> index 0364421..9a828b1 100644
> --- a/recipes-extended/libvirt/libvirt_1.0.3.bb
> +++ b/recipes-extended/libvirt/libvirt_1.0.3.bb
> @@ -19,6 +19,7 @@ RDEPENDS_libvirt-libvirtd_append_x86 = " dmidecode"
>  RCONFLICTS_${PN}_libvirtd = "connman"
>
>  SRC_URI = "http://libvirt.org/sources/libvirt-${PV}.tar.gz \
> +  file://libvirt-1.0.3-fix-thread-safety-in-lxc-callback-handling.patch \
>         file://libvirtd.sh \
>         file://libvirtd.conf"
>
> --
> 1.7.11.7
>
>
> _______________________________________________
> meta-virtualization mailing list
> meta-virtualization at 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"



More information about the meta-virtualization mailing list